/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --sidebar-bg: #1a2236;
    --sidebar-hover: #263350;
    --sidebar-active: #2d4a7a;
    --accent: #4f9cf9;
    --accent-dark: #2d7dd2;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --text-primary: #f1f5f9;
    --text-muted: #94a3b8;
    --body-bg: #f1f5f9;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --topbar-bg: #ffffff;
    --sidebar-width: 240px;

    /* Content-area theme tokens (sidebar stays dark in both modes) */
    --text-heading: #1e293b;
    --text-body-color: #334155;
    --text-faint: #64748b;
    --surface-alt: #f8fafc;
    --surface-alt-hover: #e2e8f0;
    --input-bg: #ffffff;
    --success-text: #15803d;
    --link-color: var(--accent-dark);
}

[data-theme="dark"] {
    --body-bg: #0f1420;
    --card-bg: #1a2236;
    --border: #2a3550;
    --topbar-bg: #1a2236;
    --text-heading: #f1f5f9;
    --text-body-color: #cbd5e1;
    --text-faint: #94a3b8;
    --surface-alt: #20293f;
    --surface-alt-hover: #2a3550;
    --input-bg: #141b2e;
    --success-text: var(--success);
    --link-color: var(--accent);
    /* Native controls (date pickers, select pop-ups, scrollbars) draw dark too. */
    color-scheme: dark;
}

html, body { height: 100%; font-family: 'Segoe UI', system-ui, sans-serif; background: var(--body-bg); }
/* Bootstrap sets body text to #212529; anything without its own colour must follow the theme. */
body { color: var(--text-body-color); }

/* ── Layout ── */
.app-layout { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
}


.main-wrapper { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.top-bar {
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.top-bar-title { font-size: 1rem; font-weight: 600; color: var(--text-heading); flex-shrink: 0; }
.top-bar-right { display: flex; align-items: center; gap: 16px; flex-shrink: 0; }
.server-badge { font-size: 0.75rem; color: var(--success-text); font-weight: 500; }
.server-badge-link { text-decoration: none; border-radius: 4px; padding: 2px 6px; }
.server-badge-link:hover { text-decoration: underline; background: var(--surface-alt); }
.content-area { flex: 1; overflow-y: auto; padding: 24px; }

/* ── Global Computer Search (top bar) ── */
.global-search { position: relative; flex: 1; max-width: 420px; margin: 0 24px; }
.global-search-input { width: 100%; padding: 8px 12px; border-radius: 7px; border: 1px solid var(--border); background: var(--input-bg); color: var(--text-body-color); font-size: 0.875rem; box-sizing: border-box; }
.global-search-input:focus { outline: none; border-color: var(--accent, #4f9cf9); box-shadow: 0 0 0 3px rgba(79,156,249,0.15); }
.global-search-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--card-bg); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.2); z-index: 700; max-height: 440px; overflow-y: auto; }
.global-search-result { padding: 8px 12px; display: flex; justify-content: space-between; align-items: center; gap: 10px; cursor: pointer; font-size: 0.875rem; }
.global-search-result:hover { background: var(--surface-alt); }
.global-search-result-name { font-weight: 600; color: var(--text-heading); }
.global-search-result-meta { font-size: 0.75rem; color: var(--text-faint); font-family: monospace; white-space: nowrap; }
.global-search-group { padding: 8px 12px 4px; font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-faint); }
.global-search-empty { padding: 10px 12px; font-size: 0.8rem; color: var(--text-faint); }

.theme-toggle {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 7px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.15s;
}
.theme-toggle:hover { background: var(--surface-alt-hover); }

/* ── Upload Queue (top bar) ── */
.upload-queue { position: relative; }
.upload-queue .theme-toggle { position: relative; color: var(--text-body-color); }
.upload-queue-spinner { display: inline-block; animation: upload-queue-spin 1s linear infinite; }
@keyframes upload-queue-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.upload-queue-badge { position: absolute; top: -4px; right: -4px; min-width: 16px; height: 16px; padding: 0 3px; border-radius: 8px; background: var(--accent); color: #fff; font-size: 0.65rem; font-weight: 700; display: flex; align-items: center; justify-content: center; line-height: 1; }
.upload-queue-panel { position: absolute; top: calc(100% + 6px); right: 0; width: 320px; background: var(--card-bg); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.2); z-index: 700; max-height: 400px; overflow-y: auto; padding: 10px; }
.upload-queue-panel-title { font-size: 0.8rem; font-weight: 600; color: var(--text-heading); margin-bottom: 8px; }
.upload-queue-item { padding: 8px 4px; border-top: 1px solid var(--border); }
.upload-queue-item:first-of-type { border-top: none; }
.upload-queue-item-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.upload-queue-item-name { font-size: 0.8rem; font-weight: 600; color: var(--text-heading); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upload-queue-dismiss { cursor: pointer; color: var(--text-faint); font-size: 1rem; line-height: 1; flex-shrink: 0; }
.upload-queue-dismiss:hover { color: var(--text-body-color); }
.upload-queue-item-meta { font-size: 0.7rem; color: var(--text-faint); margin-top: 4px; }

/* ── Sidebar Nav ── */
.sidebar-nav { display: flex; flex-direction: column; flex: 1; gap: 4px; padding: 12px 0; }

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    margin-bottom: 8px;
}

.brand-mark { width: 30px; height: 30px; flex: none; }
.brand-wordmark { height: 32px; width: auto; }
.brand-name { color: var(--text-primary); font-size: 1rem; font-weight: 700; letter-spacing: 0.02em; }

.nav-section { margin-bottom: 4px; }

.nav-section-label {
    display: block;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 8px 20px 4px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 20px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 600;
    transition: background 0.15s, color 0.15s;
    margin: 1px 8px;
    border-radius: 6px;
}

.nav-link:hover { background: var(--sidebar-hover); color: var(--text-primary); }
/* The current page: the whole row is filled and outlined, so it reads at a glance against the sidebar gradient. */
.nav-link.active { background: rgba(15, 23, 42, 0.55); color: var(--accent); font-weight: 700; box-shadow: inset 0 0 0 2px rgba(226, 232, 240, 0.8); }
.nav-link.active:hover { background: rgba(15, 23, 42, 0.7); }
/* Clicking a link shouldn't leave a focus ring on top of that; keyboard focus still gets one. */
.nav-link:focus { outline: none; }
.nav-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Sidebar sections (Deployment, Configuration...): the header toggles its links open or closed. */
.nav-section-toggle { display: flex; align-items: center; gap: 6px; width: 100%; margin-top: 6px; padding: 12px 20px 6px; background: none; border: none; border-top: 1px solid rgba(148, 163, 184, 0.22); font: inherit; font-size: 0.75rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: #cbd5e1; text-align: left; cursor: pointer; }
.nav-section-toggle:hover { color: var(--text-primary); }
.nav-section-toggle > span:first-child { flex: 1; }
.nav-section-toggle.has-active { color: var(--accent); }
.nav-section-toggle:focus { outline: none; }
.nav-section-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.nav-section-toggle .badge { letter-spacing: 0; }
.nav-chevron { margin-left: auto; font-size: 0.75rem; transition: transform 0.15s; transform: rotate(-90deg); }
.nav-chevron.open { transform: none; }

/* ── Cards ── */
.card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-title { font-size: 0.9rem; font-weight: 600; color: var(--text-heading); }
.card-body { padding: 20px; }

/* Settings pages: one card per page, all the same width. */
.settings-card { max-width: 800px; }

/* Computer page: people the AD-style name could belong to. */
.name-candidates { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; }

/* Settings → Active Directory: the OU checklist. */
.ad-ou-list { max-height: 360px; overflow-y: auto; border: 1px solid var(--border); border-radius: 6px; padding: 8px 12px; }
.ad-ou-row { display: flex; align-items: center; gap: 6px; }
.ad-ou-toggle { width: 20px; height: 20px; flex: none; padding: 0; border: none; background: none; color: var(--text-faint); cursor: pointer; font-size: 0.8rem; line-height: 1; border-radius: 4px; }
.ad-ou-toggle:hover { background: var(--border); color: var(--text-heading); }
.ad-ou-toggle-space { width: 20px; flex: none; }

/* Settings → Distribution Points. */
.dp-content-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.dp-faint { font-size: 0.8rem; color: var(--text-faint); }
.dp-small { font-size: 0.8rem; word-break: break-all; }
.dp-problem { font-size: 0.8rem; color: var(--danger); }
.dp-steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 14px; }
.dp-steps .btn { margin-right: 8px; }
.dp-copy-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.dp-copy-label { min-width: 110px; font-size: 0.875rem; color: var(--text-faint); }
.dp-copy-row code { font-size: 0.95rem; padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px; user-select: all; word-break: break-all; }
.dp-code { font-weight: 700; letter-spacing: 0.08em; }
.dp-edit-row > td { background: var(--bg-subtle, transparent); padding: 16px; }

/* Tabs across the top of an area's pages (PageTabs): the area, then its settings */
.page-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin: -8px 0 20px; border-bottom: 1px solid var(--border); }
.page-tab { padding: 8px 14px; font-size: 0.875rem; color: var(--text-faint); text-decoration: none;
    border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.page-tab:hover { color: var(--text-heading); }
.page-tab.active { color: var(--accent-dark); border-bottom-color: var(--accent); font-weight: 600; }
[data-theme="dark"] .page-tab.active { color: var(--accent); }
.page-tab-gear { margin-right: 4px; opacity: 0.7; }

/* Teams Alerts: options under an alert kind */
.alert-suboptions { margin: 0 0 8px 24px; }
.alert-suboptions .form-check { flex-wrap: wrap; align-items: center; }
.alert-suboptions .form-control.alert-inline-number { width: 80px; display: inline-block; margin: 0; padding: 2px 6px; }
.alert-suboptions .form-control.alert-inline-text { width: 120px; display: inline-block; margin: 0; padding: 2px 6px; }

/* Distribution point status page */
.dps-summary { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 16px; padding: 14px 18px; margin-bottom: 20px;
    border-radius: 10px; border: 1px solid var(--border); border-left-width: 5px; background: var(--card-bg); color: var(--text-heading); }
.dps-summary.dps-ok { border-left-color: var(--success); }
.dps-summary.dps-busy { border-left-color: var(--accent); }
.dps-summary.dps-bad { border-left-color: var(--danger); }
.dps-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(420px, 100%), 1fr)); gap: 20px; align-items: start; }
.dps-card { border-top: 4px solid var(--border); margin-bottom: 0; }
.dps-card-ok { border-top-color: var(--success); }
.dps-card-busy { border-top-color: var(--accent); }
.dps-card-warn { border-top-color: var(--warning); }
.dps-card-bad { border-top-color: var(--danger); }
.dps-name { font-weight: 600; font-size: 1rem; color: var(--text-heading); }
.dps-summary-line { font-size: 0.875rem; margin-bottom: 10px; color: var(--text-body-color); }
.dps-summary-line.dp-problem { color: var(--danger); }
.dps-bar { height: 8px; border-radius: 4px; background: var(--surface-alt-hover); overflow: hidden; margin-bottom: 6px; }
.dps-bar-fill { height: 100%; background: var(--text-faint); transition: width 0.4s; }
.dps-bar-ok { background: var(--success); }
.dps-bar-busy { background: var(--accent); }
.dps-bar-warn { background: var(--warning); }
.dps-bar-bad { background: var(--danger); }
.dps-missing { margin-top: 12px; font-size: 0.85rem; color: var(--text-body-color); }
.dps-missing summary { cursor: pointer; color: var(--text-heading); }
.dps-missing ul { list-style: none; margin: 8px 0 0; padding: 0; max-height: 240px; overflow-y: auto; }
.dps-missing li { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border-bottom: 1px solid var(--border); word-break: break-word; }

/* One-time password reset code, shown once on the Users page. */
.reset-code { font-family: Consolas, "Courier New", monospace; font-size: 1.6rem; font-weight: 700; letter-spacing: 0.12em; text-align: center; padding: 14px; border: 2px dashed var(--border); border-radius: 8px; color: var(--text-heading); user-select: all; }

/* Computer page: editable details on the left, read-only status/hardware/warranty on the right. */
.computer-layout { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 1000px) { .computer-layout { grid-template-columns: minmax(0, 1fr); } }
.computer-main, .computer-side, .computer-main > fieldset { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.computer-save-bar { display: flex; gap: 8px; }
.modal-backdrop-fixed { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; z-index: 500; padding: 16px; }
.form-row.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }
.note { border-top: 1px solid var(--border); padding: 10px 0; }
.history-line { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 4px; font-size: 0.875rem; }
.history-detail { font-size: 0.82rem; margin-top: 3px; color: var(--text-body-color); }
.history-detail > span { color: var(--text-faint); }
.history-comment { font-style: italic; }
.history-periods { display: flex; flex-direction: column; gap: 6px; }
.history-period { border: 1px solid var(--border); border-radius: 6px; }
.history-period-head { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; background: none; border: none; cursor: pointer; text-align: left; color: var(--text-body-color); font-size: 0.875rem; flex-wrap: wrap; }
.history-period-head:hover { background: var(--surface-alt); }
.history-caret { width: 12px; color: var(--text-faint); }
.history-user { font-weight: 600; min-width: 140px; }
.history-dates { color: var(--text-faint); font-size: 0.8rem; min-width: 130px; }
.history-statuses { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.history-count { font-size: 0.75rem; color: var(--text-faint); }
.history-table { border-top: 1px solid var(--border); }
.history-table table { font-size: 0.8rem; }
.history-table td, .history-table th { padding: 6px 10px; }
.status-rule-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.custom-field-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 0 16px; }
.custom-field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
/* A field with something beside it (CustomFieldInputs.After): takes the whole row */
.custom-field-with-extra { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 0 16px; }
.custom-field-with-extra > .form-group:first-child { flex: 2 1 340px; }
.custom-field-with-extra > .form-group + .form-group { flex: 1 1 180px; }
.person-picker { position: relative; }
.person-picker-linked { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-size: 0.7rem; font-weight: 600; color: var(--success); pointer-events: none; }
.person-picker-menu { position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: var(--card-bg); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.12); z-index: 60; max-height: 320px; overflow: auto; padding: 4px; }
.person-picker-item { padding: 6px 10px; border-radius: 6px; cursor: pointer; font-size: 0.875rem; color: var(--text-body-color); }
.person-picker-item:hover, .person-picker-item.active { background: var(--surface-alt); }
.person-picker-sub { font-size: 0.78rem; color: var(--text-faint); font-weight: 400; }
.option-tree { list-style: none; margin: 0; padding: 0; }
.option-row { display: flex; align-items: center; gap: 6px; padding: 4px 0; border-bottom: 1px solid var(--border); }
.option-tree .option-tree { margin-left: 28px; }
.option-row .option-name { flex: 1; font-size: 0.875rem; }
.option-tree .retired { color: var(--text-faint); text-decoration: line-through; }
.filter-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filter-dropdown { position: relative; }
.filter-dropdown .btn.filter-active { border: 1px solid var(--accent); color: var(--accent); }
.filter-count { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 0.7rem; font-weight: 700; }
.filter-backdrop { position: fixed; inset: 0; z-index: 55; }
.filter-menu { position: absolute; left: 0; top: calc(100% + 4px); min-width: 220px; max-width: 320px; background: var(--card-bg); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.12); z-index: 56; padding: 8px; }
.filter-menu-list { max-height: 300px; overflow: auto; }
.filter-option { margin: 0; padding: 3px 2px; font-size: 0.85rem; }
.filter-option-sub { padding-left: 22px; }
.filter-summary { font-size: 0.8rem; color: var(--text-faint); }
.rpt-computer-filter { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; padding: 6px 10px; border: 1px solid var(--accent); border-radius: 6px; font-size: 0.85rem; color: var(--text-body-color); }
.rpt-computer-filter > span { flex: 1; }
@media (max-width: 700px) { .status-rule-grid { grid-template-columns: 1fr; } }
.note-meta { display: flex; align-items: baseline; gap: 10px; font-size: 0.8rem; color: var(--text-faint); }
.note-meta strong { color: var(--text-heading); }
.note-delete { margin-left: auto; padding: 0; font-size: 0.75rem; }
.note-text { margin-top: 4px; font-size: 0.875rem; color: var(--text-body-color); white-space: pre-wrap; overflow-wrap: anywhere; }

/* Tabs that switch between related pages (Users / Roles). */
.page-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: -8px 0 20px; }
.page-tab { border-bottom: 2px solid transparent; padding: 8px 14px; font-size: 0.875rem; color: var(--text-faint); text-decoration: none; margin-bottom: -1px; }
.page-tab:hover { color: var(--text-heading); }
.page-tab.active { color: var(--text-heading); border-bottom-color: var(--accent); font-weight: 600; }

/* Configuration edit pages opened by a role without edit rights: everything is disabled and the
   action buttons (save, upload, restore, delete...) are hidden. Links like Back still work. */
.readonly-fieldset { border: none; padding: 0; margin: 0; min-width: 0; }
.readonly-fieldset:disabled button.btn, .readonly-fieldset:disabled label.btn { display: none; }

/* Users → Roles: role list on the left, its permissions on the right. */
.roles-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 20px; align-items: start; max-width: 1100px; }
@media (max-width: 800px) { .roles-layout { grid-template-columns: 1fr; } }
.roles-list-item { display: flex; justify-content: space-between; align-items: center; gap: 8px; width: 100%; padding: 10px 12px; border: none; border-radius: 6px; background: none; color: var(--text-body-color); font: inherit; font-size: 0.875rem; text-align: left; cursor: pointer; }
.roles-list-item:hover { background: var(--surface-alt); }
.roles-list-item.active { background: var(--surface-alt); box-shadow: inset 3px 0 0 var(--accent); font-weight: 600; }
.roles-list-count { color: var(--text-faint); font-size: 0.75rem; white-space: nowrap; }
.roles-group { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 12px; }
.roles-group-header { display: flex; align-items: center; gap: 4px; font-weight: 600; font-size: 0.85rem; color: var(--text-heading); margin-bottom: 6px; }
.roles-group-header > span { flex: 1; }
.roles-perm { align-items: flex-start; margin-bottom: 8px; }
.roles-perm input { margin-top: 3px; }

/* ── Stat Cards ── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 10px; padding: 20px; display: flex; align-items: center; gap: 16px; }
.stat-icon { width: 48px; height: 48px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; flex-shrink: 0; }
.stat-icon.blue { background: #dbeafe; }
.stat-icon.green { background: #dcfce7; }
.stat-icon.orange { background: #fef3c7; }
.stat-icon.purple { background: #f3e8ff; }
.stat-icon.red { background: #fee2e2; }
.stat-value { font-size: 1.8rem; font-weight: 700; color: var(--text-heading); line-height: 1; }
.stat-label { font-size: 0.75rem; color: var(--text-faint); margin-top: 2px; }

/* ── Tables ── */
.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
thead th { background: var(--surface-alt); padding: 10px 16px; text-align: left; font-size: 0.75rem; font-weight: 600; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 1px solid var(--border); }
tbody tr { border-bottom: 1px solid var(--border); transition: background 0.1s; }
tbody tr:hover { background: var(--surface-alt); }
tbody tr:last-child { border-bottom: none; }
tbody tr.row-selected, tbody tr.row-selected:hover { background: rgba(79,156,249,0.14); }
/* Bootstrap .table hardcodes light-theme text/border colours. */
.table { color: var(--text-body-color); border-color: var(--border); }
td { padding: 12px 16px; color: var(--text-body-color); vertical-align: middle; }

/* ── DataTable (reorder/resize) ── */
/* Stays table-layout: auto (natural, content-based widths) until every column has been measured
   and pinned to an explicit pixel width (DataTable.razor's freeze step) - only then does .dt-frozen
   switch to table-layout: fixed, where width: auto + min-width: 100% means widening one column
   grows the table itself instead of redistributing space taken from siblings. Switching directly to
   fixed before every column has an explicit width would make the browser redistribute space to/from
   whichever columns are still "auto" the moment any single column is resized. */
.dt-table { width: auto; min-width: 100%; }
/* Once frozen, min-width:100% must go - it was forcing the table to stay full-width even when
   pinned column widths summed to less (e.g. after shrinking one column), and table-layout:fixed
   redistributes that forced extra space across every column instead of leaving it blank, which
   is what made shrinking one column visibly resize its neighbors. Without the forced min-width,
   the table's width is just the sum of its pinned columns: narrower on shrink (blank space, no
   redistribution), wider on grow (triggers .table-container's overflow-x:auto scrollbar). */
.dt-table.dt-frozen { table-layout: fixed; min-width: 0; }
.dt-table th { position: relative; user-select: none; cursor: grab; }
.dt-table th:active { cursor: grabbing; }
.dt-th-label { display: inline-block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: calc(100% - 14px); }
.dt-resize-handle { position: absolute; top: 0; right: 0; width: 10px; height: 100%; cursor: col-resize; z-index: 1; }
.dt-resize-handle::after { content: ''; position: absolute; top: 20%; bottom: 20%; right: 4px; width: 2px; background: var(--border); }
.dt-resize-handle:hover::after { background: var(--accent, #4f9cf9); }
.dt-resize-handle:hover { background: var(--accent, #4f9cf9); opacity: 0.12; }
.dt-table td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dt-sort-indicator { font-size: 0.65rem; margin-left: 4px; opacity: 0.45; }
.dt-table th:hover .dt-sort-indicator { opacity: 0.9; }

/* ── Code editor (CodeMirror) & script content preview ── */
/* Overrides CodeMirror's default (light-only) theme colors with the app's own CSS variables
   instead of vendoring a separate dark CodeMirror theme, so it follows [data-theme="dark"]
   automatically like everything else. */
.code-editor-container { border: 1px solid var(--border); border-radius: 7px; overflow: hidden; }
.code-editor-container .CodeMirror {
    height: 320px;
    font-family: 'Cascadia Code', 'Consolas', monospace;
    font-size: 0.8rem;
    background: var(--input-bg);
    color: var(--text-body-color);
}
.code-editor-container-lg .CodeMirror { height: calc(100vh - 280px); min-height: 400px; }
.code-editor-container .CodeMirror-gutters { background: var(--surface-alt); border-right: 1px solid var(--border); }
.code-editor-container .CodeMirror-linenumber { color: var(--text-faint); }
.code-editor-container .CodeMirror-cursor { border-left-color: var(--text-heading); }
.code-editor-container .CodeMirror-selected { background: rgba(79,156,249,0.25); }
/* Light mode keeps CodeMirror's own token colours (all readable on white). Its stylesheet loads
   after app.css with .cm-s-default selectors, so the dark overrides need the extra attribute
   selector to win; without them strings/variables/built-ins were dark red/blue on navy. */
[data-theme="dark"] .CodeMirror .cm-keyword { color: #c678dd; }
[data-theme="dark"] .CodeMirror .cm-string { color: #98c379; }
[data-theme="dark"] .CodeMirror .cm-string-2 { color: #e5a36b; }
[data-theme="dark"] .CodeMirror .cm-comment { color: var(--text-faint); font-style: italic; }
[data-theme="dark"] .CodeMirror .cm-variable-2 { color: #61afef; }
[data-theme="dark"] .CodeMirror .cm-variable-3,
[data-theme="dark"] .CodeMirror .cm-type { color: #56b6c2; }
[data-theme="dark"] .CodeMirror .cm-builtin { color: #e5c07b; }
[data-theme="dark"] .CodeMirror .cm-atom,
[data-theme="dark"] .CodeMirror .cm-number { color: #d19a66; }
[data-theme="dark"] .CodeMirror .cm-def { color: #e5c07b; }
[data-theme="dark"] .CodeMirror .cm-meta,
[data-theme="dark"] .CodeMirror .cm-qualifier { color: #94a3b8; }
[data-theme="dark"] .CodeMirror .cm-tag { color: #e06c75; }
[data-theme="dark"] .CodeMirror .cm-attribute,
[data-theme="dark"] .CodeMirror .cm-link { color: #61afef; }
[data-theme="dark"] .CodeMirror .cm-bracket { color: #abb2bf; }
[data-theme="dark"] .CodeMirror .cm-header { color: #61afef; }
[data-theme="dark"] .CodeMirror .cm-quote { color: #98c379; }
[data-theme="dark"] .CodeMirror .cm-error { color: #f87171; }

.code-preview {
    font-family: 'Cascadia Code', 'Consolas', monospace;
    font-size: 0.8rem;
    background: var(--input-bg);
    color: var(--text-body-color);
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 12px;
    max-height: 260px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

@keyframes dt-row-pulse { 0% { background: rgba(79,156,249,0.35); } 100% { background: transparent; } }
.dt-row-highlight { animation: dt-row-pulse 1.6s ease-out; }

/* ── DataTable Pagination ── */
/* DataTable "Columns" menu: pick which columns a list shows (saved per user). */
.dt-toolbar { display: flex; justify-content: flex-end; padding: 10px 16px 6px; }
.dt-columns { position: relative; }
.dt-columns-backdrop { position: fixed; inset: 0; z-index: 40; }
.dt-columns-menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 41; min-width: 220px; max-height: 60vh; overflow-y: auto; padding: 12px 14px; background: var(--card-bg); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.15); }
.dt-columns-title { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); margin-bottom: 8px; }
.dt-columns-menu .form-check { margin-bottom: 6px; font-size: 0.85rem; white-space: nowrap; }

.dt-pager { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-top: 1px solid var(--border); flex-wrap: wrap; gap: 12px; }
.dt-pager-info { font-size: 0.8rem; color: var(--text-faint); }
.dt-pager-controls { display: flex; align-items: center; gap: 16px; }
.dt-pager-size { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--text-faint); }
.dt-pager-select { padding: 4px 8px; border-radius: 6px; border: 1px solid var(--border); background: var(--input-bg); color: var(--text-body-color); font-size: 0.8rem; }
.dt-pager-nav { display: flex; align-items: center; gap: 6px; }
.dt-pager-page { font-size: 0.8rem; color: var(--text-faint); min-width: 90px; text-align: center; }

/* ── Badges ── */
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 20px; font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.badge-success { background: #dcfce7; color: #15803d; }
.badge-danger { background: #fee2e2; color: #b91c1c; }
.badge-warning { background: #fef3c7; color: #b45309; }
.badge-info { background: #dbeafe; color: #1d4ed8; }
.badge-secondary { background: #f1f5f9; color: #64748b; }
.badge-purple { background: #f3e8ff; color: #7e22ce; }
.badge-teal { background: #ccfbf1; color: #0f766e; }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border: none; border-radius: 7px; font-size: 0.875rem; font-weight: 500; cursor: pointer; transition: opacity 0.15s, transform 0.1s; text-decoration: none; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-secondary { background: var(--surface-alt); color: var(--text-body-color); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--surface-alt-hover); }
.btn-success { background: var(--success); color: #fff; }
.btn-warning { background: var(--warning); color: #1f2937; }
.btn-warning:hover { background: #d97706; }
.btn-sm { padding: 5px 10px; font-size: 0.8rem; }
.btn-link { background: none; border: none; color: var(--link-color); cursor: pointer; text-decoration: underline; }

/* ── Dropdown menu (e.g. bulk action menus) ── */
.dropdown-menu { position: absolute; right: 0; top: calc(100% + 4px); background: var(--card-bg); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.12); min-width: 180px; z-index: 50; overflow: hidden; display: flex; flex-direction: column; padding: 4px; }
.dropdown-item { display: block; width: 100%; text-align: left; background: none; border: none; padding: 8px 12px; font-size: 0.875rem; color: var(--text-body-color); border-radius: 5px; cursor: pointer; }
.dropdown-item:hover { background: var(--surface-alt-hover); }
.dropdown-item-danger { color: var(--danger); }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--text-body-color); margin-bottom: 6px; }
.form-control { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 7px; font-size: 0.875rem; color: var(--text-heading); background: var(--input-bg); transition: border-color 0.15s, box-shadow 0.15s; }
.form-control:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79,156,249,0.15); }
.form-control-textarea { min-height: 200px; font-family: 'Cascadia Code', 'Consolas', monospace; font-size: 0.8rem; resize: vertical; }
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
.form-hint { font-size: 0.75rem; color: var(--text-faint); margin-top: 4px; }
.form-check { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 0.875rem; color: var(--text-body-color); }
/* Bootstrap paints disabled/read-only fields #e9ecef in both themes, which hides the near-white
   dark-mode text (e.g. the AD-sourced fields on a user's page). Keep the value readable in both. */
.form-control:disabled, .form-control[readonly], .form-select:disabled {
    background-color: var(--surface-alt); color: var(--text-body-color);
    -webkit-text-fill-color: var(--text-body-color); opacity: 1; cursor: default;
}
.form-control::placeholder { color: var(--text-faint); opacity: 1; }
fieldset:disabled .form-check, fieldset:disabled .form-group { opacity: 0.75; }
#preflight .form-check { margin-bottom: 8px; }
.form-check input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-section-title { font-weight: 600; font-size: 0.85rem; color: var(--text-heading); border-top: 1px solid var(--border); padding-top: 14px; margin: 6px 0 12px; }
@media (max-width: 700px) { .form-row { grid-template-columns: 1fr !important; } }

/* ── Page Headers ── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.page-title { font-size: 1.4rem; font-weight: 700; color: var(--text-heading); }
/* Real heading elements (h1/h2) used for these classes keep the div look. */
h1.page-title, h2.card-title { margin: 0; line-height: 1.5; }
.page-subtitle { font-size: 0.875rem; color: var(--text-faint); margin-top: 2px; }

/* ── Step Builder ── */
.step-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.step-item { background: var(--surface-alt); border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px; display: flex; align-items: center; gap: 12px; transition: opacity 0.15s, border-color 0.15s; }
.step-item.disabled-step { opacity: 0.5; }
.step-item.dragging { opacity: 0.4; }
.step-item.drag-over { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
.step-drag-handle { cursor: grab; color: var(--text-faint); font-size: 1rem; line-height: 1; letter-spacing: -2px; user-select: none; padding: 0 4px; margin-right: 4px; }
.step-drag-handle:active { cursor: grabbing; }
.step-order { font-size: 0.7rem; font-weight: 700; color: var(--text-faint); min-width: 24px; text-align: center; }
.step-name { flex: 1; font-size: 0.875rem; font-weight: 500; color: var(--text-heading); }
.step-actions { display: flex; align-items: center; gap: 4px; }
.step-editor { background: var(--input-bg); border: 1px solid var(--accent); border-radius: 8px; padding: 16px; margin-top: 4px; }
.step-condition-summary { display: block; font-size: 0.75rem; font-weight: 400; color: var(--text-faint); margin-top: 2px; }
.checkbox-scroll-list { max-height: 200px; overflow-y: auto; border: 1px solid var(--border); border-radius: 7px; padding: 8px 12px; background: var(--input-bg); }
.checkbox-scroll-list .form-check { margin-bottom: 4px; }
.screen-viewer-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.55); display: flex; align-items: center; justify-content: center; z-index: 800; padding: 16px; }
.screen-viewer { width: min(1600px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; }
/* With an image the card takes the full window height and the screenshot is scaled to fit inside
   it both ways (never cropped or scrolled), whatever the machine's resolution or aspect ratio. */
.screen-viewer.has-image { height: calc(100vh - 32px); }
.screen-viewer-body { padding: 12px; overflow: auto; text-align: center; background: var(--surface-alt); }
.screen-viewer.has-image .screen-viewer-body { flex: 1; min-height: 0; overflow: hidden; display: flex; }
.screen-viewer-body a { display: block; flex: 1; min-width: 0; min-height: 0; }
.screen-viewer-body img { width: 100%; height: 100%; object-fit: contain; display: block; }
.attachment-thumb { max-width: 240px; max-height: 150px; border: 1px solid var(--border); border-radius: 4px; display: block; margin-top: 6px; }
.build-output { max-height: 420px; overflow: auto; background: #0f172a; color: #e2e8f0; font-size: 0.75rem; padding: 12px; border-radius: 6px; white-space: pre-wrap; word-break: break-word; margin: 0; }
@media (max-width: 900px) { .boot-image-grid { grid-template-columns: 1fr !important; } }
.condition-box { border-top: 1px solid var(--border); margin-top: 12px; padding-top: 12px; }
.condition-row { display: grid; grid-template-columns: 150px 170px 1fr auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.condition-row.has-variable { grid-template-columns: 120px 120px 150px 1fr auto; }
.condition-match { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; color: var(--text-body-color); margin-bottom: 10px; }
.condition-match select { width: auto; }
@media (max-width: 900px) { .condition-row, .condition-row.has-variable { grid-template-columns: 1fr; } }

/* ── Detail Slide-out Panel ── */
.detail-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 600; opacity: 0; pointer-events: none; transition: opacity 0.2s ease; }
.detail-overlay.open { opacity: 1; pointer-events: auto; }
.detail-panel { position: fixed; top: 0; right: 0; bottom: 0; width: 380px; max-width: 90vw; background: var(--card-bg); border-left: 1px solid var(--border); box-shadow: -8px 0 24px rgba(0,0,0,0.2); z-index: 601; transform: translateX(100%); transition: transform 0.25s ease, width 0.25s ease, max-width 0.25s ease; display: flex; flex-direction: column; }
.detail-panel.open { transform: translateX(0); }
.detail-panel.expanded { width: 100vw; max-width: 100vw; }
.detail-panel-header { display: flex; align-items: center; justify-content: space-between; padding: 20px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.detail-panel-title { font-size: 1.05rem; font-weight: 700; color: var(--text-heading); }
.detail-panel-body { padding: 8px 20px 20px; overflow-y: auto; flex: 1; }
.detail-panel-body-split { display: flex; gap: 28px; align-items: flex-start; }
.detail-info-column { flex: 0 0 320px; }
.detail-history-column { flex: 1; min-width: 0; }
.detail-section-title { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-faint); margin: 20px 0 4px; }
.detail-section-title:first-child { margin-top: 16px; }
.detail-row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 0.875rem; }
.detail-row:last-child { border-bottom: none; }
.detail-row-clickable { cursor: pointer; }
.detail-row-clickable:hover .detail-value { color: var(--accent, #4f9cf9); }
.detail-label { color: var(--text-faint); }
.detail-value { color: var(--text-heading); font-weight: 600; text-align: right; }

/* ── Progress Bar ── */
.progress { height: 8px; background: #e2e8f0; border-radius: 4px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--accent); border-radius: 4px; transition: width 0.3s; }
.progress-bar.success { background: var(--success); }
.progress-bar.danger { background: var(--danger); }

/* ── Empty State ── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-faint); }
.empty-state-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state-title { font-size: 1rem; font-weight: 600; color: var(--text-faint); }
.empty-state-text { font-size: 0.875rem; margin-top: 4px; }

/* ── Alerts ── */
.alert { padding: 12px 16px; border-radius: 8px; font-size: 0.875rem; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.alert-success { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.alert-danger { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }
.alert-info { background: #dbeafe; color: #1d4ed8; border: 1px solid #bfdbfe; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }

/* ── Live Status Card ── */
.status-card { padding: 16px 20px; border-radius: 0 0 10px 10px; }
.status-phase { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); margin-bottom: 8px; }
.status-title { font-size: 1.3rem; font-weight: 700; color: var(--text-heading); margin-bottom: 6px; }
.status-subtitle { font-size: 0.8rem; color: var(--text-faint); margin-bottom: 6px; }
.status-message { font-size: 0.8rem; color: var(--text-faint); margin-bottom: 16px; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.status-meta-row { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--text-faint); margin-bottom: 6px; }
.status-percent { font-weight: 700; color: var(--accent); }
.status-elapsed { font-size: 0.7rem; color: var(--text-faint); }
.status-phase.failed { color: var(--danger); }
.status-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.status-actions-note { font-size: 0.75rem; color: var(--text-faint); flex-basis: 100%; }

/* ── Log Viewer ── */
.log-viewer { background: #0f172a; color: #e2e8f0; border-radius: 8px; padding: 16px; font-family: 'Cascadia Code', 'Consolas', monospace; font-size: 0.78rem; max-height: 400px; overflow-y: auto; line-height: 1.6; }
.log-info { color: #94a3b8; }
.log-warning { color: #fbbf24; }
.log-error { color: #f87171; }

/* ── Nav Footer (user + logout) ── */
.nav-footer { margin-top: auto; padding: 12px 8px 8px; border-top: 1px solid rgba(255,255,255,0.08); }
.nav-user { display: flex; align-items: center; gap: 8px; padding: 6px 12px; font-size: 0.8rem; color: var(--text-muted); }
.nav-user-name { font-weight: 500; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-logout { display: flex; align-items: center; gap: 8px; padding: 8px 12px; color: var(--text-muted); text-decoration: none; font-size: 0.8rem; border-radius: 6px; transition: background 0.15s, color 0.15s; }
.nav-logout:hover { background: rgba(239,68,68,0.15); color: #f87171; }
.nav-version { display: block; padding: 6px 12px 0; font-size: 0.7rem; color: rgba(255,255,255,0.35); text-decoration: none; }
.nav-version:hover { color: rgba(255,255,255,0.75); text-decoration: underline; }

/* ── Data table (used in Users page) ── */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.data-table thead th { background: var(--surface-alt); padding: 8px 12px; text-align: left; font-size: 0.75rem; font-weight: 600; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 1px solid var(--border); }
.data-table tbody tr { border-bottom: 1px solid var(--border); }
.data-table tbody tr:last-child { border-bottom: none; }
.data-table td { padding: 10px 12px; color: var(--text-body-color); vertical-align: middle; }
.form-control-sm { padding: 5px 8px; font-size: 0.8rem; }

/* ── Upload Zone ── */
.upload-zone { border: 2px dashed var(--border); border-radius: 8px; padding: 20px; text-align: center; background: var(--surface-alt); transition: border-color 0.2s, background 0.2s; margin-bottom: 16px; }
.upload-zone:has(.upload-label:hover) { border-color: var(--accent); background: var(--surface-alt-hover); }
.upload-label { display: block; cursor: pointer; color: var(--text-faint); font-size: 0.875rem; padding: 4px; transition: color 0.15s; }
.upload-label:hover { color: var(--accent); }

/* ── Blazor error UI ── */
#blazor-error-ui { position: fixed; bottom: 0; width: 100%; padding: 12px 20px; background: #b91c1c; color: white; font-size: 0.875rem; display: none; z-index: 1000; }
#blazor-error-ui .reload { color: #fef2f2; font-weight: 600; }
#blazor-error-ui .dismiss { float: right; cursor: pointer; }

/* ── Image servicing (Images → Edit → Offline Updates) ── */
.servicing-log { font-family: 'Cascadia Code', 'Consolas', monospace; font-size: 0.72rem; line-height: 1.45; color: var(--text-body-color); background: var(--surface-alt); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; max-height: 240px; overflow-y: auto; white-space: pre-wrap; word-break: break-word; margin-top: 10px; }

/* ── Charts (StackedColumnChart, BarList) ──
   One hue for single-series bars; status colours only for status series, always with a symbol.
   Hairline recessive grid, 2px surface gap between stacked segments, 4px rounded data end. */
:root { --chart-bar: #2a78d6; --chart-grid: #e1e0d9; --chart-ok: #0ca30c; --chart-bad: #d03b3b; --chart-neutral: #898781; }
[data-theme="dark"] { --chart-bar: #3987e5; --chart-grid: #2c2c2a; }
.scc-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.scc-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 0.8rem; color: var(--text-body-color); }
.scc-key { display: inline-flex; align-items: center; gap: 6px; }
.scc-swatch { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.scc-plot { display: flex; gap: 8px; }
.scc-yaxis { display: flex; flex-direction: column; justify-content: space-between; font-size: 0.7rem; color: var(--text-faint); text-align: right; min-width: 24px; font-variant-numeric: tabular-nums; transform: translateY(-0.45em); height: 100%; }
.scc-area { position: relative; flex: 1; height: 100%; }
.scc-grid { position: absolute; left: 0; right: 0; height: 1px; background: var(--chart-grid); }
.scc-cols { position: absolute; inset: 0; display: flex; align-items: stretch; }
.scc-band { flex: 1; position: relative; display: flex; justify-content: center; align-items: flex-end; outline: none; cursor: default; }
.scc-band:hover, .scc-band:focus-visible { background: var(--surface-alt); }
.scc-col { width: 70%; max-width: 24px; height: 100%; display: flex; flex-direction: column-reverse; }
.scc-seg { width: 100%; }
.scc-seg + .scc-seg { margin-bottom: 2px; }
.scc-top { border-radius: 4px 4px 0 0; }
.scc-tip { display: none; position: absolute; bottom: calc(100% - 20px); left: 50%; transform: translateX(-50%); z-index: 20; background: var(--card-bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; box-shadow: 0 4px 14px rgba(0,0,0,0.15); white-space: nowrap; font-size: 0.78rem; color: var(--text-body-color); pointer-events: none; }
.scc-band:hover .scc-tip, .scc-band:focus .scc-tip { display: block; }
.scc-tip-title { font-weight: 600; color: var(--text-heading); margin-bottom: 4px; }
.scc-tip-row { display: flex; align-items: center; gap: 6px; }
.scc-tip-row strong { color: var(--text-heading); min-width: 18px; text-align: right; }
.scc-tip-key { width: 10px; height: 2px; display: inline-block; }
.scc-tip-total { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 4px; padding-left: 16px; }
.scc-xaxis { display: flex; margin-left: 32px; font-size: 0.68rem; color: var(--text-faint); margin-top: 6px; }
.scc-xaxis span { flex: 1; text-align: center; white-space: nowrap; overflow: visible; }
.scc-table { max-height: 320px; overflow: auto; }
.scc-table th.num, .scc-table td.num { text-align: right; font-variant-numeric: tabular-nums; }

.barlist { display: flex; flex-direction: column; gap: 2px; }
.barlist-row { display: grid; grid-template-columns: minmax(110px, 40%) 1fr 72px; gap: 10px; align-items: center; padding: 5px 4px; border-radius: 6px; }
.barlist-row:hover { background: var(--surface-alt); }
.barlist-label { font-size: 0.83rem; color: var(--text-body-color); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barlist-sub { display: block; font-size: 0.72rem; color: var(--text-faint); }
.barlist-track { height: 10px; }
.barlist-bar { height: 10px; min-width: 2px; background: var(--chart-bar); border-radius: 0 4px 4px 0; }
.barlist-value { font-size: 0.8rem; color: var(--text-body-color); text-align: right; font-variant-numeric: tabular-nums; }
.barlist-empty { font-size: 0.85rem; color: var(--text-faint); padding: 8px 0; }

/* Backup page progress */
.backup-progress { margin-bottom: 14px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-alt); }
.backup-progress-head { display: flex; justify-content: space-between; font-size: 0.85rem; color: var(--text-heading); margin-bottom: 8px; }
.backup-progress-head span { color: var(--text-faint); font-variant-numeric: tabular-nums; }
.backup-progress-detail { font-size: 0.78rem; color: var(--text-faint); margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Top-bar background-activity indicator: while anything runs, a line circles the button's
   outline non-stop, stretching out and shrinking each lap (like the Windows loading circle). */
.activity-orbit { position: absolute; inset: -3px; width: calc(100% + 6px); height: calc(100% + 6px); overflow: visible; pointer-events: none; }
.activity-orbit rect { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-dasharray: 0.5 99.5; animation: activity-orbit 1.4s linear infinite; }
@keyframes activity-orbit {
    0%   { stroke-dasharray: 0.5 99.5; stroke-dashoffset: 0; }
    50%  { stroke-dasharray: 45 55; stroke-dashoffset: -15; }
    100% { stroke-dasharray: 0.5 99.5; stroke-dashoffset: -100; }
}
.upload-queue-badge.failed { background: var(--danger); }
.upload-queue-item-name a { color: inherit; text-decoration: none; }
.upload-queue-item-name a:hover { text-decoration: underline; }
.progress.indeterminate { overflow: hidden; }
.progress.indeterminate .progress-bar { animation: activity-indeterminate 1.4s ease-in-out infinite; }
@keyframes activity-indeterminate { 0% { margin-left: -30%; } 100% { margin-left: 100%; } }
@media (prefers-reduced-motion: reduce) {
    .progress.indeterminate .progress-bar { animation: none; }
}

/* ── Accessibility ── */
:root { --focus-ring: var(--accent-dark); --danger-text: #b91c1c; --warning-text: #b45309; }
[data-theme="dark"] { --focus-ring: var(--accent); --danger-text: #f87171; --warning-text: #fbbf24; }
.app-layout { height: 100dvh; }
/* Keyboard focus is always visible (3:1 against the page in both themes); components with their
   own focus style (.nav-link, .form-control...) keep it - :where() has no specificity. */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
.btn:focus-visible, .theme-toggle:focus-visible, .server-badge-link:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; box-shadow: none; }
.skip-link { position: absolute; left: 8px; top: -120px; z-index: 2000; padding: 10px 16px; border-radius: 6px; background: var(--accent-dark); color: #fff; font-weight: 600; text-decoration: none; }
.skip-link:focus { top: 8px; color: #fff; outline: 3px solid #fff; outline-offset: 2px; }
#main-content:focus { outline: none; }
[data-theme="dark"] .progress { background: var(--surface-alt-hover); }

/* ── Phones and narrow windows: slide-out sidebar ── */
.nav-toggle, .sidebar-backdrop { display: none; }
@media (max-width: 900px) {
    .nav-toggle { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 44px; height: 44px; margin-left: -6px; padding: 0; border: none; border-radius: 8px; background: none; color: var(--text-heading); cursor: pointer; }
    .nav-toggle:hover { background: var(--surface-alt); }
    body .app-layout .sidebar { position: fixed; top: 0; bottom: 0; left: 0; z-index: 900; width: min(300px, 85vw); transform: translateX(-100%); visibility: hidden; transition: transform 0.2s ease, visibility 0s linear 0.2s; box-shadow: 4px 0 24px rgba(0,0,0,0.35); }
    body .app-layout.nav-open .sidebar { transform: none; visibility: visible; transition: transform 0.2s ease; }
    .nav-open .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 899; background: rgba(0,0,0,0.45); }
    .top-bar { height: auto; min-height: 56px; flex-wrap: wrap; gap: 4px 8px; padding: 6px 12px; }
    .top-bar-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .top-bar-right { gap: 8px; }
    .top-bar .global-search { order: 3; flex: 1 1 100%; max-width: none; margin: 0 0 6px; }
    .content-area { padding: 16px; }
    .page-header { flex-wrap: wrap; gap: 12px; }
    /* 16px keeps iOS from zooming the page when a field is focused. */
    .form-control, .global-search-input, .dt-pager-select { font-size: 16px; }
}
@media (max-width: 600px) {
    .server-badge-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
    .content-area { padding: 12px; }
}
/* Finger-sized targets on touch screens. */
@media (pointer: coarse) {
    .btn { min-height: 44px; }
    .btn-sm { min-height: 40px; }
    .theme-toggle { width: 44px; height: 44px; }
    .nav-link, .nav-section-toggle { min-height: 44px; }
}

/* ── Dashboard (Home.razor) - layout from the Imvori dashboard design ── */
.dash-h1 { margin: 0; line-height: 1.2; }
.dash-header .page-subtitle { margin: 2px 0 0; }
.dash-alert { flex-wrap: wrap; }
.dash-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 0 0 16px; }
.dash-tile { background: var(--card-bg); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; }
.dash-tile dt { font-size: 0.8125rem; font-weight: 400; color: var(--text-faint); }
.dash-tile dd { margin: 0; font-size: 1.6rem; font-weight: 800; line-height: 1.25; color: var(--text-heading); font-variant-numeric: tabular-nums; }
.dash-tile-warn dd { color: var(--warning-text); }
.dash-tile-bad dd { color: var(--danger-text); }
.dash-panes { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.dash-pane { padding: 12px 14px 14px; }
.dash-pane-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; min-height: 32px; margin-bottom: 6px; }
.dash-pane-title { margin: 0; font-size: 0.95rem; font-weight: 600; color: var(--text-heading); }
.dash-pane-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.dash-filter { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 0.8rem; color: var(--text-faint); }
.dash-deps { list-style: none; margin: 0; padding: 0; }
.dash-dep + .dash-dep { border-top: 1px solid var(--border); }
.dash-dep-row { display: grid; grid-template-columns: minmax(7.5em, 12em) minmax(0, 1fr) 3.5em; gap: 6px 12px; align-items: center; width: 100%; margin: 0; padding: 10px 8px; border: none; border-radius: 6px; background: none; font: inherit; font-size: 0.875rem; text-align: left; color: var(--text-body-color); cursor: pointer; }
.dash-dep-row:hover, .dash-dep-row[aria-expanded="true"] { background: var(--surface-alt); }
.dash-dep-name { font-weight: 600; color: var(--text-heading); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-dep-step { font-size: 0.8125rem; color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-dep-pct { text-align: right; font-weight: 600; color: var(--text-heading); font-variant-numeric: tabular-nums; }
.dash-bar { grid-column: 1 / -1; height: 6px; border-radius: 3px; overflow: hidden; background: var(--surface-alt-hover); }
.dash-bar i { display: block; height: 100%; border-radius: 3px; background: var(--accent); transition: width 0.6s ease; }
.dash-dep.done .dash-bar i { background: var(--success); }
.dash-dep.done .dash-dep-pct { color: var(--success-text); }
.dash-dep.failed .dash-bar i { background: var(--danger); }
.dash-dep.attention .dash-bar i { background: var(--warning); }
.dash-dep.cancelled .dash-bar i { background: var(--text-faint); }
.dash-dep.failed .dash-dep-step, .dash-dep.attention .dash-dep-step { color: var(--danger-text); font-weight: 600; }
.dash-dep-detail { padding: 6px 8px 14px; }
.dash-dep-detail p { margin: 0; }
.dash-detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px 24px; }
.dash-dep-detail .status-phase { margin-bottom: 4px; }
.dash-detail-title { font-size: 1.05rem; font-weight: 700; color: var(--text-heading); overflow-wrap: anywhere; }
.dash-dep-detail .dash-detail-meta { margin: 4px 0 6px; font-size: 0.8rem; color: var(--text-faint); }
.dash-progress { margin-bottom: 10px; }
.dash-actions { margin-top: 12px; }
.dash-push-right { margin-left: auto; }
.dash-log { list-style: none; margin: 0; padding: 0 2px 0 0; display: grid; gap: 8px; font-size: 0.8125rem; max-height: 560px; overflow-y: auto; }
.dash-log-item { display: grid; grid-template-columns: 3.4em minmax(0, 1fr); gap: 8px; color: var(--text-body-color); overflow-wrap: anywhere; }
.dash-log-item time { color: var(--text-faint); font-variant-numeric: tabular-nums; }
.dash-log-item strong { font-weight: 600; color: var(--text-heading); }
.dash-log-error > span { color: var(--danger-text); }
.dash-log-warning > span { color: var(--warning-text); }
.dash-empty { padding: 32px 12px; text-align: center; font-size: 0.875rem; color: var(--text-faint); }
.dash-empty p { margin: 0; }
.dash-empty .dash-empty-title { margin-bottom: 4px; font-weight: 600; color: var(--text-heading); }
.dash-dialog { width: min(440px, 100%); padding: 24px; }
.dash-dialog-title { margin: 0 0 12px; font-size: 1.05rem; font-weight: 600; color: var(--text-heading); }
.dash-dialog-text { margin: 0 0 20px; font-size: 0.875rem; color: var(--text-body-color); }
.dash-dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
@media (max-width: 1100px) { .dash-panes { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 700px) {
    .dash-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .dash-detail-grid { grid-template-columns: minmax(0, 1fr); }
    /* Name and % on the first line, the step under them, then the bar. */
    .dash-dep-row { grid-template-columns: minmax(0, 1fr) auto; }
    .dash-dep-step { grid-column: 1 / -1; grid-row: 2; white-space: normal; }
    .dash-push-right { margin-left: 0; }
    .dash-actions .btn { flex: 1 1 auto; justify-content: center; }
    .dash-log { max-height: 420px; }
}
@media (prefers-reduced-motion: reduce) {
    .dash-bar i, .progress-bar, .sidebar, .nav-chevron { transition: none !important; }
}

/* Label/value list (Settings → Imvori Cloud). Stacks on narrow screens. */
.detail-list { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; margin: 0; }
.detail-list dt { color: var(--text-muted, #6b7280); font-weight: 600; }
.detail-list dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 600px) { .detail-list { grid-template-columns: 1fr; gap: 2px; } .detail-list dd { margin-bottom: 8px; } }
