/* The app itself — tokens from Theme.kt / WebColors.kt. 1 CSS px = 1 dp. */
#viewport {
  --navy: #0B3D5C; --bg: #F5F5F5; --primary: #0066CC; --ok: #2A9D2A; --err: #CC2A2A; --warn: #E07B00;
  --day: #EEF4FB; --border: #DDE3EA; --rowline: #EEEEEE; --muted: #888; --label: #555; --text: #222;
  --tile: #F7F8FA;
  color: var(--text); font-family: Roboto, system-ui, sans-serif; font-size: 14px;
  font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased;
}
#viewport button { font-family: inherit; }
#screen { flex: 1; min-height: 0; position: relative; }
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; background: var(--bg); }

/* Top bar */
.topbar { background: var(--navy); color: #fff; display: flex; align-items: center; min-height: 64px; padding: 0 8px 0 16px; flex: none; gap: 8px; }
.tb-back { background: none; border: 0; color: #fff; font-size: 15px; font-weight: 500; padding: 8px 10px 8px 2px; cursor: pointer; }
.tb-titles { flex: 1; min-width: 0; }
.tb-title { font-size: 22px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.narrow .tb-title { font-size: 20px; }
.tb-suffix { font-size: 14px; color: rgba(255,255,255,.75); }
.tb-sub { font-size: 12px; font-weight: 500; letter-spacing: .6px; margin-top: 1px; }
.tb-actions { display: flex; align-items: center; gap: 2px; }
.text-act { background: none; border: 0; color: #fff; font-size: 15px; font-weight: 500; padding: 10px 12px; cursor: pointer; border-radius: 6px; }
.text-act:hover, .icon-btn:hover { background: rgba(255,255,255,.1); }
.text-act:disabled { opacity: .45; cursor: default; }
.icon-btn { background: none; border: 0; color: #fff; padding: 8px; display: inline-flex; border-radius: 50%; cursor: pointer; }
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn.dark { color: #333; }
.icon-btn.dark:hover { background: rgba(0,0,0,.06); }

/* Generic */
.page { flex: 1; overflow-y: auto; padding: 16px; }
.page-flush { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.col-640 { max-width: 640px; margin: 0 auto; }
.card { background: #fff; border-radius: 8px; box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.row { display: flex; align-items: center; }
.row.inline { display: inline-flex; }
.wrap { flex-wrap: wrap; }
.gap6 { gap: 6px; } .gap8 { gap: 8px; }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; }
.right { text-align: right; }
.mt6 { margin-top: 6px; } .mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; }
.caption { font-size: 12px; color: var(--muted); line-height: 1.45; }
.label-text { color: var(--label); }
.small { font-size: 13px; }
.small-muted { font-size: 11px; color: var(--muted); }
.muted { color: var(--muted); font-size: .9em; }
.ok-text { color: var(--ok); }
.err-text { color: var(--err); }
.warn-text { color: var(--warn); font-size: 12px; }
.link { color: var(--primary); font-weight: 500; }
.demo-note { font-size: 12px; color: #6a8597; margin-top: 30px; }
.dir-arrow { vertical-align: -3px; flex: none; }

.btn { border-radius: 6px; padding: 9px 16px; font-size: 14px; font-weight: 500; cursor: pointer; border: 1px solid transparent; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.outline { background: #fff; border-color: #CFD8E0; color: var(--primary); }
.btn.outline:hover { background: #F2F7FC; }
.btn.danger { color: var(--err); }
.btn.sm { padding: 6px 12px; }
.btn.sq { padding: 4px 10px; }
.btn.big-pad { padding: 12px 22px; font-size: 15px; }
.btn:disabled { opacity: .45; cursor: default; }
.text-btn { background: none; border: 0; color: var(--primary); font-size: 14px; font-weight: 500; padding: 8px 12px; cursor: pointer; border-radius: 6px; }
.text-btn.danger { color: var(--err); }
.link-btn { background: none; border: 0; color: var(--primary); font-size: 14px; font-weight: 500; cursor: pointer; padding: 4px; }
.close-x { background: none; border: 0; color: var(--muted); font-size: 24px; cursor: pointer; padding: 0 6px; line-height: 1; }

.spinner { width: 18px; height: 18px; border: 2.5px solid #C9D9E8; border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.badge { display: inline-block; color: #fff; font-size: 10px; font-weight: 700; padding: 3px 5px; border-radius: 3px; letter-spacing: .3px; white-space: nowrap; flex: none; }
.badge.ok { background: #2E7D32; } .badge.weak { background: #757575; } .badge.bad { background: #C62828; }

.switch { width: 46px; height: 26px; border-radius: 13px; background: #B9C6D1; position: relative; display: inline-block; cursor: pointer; flex: none; transition: background .15s; }
.switch span { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: left .15s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.switch.on { background: var(--primary); }
.switch.navy.on { background: var(--navy); }
.switch.on span { left: 23px; }
.switch-row { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }

/* Splash */
.splash { position: absolute; inset: 0; background: var(--navy); overflow: hidden; cursor: pointer; transition: opacity .5s; }
.splash.out { opacity: 0; }
.splash video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.splash-veil { position: absolute; left: 0; right: 0; top: 0; height: 45%; background: linear-gradient(rgba(11,61,92,.55), rgba(11,61,92,0)); }
.splash-logo { position: absolute; width: 34%; max-width: 440px; right: 9%; top: 10%; opacity: 0; transition: opacity .6s; }
.narrow .splash-logo { width: 62%; left: 19%; right: auto; top: 12%; }
.splash-logo.in { opacity: 1; }
.splash-hint { position: absolute; bottom: 14px; width: 100%; text-align: center; color: rgba(255,255,255,.6); font-size: 12px; }

/* Scan */
.known-card { padding: 14px 16px; margin-bottom: 14px; }
.known-name { color: var(--primary); font-weight: 700; font-size: 16px; margin-bottom: 4px; }
.scan-result { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; margin-top: 14px; cursor: pointer; }
.scan-result:hover { background: #F7FAFD; }

/* Live */
.live-wide { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 12px 16px 0; }
.subline { font-size: 12px; color: var(--muted); margin-bottom: 8px; line-height: 1.7; letter-spacing: .3px; }
.subline .ok-text { font-size: 12.5px; }
.banner { color: #fff; font-weight: 700; font-size: 15px; border-radius: 6px; padding: 10px 14px; transition: background .3s; }
.big-btn { width: 100%; min-height: 56px; border: 0; border-radius: 6px; color: #fff; font-size: 18px; font-weight: 700; margin-top: 8px; cursor: pointer; transition: filter .15s; }
.big-btn:hover { filter: brightness(1.08); }
.two-col { flex: 1; min-height: 0; display: flex; gap: 12px; margin-top: 8px; }
.two-col > .col { flex: 1; min-width: 0; overflow-y: auto; padding-bottom: 16px; }
.two-col > .col > .card, .two-col > .col > .readouts { margin-bottom: 10px; }
.page > .card, .page > .readouts { margin-top: 10px; }
.readouts { display: flex; gap: 8px; }
.value-card { flex: 1; background: #fff; border-radius: 8px; padding: 10px 14px; box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.vc-value { font-size: 24px; font-weight: 700; color: var(--primary); display: flex; align-items: center; gap: 4px; }
.vc-unit { font-size: 14px; font-weight: 400; }
.vc-label { font-size: 12px; color: var(--muted); margin-top: 2px; }
.last-box { padding: 10px 16px; cursor: pointer; }
.last-box:hover { background: #FAFCFE; }
.last-line { font-size: 16px; margin: 2px 0; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.table-card { overflow: hidden; }
table.kv { width: 100%; border-collapse: collapse; font-size: 14px; }
table.kv td { padding: 9px 12px; border-bottom: 1px solid var(--rowline); }
table.kv td:first-child { color: var(--label); width: 45%; }
table.kv td:last-child { font-weight: 700; }
table.kv tr:last-child td { border-bottom: 0; }
.device-toggle { background: none; border: 0; width: 100%; text-align: left; padding: 10px 12px; font-size: 14px; font-weight: 700; color: var(--primary); cursor: pointer; }
.today-card { overflow: hidden; }
.today-cap { padding: 8px 10px; }
table.today { width: 100%; border-collapse: collapse; font-size: 14px; }
table.today th { background: var(--primary); color: #fff; text-align: left; padding: 9px 10px; font-weight: 700; }
table.today td { padding: 8px 10px; border-bottom: 1px solid var(--rowline); vertical-align: middle; }
table.today tbody tr { cursor: pointer; }
table.today tbody tr:hover { background: #F7FAFD; }
table.today.small { font-size: 12px; }
table.today.small th, table.today.small td { padding: 6px 8px; }
.new-row { animation: flash 2.4s ease-out; }
@keyframes flash { from { background: #FFF3C4; } to { background: transparent; } }

/* Logs */
.logs { flex: 1; min-height: 0; display: flex; }
.logs-list { flex: 1; overflow-y: auto; padding: 12px 16px; min-width: 0; }
.logs.with-pane .logs-list { flex: 0 0 50%; }
.logs-pane { flex: 1; min-width: 0; background: #fff; border-left: 1px solid var(--border); display: flex; flex-direction: column; }
.day { background: #fff; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin-top: 14px; }
.day-h { background: var(--day); display: flex; align-items: center; gap: 8px; padding: 8px 10px; font-size: 15px; }
.cb { display: inline-flex; padding: 4px; cursor: pointer; }
.cb input { width: 18px; height: 18px; margin: 0; accent-color: var(--primary); cursor: pointer; }
.log-row { display: grid; grid-template-columns: 34px 110px 1fr auto; align-items: center; gap: 4px 10px; padding: 10px; border-top: 1px solid var(--rowline); }
.log-row.stacked { grid-template-columns: 34px 1fr auto; }
.log-row.stacked .lr-result { grid-column: 2 / 4; grid-row: 2; }
.log-row.opened { background: #FFF3C4; }
.lr-time b { font-size: 16px; }
.lr-result { font-size: 14px; display: flex; flex-direction: column; gap: 2px; }
.lr-result > div { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.lr-btns { display: flex; gap: 6px; }
.status-card { padding: 10px 14px; margin-top: 10px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.progress { flex: 1; min-width: 120px; height: 6px; background: #E3EAF0; border-radius: 3px; overflow: hidden; }
.progress div { height: 100%; background: var(--ok); transition: width .2s; }
.sel-bar { position: absolute; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 8px; padding: 10px 16px; box-shadow: 0 -2px 8px rgba(0,0,0,.08); font-weight: 500; }

/* Log detail */
.ld { flex: 1; overflow-y: auto; padding: 14px 16px 20px; background: #fff; }
.ld.two-col { margin-top: 0; padding: 14px 16px 0; gap: 22px; }
.ld-head { display: flex; align-items: center; gap: 10px; }
.ld-bar { width: 4px; align-self: stretch; border-radius: 2px; flex: none; display: inline-block; }
.ld-name { font-size: 19px; font-weight: 700; }
.verdict { display: flex; align-items: center; gap: 8px; border-radius: 6px; margin-top: 10px; padding: 8px 10px 8px 0; font-size: 13px; overflow: hidden; }
.verdict .v-edge { width: 4px; align-self: stretch; margin: -8px 4px -8px 0; }
.verdict.ok { background: #E8F5E9; color: #1B5E20; } .verdict.ok .v-edge { background: #2E7D32; }
.verdict.weak { background: #F1F1F1; color: #424242; } .verdict.weak .v-edge { background: #757575; }
.verdict.bad { background: #FDECEA; color: #7A1C1C; } .verdict.bad .v-edge { background: #C62828; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.tile { background: var(--tile); border-radius: 6px; padding: 8px 12px; }
.tile-label { font-size: 12px; color: var(--label); }
.tile-val { font-size: 19px; font-weight: 700; margin-top: 2px; }
.tile-val small { font-size: 12px; font-weight: 400; color: var(--label); }
.ld-h { font-size: 12px; font-weight: 700; letter-spacing: .5px; color: #444; text-transform: uppercase; margin: 16px 0 4px; }
.chart-wrap { position: relative; margin-top: 6px; }
.track-wrap { display: flex; justify-content: center; }
.track-canvas { border-radius: 4px; touch-action: none; }
canvas.series { width: 100%; height: 120px; display: block; touch-action: none; border: 1px solid var(--rowline); border-radius: 4px; }
.chart-tip { position: absolute; background: #222; color: #fff; font-size: 11px; padding: 4px 7px; border-radius: 4px; pointer-events: none; white-space: nowrap; z-index: 5; }
table.sect { width: 100%; border-collapse: collapse; font-size: 13px; }
table.sect td { padding: 6px 10px; border-bottom: 1px solid var(--rowline); vertical-align: top; }
table.sect td:first-child { color: var(--label); width: 40%; }
table.sect .sect-h td { background: #F5F6F8; color: #444; font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }

/* Map */
.mp-top, .mp-tool { flex: none; }
.map-toolbar { background: #fff; display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; padding: 8px 12px; font-size: 15px; font-weight: 500; }
.map-toolbar .num { min-width: 22px; text-align: center; display: inline-block; }
.narrow .map-toolbar { font-size: 13px; gap: 6px 12px; }
.chips { background: #fff; display: flex; gap: 6px; overflow-x: auto; padding: 0 12px 8px; }
.chip { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--border); border-left: 4px solid; border-radius: 6px; padding: 2px 6px 2px 2px; font-size: 12px; white-space: nowrap; cursor: pointer; }
.chip input { width: 14px; height: 14px; accent-color: var(--primary); }
.mp-body { flex: 1; min-height: 0; display: flex; }
.mp-mapwrap { flex: 1; position: relative; min-width: 0; }
.mp-map { position: absolute; inset: 0; background: #0E1A24; }
.mp-map .leaflet-top.leaflet-right { top: 50%; transform: translateY(-50%); }
.mp-map .leaflet-top.leaflet-right .leaflet-control { margin-top: 0; margin-bottom: 8px; }
.mp-map.light { background: #E9EEF1; }
.mp-map .tint-navy { filter: url(#navy); }
.mp-map .tint-light { filter: url(#lightmap); }
.mp-map .field-canvas { pointer-events: none; }
.map-toolbar .seg button { padding: 6px 12px; font-size: 14px; }
.leaflet-container { font-family: Roboto, sans-serif; }
.dark-tip { background: #222; color: #fff; border: 0; font-size: 11px; padding: 3px 6px; box-shadow: none; }
.dark-tip::before { border-top-color: #222 !important; }
.mp-tw { position: absolute; left: 0; top: 12px; z-index: 500; }
.tw-tab { background: #fff; border: 0; border-radius: 0 10px 10px 0; padding: 8px 10px 8px 14px; display: flex; align-items: center; gap: 8px; color: var(--primary); cursor: pointer; box-shadow: 0 2px 6px rgba(0,0,0,.3); text-align: left; }
.tw-tab b { color: var(--text); font-size: 16px; font-weight: 500; }
.tw-card { background: #fff; border-radius: 10px; margin-left: 12px; width: 300px; padding: 10px 14px 12px; box-shadow: 0 2px 8px rgba(0,0,0,.3); }
.tw-card hr { border: 0; border-top: 1px solid #E2E6EA; margin: 8px 0; }
.tw-h { color: var(--primary); font-size: 13px; font-weight: 500; letter-spacing: 1.5px; }
.tw-h.dark { color: #333; }
.tw-range b { font-size: 18px; font-weight: 500; }
.legend { position: absolute; right: 12px; bottom: 12px; z-index: 500; background: #fff; border-radius: 6px; padding: 8px 12px; display: flex; align-items: center; gap: 12px; font-size: 13px; box-shadow: 0 2px 6px rgba(0,0,0,.3); }
.lg-scale { width: 130px; }
.lg-grad { height: 8px; border-radius: 4px; }
.lg-labels { display: flex; justify-content: space-between; font-size: 10px; color: var(--label); margin-top: 2px; }
.lg-weak { font-size: 12px; color: var(--label); display: inline-flex; align-items: center; gap: 4px; }
.lg-weak i { width: 22px; border-top: 3px dotted #444; display: inline-block; }
.attrib { position: absolute; left: 0; bottom: 0; z-index: 500; font-size: 9px; color: #ddd; background: rgba(0,0,0,.45); padding: 2px 6px; }
.mp-map.light ~ .attrib { color: #333; background: rgba(255,255,255,.6); }
.leaflet-bottom.leaflet-left { bottom: 18px; }
.mp-offline { display: none; position: absolute; left: 50%; top: 12px; transform: translateX(-50%); z-index: 500; background: rgba(0,0,0,.6); color: #fff; font-size: 12px; padding: 4px 10px; border-radius: 12px; }
.mp-offline.show { display: block; animation: fadeout 6s forwards; }
@keyframes fadeout { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }
.mp-tab { position: absolute; right: 0; top: 12px; z-index: 500; background: #fff; border: 0; border-radius: 10px 0 0 10px; padding: 10px 12px; color: var(--primary); font-weight: 500; cursor: pointer; box-shadow: 0 2px 6px rgba(0,0,0,.3); }
.mp-side { display: none; }
.mp-side.open { display: flex; width: 300px; flex: none; background: #fff; border-left: 1px solid var(--border); }
.mp-side.open.wide { width: 380px; }
.mp-panel { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.mp-ph { padding: 12px 12px 4px 14px; }
.pad-h { padding: 0 14px 8px; border-bottom: 1px solid var(--rowline); }
.mp-rows { flex: 1; overflow-y: auto; }
.mp-row { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 0; border-bottom: 1px solid var(--rowline); cursor: pointer; }
.mp-row:hover { background: #F7FAFD; }
.mp-edge { width: 5px; align-self: stretch; flex: none; }
.cb-color { width: 18px; height: 18px; margin: 0 2px; flex: none; }
.mp-big { font-size: 21px; } .mp-big small { font-size: 13px; color: var(--label); }
.mp-dir { font-size: 16px; }
.mp-panel.detail .ld { padding-top: 12px; }
.sel-card { position: absolute; left: 60px; right: 12px; bottom: 64px; z-index: 600; background: #fff; border-radius: 10px; padding: 10px 12px; box-shadow: 0 2px 10px rgba(0,0,0,.35); font-size: 14px; }
.sel-card:empty { display: none; }
.mp-selcard:empty { display: none; }
.mp-table { background: #fff; border-top: 1px solid var(--border); flex: none; }
.mp-table-scroll { max-height: 220px; overflow-y: auto; }

/* Settings */
.settings-cols { padding: 0 16px; margin-top: 0; }
.sect-title { font-size: 12px; font-weight: 500; letter-spacing: 1px; color: #444; text-transform: uppercase; margin: 16px 0 8px; }
.set-card { padding: 4px 16px 12px; }
.set-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--rowline); }
.set-label { font-size: 15px; font-weight: 500; }
.val-row { display: flex; padding: 8px 0; font-size: 14px; gap: 8px; }
.val-row > span { color: var(--label); flex: 0 0 45%; }
.val-row > b { flex: 1; }
.seg { display: inline-flex; border-radius: 6px; overflow: hidden; background: #E3EAF0; flex: none; }
.seg button { border: 0; background: none; padding: 9px 14px; font-size: 15px; font-weight: 500; cursor: pointer; color: #333; }
.seg button.on { background: var(--primary); color: #fff; }
.stepper { display: inline-flex; align-items: center; gap: 10px; flex: none; }
.stepper .btn { padding: 6px 18px; }
.stepper b { min-width: 52px; text-align: center; }

/* Dialog + toast */
#dialog { position: absolute; inset: 0; z-index: 900; background: rgba(0,0,0,.4); display: none; align-items: center; justify-content: center; }
#dialog.show { display: flex; }
.dlg { background: #fff; border-radius: 24px; padding: 22px 22px 12px; width: 360px; max-width: 90%; box-shadow: 0 10px 30px rgba(0,0,0,.35); }
.dlg-title { font-size: 22px; margin-bottom: 10px; }
.dlg-body { font-size: 14px; color: #444; line-height: 1.5; }
.dlg-body p { margin: 0 0 10px; }
.dlg-btns { display: flex; justify-content: flex-end; gap: 4px; margin-top: 8px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; margin-bottom: 6px; }
.cal-dow { font-size: 12px; color: var(--muted); padding: 4px 0; }
.cal-day { border: 0; background: none; height: 38px; border-radius: 50%; font-size: 14px; color: #bbb; }
.cal-day.has { color: #222; font-weight: 700; cursor: pointer; }
.cal-day.has:hover { background: #E8F0F8; }
.cal-day.sel { background: var(--primary) !important; color: #fff; }
#toast { position: absolute; left: 50%; bottom: 40px; transform: translate(-50%, 20px); z-index: 950; background: #323232; color: #fff; font-size: 14px; padding: 10px 18px; border-radius: 20px; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; white-space: nowrap; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
