/* Flat, dark, responsive — hand-written, no framework (WEB ADMIN PLAN.md §1.1). */

:root {
    --bg: #14161a;
    --bg-elevated: #1c1f25;
    --bg-input: #20242b;
    --border: #2a2e36;
    --text: #e6e8eb;
    --text-dim: #9aa1ac;
    --accent: #4f8cff;
    --accent-dim: #2c4a82;
    --danger: #e5534b;
    --success: #3fb950;
    --warning: #d29922;
    --radius: 6px;

    /* Chart categorical palette — dataviz skill's validated dark-mode steps, fixed slot order
       (never cycled/reassigned per-chart). Only as many slots as the widest chart needs (4). */
    --chart-series-1: #3987e5; /* blue */
    --chart-series-2: #199e70; /* aqua */
    --chart-series-3: #c98500; /* yellow */
    --chart-series-4: #008300; /* green */
    --chart-grid: #2c2c2a;
    --chart-axis: #383835;

    /* Disk-space chart's dashed threshold reference lines (owner request, 2026-08-05) — distinct
       from the categorical series palette above so a threshold line never reads as "just another
       data series." Warning/Danger reuse the existing status colors; Stop/Restart are new. */
    --chart-threshold-warning: var(--warning);
    --chart-threshold-danger: var(--danger);
    --chart-threshold-stop: #ff5c5c;
    --chart-threshold-restart: #58a6ff;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 12px 20px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.brand { font-weight: 600; }

.topnav { display: flex; gap: 16px; flex-wrap: wrap; flex: 1; }
.topnav a { color: var(--text-dim); padding: 4px 0; border-bottom: 2px solid transparent; }
.topnav a:hover { color: var(--text); text-decoration: none; }
.topnav a.active { color: var(--text); border-bottom-color: var(--accent); }

.logout-form { display: flex; align-items: center; gap: 10px; margin: 0; }
.who { color: var(--text-dim); font-size: 13px; }
.link-button {
    background: none; border: none; color: var(--accent); cursor: pointer; font: inherit; padding: 0;
}
.link-button:hover { color: var(--text); }

.content { padding: 24px; max-width: 1100px; margin: 0 auto; }

#back-to-top {
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    z-index: 100;
}
#back-to-top:hover { background: var(--bg-input); }
#back-to-top.visible { opacity: 1; visibility: visible; transform: translateY(0); }

/* Floating "unsaved changes" cue (dirty-form.js, owner follow-up 2026-07-30) — same fixed-
   position/IntersectionObserver pattern as #back-to-top just above it, appears whenever a dirty
   tracked form's own Save button has scrolled out of view. Clicking it submits that form. */
#dirty-form-save-cue {
    position: fixed;
    right: 20px;
    bottom: 70px;
    padding: 10px 16px;
    border-radius: 20px;
    background: var(--warning);
    border: 1px solid var(--warning);
    color: #1a1200;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    z-index: 100;
}
#dirty-form-save-cue:hover { background: #e0a52e; }
#dirty-form-save-cue.visible { opacity: 1; visibility: visible; transform: translateY(0); }

h1, h2, h3 { font-weight: 600; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.1rem; margin-top: 2em; }

.card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
}

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--text-dim); font-weight: 500; font-size: 13px; text-transform: uppercase; }
tr:hover td { background: rgba(255, 255, 255, 0.02); }

.table-scroll { overflow-x: auto; }
.table-scroll table { width: auto; min-width: 100%; }
.table-scroll th.group-header { text-align: center; border-bottom: 1px solid var(--border); }
.table-scroll th.group-header + th.group-header { border-left: 1px solid var(--border); }

.status-ok { color: var(--success); }
.status-error { color: var(--danger); }
.status-warn { color: var(--warning); }
.status-dim { color: var(--text-dim); }

input, select, textarea {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius);
    padding: 8px 10px;
    font: inherit;
    width: 100%;
}

label { display: block; margin-bottom: 12px; font-size: 13px; color: var(--text-dim); }
label input, label select, label textarea { margin-top: 4px; color: var(--text); }

/* Flat toggle switch — replaces the native checkbox box, single element, no markup changes.
   background-size must be set explicitly smaller than the box, otherwise the generated gradient
   image fills the whole element and background-position has nothing to slide. */
input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    width: 40px;
    height: 22px;
    min-width: 40px;
    padding: 0;
    border-radius: 999px;
    background-color: var(--bg-input);
    border: 1px solid var(--border);
    background-image: radial-gradient(circle 8px, var(--text-dim) 100%, transparent 0);
    background-repeat: no-repeat;
    background-size: 16px 16px;
    background-position: left 3px center;
    transition: background-color 0.15s ease, background-position 0.15s ease, border-color 0.15s ease;
    cursor: pointer;
    vertical-align: middle;
    margin-top: 0;
    flex-shrink: 0;
}
input[type="checkbox"]:checked {
    background-color: var(--accent-dim);
    border-color: var(--accent);
    background-image: radial-gradient(circle 8px, var(--text) 100%, transparent 0);
    background-position: right 3px center;
}
input[type="checkbox"]:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

button, .button {
    background: var(--accent-dim);
    color: var(--text);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    padding: 8px 14px;
    cursor: pointer;
    font: inherit;
}
button:hover, .button:hover { background: var(--accent); }
button.danger { border-color: var(--danger); background: transparent; color: var(--danger); }
button.danger:hover { background: var(--danger); color: var(--text); }
button.secondary { background: transparent; border-color: var(--border); }

/* Configuration pages: unsaved-changes visual cue (owner request, 2026-07-29) — dirty-form.js
   toggles this on a tracked form's own Save button once a field differs from its page-load
   value. Amber rather than the usual accent blue so it reads as "pending", not just "primary
   action" (which every Save button already looks like by default). */
.is-dirty, .is-dirty:hover { background: var(--warning); border-color: var(--warning); color: #1a1200; }

.login-wrap { display: flex; justify-content: center; align-items: center; min-height: 70vh; }
.login-form {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    width: 320px;
}
.login-form h1 { text-align: center; margin-top: 0; }
.login-form button { width: 100%; margin-top: 8px; }
.error { color: var(--danger); font-size: 14px; }

.pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-dim);
    text-decoration: none !important;
}
.pill:hover { color: var(--text); }
.pill.active {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--text);
    font-weight: 600;
}

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar form { display: flex; gap: 8px; align-items: center; }

.bulk-toolbar {
    position: sticky;
    top: 0;
    z-index: 20;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
    padding: 10px 14px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
}
.bulk-toolbar span { font-size: 13px; color: var(--text-dim); margin-right: auto; }

.log-tail-wrapper {
    background: #0c0e11;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-height: 70vh;
    overflow-y: auto;
}

.log-tail {
    padding: 12px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12.5px;
    white-space: pre-wrap;
}

/* Owner request: the Dashboard log card's error count dropped the operator into the raw tail
   with no indication of which line(s) were actually counted — highlight ERROR/CRITICAL (and,
   more subtly, WARNING) lines so they're traceable at a glance instead of a manual scan. Same
   rgba-of-the-theme-color convention as .row-problem above (--danger is #e5534b, --warning is
   #d29922) rather than color-mix(), for consistency with the rest of this file. */
.log-line-error { background: rgba(229, 83, 75, 0.14); color: var(--danger); }
.log-line-warning { background: rgba(210, 153, 34, 0.1); color: var(--warning); }

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 16px;
    padding: 10px;
}
.pagination .button {
    padding: 6px 14px;
    font-size: 13px;
}
.pagination span { color: var(--text-dim); font-size: 13px; white-space: nowrap; }

/* --- Directories page --- */

.dir-tabs { display: flex; align-items: center; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 0; flex-wrap: wrap; }
.dir-tab {
    padding: 8px 16px;
    color: var(--text-dim);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    text-decoration: none !important;
    font-size: 14px;
}
.dir-tab:hover { color: var(--text); }
.dir-tab.active { color: var(--text); border-bottom-color: var(--accent); }

.type-badge {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-dim);
}
.type-video  { background: #1a2744; border-color: #2a4a88; color: #7aadff; }
.type-image  { background: #1a2a1a; border-color: #2a6a2a; color: #6fd96f; }
.type-subtitle { background: #2a2214; border-color: #6a4a14; color: #d4a85a; }
.type-ebook  { background: #2a1a2a; border-color: #6a2a6a; color: #d47ad4; }
.type-folder { background: var(--bg-input); border-color: var(--border); color: var(--text-dim); }
.type-file   { background: var(--bg-input); border-color: var(--border); color: var(--text-dim); }

.actions-cell { white-space: nowrap; }

/* Generic "Actions" dropdown menu (actions-menu.js) — one button per row instead of a cluster of
   buttons, same idea as the existing "Move to..." button on Directories/Completed. Reused first
   on Logs -> Search queue (owner request, 2026-07-30: "if other actions rise, it will be
   simpler and more UI friendly"). */
.actions-menu { position: relative; display: inline-block; }
.actions-menu-panel {
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 4px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    z-index: 30;
    min-width: 140px;
    display: flex;
    flex-direction: column;
    padding: 4px;
}
/* The [hidden] attribute alone isn't enough: this rule's own `display: flex` above has the same
   specificity as the browser's built-in `[hidden] { display: none }` UA rule and loads after it,
   so it silently won unconditionally — every menu rendered open regardless of the attribute
   (owner report, 2026-07-30). Spelled out explicitly here instead of relying on cascade order. */
.actions-menu-panel[hidden] { display: none; }
.actions-menu-panel form { display: contents; }
.actions-menu-item {
    background: none;
    border: none;
    color: var(--text);
    text-align: left;
    padding: 8px 12px;
    width: 100%;
    border-radius: var(--radius);
    cursor: pointer;
    font: inherit;
}
.actions-menu-item:hover { background: var(--bg-input); }
.actions-menu-item-danger { color: var(--danger); }
.actions-menu-item-danger:hover { background: var(--danger); color: var(--text); }
.name-cell { word-break: break-all; max-width: 400px; }

/* Generic "dropdown of checkboxes, default All" toolbar filter (filter-dropdown.js), owner
   request 2026-08-08 — same shape as .actions-menu above, just triggered from a toolbar rather
   than a table row. First used on Survey -> Sent Questions. */
.filter-dropdown { position: relative; display: inline-block; }
.filter-dropdown-panel {
    position: absolute;
    left: 0;
    top: 100%;
    margin-top: 4px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    z-index: 30;
    min-width: 160px;
    display: flex;
    flex-direction: column;
    padding: 8px;
    gap: 4px;
}
.filter-dropdown-panel[hidden] { display: none; }
.filter-dropdown-panel label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: normal;
    padding: 2px 4px;
    white-space: nowrap;
}
/* Site-wide input[type="checkbox"] (above) is restyled into a 40px flat toggle-switch pill —
   too big and unfamiliar-looking for a dense multi-select filter list (owner report, 2026-08-09:
   read as "radio buttons"). Restores the native small square checkbox, scoped to this panel only
   — every other checkbox on the site keeps the toggle-switch look. */
.filter-dropdown-panel input[type="checkbox"] {
    -webkit-appearance: auto;
    appearance: auto;
    width: 15px;
    height: 15px;
    min-width: 15px;
    padding: 0;
    margin: 0;
    border-radius: 3px;
    background-color: initial;
    background-image: none;
    background-position: initial;
    background-size: initial;
    border: initial;
    transition: none;
}
.filter-dropdown-panel input[type="checkbox"]:checked {
    background-color: initial;
    background-image: none;
    background-position: initial;
}
.filter-dropdown-panel .filter-all-label {
    border-bottom: 1px solid var(--border);
    padding-bottom: 6px;
    margin-bottom: 2px;
}

/* --- Listing toolbar (filter / view-style / sort) — Directories & Private --- */
/* Sits at the end of .dir-tabs (margin-left: auto pushes it flush right on that flex row),
   shared identically by both pages via list-toolbar.js. */

.listing-toolbar { display: flex; align-items: center; gap: 10px; margin-left: auto; padding: 4px 0; }
/* .listing-filter-wrap is injected by list-toolbar.js around the filter input so the clear (x)
   button can be absolutely positioned inside it without a template/markup change on either page
   that uses this toolbar. */
.listing-filter-wrap { position: relative; display: inline-block; }
.listing-filter { width: 220px; padding: 5px 26px 5px 10px; font-size: 13px; }
.listing-filter-clear {
    display: none;
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 15px;
    line-height: 1;
    padding: 4px 6px;
    cursor: pointer;
    margin: 0;
}
.listing-filter-clear:hover { color: var(--text); }
.listing-filter-wrap.has-value .listing-filter-clear { display: block; }
.listing-sort { width: auto; padding: 5px 8px; font-size: 13px; }
.view-style-buttons { display: flex; gap: 2px; }
/* Named view-style-btn, not view-btn — Directories' existing per-row "View" (play video) button
   already uses the .view-btn class; colliding names would make its global
   document.querySelectorAll('.view-btn') pick up these toolbar buttons too. */
.view-style-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim);
    border-radius: var(--radius);
    padding: 4px 8px;
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
}
.view-style-btn:hover { background: var(--bg-input); color: var(--text); }
.view-style-btn[aria-pressed="true"] { background: var(--accent-dim); border-color: var(--accent); color: var(--text); }

/* Items hidden by the filter — list-toolbar.js toggles this class rather than inline styles,
   so it composes cleanly with the list/grid display rules below instead of fighting them. */
.listing-hidden { display: none !important; }

/* File size display toggle (Directories/Private, owner request) — a container gets
   .sizes-hidden and every `.file-size` element inside it disappears, regardless of which
   listing view (table row or card) it's rendered in. */
.sizes-hidden .file-size { display: none; }

.btn-sm {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim);
    border-radius: var(--radius);
    padding: 3px 10px;
    font: inherit;
    font-size: 12px;
    cursor: pointer;
    margin-right: 4px;
}
.btn-sm:hover { background: var(--bg-elevated); color: var(--text); }
.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: var(--text); }
/* Reserves the same box (including the label text, so width matches exactly) as its real
   counterpart on other rows — keeps action buttons that only apply to some rows (e.g. View,
   only for video/image entries) from making the rest of the row's buttons ragged/misaligned. */
.btn-placeholder { visibility: hidden; }

/* --- Modals --- */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-box {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    width: 420px;
    max-width: 95vw;
}
.modal-box-wide { width: 760px; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; justify-content: flex-end; }

/* --- Directories/Private view-style toggle --- */
/* .listing wraps both a page's item collection(s); list-toolbar.js sets data-view on it.
   Directories renders two sibling blocks (.listing-table + .listing-cards) and toggles which is
   visible; Private only has .video-grid and gets restyled in place for "list" mode below. */

.listing[data-view="list"] .listing-cards { display: none; }
.listing[data-view="grid-small"] .listing-table,
.listing[data-view="grid-large"] .listing-table { display: none; }

.listing[data-view="grid-small"] .listing-cards,
.listing[data-view="grid-small"] .video-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
}
.listing[data-view="grid-large"] .listing-cards,
.listing[data-view="grid-large"] .video-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

/* Private's cards double as the "list" row shape too — no separate markup, just reflowed. */
.listing[data-view="list"] .video-grid { display: block; }
.listing[data-view="list"] .video-card { flex-direction: row; align-items: center; margin-bottom: 6px; }
.listing[data-view="list"] .video-card-thumb { width: 70px; flex-shrink: 0; }
.listing[data-view="list"] .video-card-body { flex-direction: row; align-items: center; gap: 12px; padding: 6px 12px; }
.listing[data-view="list"] .video-card-title { flex: 1; }
.listing[data-view="list"] .video-card-actions { flex-shrink: 0; }

/* --- Directories' card view (mirrors .video-card, reuses the same row actions/data attrs) --- */

.listing-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 16px;
}
.listing-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.listing-card-thumb {
    aspect-ratio: 16 / 9;
    background: #0c0e11;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.listing-card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.listing-card-placeholder { color: var(--text-dim); font-size: 28px; }
.listing-card-body { padding: 10px 12px; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.listing-card-title {
    font-size: 13px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
}
.listing-card-meta { font-size: 11px; color: var(--text-dim); display: flex; gap: 8px; flex-wrap: wrap; }
.listing-card-actions { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }

/* --- Private / video card grid --- */

.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.video-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.video-card.selected { outline: 2px solid var(--accent); outline-offset: -2px; }

/* Selection checkmark, overlaid on the thumbnail — deliberately NOT a native
   input[type="checkbox"], to avoid the site-wide toggle-switch restyle above, which is sized
   and shaped for config forms, not a compact per-card overlay. */
.card-select-btn {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 3;
    width: 18px;
    height: 18px;
    padding: 0;
    border-radius: 4px;
    border: 2px solid rgba(255, 255, 255, 0.75);
    background: rgba(0, 0, 0, 0.45);
    color: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, border-color 0.15s, color 0.1s;
}
.card-select-btn[aria-pressed="true"] {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.card-select-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.card-sidecars, .card-image-sidecars { display: none; margin: 0; padding: 0; list-style: none; }

.video-card-thumb {
    aspect-ratio: 16 / 9;
    background: #0c0e11;
    cursor: pointer;
    overflow: hidden;
    position: relative;
}
.video-card-thumb::after {
    content: '\25B6';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: #fff;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    transition: opacity 0.15s;
}
.video-card-thumb:hover::after { opacity: 1; }

.video-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.video-card-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-dim);
    font-size: 28px;
}

.video-card-body {
    padding: 10px 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.video-card-title {
    font-size: 13px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
}

.video-card-actions {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    align-items: center;
}

.btn-icon {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim);
    border-radius: var(--radius);
    padding: 4px 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.btn-icon:hover { background: var(--bg-input); color: var(--text); }
.btn-icon.danger { border-color: var(--danger); color: var(--danger); }
.btn-icon.danger:hover { background: var(--danger); color: var(--text); }

@media (max-width: 700px) {
    .topbar { flex-direction: column; align-items: flex-start; }
    .content { padding: 16px; }
}

/* --- Health page --- */

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-dim);
}
.badge-ok { background: #163a1e; border-color: #2a6a2a; color: var(--success); }
.badge-error { background: #3a1a18; border-color: #6a2a2a; color: var(--danger); }
.badge-warn { background: #3a2e14; border-color: #6a5a2a; color: var(--warning); }
.badge-dim { background: var(--bg-input); border-color: var(--border); color: var(--text-dim); }
.badge-info { background: #1a2744; border-color: #2a4a88; color: #7aadff; }

.row-problem { background: rgba(229, 83, 75, 0.08); }

.alert-summary { color: var(--warning); margin: 0 0 12px 0; }

.sortable-th { cursor: pointer; user-select: none; white-space: nowrap; }
.sortable-th:hover { color: var(--text); }
.sortable-th .sort-arrow { color: var(--text-dim); font-size: 11px; margin-left: 4px; }

/* --- Dashboard cards --- */

.dash-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
}

.dash-card {
    display: block;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-left: 4px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    color: var(--text);
    text-decoration: none !important;
    cursor: grab;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.dash-card:hover { box-shadow: 0 0 0 1px var(--accent); }
.dash-card.dragging { opacity: 0.4; cursor: grabbing; }

.dash-card-good { border-left-color: var(--success); }
.dash-card-warning { border-left-color: var(--warning); }
.dash-card-error { border-left-color: var(--danger); }
.dash-card-neutral { border-left-color: var(--border); }

.dash-card-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    margin-bottom: 8px;
}

.dash-card-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--border);
}
.dash-card-good .dash-card-dot { background: var(--success); }
.dash-card-warning .dash-card-dot { background: var(--warning); }
.dash-card-error .dash-card-dot { background: var(--danger); }

.dash-card-lines { font-size: 13px; color: var(--text-dim); line-height: 1.6; }

/* --- Analytics charts --- */

.chart-toolbar { display: flex; gap: 6px; align-items: center; margin-bottom: 12px; }

.chart-card { margin-bottom: 16px; }
.chart-card h2 { margin: 0 0 4px 0; font-size: 15px; }
.chart-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 4px;
}
.chart-card-header h2 { margin: 0; }
.chart-card-header .chart-toolbar { margin-bottom: 0; }

.chart-legend {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 12px;
    margin-bottom: 8px;
}
.chart-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px 3px 8px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg-input);
    text-decoration: none !important;
    color: var(--text);
    cursor: pointer;
    transition: opacity 0.1s ease, border-color 0.1s ease;
}
.chart-legend-item:hover { border-color: var(--accent); }
.chart-legend-item.disabled {
    opacity: 0.5;
    background: transparent;
    border-style: dashed;
}
.chart-legend-item.disabled .chart-legend-label { text-decoration: line-through; }
.chart-legend-item.disabled .chart-legend-swatch { background: var(--text-dim) !important; }
.chart-legend-swatch { width: 14px; height: 2px; border-radius: 1px; display: inline-block; }

.chart-svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-svg .grid-line { stroke: var(--chart-grid); stroke-width: 1; }
.chart-svg .axis-line { stroke: var(--chart-axis); stroke-width: 1; }
.chart-svg .axis-label { fill: var(--text-dim); font-size: 11px; }
.chart-svg .series-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-svg .crosshair { stroke: var(--text-dim); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-svg .hover-dot { stroke: var(--bg-elevated); stroke-width: 2; }
.chart-svg .threshold-line { stroke-width: 1.5; stroke-dasharray: 6 4; opacity: 0.85; }
.chart-svg .threshold-label { font-size: 10px; opacity: 0.85; }

.chart-tooltip {
    position: absolute;
    display: none;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 10px;
    font-size: 12px;
    pointer-events: none;
    z-index: 5;
    white-space: nowrap;
}
.chart-tooltip-date { color: var(--text-dim); margin-bottom: 4px; }
.chart-tooltip-row { display: flex; align-items: center; gap: 6px; }
.chart-tooltip-row + .chart-tooltip-row { margin-top: 2px; }
.chart-tooltip-key { width: 10px; height: 2px; display: inline-block; border-radius: 1px; }
.chart-tooltip-value { color: var(--text); font-weight: 600; margin-left: auto; padding-left: 10px; }

/* --- Tasks page: flow diagram + grouped task cards --- */

.tasks-flow {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin: 20px 0 6px;
}
.flow-sources, .flow-dests { display: flex; flex-direction: column; gap: 6px; }
.flow-node {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    font-size: 12.5px;
    text-align: center;
    white-space: nowrap;
    color: inherit;
    text-decoration: none;
    display: block;
}
.flow-node:hover { border-color: var(--accent); cursor: pointer; }
.flow-node small { display: block; color: var(--text-dim); font-size: 10.5px; margin-top: 2px; font-weight: 400; }
.flow-source { border-color: #2a4a30; background: #16241a; }
.flow-stage { border-color: var(--accent-dim); }
.flow-dest { border-color: #4a2f14; background: #241b12; white-space: normal; }
.flow-arrow { color: var(--text-dim); font-size: 15px; flex-shrink: 0; }
.flow-note { font-size: 12px; color: var(--text-dim); margin: 0 0 28px; }

/* Configuration -> Other content / Exceptions: live search results are click-to-jump (select the
   matching line inside its textarea, browsers auto-scroll a focused selection into view). */
.search-hit-line { cursor: pointer; padding: 1px 2px; border-radius: 2px; }
.search-hit-line:hover { background: var(--bg-elevated); color: var(--accent); }

.task-group { padding: 0; overflow: hidden; }
.task-group-head {
    padding: 14px 16px 12px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: flex-start;
    gap: 14px;
}
.task-group-head-text { flex: 1; min-width: 0; }
.task-group-head h2 { font-size: 14.5px; font-weight: 600; margin: 0; }
.task-group-head p { font-size: 12.5px; color: var(--text-dim); margin: 3px 0 0; }
.task-group-head-run {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    flex-shrink: 0;
}
.task-group-head-run form { margin: 0; }
.task-group-last-run { font-size: 11.5px; color: var(--text-dim); text-align: right; white-space: nowrap; }
.task-run-label { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.task-stage-badge {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    color: var(--accent);
    background: var(--accent-dim);
    border-radius: 4px;
    padding: 1px 8px;
    flex-shrink: 0;
}
.task-stage-badge.independent { color: var(--text-dim); background: var(--bg-input); }
.task-group table { margin: 0; }
.task-group td { padding: 10px 16px; }
.task-name-child code { color: var(--text-dim); }
.task-name-child::before { content: "↳ "; color: var(--text-dim); }
.task-enabled-cell { white-space: nowrap; text-align: right; }
.enabled-badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 500;
}
.enabled-badge.enabled { background: #16241a; border: 1px solid #2a4a30; color: var(--success); }
.enabled-badge.disabled { background: var(--bg-input); border: 1px solid var(--border); color: var(--text-dim); }

/* Survey Movies/TVShows Edit grid (owner request, 2026-08-14) -- 3 clickable, mostly-greyed-out
   icons per user/asset cell (heart/cross/question), the active one colored in. */
.edit-cell { text-align: center; white-space: nowrap; }
.edit-icon {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 15px;
    padding: 2px 3px;
    opacity: 0.3;
    filter: grayscale(100%);
}
.edit-icon:hover { opacity: 0.7; }
.edit-icon.icon-active { opacity: 1; filter: none; }
/* Recorded but not yet physically applied (e.g. a Yes for something not downloaded yet, or a
   still-unanswered "?") -- grayscale first neutralizes the emoji's own native color (red heart,
   red X, etc.) before sepia/saturate impose a consistent amber/orange tone, so the same
   treatment reads as "orange" regardless of which of the 3 icons it's applied to. */
.edit-icon.icon-active.icon-pending { filter: grayscale(1) sepia(1) saturate(4) brightness(1.05); }
.edit-cell.cell-dirty { background: var(--accent-dim); border-radius: var(--radius); }
tr.row-dirty > td:first-child { box-shadow: inset 3px 0 0 var(--accent); }

.chart-empty { color: var(--text-dim); font-size: 13px; padding: 24px 0; text-align: center; }
