/* Førportal, app-sider (Flåte, Kamera, Mannskap) og nye moduler */
.page { position: fixed; inset: 0; background: var(--bg); overflow: auto; }
.topbar a.brand { color: #fff; text-decoration: none; }
.app-title { font-weight: 600; color: #fdba74; white-space: nowrap; }
.app-nav { display: flex; gap: 2px; overflow-x: auto; }
.app-nav a { color: #d1d5db; text-decoration: none; padding: 6px 10px; border-radius: 7px; font-size: 13px; white-space: nowrap; }
.app-nav a:hover { background: #374151; color: #fff; }
.app-nav a.on { background: #374151; color: #fff; }
.topbar .grow { flex: 1; }
.page-main { max-width: 1400px; margin: 0 auto; padding: 76px 16px 40px; }
.page-main h1 { font-size: 24px; margin: 0 0 4px; }
.page-main h2 { font-size: 16px; margin: 0 0 10px; }
.box { background: #fff; border-radius: 12px; box-shadow: var(--shadow); padding: 16px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar .input { width: auto; }

/* Portal */
.portal-head { margin-bottom: 18px; }
.portal-grid { display: grid; grid-template-columns: 1fr 400px; gap: 20px; align-items: start; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 12px; margin-bottom: 18px; }
.tile { display: flex; gap: 14px; background: #fff; border-radius: 12px; box-shadow: var(--shadow); padding: 16px; color: var(--ink); text-decoration: none; border: 1px solid transparent; transition: border-color .15s, transform .15s; }
a.tile:hover { border-color: var(--accent); transform: translateY(-1px); }
.tile-ico { width: 44px; height: 44px; border-radius: 10px; background: #fff7ed; display: grid; place-items: center; flex: none; }
.tile-ico svg { width: 24px; height: 24px; fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.tile-body b { font-size: 15px; }
.tile-kpis { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.tile-kpis b { color: var(--ink); font-size: 15px; }
.tile-kpis .hot, .tile-kpis .hot b { color: var(--bad); }
.tiles.locked .tile { opacity: .6; box-shadow: none; border: 1px dashed var(--line); }
.tiles.locked .tile-ico { background: #f1f5f9; }
.tiles.locked .tile-ico svg { stroke: var(--muted); }
.varsler { background: #fff; border-radius: 12px; box-shadow: var(--shadow); padding: 16px; position: sticky; top: 72px; max-height: calc(100vh - 96px); overflow: auto; }
.varsel { display: flex; gap: 10px; align-items: flex-start; padding: 9px 6px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 13px; border-radius: 6px; }
.varsel:hover { background: #f8fafc; }
.varsel .dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 5px; flex: none; background: #3b82f6; }
.varsel.bad .dot { background: var(--bad); }
.varsel.warn .dot { background: #f59e0b; }
@media (max-width: 1000px) { .portal-grid { grid-template-columns: 1fr; } .varsler { position: static; max-height: none; } }
@media (max-width: 700px) { .app-nav { display: none; } }

/* Tabeller */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; padding: 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: #fffbf7; }
.tbl .num { text-align: right; white-space: nowrap; }
.tbl-wrap { overflow-x: auto; }
.st { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.st::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #16a34a; }
.st.snart::before { background: #f59e0b; } .st.snart { color: #92400e; }
.st.forfalt::before { background: var(--bad); } .st.forfalt { color: #991b1b; }
.st.ok { color: #166534; }

/* Flåte */
.kpis.five { grid-template-columns: repeat(5, 1fr); margin-bottom: 14px; }
@media (max-width: 900px) { .kpis.five { grid-template-columns: repeat(2, 1fr); } }
.kpi.click { cursor: pointer; background: #fff; }
.kpi.click.on { border-color: var(--accent); box-shadow: 0 0 0 2px #fed7aa; }
.flate-grid { display: grid; grid-template-columns: 1fr 460px; gap: 16px; align-items: start; }
.flate-grid:has(> .detail.hidden) { grid-template-columns: 1fr; }
.detail { position: sticky; top: 72px; max-height: calc(100vh - 92px); overflow: auto; }
@media (max-width: 1100px) { .flate-grid { grid-template-columns: 1fr; } .detail { position: static; max-height: none; } }
.detail h3 { margin: 16px 0 6px; font-size: 13px; }
.fr { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.fr .grow { flex: 1; min-width: 0; }
.cal { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.cal .m { border: 1px solid var(--line); border-radius: 8px; padding: 8px; font-size: 12px; background: #fff; }
.cal .m h4 { margin: 0 0 4px; font-size: 12px; text-transform: capitalize; }
.cal .m div { padding: 2px 0; }

/* Kamera */
.cam-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.cam { background: #0f172a; border-radius: 10px; overflow: hidden; position: relative; cursor: pointer; aspect-ratio: 16 / 9; }
.cam img, .cam iframe { width: 100%; height: 100%; object-fit: cover; display: block; border: 0; }
.cam .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 6px 10px; background: linear-gradient(transparent, rgba(0,0,0,.75)); color: #fff; font-size: 12px; display: flex; justify-content: space-between; }
.cam .off { position: absolute; inset: 0; display: grid; place-items: center; color: #94a3b8; font-size: 13px; text-align: center; padding: 10px; }
.cam-thumbs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.cam-thumbs .cam { aspect-ratio: 16 / 9; }
.viewer { background: #0f172a; border-radius: 10px; overflow: hidden; aspect-ratio: 16 / 9; }
.viewer img, .viewer iframe { width: 100%; height: 100%; object-fit: contain; border: 0; display: block; }
.mk.cam-mk { width: 24px; height: 24px; border-radius: 6px; background: #111827; color: #fff; display: grid; place-items: center; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); cursor: pointer; }
.mk.cam-mk svg { width: 14px; height: 14px; fill: #fff; }
.mk.cam-mk:hover { background: var(--accent); transform: scale(1.15); }
.mk.cam-mk.off { opacity: .45; }
.cam-card { display: flex; gap: 10px; align-items: flex-start; }
.cam-card img { width: 112px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 6px; background: #0f172a; flex: none; }
.cam-pop .maplibregl-popup-content { padding: 8px; }

/* Mannskap */
.crew { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.crew .p { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; font-size: 13px; }
.crew .p.ue { border-left: 3px solid #6366f1; }
.badge-live { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: #166534; font-weight: 600; }
.badge-live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #16a34a; animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
pre.code { background: #0f172a; color: #e2e8f0; padding: 10px; border-radius: 8px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-break: break-all; }
.reader-sim { border: 1px dashed var(--line); border-radius: 10px; padding: 10px; margin-top: 10px; }
.reader-out { font-size: 18px; font-weight: 700; padding: 10px; border-radius: 8px; text-align: center; margin-top: 8px; }
.reader-out.ok { background: #dcfce7; color: #166534; } .reader-out.bad { background: #fee2e2; color: #991b1b; }
.modgroup { margin: 12px 0 4px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
