/* Customer dashboard — reuses the operator rig's "Field Station" palette. Kept dark-first:
   the ported SVG chart renderers draw light-on-dark grid/axis colors. */
:root {
    --bg-color: #37483c;
    --bg-2: #313f34;
    --panel-bg: rgba(55, 73, 42, 0.72);
    --surface: #37492a;
    --border-color: rgba(225, 232, 220, 0.16);
    --line: rgba(225, 232, 220, 0.10);
    --track: rgba(225, 232, 220, 0.14);
    --text-primary: #f1efe6;
    --text-secondary: #b6c3b4;
    --accent: #ecdfc4;
    --accent-2: #d8b877;
    --success: #86cfa0;
    --warn: #e2b65f;
    --danger: #e28871;
    --led-green: #7fdca0;
    --led-red: #e2725b;
    --led-amber: #e2b65f;
    --font-main: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-code: 'Fira Code', ui-monospace, monospace;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-main);
    background-image: radial-gradient(1100px circle at 50% -10%, #43584a, var(--bg-color) 60%),
        linear-gradient(180deg, var(--bg-color), var(--bg-2));
    background-attachment: fixed;
    min-height: 100vh;
    font-size: 14px;
}

a { color: var(--accent-2); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.strong { font-weight: 600; }
.mono { font-family: var(--font-code); font-size: 12px; color: var(--text-secondary); }
.muted { color: var(--text-secondary); }
.empty, .dd-empty { color: var(--text-secondary); padding: 18px; text-align: center; font-size: 13px; }
button { font-family: inherit; cursor: pointer; }

/* ---- header ---- */
header {
    display: flex; align-items: center; gap: 14px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(40, 52, 42, 0.6);
    position: sticky; top: 0; z-index: 200;
    backdrop-filter: blur(6px);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .2px; cursor: pointer; }
.brand:hover { opacity: .85; }
.brand .mark {
    width: 30px; height: 30px; border-radius: 8px;
    background: linear-gradient(135deg, var(--accent-2), #7fae86);
    display: grid; place-items: center; font-size: 16px;
}
.brand small { display: block; font-weight: 400; color: var(--text-secondary); font-size: 11px; }
header .spacer { flex: 1; }
header select, .btn {
    background: var(--surface); color: var(--text-primary);
    border: 1px solid var(--border-color); border-radius: 8px;
    padding: 7px 11px; font-size: 13px;
}
.btn:hover { border-color: var(--accent-2); }
.btn.small { padding: 4px 9px; font-size: 12px; }

/* ---- health pill (header) ---- */
.health-pill {
    position: relative; display: inline-flex; align-items: center; gap: 7px;
    padding: 6px 11px; border-radius: 999px; font-size: 12px; cursor: default;
    border: 1px solid var(--border-color); background: var(--surface); outline: none;
}
.health-pill .hp-led { width: 9px; height: 9px; border-radius: 50%; background: var(--text-secondary); box-shadow: 0 0 0 3px transparent; }
.health-pill.healthy .hp-led { background: var(--led-green); box-shadow: 0 0 8px 0 var(--led-green); }
.health-pill.partial .hp-led { background: var(--led-amber); box-shadow: 0 0 8px 0 var(--led-amber); }
.health-pill.dead .hp-led { background: var(--led-red); box-shadow: 0 0 8px 0 var(--led-red); }
.health-pill.healthy { border-color: rgba(127, 220, 160, .5); }
.health-pill.partial { border-color: rgba(226, 182, 95, .5); }
.health-pill.dead { border-color: rgba(226, 114, 91, .5); }
.hp-tip {
    display: none; position: absolute; top: calc(100% + 8px); right: 0; z-index: 300;
    background: var(--surface); border: 1px solid var(--border-color); border-radius: 10px;
    padding: 8px 12px; min-width: 130px; box-shadow: 0 10px 26px rgba(0, 0, 0, .45);
}
.health-pill:hover .hp-tip, .health-pill:focus .hp-tip { display: block; }
.hp-row { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-size: 13px; }

/* health LEDs (dropdown + tooltip) */
.led { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; background: var(--text-secondary); }
.led.green { background: var(--led-green); box-shadow: 0 0 6px 0 var(--led-green); }
.led.red { background: var(--led-red); box-shadow: 0 0 6px 0 var(--led-red); }
.led.amber { background: var(--led-amber); box-shadow: 0 0 6px 0 var(--led-amber); }
.led.unknown { background: var(--text-secondary); opacity: .5; }

/* ---- banners ---- */
.banner { margin: 12px 20px 0; padding: 10px 14px; border-radius: 10px; font-size: 13px; border: 1px solid var(--border-color); }
.banner.danger { background: rgba(226, 135, 113, 0.16); border-color: rgba(226, 135, 113, 0.5); }

/* ---- layout ---- */
main { padding: 16px 20px 44px; max-width: 1400px; margin: 0 auto; }
.card { background: var(--panel-bg); border: 1px solid var(--border-color); border-radius: 14px; padding: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.card h2, .panel h2 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-secondary); font-weight: 600; }

/* ---- big anonymized frame ---- */
.frame-card { margin-bottom: 14px; }
.frame-title { display: flex; align-items: center; gap: 10px; }
.frame-mode { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; letter-spacing: .06em; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--border-color); }
.frame-mode .mode-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.frame-mode.live { color: var(--led-green); border-color: rgba(127, 220, 160, .5); background: rgba(127, 220, 160, .08); }
.frame-mode.live .mode-dot { background: var(--led-green); box-shadow: 0 0 6px var(--led-green); animation: livepulse 1.6s ease-in-out infinite; }
.frame-mode.history { color: var(--led-amber); border-color: rgba(226, 182, 95, .5); background: rgba(226, 182, 95, .08); }
.frame-mode.history .mode-dot { background: var(--led-amber); }
@keyframes livepulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
/* Center the frame (both axes); scale down to fit, never stretch a smaller image.
   margin:0 auto centers the wrap itself — under the height cap it can end up narrower
   than the card, and without this it would sit left. */
.frame-wrap { position: relative; margin: 0 auto; background: #10140f; border-radius: 10px; overflow: hidden; max-height: 72vh; aspect-ratio: 16 / 9; display: flex; align-items: center; justify-content: center; }
.frame-wrap img { max-width: 100%; max-height: 100%; width: auto; height: auto; margin: auto; object-fit: contain; display: block; }
.zoomable { cursor: zoom-in; }
.zoom-hint { position: absolute; right: 10px; bottom: 10px; background: rgba(0, 0, 0, .55); color: #fff; font-size: 11px; padding: 3px 8px; border-radius: 6px; pointer-events: none; }
.frame-empty { color: var(--text-secondary); font-size: 13px; }
/* prev/next frame arrows overlaid on the frame edges */
.frame-arrow { position: absolute; top: 50%; transform: translateY(-50%); z-index: 5; width: 42px; height: 42px; border-radius: 50%; background: rgba(0, 0, 0, .45); color: #fff; border: 1px solid rgba(255, 255, 255, .25); font-size: 26px; line-height: 1; display: grid; place-items: center; cursor: pointer; transition: background .15s, opacity .15s; }
.frame-arrow:hover:not(:disabled) { background: rgba(0, 0, 0, .72); }
.frame-arrow.left { left: 12px; }
.frame-arrow.right { right: 12px; }
.frame-arrow:disabled { opacity: .22; cursor: default; }
/* date/time under the frame (#2) */
.frame-meta { margin-top: 10px; text-align: center; }
.frame-datetime { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.frame-sub { margin-top: 3px; font-size: 12px; color: var(--text-secondary); }

/* ---- overview (compact, sized to content) ---- */
.overview { margin-bottom: 16px; }
.tiles { display: inline-flex; flex-wrap: wrap; gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--border-color); border-radius: 12px; padding: 12px 22px; min-width: 130px; }
.tile-val { font-size: 28px; font-weight: 700; line-height: 1; }
.tile-key { margin-top: 6px; color: var(--text-secondary); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }

/* ---- filters (rig-matched) ---- */
.stats-controls {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px 22px;
    background: var(--panel-bg); border: 1px solid var(--border-color); border-radius: 14px;
    padding: 14px 16px; margin-bottom: 16px;
}
.ctl { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.ctl > label { font-size: 12px; color: var(--text-secondary); display: flex; align-items: center; gap: 4px; }
/* #4: start/end fill the row, on one line; click anywhere opens the picker */
.range-row { display: flex; align-items: center; gap: 8px; }
.date-in { flex: 1; min-width: 0; cursor: pointer; }
.range-row .to { color: var(--text-secondary); flex: none; }
.ctl input[type=datetime-local] { background: var(--surface); color: var(--text-primary); border: 1px solid var(--border-color); border-radius: 8px; padding: 8px 10px; font-size: 12px; width: 100%; }
.lookback-row { display: flex; align-items: center; gap: 10px; }
.lookback-row input[type=range] { flex: 1; }
.range-label { display: flex; justify-content: space-between; color: var(--text-secondary); font-size: 11px; }
.hint { color: var(--text-secondary); font-size: 11px; }
input[type=range] { accent-color: var(--accent-2); width: 100%; }
/* #5: presets span the slider width with even spacing (like the rig) */
.window-presets { display: flex; gap: 6px; }
.preset { flex: 1 1 0; text-align: center; min-width: 30px; background: transparent; border: 1px solid var(--border-color); color: var(--text-secondary); border-radius: 6px; padding: 5px 0; font-size: 12px; }
.preset.active { background: var(--accent-2); color: #2a2118; border-color: var(--accent-2); font-weight: 600; }
.help-icon { display: inline-grid; place-items: center; width: 15px; height: 15px; border-radius: 50%; border: 1px solid var(--border-color); font-size: 10px; cursor: help; position: relative; color: var(--text-secondary); }
.help-icon .tooltip { display: none; position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); width: 250px; background: var(--surface); border: 1px solid var(--border-color); border-radius: 8px; padding: 8px 10px; font-size: 11px; color: var(--text-primary); line-height: 1.4; z-index: 300; box-shadow: 0 10px 26px rgba(0, 0, 0, .45); }
.help-icon:hover .tooltip, .help-icon:focus .tooltip { display: block; }

/* #6: the two dropdowns grouped side by side (tidier filter row) */
.ctl-dd { flex-direction: row; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.dd-field { display: flex; flex-direction: column; gap: 5px; }
/* dropdowns (project/camera + species) */
.dropdown { position: relative; }
.dropdown-btn { min-width: 140px; text-align: left; }
.dropdown-menu {
    display: none; position: absolute; z-index: 250; margin-top: 4px; width: 300px; max-height: 340px;
    overflow: auto; background: var(--surface); border: 1px solid var(--border-color);
    border-radius: 10px; padding: 6px; box-shadow: 0 12px 30px rgba(0, 0, 0, .4);
}
.dropdown-menu.open { display: block; }
.dd-actions { display: flex; gap: 6px; padding: 4px 4px 8px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.dd-action { background: transparent; border: 1px solid var(--border-color); color: var(--text-secondary); border-radius: 6px; padding: 3px 8px; font-size: 12px; }
.dd-item { display: flex; align-items: center; gap: 7px; padding: 4px 6px; font-size: 13px; border-radius: 6px; }
.dd-item:hover { background: var(--line); }
.dd-check { display: flex; align-items: center; gap: 7px; flex: 1; cursor: pointer; min-width: 0; }
.dd-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-count { color: var(--text-secondary); font-size: 11px; margin-left: auto; }
.dd-toggle { background: transparent; border: none; color: var(--text-secondary); width: 18px; font-size: 14px; }
.dd-toggle.spacer { visibility: hidden; }
.dd-project { font-weight: 600; }
.dd-camera { padding-left: 16px; color: var(--text-secondary); font-size: 12px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; background: var(--accent); flex: none; vertical-align: middle; }
.dot.group { background: transparent; border: 1px solid var(--text-secondary); }
.rank-tag { font-size: 10px; color: var(--text-secondary); border: 1px solid var(--border-color); border-radius: 4px; padding: 0 4px; margin-left: 5px; }
/* off-taxonomy model labels (gazelle/vehicle/human that the taxonomy doesn't recognise) */
.rank-tag.warn { color: #e0b055; border-color: #7a6326; }

/* ---- tabs ---- */
.tab-bar { display: flex; gap: 4px; border-bottom: 1px solid var(--border-color); margin-bottom: 14px; }
.tab { background: transparent; border: none; color: var(--text-secondary); padding: 10px 16px; font-size: 13px; border-bottom: 2px solid transparent; }
.tab.active { color: var(--text-primary); border-bottom-color: var(--accent-2); font-weight: 600; }
.tab .sub { font-size: 11px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---- charts & tables (rig grid: 2 across) ---- */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
@media (max-width: 900px) { .stats-grid { grid-template-columns: 1fr; } }
.panel { background: var(--panel-bg); border: 1px solid var(--border-color); border-radius: 14px; padding: 14px; }
.panel h2 { margin-bottom: 10px; }
.sub { color: var(--text-secondary); font-size: 12px; text-transform: none; letter-spacing: 0; font-weight: 400; }
.chart { min-height: 120px; }
.chart-svg { width: 100%; height: auto; display: block; }
.chart-svg .ax { fill: var(--text-secondary); font-size: 11px; }
.pie-total { fill: var(--text-primary); font-size: 26px; font-weight: 700; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 8px; font-size: 12px; color: var(--text-secondary); }
.lg { display: inline-flex; align-items: center; gap: 5px; }
/* compact pie so it sits at ~the species-table size, side by side (#Ask A) */
.pie-svg { max-width: 240px; margin: 0 auto; }
/* top-species pie: metric toggle (records / frames / events) */
.pie-metric { display: flex; gap: 4px; margin: 2px 0 8px; }
.pm-btn { background: transparent; border: 1px solid var(--border-color); color: var(--text-secondary); border-radius: 6px; padding: 3px 10px; font-size: 11px; text-transform: capitalize; cursor: pointer; }
.pm-btn.active { background: var(--accent-2); color: #2a2118; border-color: var(--accent-2); font-weight: 600; }
/* top-5 busiest hours under the diurnal chart */
.hour-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 10px; font-size: 12px; }
.hour-top .ht-label { text-transform: uppercase; letter-spacing: .05em; font-size: 11px; color: var(--text-secondary); }
.hour-top .ht { display: inline-flex; align-items: center; gap: 5px; color: var(--text-primary); font-variant-numeric: tabular-nums; }

/* ---- modular dashboard panes ---- */
.section-hint { color: var(--text-secondary); font-size: 12px; margin: 0 0 10px; }
.pane { position: relative; }
.pane[draggable="true"] { cursor: grab; }
.pane.dragging { opacity: .45; }
.pane-remove { position: absolute; top: 8px; right: 10px; z-index: 6; width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--border-color); background: var(--surface); color: var(--text-secondary); font-size: 15px; line-height: 1; display: none; place-items: center; cursor: pointer; }
.pane:hover .pane-remove { display: grid; }
.pane-remove:hover { color: var(--danger); border-color: var(--danger); }
.pane-add { border: 2px dashed var(--border-color); border-radius: 14px; display: grid; place-items: center; cursor: pointer; color: var(--text-secondary); background: rgba(225, 232, 220, .02); }
.pane-add:hover { border-color: var(--accent-2); color: var(--accent-2); }
.stats-grid.modular .pane.panel, .stats-grid.modular .pane-add.panel { min-height: 230px; }
.pane-add.tile { min-width: 130px; min-height: 76px; padding: 12px 22px; }
.add-plus { font-size: 34px; font-weight: 300; line-height: 1; }
.pane-picker { position: absolute; z-index: 70; top: 58%; left: 50%; transform: translateX(-50%); background: var(--surface); border: 1px solid var(--border-color); border-radius: 10px; padding: 6px; min-width: 180px; box-shadow: 0 12px 30px rgba(0, 0, 0, .45); display: flex; flex-direction: column; gap: 2px; }
.pp-item { background: transparent; border: none; color: var(--text-primary); text-align: left; padding: 8px 10px; border-radius: 6px; font-size: 13px; cursor: pointer; }
.pp-item:hover { background: var(--line); }
.pp-empty { color: var(--text-secondary); font-size: 12px; padding: 8px 10px; }

/* tables */
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { padding: 7px 9px; border-bottom: 1px solid var(--line); text-align: left; }
table.data th { color: var(--text-secondary); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
table.data tbody tr:hover { background: var(--line); }
table.data td .dot { margin-right: 9px; }         /* #7: keep the color dot off the label text */
.tbl-scroll { overflow-x: auto; }
/* #4: the frame table scrolls WITHIN the page (rig pattern) — a fixed-height window over the
   100-row page with a sticky header; the Prev/Next pager sits below. */
.frames-wrap { position: relative; }
.frames-scroll { max-height: 60vh; overflow-y: auto; }
.frames-table thead th { position: sticky; top: 0; z-index: 2; background: var(--surface); box-shadow: inset 0 -1px 0 var(--line); }
/* sortable column headers */
.frames-table thead th.sortable { cursor: pointer; position: relative; user-select: none; white-space: nowrap; }
.frames-table thead th.sortable:hover { color: var(--text-primary); }
.frames-table thead th .sort-ind { color: var(--accent-2); font-size: 10px; }
.th-menu { position: absolute; top: 100%; left: 6px; z-index: 20; background: var(--surface); border: 1px solid var(--border-color); border-radius: 8px; padding: 4px; min-width: 150px; box-shadow: 0 12px 30px rgba(0, 0, 0, .45); display: flex; flex-direction: column; gap: 2px; }
.th-menu[hidden] { display: none; }   /* the [hidden] attr must win over display:flex above */
.th-menu button { text-align: left; background: none; border: 0; color: var(--text-primary); font-size: 12px; padding: 7px 9px; border-radius: 6px; cursor: pointer; text-transform: none; letter-spacing: normal; }
.th-menu button:hover { background: var(--line); }
.th-menu button.active { color: var(--accent-2); font-weight: 600; }
.sp-row.off { opacity: .4; }
.more { color: var(--text-secondary); font-size: 11px; }
.frames-table tbody tr { cursor: pointer; }        /* #6: rows load their frame */
.risk-badge { display:inline-block; min-width:22px; text-align:center; padding:1px 6px; border-radius:6px; color:#26301f; font-weight:700; font-size:11px; }

/* pagination */
.pager { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.pager button { background: var(--surface); color: var(--text-primary); border: 1px solid var(--border-color); border-radius: 8px; padding: 6px 14px; font-size: 13px; }
.pager button:disabled { opacity: .4; cursor: default; }
.pager .pinfo { color: var(--text-secondary); font-size: 12px; }

/* map */
.map-wrap { position: relative; }   /* #3: anchors the localized map spinner */
#geo-map { height: 520px; border-radius: 12px; overflow: hidden; }
.map-note { color: var(--text-secondary); font-size: 12px; margin-top: 8px; }
.map-pop .pop-head { font-size: 14px; margin-bottom: 2px; }
.pop-stats { width: 100%; font-size: 12px; margin: 6px 0; }
.pop-stats td { padding: 2px 0; }
.pop-stats td:last-child { text-align: right; font-weight: 600; }
.pop-top { margin: 4px 0 0; padding-left: 18px; font-size: 12px; }
.map-filter-btn { margin-top: 8px; width: 100%; background: var(--accent-2); color: #2a2118; border: none; border-radius: 6px; padding: 6px; font-size: 12px; font-weight: 600; }

/* fullscreen image modal */
.img-modal { position: fixed; inset: 0; z-index: 500; background: rgba(0, 0, 0, .85); display: grid; place-items: center; padding: 30px; }
.img-modal[hidden] { display: none; }
.img-modal img { max-width: 95vw; max-height: 88vh; object-fit: contain; border-radius: 8px; }
.img-modal-cap { color: #fff; margin-top: 10px; font-size: 13px; }
.img-modal-close { position: absolute; top: 18px; right: 24px; background: transparent; border: none; color: #fff; font-size: 34px; line-height: 1; }

/* ---- loading overlays (global + localized), ported from the rig ---- */
#loading-overlay { position: fixed; inset: 0; z-index: 1000; display: none; cursor: progress; align-items: center; justify-content: center; background: rgba(20, 28, 22, .42); backdrop-filter: blur(3px); }
#loading-overlay.on { display: flex; }
.loader { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.loading-text { font-family: var(--font-code); font-size: 12px; letter-spacing: .16em; text-transform: uppercase; color: var(--text-primary); }
.spinner { width: 30px; height: 30px; border-radius: 50%; border: 4px solid rgba(241, 239, 230, .22); border-top-color: var(--text-primary); animation: cw-spin .8s linear infinite; }
.spinner.big { width: 52px; height: 52px; border-width: 5px; }
@keyframes cw-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }
/* localized spinner over the frame viewer (#2) or a modular section (#3) */
.section-host { position: relative; }
.local-spinner { position: absolute; inset: 0; z-index: 40; display: grid; place-items: center; background: rgba(20, 28, 22, .4); backdrop-filter: blur(1px); border-radius: 12px; }
.local-spinner[hidden] { display: none; }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { background: var(--panel-bg); border: 1px solid var(--border-color); border-radius: 16px; padding: 30px; width: 100%; max-width: 380px; }
.login-card h1 { margin: 0 0 4px; font-size: 20px; }
.login-card p.tag { margin: 0 0 22px; color: var(--text-secondary); font-size: 13px; }
.app-version { margin: 14px 0 0; color: var(--text-secondary); font-size: 11px; letter-spacing: .04em; opacity: .6; text-align: center; }
.login-card label { display: block; font-size: 12px; color: var(--text-secondary); margin: 12px 0 5px; }
.login-card input { width: 100%; background: var(--surface); color: var(--text-primary); border: 1px solid var(--border-color); border-radius: 9px; padding: 10px 12px; font-size: 14px; }
.login-card button { width: 100%; margin-top: 20px; background: var(--accent-2); color: #2a2118; border: none; border-radius: 9px; padding: 11px; font-size: 14px; font-weight: 600; }
.login-err { color: var(--danger); font-size: 13px; margin-top: 12px; min-height: 18px; }

/* ===================== Field Station signature touches ===================== */
:root {
    --trk-boar: url("/static/img/track-boar.png");
    --trk-jackal: url("/static/img/track-jackal.png");
    --trk-badger: url("/static/img/track-badger.png");
}
/* a track glyph = the real PNG, recoloured via CSS mask */
.trk { display: inline-block; background: var(--accent);
    -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
    -webkit-mask-position: center; mask-position: center;
    -webkit-mask-size: contain; mask-size: contain; }
.trk.boar { -webkit-mask-image: var(--trk-boar); mask-image: var(--trk-boar); }
.trk.jackal { -webkit-mask-image: var(--trk-jackal); mask-image: var(--trk-jackal); }
.trk.badger { -webkit-mask-image: var(--trk-badger); mask-image: var(--trk-badger); }

/* (brand mark left as the original emoji per feedback — no jackal-print override) */

/* dusk city / edge-of-wild silhouette behind the dashboard */
.skyline-bg { position: fixed; left: 0; right: 0; bottom: 0; height: 44vh; z-index: 0; opacity: .5; pointer-events: none; overflow: hidden; }
.skyline-bg .glow { position: absolute; inset: 0; background: radial-gradient(120% 80% at 70% 100%, rgba(216, 184, 119, .16), transparent 60%); }
.skyline-bg svg { position: absolute; bottom: 0; left: 0; width: 100%; height: 100%; display: block; }
main { position: relative; z-index: 1; }

/* the wheel of wildlife tracks (replaces the ring spinner) */
.track-wheel { position: relative; width: 62px; height: 62px; }
.track-wheel.big { width: 96px; height: 96px; }
.track-wheel .t { position: absolute; top: 50%; left: 50%; width: 12px; height: 12px; margin: -6px; background: var(--text-primary);
    -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat; -webkit-mask-position: center; mask-position: center;
    -webkit-mask-size: contain; mask-size: contain; animation: cw-fade 1.5s linear infinite; }
.track-wheel.big .t { width: 19px; height: 19px; margin: -9.5px; }
.track-wheel .t.boar { -webkit-mask-image: var(--trk-boar); mask-image: var(--trk-boar); }
.track-wheel .t.jackal { -webkit-mask-image: var(--trk-jackal); mask-image: var(--trk-jackal); }
.track-wheel .t.badger { -webkit-mask-image: var(--trk-badger); mask-image: var(--trk-badger); }
@keyframes cw-fade { 0% { opacity: 1; } 70%, 100% { opacity: .12; } }
@media (prefers-reduced-motion: reduce) { .track-wheel .t { animation-duration: 3s; } }

/* faint topographic contour — on EVERY dashboard pane, varied per slot so it never repeats */
.frame-card, .pane:not(.pane-add) { position: relative; }
.frame-card::after, .pane:not(.pane-add)::after {
    content: ""; position: absolute; inset: 0; opacity: .45; pointer-events: none; border-radius: inherit; background-repeat: no-repeat; }
/* variant 1 — top-right, medium (also the frame card) */
.frame-card::after,
.pane:not(.pane-add):nth-child(4n+1)::after {
    background-image:
        radial-gradient(150px 150px at 92% -10%, transparent 43%, var(--line) 44%, transparent 45%),
        radial-gradient(150px 150px at 92% -10%, transparent 59%, var(--line) 60%, transparent 61%),
        radial-gradient(150px 150px at 92% -10%, transparent 75%, var(--line) 76%, transparent 77%); }
/* variant 2 — bottom-left, wide */
.pane:not(.pane-add):nth-child(4n+2)::after {
    background-image:
        radial-gradient(190px 190px at 5% 112%, transparent 49%, var(--line) 50%, transparent 51%),
        radial-gradient(190px 190px at 5% 112%, transparent 65%, var(--line) 66%, transparent 67%),
        radial-gradient(190px 190px at 5% 112%, transparent 81%, var(--line) 82%, transparent 83%); }
/* variant 3 — bottom-right, tight */
.pane:not(.pane-add):nth-child(4n+3)::after {
    background-image:
        radial-gradient(110px 110px at 107% 109%, transparent 37%, var(--line) 38%, transparent 39%),
        radial-gradient(110px 110px at 107% 109%, transparent 53%, var(--line) 54%, transparent 55%),
        radial-gradient(110px 110px at 107% 109%, transparent 69%, var(--line) 70%, transparent 71%); }
/* variant 4 — top-left, large/soft */
.pane:not(.pane-add):nth-child(4n)::after {
    background-image:
        radial-gradient(210px 170px at -8% -14%, transparent 47%, var(--line) 48%, transparent 49%),
        radial-gradient(210px 170px at -8% -14%, transparent 63%, var(--line) 64%, transparent 65%),
        radial-gradient(210px 170px at -8% -14%, transparent 79%, var(--line) 80%, transparent 81%); }

/* ---- login: full-width city street silhouette + a jackal that walks by ---- */
.login-wrap { position: relative; overflow: hidden; }
.city-scene { position: fixed; left: 0; right: 0; bottom: 0; height: 52vh; min-height: 320px; z-index: 0; overflow: hidden; pointer-events: none; }
.city-scene .glow { position: absolute; inset: 0; background: radial-gradient(120% 70% at 62% 82%, rgba(216, 184, 119, .18), transparent 55%); }
.city-scene svg { position: absolute; bottom: 0; left: 0; width: 100%; height: 100%; display: block; }
.login-card { position: relative; z-index: 2; }
/* jackal = sprite-sheet walk cycle (3 left-facing frames), moving right->left */
.jackal { position: fixed; left: 0; bottom: 34px; width: 154px; height: 110px; z-index: 1; pointer-events: none;
    background: url("/static/img/jackal-walk.png") 0 0 / 924px 110px no-repeat;
    filter: drop-shadow(0 6px 6px rgba(0, 0, 0, .4));
    animation: runby 15s linear infinite, jwalk .75s steps(6) infinite; }
@keyframes runby { 0% { transform: translateX(112vw); } 16% { transform: translateX(-24vw); } 100% { transform: translateX(-24vw); } }
@keyframes jwalk { to { background-position-x: -924px; } }
@media (prefers-reduced-motion: reduce) { .jackal { display: none; } }

/* login night sky — a low crescent moon + faint stars, opposite the horizon glow */
.night-sky { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.night-sky svg { width: 100%; height: 100%; display: block; }
.night-sky .tw { animation: twinkle 4.5s ease-in-out infinite; }
@keyframes twinkle { 0%, 100% { opacity: .2; } 50% { opacity: .62; } }
@media (prefers-reduced-motion: reduce) { .night-sky .tw { animation: none; opacity: .45; } }

/* ===================== Metrofauna brand ===================== */
.bo { color: var(--accent-2); }
.brand .mark { background: none; border: 0; padding: 0; }
.brand .mark img { width: 100%; height: 100%; display: block; }
.login-card .brandmark { letter-spacing: -.01em; }
.login-card .byline { margin: 9px 0 2px; color: var(--text-secondary); font-size: 12.5px; }

/* Metrofauna emblem in the header (top-left) + login card */
.brand-emblem { height: 42px; width: auto; display: block; }
.login-card .login-emblem { display: block; width: 230px; max-width: 100%; height: auto; margin: 2px auto 16px; }
/* welcome-back card (returning session) */
.welcome-card { text-align: center; }
.welcome-card .welcome-msg { margin: 14px 0 6px; font-size: 20px; color: var(--text-primary); }
.welcome-card .welcome-msg span { font-weight: 700; }
.welcome-card .welcome-hint { margin: 0 0 8px; color: var(--text-secondary); font-size: 13px; animation: welcomePulse 1.8s ease-in-out infinite; }
@keyframes welcomePulse { 0%,100% { opacity: .55; } 50% { opacity: 1; } }
.welcome-card .welcome-switch { display: inline-block; margin-top: 14px; color: var(--text-secondary); font-size: 12px; text-decoration: underline; }
.welcome-card .welcome-switch:hover { color: var(--text-primary); }
.login-card .brandmark, .login-card .tag, .login-card .byline { text-align: center; }

/* ===================== signup (auth-card) ===================== */
/* Mirrors .login-card's look (same tokens, radius, padding) but taller/scrollable
   since the signup form has many fields — centered horizontally, not vertically. */
.auth-card {
    background: var(--panel-bg); border: 1px solid var(--border-color); border-radius: 16px;
    padding: 30px; width: 100%; max-width: 480px; box-sizing: border-box; margin: 40px auto;
}
.auth-card h1 { margin: 0 0 18px; font-size: 20px; text-align: center; }
.auth-card label { display: block; font-size: 12px; color: var(--text-secondary); margin: 12px 0 5px; }
.auth-card input, .auth-card select {
    width: 100%; background: var(--surface); color: var(--text-primary);
    border: 1px solid var(--border-color); border-radius: 9px; padding: 10px 12px;
    font-size: 14px; font-family: inherit; box-sizing: border-box;
}
.auth-card button[type="submit"] {
    width: 100%; margin-top: 20px; background: var(--accent-2); color: #2a2118;
    border: none; border-radius: 9px; padding: 11px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.auth-card > p { text-align: center; margin-top: 16px; font-size: 13px; }
.auth-card > p a { color: var(--accent-2); }

/* country-code select + phone-number input on one row */
.phone-row { display: flex; gap: 8px; }
.phone-row select { flex: 0 0 auto; width: auto; min-width: 120px; }
.phone-row input { flex: 1; min-width: 0; }

/* grouped sections ("Billing / contact", "Billing — coming soon") */
.auth-card fieldset {
    border: 1px solid var(--border-color); border-radius: 10px; margin: 18px 0 0; padding: 4px 14px 14px;
}
.auth-card legend {
    padding: 0 6px; font-size: 12px; color: var(--text-secondary);
    text-transform: uppercase; letter-spacing: .05em;
}
.coming-soon { background: var(--line); opacity: .6; }
.coming-soon p { color: var(--text-secondary); font-size: 13px; margin: 8px 0 4px; }

/* #signup-error */
.error { color: var(--danger); font-size: 13px; margin: 12px 0; min-height: 18px; }

/* honeypot field (bots fill it, humans never see it) + NDA agreement checkbox */
.hp-field { position: absolute; left: -9999px; top: -9999px; height: 0; width: 0; overflow: hidden; }
/* Scoped under .auth-card to beat `.auth-card label{display:block}` and
   `.auth-card input{width:100%}` — otherwise the checkbox stretches full-width and
   drops onto its own line above the text. align-items:center puts them on one line. */
.auth-card label.nda-agree { display: flex; align-items: center; gap: 8px; margin: 14px 0; font-size: 0.95em; }
.auth-card .nda-agree input[type="checkbox"] { width: auto; margin: 0; flex: 0 0 auto; }

/* settings menu + submenu (dashboard header cog) */
.settings-wrap { position: relative; display: inline-block; }
.btn.icon { padding: 6px 10px; font-size: 15px; line-height: 1; }
.settings-menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 180px;
  background: var(--surface); border: 1px solid var(--border-color); border-radius: 10px;
  padding: 6px; z-index: 60; box-shadow: 0 8px 24px rgba(0,0,0,.35); }
.settings-item { position: relative; padding: 8px 10px; border-radius: 7px; cursor: pointer;
  color: var(--text-primary); font-size: 13px; }
.settings-item:hover { background: var(--line); }
.settings-item .chev { float: right; opacity: .6; }
.settings-sub { position: absolute; right: calc(100% + 4px); top: 0; min-width: 170px;
  background: var(--surface); border: 1px solid var(--border-color); border-radius: 10px;
  padding: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.35); }
.settings-subitem { display: block; width: 100%; text-align: left; background: none; border: 0;
  color: var(--text-primary); font-size: 13px; padding: 8px 10px; border-radius: 7px; cursor: pointer; }
.settings-subitem:hover { background: var(--line); }

/* generic modal (change-password). NOTE the :not([hidden]) so the `hidden` attribute hides it. */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); align-items: center;
  justify-content: center; z-index: 100; display: none; }
.modal:not([hidden]) { display: flex; }
.modal-card { background: var(--surface); border: 1px solid var(--border-color);
  border-radius: 14px; padding: 22px 24px; width: min(92vw, 380px); }
.modal-card h2 { margin: 0 0 8px; font-size: 18px; }
.modal-card label { display: block; font-size: 12px; color: var(--text-secondary); margin: 12px 0 5px; }
.modal-card input { width: 100%; background: var(--surface); color: var(--text-primary);
  border: 1px solid var(--border-color); border-radius: 9px; padding: 10px 12px; font-size: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.btn.primary { background: var(--accent-2); color: #10231f; border: none; }
