/* ---- reset: kill the default body margin so the app reaches the window edges
   (otherwise an 8px inset looks like a border around the UI) ---- */
html, body { margin: 0; padding: 0; }
#react-entry-point, #_dash-app-content { height: 100%; }
html, body { height: 100%; }

/* ---- theme variables ---- */
.app.dark {
    --bg: #0f141b;
    --bg-panel: #161c26;
    --bg-sidebar: #131922;
    --text: #e8eaed;
    --muted: #9aa0a6;
    --border: #2a3340;
    --accent: #4ea1ff;
}
.app.light {
    --bg: #f5f6f8;
    --bg-panel: #ffffff;
    --bg-sidebar: #eef1f5;
    --text: #1b1f24;
    --muted: #5f6368;
    --border: #d8dce2;
    --accent: #1a73e8;
}

.app {
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", system-ui, sans-serif;
    min-height: 100vh;
}

/* ---- layout ---- */
.body-row { display: flex; min-height: 100vh; }
.sidebar {
    width: 210px;
    flex-shrink: 0;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    padding: 18px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: sticky;
    top: 0;
    height: 100vh;
    box-sizing: border-box;
}
.brand { margin-bottom: 18px; }
/* Watchdesk lockup: scales to the sidebar width, keeps its own aspect ratio.
   Only the lockup matching the active theme is shown (cream wordmark on dark,
   navy on light) — see the theme rules below. */
.brand-mark { display: block; width: 100%; max-width: 170px; height: auto; }
.app.dark .brand-light, .app.light .brand-dark { display: none; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-link {
    color: var(--text);
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 14px;
}
.nav-link:hover { background: var(--bg-panel); color: var(--accent); }
.theme-btn { margin-top: auto; }
.content { flex: 1; padding: 20px 28px; min-width: 0; }

/* ---- panels & cards ---- */
.panel {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 18px;
    margin-bottom: 14px;
    flex: 1;
    min-width: 280px;
}
.panel-row { display: flex; gap: 14px; flex-wrap: wrap; }

.kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 12px;
    margin: 14px 0;
}
.kpi-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 16px;
}
.kpi-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.kpi-value { font-size: 28px; font-weight: 700; margin-top: 4px; }

.graph-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(440px, 1fr));
    gap: 16px;
    margin: 16px 0;
}
.graph-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 6px;
    overflow: hidden;
}

/* ---- controls ---- */
.btn {
    background: var(--bg-panel);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 16px;
    margin: 4px 6px 4px 0;
    cursor: pointer;
    font-size: 14px;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { opacity: 0.9; color: #fff; }

.text-input {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    margin: 4px 8px 4px 0;
    font-size: 14px;
}
.text-input.wide { width: 100%; max-width: 560px; box-sizing: border-box; }

.muted { color: var(--muted); font-size: 13px; }
.error-text { color: #ff6b6b; font-size: 13px; }

.status-pill { font-weight: 600; font-size: 13px; }
.status-on { color: #2ecc71; }
.status-off { color: #ff6b6b; }

/* Filter/section labels and checklist/radio option text. Uses --text (not
   --muted) so the controls stay readable — muted grey on the panel background
   was too low-contrast to read. */
label { font-size: 13px; color: var(--text); display: block; margin-top: 8px; }
/* dcc.Checklist / dcc.RadioItems options render as <label><input>text; keep
   their text bright and normal-weight in both themes. */
.app .dash-checklist label, .app .dash-radioitems label,
.app label > input[type="checkbox"] ~ *, .app label:has(> input) {
    color: var(--text);
}

/* dropdowns readable in dark mode */
.app.dark .Select-control, .app.dark .Select-menu-outer,
.app.dark .Select-value-label, .app.dark .Select-input > input,
.app.dark .Select-placeholder {
    background: var(--bg) !important;
    color: var(--text) !important;
}
.app.dark .Select-menu-outer .VirtualizedSelectOption { background: var(--bg-panel); color: var(--text); }
.app.dark .Select-menu-outer .VirtualizedSelectFocusedOption { background: var(--border); }
.dropdown { margin-bottom: 8px; }

/* ---- custom frameless title bar (desktop build) ---- */
.titlebar {
    height: 36px;
    flex-shrink: 0;
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border);
    user-select: none;
}
.tb-drag {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 14px;
    flex: 1;
    -webkit-app-region: drag;   /* fallback for app-region drag */
}
.tb-logo { width: 18px; height: 18px; display: block; border-radius: 4px; }
.tb-title { font-size: 13px; font-weight: 600; color: var(--text); letter-spacing: 0.3px; }
.tb-controls { display: flex; -webkit-app-region: no-drag; }
.win-btn {
    width: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    color: var(--muted);
    cursor: default;
}
.win-btn:hover { background: var(--border); color: var(--text); }
.win-close:hover { background: #d62b32; color: #fff; }

/* When the title bar is present, lay out the app as a column and let the body
   fill the remaining height (no native chrome, no extra scroll). */
.app.has-titlebar { display: flex; flex-direction: column; height: 100vh; min-height: 0; overflow: hidden; }
.app.has-titlebar .body-row { flex: 1; min-height: 0; height: auto; }
.app.has-titlebar .sidebar { height: auto; position: static; }
.app.has-titlebar .content { overflow-y: auto; }

/* ---- station detail page (gauge stick + LFG impacts) ---- */
.gauge-link {
    display: block;
    padding: 8px 12px 2px;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
    text-decoration: none;
}
.gauge-link:hover { text-decoration: underline; }

.station-row { display: flex; gap: 16px; margin: 16px 0; flex-wrap: wrap; }
.station-stick-card { flex: 0 1 360px; min-width: 300px; }
.station-graph-card { flex: 1 1 480px; min-width: 320px; }

.impact-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 13px;
}
.impact-table th, .impact-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}
.impact-table th {
    background: var(--bg-sidebar);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
    color: var(--muted);
}
.impact-height { white-space: nowrap; font-weight: 700; }
.impact-reached { color: #1f77b4; font-weight: 700; white-space: nowrap; }
.impact-row-reached td { background: rgba(31, 119, 180, 0.10); }

/* markdown station links inside the flood table */
.dash-table-container .dash-cell a { color: var(--accent); text-decoration: none; }
.dash-table-container .dash-cell a:hover { text-decoration: underline; }
.dash-table-container .dash-cell p { margin: 0; }

/* ---- sidebar VicEmergency incident log ---- */
.side-log {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    margin-top: 14px;
    border-top: 1px solid var(--border);
    padding-top: 10px;
}
.side-log-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--muted);
    margin-bottom: 6px;
}
.side-log-row {
    font-size: 11px;
    line-height: 1.35;
    padding: 3px 2px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.side-log-dot { margin-right: 5px; font-size: 9px; }
.side-log-time { color: var(--muted); font-family: Consolas, monospace; }
.side-log-empty { font-size: 11px; color: var(--muted); }

/* A newly-arrived incident slots in at the top: it grows from height 0 (which
   pushes the rows below it smoothly down), slides down from just above, and
   flashes a fading accent glow so it catches the eye. Only rows the server
   tagged .side-log-new animate, so the list is calm between arrivals. */
.side-log-new {
    animation: feed-slot-in 0.6s ease-out;
}
@keyframes feed-slot-in {
    0% {
        max-height: 0;
        opacity: 0;
        transform: translateY(-10px);
        padding-top: 0;
        padding-bottom: 0;
        background: rgba(78, 161, 255, 0.30);
    }
    55% {
        max-height: 48px;
        opacity: 1;
        transform: translateY(0);
        background: rgba(78, 161, 255, 0.22);
    }
    100% {
        max-height: 48px;
        opacity: 1;
        transform: translateY(0);
        background: transparent;
    }
}
@media (prefers-reduced-motion: reduce) {
    .side-log-new { animation: none; }
}

/* ---- bottom news ticker ---- */
.content { padding-bottom: 60px; }  /* keep page bottom clear of the ticker */
.ticker {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 36px;
    display: flex;
    align-items: center;
    overflow: hidden;
    background: var(--bg-sidebar);
    border-top: 2px solid var(--accent);
    color: var(--text);
    font-size: 14px;
    z-index: 900;
}
.ticker-hidden { display: none; }
.ticker-emergency {
    background: #a11212;
    border-top-color: #ff5a5a;
    color: #ffffff;
}
.ticker-emergency .ticker-time { color: #ffd9d9; }
.ticker-label {
    flex-shrink: 0;
    align-self: stretch;
    display: flex;
    align-items: center;
    padding: 0 14px;
    font-weight: 700;
    letter-spacing: 1px;
    font-size: 12px;
    background: rgba(0, 0, 0, 0.25);
}
.ticker-track {
    white-space: nowrap;
    display: inline-block;
    padding-left: 100vw;
    animation: ticker-scroll linear infinite;
}
.ticker-time { color: var(--muted); font-family: Consolas, monospace; }
.ticker-sep { opacity: 0.5; }
@keyframes ticker-scroll {
    0%   { transform: translateX(0); }
    100% { transform: translateX(-100%); }
}

/* ---- Intelligence Feed (/feed) ----
   Each entry is a left-accented card: one headline row (time · layer chip ·
   what moved) over the quantified lines. The accent colour is the entry's
   severity, so the eye can scan a long feed by colour alone. */
.feed { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.feed-entry {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);   /* colour set per entry inline */
    border-radius: 10px;
    padding: 10px 14px;
}
.feed-head {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 10px;
}
.feed-time {
    font-family: Consolas, monospace;
    font-size: 15px;
    font-weight: 700;
    color: var(--muted);
}
.feed-chip {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    border: 1px solid currentColor;
    border-radius: 999px;
    padding: 1px 8px;
}
.feed-headline {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
}
.feed-headline:hover { color: var(--accent); text-decoration: underline; }
/* The numbers. Monospace so a column of "214 → 296 ha" lines reads as data. */
.feed-body { margin: 5px 0 0 4px; }
.feed-line {
    font-size: 13px;
    line-height: 1.5;
    color: var(--muted);
    font-family: Consolas, "Segoe UI", monospace;
}
/* The first line is the delta itself — the whole point of the entry. */
.feed-line:first-child { color: var(--text); font-weight: 600; }
.feed-empty-title { font-size: 15px; font-weight: 600; margin-bottom: 4px; }

/* A newly-detected entry slots in at the top, reusing the sidebar log's
   animation shape at card scale (grow from 0 height, slide down, accent glow
   fading out). Only entries the page has not painted before get the class. */
.feed-entry-new { animation: feed-card-in 0.7s ease-out; }
@keyframes feed-card-in {
    0% {
        max-height: 0;
        opacity: 0;
        transform: translateY(-14px);
        padding-top: 0;
        padding-bottom: 0;
        background: rgba(78, 161, 255, 0.30);
    }
    55% {
        max-height: 320px;
        opacity: 1;
        transform: translateY(0);
        background: rgba(78, 161, 255, 0.18);
    }
    100% {
        max-height: 320px;
        opacity: 1;
        transform: translateY(0);
        background: var(--bg-panel);
    }
}
@media (prefers-reduced-motion: reduce) {
    .feed-entry-new { animation: none; }
}

/* Filter controls on the feed panel: options on one line each, tight. */
.radio-row label, .check-row label { margin-top: 4px; font-size: 13px; }

/* ---- Overview "What changed" panel ---- */
.feed-compact .feed-entry { padding: 7px 10px; border-radius: 8px; }
.feed-compact .feed-time { font-size: 13px; }
.feed-compact .feed-headline { font-size: 13px; }
.feed-compact .feed-line { font-size: 12px; }

/* ---- flood rate-of-rise / trend projection ---- */
.trend-summary { font-size: 14px; margin: 6px 0 4px; line-height: 1.6; }

/* The projection caveat is deliberately prominent and always adjacent to any
   ETA: an extrapolated arrival time read as a forecast is the one genuinely
   dangerous thing this page can produce. */
.trend-disclaimer {
    font-size: 12px;
    color: var(--muted);
    border-left: 3px solid #d62728;
    padding: 6px 10px;
    margin: 10px 0 14px;
    background: rgba(214, 39, 40, 0.07);
    border-radius: 0 6px 6px 0;
    max-width: 900px;
}
.trend-disclaimer-strong { color: #d62728; font-weight: 700; }

.trend-table-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--muted);
    margin: 12px 0 6px;
}
.trend-table { border-collapse: collapse; font-size: 13px; }
.trend-table th {
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
    padding: 4px 16px 4px 0;
    font-weight: 700;
}
.trend-table td {
    padding: 3px 16px 3px 0;
    border-bottom: 1px solid var(--border);
}
/* Readings are a column of numbers — monospace so they line up and a rise is
   visible as a shape, not just as text. */
.trend-time, .trend-height { font-family: Consolas, monospace; }
.trend-height { font-weight: 600; }
.trend-up { color: #d62728; font-family: Consolas, monospace; }
.trend-down { color: #2ca02c; font-family: Consolas, monospace; }

/* --- Briefing Mode ------------------------------------------------------ */
/* Warning rows are links, but a panel of default-blue anchors is unreadable
   against the dark theme and turns the section into a wall of colour. Same
   treatment as .feed-headline: body colour, accent only on hover. */
.briefing-warning {
    color: var(--text);
    text-decoration: none;
    font-size: 13px;
}
.briefing-warning:hover { color: var(--accent); text-decoration: underline; }
.briefing-level { font-weight: 600; margin: 8px 0 4px; }

/* --- Event Replay ------------------------------------------------------- */
/* Timeline entries are real <button>s so they are keyboard-reachable, but they
   must read as a list, not a row of chrome buttons. */
.replay-seek {
    display: block;
    width: 100%;
    text-align: left;
    background: transparent;
    color: var(--text);
    border: none;
    border-left: 3px solid transparent;
    padding: 6px 8px;
    margin-bottom: 2px;
    border-radius: 6px;
    cursor: pointer;
    font: inherit;
}
.replay-seek:hover { background: var(--bg-panel); }
/* The entry nearest the selected moment — this is what ties the timeline to
   the slider, so it has to be obvious at a glance. */
.replay-seek-active {
    background: var(--bg-panel);
    border-left-color: var(--accent);
}

/* --- Feedback widget ---------------------------------------------------- */
/* The launcher sits above the news ticker (z-index 900) and clear of its
   36px bar, so the two never overlap on a page with an active ticker. */
.fab {
    position: fixed;
    right: 22px;
    bottom: 50px;
    z-index: 950;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 24px;
    padding: 11px 20px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}
.fab:hover { filter: brightness(1.1); }
.fab:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
.fab-icon { font-size: 16px; line-height: 1; }

.fb-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.55);
    overflow-y: auto;
}
.fb-hidden { display: none; }
.fb-panel {
    background: var(--bg-panel);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px 24px 22px;
    width: 100%;
    max-width: 540px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}
.fb-head { display: flex; align-items: flex-start; justify-content: space-between; }
.fb-title { margin: 0 0 4px; }
.fb-x {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 18px;
    line-height: 1;
    padding: 4px 6px;
    cursor: pointer;
}
.fb-x:hover { color: var(--text); }

/* Kind picker reads as two choices, not a settings row, so it gets more space
   than the shared `label` rule gives radio items elsewhere. */
.fb-kind { margin: 6px 0 4px; }
.fb-kind label { display: inline-flex; align-items: center; margin-right: 18px; }
.fb-dropdown { max-width: 100%; margin-bottom: 4px; }
.fb-textarea { min-height: 130px; resize: vertical; font-family: inherit; }
.fb-row { display: flex; gap: 14px; flex-wrap: wrap; }
.fb-col { flex: 1; min-width: 200px; }
.fb-note { margin: 12px 0 4px; font-size: 12px; }
.fb-actions { margin-top: 8px; }
.fb-error { margin-top: 10px; }

/* Receipt. The reference is the one thing the reporter has to be able to read
   back and retype, so it is set large, monospaced and selectable. */
.fb-receipt { text-align: center; padding: 8px 0 4px; }
.fb-tick {
    font-size: 34px;
    color: #2ecc71;
    line-height: 1;
    margin-bottom: 6px;
}
.fb-ref {
    font-family: Consolas, monospace;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--accent);
    background: var(--bg);
    border: 1px dashed var(--border);
    border-radius: 8px;
    padding: 10px;
    margin: 6px auto 12px;
    user-select: all;
}

/* Admin report queue */
.fb-admin-row { border-top: 1px solid var(--border); padding: 10px 0; }
.fb-admin-row:first-child { border-top: none; }
.fb-admin-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.fb-admin-ref { font-family: Consolas, monospace; font-weight: 600; }
.fb-admin-body { white-space: pre-wrap; font-size: 13px; margin: 6px 0 4px; }
.fb-tag {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 4px;
    padding: 2px 7px;
}
.fb-tag-bug { background: rgba(214, 39, 40, 0.18); color: #ff8080; }
.fb-tag-suggestion { background: rgba(78, 161, 255, 0.18); color: var(--accent); }
.fb-tag-high { background: rgba(214, 39, 40, 0.18); color: #ff8080; }
.fb-tag-medium { background: rgba(242, 169, 59, 0.18); color: #f2a93b; }
.fb-tag-low { background: rgba(154, 160, 166, 0.18); color: var(--muted); }
.app.light .fb-tag-bug, .app.light .fb-tag-high { color: #b3261e; }

@media (max-width: 620px) {
    /* Collapse to the icon so the launcher never covers page content on a
       phone; the title attribute still names it for screen readers. */
    .fab { padding: 12px 14px; }
    .fab span:last-child { display: none; }
}
