/* Fieldwatch Analyzer — look and feel follows oh2gax/wspr_logger */

/* ── CSS Variables — Dark (default) ── */
:root {
    --bg-base:       #111827;
    --bg-surface:    #1f2937;
    --bg-deep:       #0d1117;
    --border:        #374151;
    --text-primary:  #d1d5db;
    --text-secondary:#9ca3af;
    --text-muted:    #4b5563;
    --accent:        #38bdf8;
    --accent-dim:    #0369a1;
    --accent-bg:     #1e3a5f;
    --accent-btn:    #0369a1;
    --accent-btn-hover: #0284c7;
    --green:         #4ade80;
    --amber:         #f59e0b;
    --red:           #f43f5e;
    --overlay-bg:    rgba(17,24,39,.93);
    --input-bg:      #111827;
    --mini-card-bg:  #111827;
    --scrollbar-thumb: #374151;
    --row-hover:     #263142;
}
/* ── CSS Variables — Light ── */
html.light {
    --bg-base:       #f1f5f9;
    --bg-surface:    #ffffff;
    --bg-deep:       #e2e8f0;
    --border:        #cbd5e1;
    --text-primary:  #1e293b;
    --text-secondary:#475569;
    --text-muted:    #94a3b8;
    --accent:        #0284c7;
    --accent-dim:    #7dd3fc;
    --accent-bg:     #e0f2fe;
    --accent-btn:    #0284c7;
    --accent-btn-hover: #0369a1;
    --green:         #16a34a;
    --amber:         #d97706;
    --red:           #dc2626;
    --overlay-bg:    rgba(241,245,249,.93);
    --input-bg:      #f8fafc;
    --mini-card-bg:  #f1f5f9;
    --scrollbar-thumb: #94a3b8;
    --row-hover:     #f1f5f9;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-base);
    color: var(--text-primary);
    display: flex;
    height: 100vh;
    font-size: 13px;
}
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* ── Sidebar ── */
#sidebar {
    width: 285px; min-width: 285px;
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    overflow-y: auto; overflow-x: hidden;
    z-index: 10;
    transition: width .25s ease, min-width .25s ease;
}
#sidebar.collapsed { width: 0; min-width: 0; border-right: none; }
.sb-header { padding: 14px 16px 10px; border-bottom: 1px solid var(--border); position: relative; }
.sb-title { font-size: 15.5px; padding-right: 60px; white-space: nowrap; font-weight: 700; color: var(--accent); letter-spacing: .3px; }
.sb-sub { font-size: 11px; color: var(--text-secondary); margin-top: 3px; }
.sb-sub strong { color: var(--text-primary); }
.sb-btns { position: absolute; right: 10px; top: 12px; display: flex; gap: 6px; }
.icon-btn {
    background: var(--bg-base); border: 1px solid var(--border); color: var(--text-secondary);
    border-radius: 5px; width: 26px; height: 24px; cursor: pointer; font-size: 12px;
}
.icon-btn:hover { color: var(--accent); border-color: var(--accent-dim); }

.nav { padding: 6px 0; border-bottom: 1px solid var(--border); }
.nav-item {
    display: flex; align-items: center; gap: 10px; padding: 9px 18px;
    cursor: pointer; color: var(--text-primary); font-size: 13.5px; border-left: 3px solid transparent;
}
.nav-item:hover { background: var(--row-hover); }
.nav-item.active { background: var(--accent-bg); color: var(--accent); border-left-color: var(--accent); }
.nav-item .cnt { margin-left: auto; font-size: 11px; color: var(--text-secondary); }

.sb-section { padding: 10px 16px 12px; border-bottom: 1px solid var(--border); }
.sb-label { font-size: 10px; text-transform: uppercase; letter-spacing: .8px; color: var(--text-secondary); margin-bottom: 7px; display: flex; align-items: center; }
.sb-label .r { margin-left: auto; text-transform: none; letter-spacing: 0; }
.sb-label a { color: var(--accent); cursor: pointer; text-decoration: none; }

select, input[type=text], input[type=search] {
    width: 100%; background: var(--input-bg); color: var(--text-primary);
    border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; font-size: 13px; font-family: inherit;
}
select:focus, input:focus { outline: none; border-color: var(--accent-dim); }
.day-row { display: flex; gap: 6px; }
.day-row select { flex: 1; }

.seg { display: flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; margin-top: 8px; }
.seg button {
    flex: 1; background: var(--input-bg); color: var(--text-secondary); border: none; padding: 5px 0;
    font-size: 12px; cursor: pointer; font-family: inherit; border-right: 1px solid var(--border);
}
.seg button:last-child { border-right: none; }
.seg button.on { background: var(--accent-btn); color: #fff; }

.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
    display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 12px;
    border: 1px solid var(--border); background: var(--input-bg); color: var(--text-muted);
    font-size: 11.5px; cursor: pointer; user-select: none;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; opacity: .35; }
.chip.on { color: var(--text-primary); border-color: var(--text-muted); }
.chip.on .dot { opacity: 1; }
.chip small { color: var(--text-secondary); }

.range-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 12px; color: var(--text-secondary); }
.range-row input { flex: 1; accent-color: var(--accent); }
.range-row b { color: var(--accent); min-width: 58px; text-align: right; font-variant-numeric: tabular-nums; }

/* toggle switches (same as the Map Layers list) */
.sw-row { display: flex; align-items: center; justify-content: space-between; padding: 4px 0; font-size: 13px; cursor: pointer; user-select: none; }
.sw-row small { color: var(--text-secondary); font-size: 11px; }
.switch { position: relative; display: inline-block; width: 34px; height: 18px; flex: none; vertical-align: middle; }
.switch input { display: none; }
.switch span { position: absolute; inset: 0; background: var(--border); border-radius: 18px; transition: .2s; }
.switch span::before { content: ""; position: absolute; width: 14px; height: 14px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: var(--accent-btn); }
.switch input:checked + span::before { transform: translateX(16px); }

.mini-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mini-card { background: var(--mini-card-bg); border: 1px solid var(--border); border-radius: 7px; padding: 7px 10px; }
.mini-card span { font-size: 10.5px; color: var(--text-secondary); display: block; }
.mini-card b { font-size: 19px; color: var(--accent); font-weight: 650; font-variant-numeric: tabular-nums; }
.mini-card b.grn { color: var(--green); }
.mini-card b.red { color: var(--red); }
.mini-card b.amb { color: var(--amber); }
.sb-foot { padding: 10px 16px; font-size: 10.5px; color: var(--text-muted); margin-top: auto; }

/* ── Main ── */
#main { flex: 1; position: relative; min-width: 0; }
#sbOpenBtn {
    display: none; position: absolute; left: 0; top: 50%; transform: translateY(-50%); z-index: 1001;
    width: 30px; height: 84px; align-items: center; justify-content: center;
    background: var(--bg-surface); color: var(--accent); border: 1px solid var(--border); border-left: none;
    border-radius: 0 10px 10px 0; font-size: 18px; cursor: pointer;
}
#sidebar.collapsed + #main #sbOpenBtn { display: flex; }
.view { position: absolute; inset: 0; display: none; }
.view.active { display: block; }
#map { position: absolute; inset: 0; background: var(--bg-deep); }

/* ── Map overlay panels ── */
.panel {
    position: absolute; z-index: 500;
    background: var(--overlay-bg); border: 1px solid var(--border); border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0,0,0,.3); padding: 10px 14px; backdrop-filter: blur(2px);
}
.panel-title { font-size: 10px; text-transform: uppercase; letter-spacing: .8px; color: var(--text-secondary); margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
.panel-title .r { margin-left: auto; text-transform: none; letter-spacing: 0; }
.panel-close { cursor: pointer; color: var(--text-secondary); font-size: 14px; }
.panel-close:hover { color: var(--accent); }
.hidden { display: none !important; }

#timelinePanel { top: 10px; left: 60px; right: 330px; height: 170px; }
#timelinePanel canvas { width: 100% !important; height: 128px !important; }
#detailPanel { top: 10px; right: 10px; width: 310px; max-height: calc(100% - 20px); overflow-y: auto; }
#catPanel { bottom: 24px; right: 10px; width: 310px; }
#detailPanel:not(.hidden) ~ #catPanel { display: none; }
#legendPanel { bottom: 24px; left: 10px; padding: 7px 12px; font-size: 11px; color: var(--text-secondary); }

.dev-name { font-size: 17px; font-weight: 650; color: var(--accent); word-break: break-word; }
.dev-mac { font-family: Consolas, monospace; font-size: 12.5px; color: var(--text-primary); margin-top: 2px; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; color: #0b1220; margin: 6px 4px 2px 0; }
.pill.ghost { background: var(--bg-base); color: var(--text-secondary); border: 1px solid var(--border); font-weight: 500; }
.kv { display: grid; grid-template-columns: 92px 1fr; gap: 3px 8px; margin-top: 8px; font-size: 12px; }
.kv span { color: var(--text-secondary); }
.kv b { font-weight: 500; color: var(--text-primary); word-break: break-all; }
.kv b.acc { color: var(--accent); font-weight: 650; }
.kv b.warn { color: var(--red); font-weight: 650; }
.kv b.ok { color: var(--green); font-weight: 650; }
.mono { font-family: Consolas, monospace; font-size: 11px; }
.dev-chart { height: 110px; margin-top: 10px; }
.note { font-size: 11px; color: var(--text-secondary); margin-top: 8px; line-height: 1.45; }
.note.warn { color: var(--amber); }

.cat-row { display: grid; grid-template-columns: 110px 1fr 40px; align-items: center; gap: 8px; padding: 2px 0; font-size: 12px; cursor: pointer; }
.cat-row:hover span:first-child { color: var(--accent); }
.cat-bar { height: 5px; background: var(--bg-deep); border-radius: 3px; overflow: hidden; }
.cat-bar i { display: block; height: 100%; border-radius: 3px; }
.cat-row b { text-align: right; color: var(--accent); font-variant-numeric: tabular-nums; }
.cat-row.off { opacity: .35; }

.leaflet-tooltip.dev-tip { background: var(--bg-surface); color: var(--text-primary); border: 1px solid var(--border); font-size: 12px; box-shadow: 0 2px 8px rgba(0,0,0,.3); }
.leaflet-tooltip.dev-tip::before { display: none; }
.leaflet-container { font-family: inherit; }

/* ── Table views ── */
.page { position: absolute; inset: 0; overflow: auto; padding: 18px 22px; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.page-head h2 { font-size: 17px; color: var(--accent); font-weight: 650; }
.page-head .sub { color: var(--text-secondary); font-size: 12px; }
.page-head .grow { flex: 1; }
.btn {
    background: var(--accent-btn); color: #fff; border: none; border-radius: 6px; padding: 7px 14px;
    font-size: 12.5px; cursor: pointer; font-family: inherit;
}
.btn:hover { background: var(--accent-btn-hover); }
.btn.ghost { background: var(--bg-surface); color: var(--text-primary); border: 1px solid var(--border); }
.btn.ghost:hover { border-color: var(--accent-dim); color: var(--accent); }
.btn.danger { background: transparent; color: var(--red); border: 1px solid var(--border); padding: 3px 9px; }

table.grid { width: 100%; border-collapse: collapse; font-size: 12.5px; background: var(--bg-surface); border: 1px solid var(--border); border-radius: 8px; }
table.grid th {
    position: sticky; top: 0; background: var(--bg-surface); z-index: 1;
    text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--text-secondary);
    padding: 8px 8px; border-bottom: 1px solid var(--border); cursor: pointer; white-space: nowrap; user-select: none;
}
table.grid th.sorted { color: var(--accent); }
table.grid td { padding: 5px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
table.grid tbody tr { cursor: pointer; }
table.grid tbody tr:hover { background: var(--row-hover); }
table.grid tbody tr.sel { background: var(--accent-bg); }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
td.mono { font-family: Consolas, monospace; font-size: 11.5px; }
.cdot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.tag { display: inline-block; font-size: 10px; padding: 0 6px; border-radius: 8px; border: 1px solid var(--border); color: var(--text-secondary); margin-left: 4px; }
.tag.red { color: var(--red); border-color: var(--red); }
.tag.grn { color: var(--green); border-color: var(--green); }
.tag.amb { color: var(--amber); border-color: var(--amber); }

.drop {
    border: 2px dashed var(--border); border-radius: 10px; padding: 26px; text-align: center;
    color: var(--text-secondary); background: var(--bg-surface); margin-bottom: 16px;
}
.drop.over { border-color: var(--accent); color: var(--accent); }
.drop b { color: var(--text-primary); }
.results { margin: 0 0 16px; font-size: 12px; }
.results div { padding: 2px 0; }
.results .ok { color: var(--green); }
.results .skip { color: var(--text-secondary); }
.results .err { color: var(--red); }
.empty { padding: 40px; text-align: center; color: var(--text-secondary); }

#toast {
    position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 3000;
    background: var(--accent-bg); color: var(--text-primary); border: 1px solid var(--border);
    padding: 8px 16px; border-radius: 8px; font-size: 13px; opacity: 0; transition: opacity .25s; pointer-events: none;
}
#toast.show { opacity: 1; }
#busy { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 2000; }

.time-row { display: grid; grid-template-columns: auto 1fr auto 1fr; align-items: center; gap: 6px; margin-top: 8px; font-size: 12px; color: var(--text-secondary); }
input[type=time] { width: 100%; min-width: 0; background: var(--input-bg); color: var(--text-primary); border: 1px solid var(--border); border-radius: 6px; padding: 4px 4px; font-family: inherit; font-size: 12px; color-scheme: dark; }
html.light input[type=time] { color-scheme: light; }

/* ── Device layers (sidebar) ── */
.lay-group { font-size: 10px; text-transform: uppercase; letter-spacing: .7px; color: var(--text-muted); margin: 8px 0 2px; cursor: pointer; }
.lay-group:first-child { margin-top: 0; }
.lay-group:hover { color: var(--accent); }
.lay-row { display: flex; align-items: center; gap: 8px; padding: 2.5px 0; font-size: 12.5px; }
.lay-row .switch { transform: scale(.85); transform-origin: left center; margin-right: -4px; }
.lay-name { flex: 1; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lay-name:hover { color: var(--accent); text-decoration: underline; }
.lay-row small { color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.lay-row.zero { opacity: .45; }
.lay-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; margin: 0 3px; }
.lay-ico { width: 16px; text-align: center; flex: none; font-size: 13px; }

/* ── Icon pins for watch-list layers ── */
.emo-pin {
    width: 26px; height: 26px; border-radius: 50%; border: 2px solid; background: var(--bg-surface);
    display: flex; align-items: center; justify-content: center; font-size: 14px; line-height: 1;
    box-shadow: 0 1px 6px rgba(0,0,0,.45);
}
.emo-pin.alert { animation: pinPulse 1.6s ease-in-out infinite; border-color: #f43f5e !important; }
@keyframes pinPulse { 0%,100% { box-shadow: 0 0 0 0 rgba(244,63,94,.7); } 50% { box-shadow: 0 0 0 7px rgba(244,63,94,0); } }

/* ── My devices ── */
.own-box { background: var(--bg-surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; margin-bottom: 14px; }
.own-box summary { cursor: pointer; font-weight: 600; color: var(--amber); font-size: 13.5px; }
.own-box summary span { color: var(--text-secondary); font-weight: 400; font-size: 12px; }
.own-form { display: grid; grid-template-columns: 120px 170px 1fr 1fr auto; gap: 8px; }
.own-cell { width: 30px; text-align: center; }
.own-add { background: transparent; border: 1px solid var(--border); color: var(--text-secondary); border-radius: 5px; width: 22px; height: 20px; cursor: pointer; font-size: 12px; line-height: 1; }
.own-add:hover { color: var(--amber); border-color: var(--amber); }
.own-star { color: var(--amber); font-size: 14px; }
table.grid tbody tr.mine td { color: var(--text-secondary); }

/* timeline "Show" selector */
.tl-cat { width: auto; padding: 1px 6px; font-size: 11px; text-transform: none; letter-spacing: 0; margin-left: 6px; }
.tl-note { text-transform: none; letter-spacing: 0; font-size: 11px; color: var(--text-secondary); }
#timelinePanel.tl-filtered { border-color: var(--accent-dim); }

/* ── What's new / User guides / About (as in WSPR Logger) ── */
.sb-whatsnew { font-size: 12px; margin-top: 5px; color: var(--accent); cursor: pointer; user-select: none; display: inline-flex; align-items: center; gap: 6px; }
.sb-whatsnew:hover { text-decoration: underline; }
.nav-badge { font-size: 9.5px; color: var(--text-muted); border: 1px solid var(--border); border-radius: 8px; padding: 1px 6px; font-family: Consolas, monospace; }
.nav-badge.new { color: #f59e0b; border-color: #f59e0b; }
.modal-back { position: fixed; inset: 0; z-index: 10000; background: rgba(0,0,0,.55); display: none; align-items: center; justify-content: center; padding: 20px; }
.modal-card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: 10px; width: min(580px, 100%);
    height: min(680px, calc(100vh - 40px)); display: flex; flex-direction: column; box-shadow: 0 10px 40px rgba(0,0,0,.45); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.modal-title { font-size: 15px; font-weight: 600; color: var(--accent); }
.modal-x { background: transparent; border: 1px solid var(--border); color: var(--text-secondary); border-radius: 4px; width: 26px; height: 26px; cursor: pointer; font-size: 12px; }
.modal-x:hover { color: var(--text-primary); border-color: var(--accent); }
.modal-body { padding: 14px 18px 18px; overflow-y: auto; font-size: 13px; color: var(--text-primary); line-height: 1.5; }
.modal-body a { color: var(--accent); }
.info-tabs { display: flex; gap: 4px; margin: -4px 0 12px; border-bottom: 1px solid var(--border); }
.info-tab { background: none; border: none; border-bottom: 2px solid transparent; color: var(--text-muted); padding: 6px 12px; cursor: pointer; font-size: 12px; margin-bottom: -1px; font-family: inherit; }
.info-tab.on { color: var(--accent); border-bottom-color: var(--accent); }
.wn-ver { font-size: 11px; color: var(--text-muted); margin-bottom: 10px; }
.wn-version { display: flex; align-items: baseline; gap: 10px; margin: 18px 0 2px; padding-bottom: 3px; border-bottom: 1px solid var(--border); }
.wn-version:first-of-type { margin-top: 6px; }
.wn-vnum { font-size: 13px; font-weight: 700; color: var(--accent); font-family: Consolas, monospace; }
.wn-vdate { font-size: 11px; color: var(--text-muted); }
.wn-headline { font-size: 13px; font-weight: 600; color: var(--text-primary); margin: 6px 0; line-height: 1.4; }
.wn-notes { margin: 0 0 0 18px; padding: 0; }
.wn-notes li { margin: 6px 0; font-size: 12.5px; line-height: 1.5; color: var(--text-secondary); }
.wn-notes li b { color: var(--text-primary); }
.wn-notes code { font-size: 11.5px; background: var(--bg-deep); border: 1px solid var(--border); border-radius: 3px; padding: 0 4px; }
.gd-item { border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px; margin: 0 0 10px; }
.gd-title { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.gd-desc { font-size: 12px; color: var(--text-secondary); margin: 4px 0 8px; line-height: 1.45; }
.gd-meta { font-size: 11px; color: var(--text-muted); }
.gd-links a { font-size: 12px; margin-right: 14px; }
.about-row { display: grid; grid-template-columns: 110px 1fr; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.about-row:last-child { border-bottom: none; }
.about-lbl { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; padding-top: 2px; }
.about-note { font-size: 11px; color: var(--text-muted); }

/* ── Identification ── */
.id-high { color: var(--text-primary); }
.id-med { color: var(--text-primary); }
.id-med::after { content: " ·"; color: var(--amber); }
.id-low { color: var(--text-secondary); font-style: italic; }
.id-low::after { content: " ?"; color: var(--text-muted); font-style: normal; }
.conf-pill { font-size: 10px; border: 1px solid var(--border); border-radius: 8px; padding: 0 6px; color: var(--text-secondary); font-weight: 400; }
.id-h { font-size: 13px; color: var(--accent); font-weight: 600; margin: 4px 0 6px; }

/* "Identified as" selector in Filter */
.ident-sel { width: 100%; margin-top: 8px; }
.ident-sel.active { border-color: var(--accent); color: var(--accent); font-weight: 600; }
