/* Odoo Backup Panel — clean, friendly UI with a left sidebar, light/dark support and a
   customisable accent. Light is the default; dark applies automatically when the device
   prefers it (prefers-color-scheme) unless the user forced a theme via the toggle
   (data-theme="light"/"dark" on <html>). The accent (and an optional second gradient stop)
   is set on <html> by theme.js from localStorage. */

:root {
    color-scheme: light dark;

    --bg: #f4f6f8;
    --surface: #ffffff;
    --surface-2: #eef1f5;
    --border: #e2e6ec;
    --text: #19222d;
    --muted: #687481;
    --accent: #4f46e5;
    --accent-hover: color-mix(in srgb, var(--accent), #000 14%);
    --accent-soft: color-mix(in srgb, var(--accent) 12%, #fff);
    --accent-on: #ffffff;
    --ok-bg: #e7f6ec; --ok-fg: #15803d;
    --err-bg: #fdecec; --err-fg: #c0392b;
    --warn-bg: #fdf4e3; --warn-fg: #92600c;
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 4px 16px rgba(16, 24, 40, 0.04);
    --shadow-lg: 0 8px 30px rgba(16, 24, 40, 0.10);
    --radius-lg: 20px;
    --radius: 14px;
    --radius-sm: 9px;
    /* Gradient stops: default to a hue-preserving sheen of the (possibly custom)
       accent; dual-tone presets override --grad-a/--grad-b with two distinct hues. */
    --grad-a: color-mix(in srgb, var(--accent), #fff 10%);
    --grad-b: color-mix(in srgb, var(--accent), #000 14%);
    --accent-grad: linear-gradient(135deg, var(--grad-a), var(--grad-b));
    --ring: color-mix(in srgb, var(--accent) 32%, transparent);
    --sidebar-w: 248px;
}

/* Dark palette — shared by forced-dark and auto-dark. */
:root[data-theme="dark"] {
    --bg: #0d131e;
    --surface: #151c29;
    --surface-2: #1c2536;
    --border: #283346;
    --text: #e6eaf0;
    --muted: #94a3b8;
    --accent: #7c83ff;
    --accent-hover: color-mix(in srgb, var(--accent), #fff 20%);
    --accent-soft: color-mix(in srgb, var(--accent) 24%, var(--surface));
    --accent-on: #0e1420;
    --ok-bg: #15311f; --ok-fg: #5fd58a;
    --err-bg: #3a1d1d; --err-fg: #f29a93;
    --warn-bg: #382c14; --warn-fg: #e8be73;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 22px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 10px 34px rgba(0, 0, 0, 0.45);
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0d131e;
        --surface: #151c29;
        --surface-2: #1c2536;
        --border: #283346;
        --text: #e6eaf0;
        --muted: #94a3b8;
        --accent: #7c83ff;
        --accent-hover: color-mix(in srgb, var(--accent), #fff 20%);
        --accent-soft: color-mix(in srgb, var(--accent) 24%, var(--surface));
        --accent-on: #0e1420;
        --ok-bg: #15311f; --ok-fg: #5fd58a;
        --err-bg: #3a1d1d; --err-fg: #f29a93;
        --warn-bg: #382c14; --warn-fg: #e8be73;
        --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 22px rgba(0, 0, 0, 0.35);
        --shadow-lg: 0 10px 34px rgba(0, 0, 0, 0.45);
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14.5px;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.2s ease, color 0.2s ease;
}

::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }

a { color: var(--accent); }

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: none; }
}

/* === App shell: sidebar + main ============================================== */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
    align-self: stretch; position: relative; isolation: isolate;
    background: var(--surface); border-right: 1px solid var(--border);
    z-index: 60;
}
/* The glass panel spans the full document height (reaches the bottom on long
   pages); the inner block is sticky so the nav/footer stay in view while the
   content scrolls. */
.sidebar-inner {
    position: sticky; top: 0; height: 100vh;
    display: flex; flex-direction: column;
    padding: 16px 14px;
}
.sidebar-brand {
    display: flex; align-items: center; gap: 11px;
    font-size: 16px; font-weight: 680; letter-spacing: -0.01em;
    padding: 6px 8px 14px; color: var(--text); text-decoration: none;
}
.sidebar-brand .logo {
    width: 32px; height: 32px; border-radius: 10px; flex: 0 0 auto;
    background: var(--accent-grad); color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    box-shadow: 0 3px 12px var(--ring);
}
.sidebar-brand .logo svg { width: 18px; height: 18px; }
.sidebar-brand small { display: block; font-size: 11px; font-weight: 500; color: var(--muted); }

.sidebar-nav { display: flex; flex-direction: column; gap: 3px; }
.sidebar-group-label {
    font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--muted); font-weight: 700; padding: 14px 10px 6px;
}
.nav-link {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 11px; border-radius: var(--radius-sm);
    color: var(--text); text-decoration: none; font-size: 14px; font-weight: 550;
    position: relative; transition: background-color 0.13s ease, color 0.13s ease;
}
.nav-link:hover { background: var(--surface-2); }
.nav-link .nav-ico { width: 19px; height: 19px; flex: 0 0 auto; color: var(--muted); transition: color 0.13s ease; }
.nav-link:hover .nav-ico { color: var(--text); }
.nav-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.nav-link.active .nav-ico { color: var(--accent); }
.nav-link.active::before {
    content: ""; position: absolute; left: -14px; top: 9px; bottom: 9px;
    width: 3px; border-radius: 0 3px 3px 0; background: var(--accent);
}
.sidebar-spacer { flex: 1 1 auto; }
.sidebar-foot { font-size: 11px; color: var(--muted); padding: 10px 10px 2px; }
.sidebar-foot .appfoot-ver { font-variant-numeric: tabular-nums; opacity: 0.85; }

.app-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.content { flex: 1 1 auto; width: 100%; max-width: 1120px; margin: 0 auto; padding: 26px 28px 40px; }

/* Mobile sidebar toggle (hidden on desktop). */
.menu-btn {
    display: none; background: var(--surface-2); border: 1px solid var(--border);
    color: var(--text); width: 38px; height: 38px; border-radius: 10px;
    cursor: pointer; align-items: center; justify-content: center;
}
.menu-btn svg { width: 18px; height: 18px; }
.sidebar-backdrop { display: none; }

/* === Top bar (inside the main column) ====================================== */
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; position: sticky; top: 0; z-index: 40;
    background: color-mix(in srgb, var(--surface) 82%, transparent);
    backdrop-filter: saturate(160%) blur(12px);
    -webkit-backdrop-filter: saturate(160%) blur(12px);
    border-bottom: 1px solid var(--border); padding: 11px 28px;
}
.topbar-title { font-size: 15px; font-weight: 600; color: var(--text); }
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* Brand shown in the bar on pre-login pages (no sidebar). */
.brand { font-size: 16px; font-weight: 660; letter-spacing: -0.01em; display: flex; align-items: center; gap: 10px; }
.brand .logo {
    width: 28px; height: 28px; border-radius: 9px;
    background: var(--accent-grad); color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 10px var(--ring);
}
.brand .logo svg { width: 16px; height: 16px; }

/* Simple centered layout for pre-login pages (login / connection setup). */
.plain-main { width: 100%; }
.plain-main .content { max-width: 760px; }

/* === Avatar (shared) ======================================================= */
.avatar {
    width: 26px; height: 26px; border-radius: 50%;
    background: var(--accent); color: var(--accent-on);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700; flex: 0 0 auto; line-height: 1;
}
.avatar-lg { width: 38px; height: 38px; font-size: 16px; }

/* === Account / settings dropdown =========================================== */
.usermenu { position: relative; }
.usermenu-trigger {
    display: inline-flex; align-items: center; gap: 8px;
    background: var(--surface-2); color: var(--text);
    border: 1px solid var(--border); border-radius: 999px;
    padding: 5px 12px 5px 5px; font-size: 14px; cursor: pointer; line-height: 1;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}
.usermenu-trigger:hover { border-color: var(--accent); }
.usermenu-name { font-weight: 550; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usermenu-caret { color: var(--muted); font-size: 11px; transition: transform 0.2s ease; }
.usermenu.open .usermenu-caret { transform: rotate(180deg); }

/* Icon-only trigger (settings / gear, used on pre-login pages). */
.usermenu-trigger-icon { padding: 0; width: 38px; height: 38px; justify-content: center; border-radius: 50%; }
.settings-ico { font-size: 17px; line-height: 1; display: inline-block; color: var(--muted); transition: transform 0.3s ease, color 0.15s ease; }
.usermenu-trigger-icon:hover .settings-ico { color: var(--accent); }
.usermenu.open .settings-ico { transform: rotate(90deg); color: var(--accent); }

.usermenu-panel {
    position: absolute; right: 0; top: calc(100% + 8px);
    width: 268px; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-lg); padding: 8px; z-index: 50;
    max-height: min(82vh, 600px); overflow-y: auto;
    opacity: 0; transform: translateY(-8px) scale(0.97);
    transform-origin: top right; pointer-events: none;
    transition: opacity 0.16s ease, transform 0.16s cubic-bezier(0.4, 0, 0.2, 1);
}
.usermenu.open .usermenu-panel { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }

.usermenu-head { display: flex; align-items: center; gap: 11px; padding: 8px 8px 10px; }
.usermenu-head-text { display: flex; flex-direction: column; min-width: 0; }
.usermenu-head-name { font-weight: 650; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usermenu-head-sub { font-size: 12px; color: var(--muted); }

.usermenu-sep { height: 1px; background: var(--border); margin: 6px 2px; }

.usermenu-item {
    display: flex; align-items: center; gap: 11px;
    padding: 9px 10px; border-radius: var(--radius-sm);
    color: var(--text); text-decoration: none; font-size: 14px;
    transition: background-color 0.12s ease;
}
.usermenu-item:hover { background: var(--surface-2); }
.usermenu-item:hover .usermenu-ico { transform: translateX(2px); }
.usermenu-ico { width: 18px; text-align: center; color: var(--muted); font-size: 15px; transition: transform 0.15s ease; }
.usermenu-item-danger { color: var(--err-fg); }
.usermenu-item-danger:hover { background: var(--err-bg); }
.usermenu-item-danger .usermenu-ico { color: var(--err-fg); }

.usermenu-section { padding: 6px 8px 8px; }
.usermenu-label {
    display: block; font-size: 11px; text-transform: uppercase;
    letter-spacing: 0.05em; color: var(--muted); margin-bottom: 9px;
}

/* === Segmented theme control (Auto / Light / Dark) ========================= */
.theme-seg {
    position: relative; display: grid; grid-template-columns: repeat(3, 1fr);
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: 999px; padding: 3px;
}
.theme-seg-thumb {
    position: absolute; top: 3px; bottom: 3px; left: 3px;
    width: calc((100% - 6px) / 3);
    background: var(--surface); border-radius: 999px;
    box-shadow: 0 1px 3px rgba(16, 24, 40, 0.16);
    transition: transform 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform: translateX(0); z-index: 0;
}
.theme-seg[data-active="light"] .theme-seg-thumb { transform: translateX(100%); }
.theme-seg[data-active="dark"] .theme-seg-thumb { transform: translateX(200%); }
.theme-seg-opt {
    position: relative; z-index: 1;
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    border: none; background: transparent; cursor: pointer;
    padding: 7px 4px; font-size: 13px; color: var(--muted); line-height: 1;
    transition: color 0.2s ease;
}
.theme-seg-opt[aria-checked="true"] { color: var(--text); font-weight: 600; }
.theme-seg-opt:hover:not([aria-checked="true"]) { color: var(--text); }
.theme-seg-ico { font-size: 14px; line-height: 1; }

/* === Language segmented control (links, server-side active state) ========== */
.lang-seg {
    display: grid; grid-template-columns: repeat(2, 1fr);
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: 999px; padding: 3px; gap: 3px;
}
.lang-seg-opt {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 7px 4px; font-size: 13px; color: var(--muted); line-height: 1;
    border-radius: 999px; text-decoration: none; transition: color 0.15s ease, background-color 0.15s ease;
}
.lang-seg-opt:hover { color: var(--text); }
.lang-seg-opt.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(16, 24, 40, 0.16); }
.lang-seg-flag { font-size: 14px; line-height: 1; }

/* === Appearance section (sub-labels + accent palette) ====================== */
.appearance-sublabel { display: block; font-size: 11px; color: var(--muted); margin: 0 0 7px; font-weight: 550; }
.appearance .theme-seg + .appearance-sublabel,
.appearance .lang-seg + .appearance-sublabel,
.accent-swatches + .appearance-sublabel { margin-top: 14px; }

.accent-swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.accent-sw {
    width: 26px; height: 26px; padding: 0; border-radius: 50%;
    border: none; background: transparent; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    position: relative; transition: transform 0.12s ease;
}
.accent-sw:hover { transform: scale(1.12); }
.accent-sw-dot {
    width: 20px; height: 20px; border-radius: 50%;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
    transition: box-shadow 0.15s ease;
}
.accent-sw.is-active .accent-sw-dot { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.accent-sw.is-active::after {
    content: "✓"; position: absolute; color: #fff; font-size: 12px;
    font-weight: 700; line-height: 1; text-shadow: 0 1px 1px rgba(0, 0, 0, 0.3);
}

/* Liquid-glass intensity slider (Clear → Solid). */
.glass-range-row { display: flex; align-items: center; gap: 10px; }
.glass-range-cap { font-size: 11px; color: var(--muted); flex: 0 0 auto; }
.glass-range {
    -webkit-appearance: none; appearance: none;
    flex: 1 1 auto; height: 6px; border-radius: 999px; margin: 0;
    background: linear-gradient(90deg, var(--surface-2), var(--accent));
    cursor: pointer; outline: none;
}
.glass-range::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 18px; height: 18px; border-radius: 50%;
    background: #fff; border: 1px solid var(--border);
    box-shadow: 0 1px 4px rgba(16, 24, 40, 0.3);
}
.glass-range::-moz-range-thumb {
    width: 18px; height: 18px; border: 1px solid var(--border); border-radius: 50%;
    background: #fff; box-shadow: 0 1px 4px rgba(16, 24, 40, 0.3);
}
.glass-range:focus-visible { box-shadow: 0 0 0 3px var(--ring); }

/* === Page header =========================================================== */
.page-head { margin-bottom: 20px; }
.page-head-row {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 16px; flex-wrap: wrap;
}
.page-head h1 { margin: 0; font-size: 23px; font-weight: 680; letter-spacing: -0.02em; }
.page-head .lead { margin: 5px 0 0; color: var(--muted); font-size: 14px; line-height: 1.5; max-width: 680px; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* === Cards ================================================================= */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow);
    animation: fadeUp 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.layout { display: grid; grid-template-columns: 1fr 308px; gap: 20px; align-items: start; }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }

.card-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; flex-wrap: wrap; margin-bottom: 16px;
}
.card-head h2 { margin: 0; font-size: 18px; font-weight: 660; letter-spacing: -0.01em; }
.card-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* === Plain-language mode banner ============================================ */
.mode-banner {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 13px 15px; border-radius: var(--radius-sm); margin-bottom: 18px;
    background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
}
.mode-banner.is-warn { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn-fg) 30%, transparent); }
.mode-banner-ico { flex: 0 0 auto; width: 22px; height: 22px; color: var(--accent); }
.mode-banner.is-warn .mode-banner-ico { color: var(--warn-fg); }
.mode-banner-text { font-size: 13.5px; line-height: 1.5; }
.mode-banner-text strong { font-weight: 650; }
.mode-banner-text small { display: block; color: var(--muted); margin-top: 2px; font-size: 12.5px; }

/* === Backup table ========================================================== */
/* overflow: visible so the per-row "More" menu is never clipped. The table fits
   without horizontal scroll above the stacked-card breakpoint (620px), below which
   the rows become stacked cards, so no horizontal scrolling is lost. */
.table-wrap { overflow: visible; margin: 0 -4px; }
.bk-table { width: 100%; border-collapse: collapse; min-width: 540px; }
.bk-table th, .bk-table td { text-align: left; padding: 12px 12px; border-bottom: 1px solid var(--border); font-size: 14px; }
.bk-table thead th {
    color: var(--muted); font-weight: 600; font-size: 12px;
    text-transform: uppercase; letter-spacing: 0.04em;
    background: color-mix(in srgb, var(--surface-2) 60%, var(--surface));
    position: sticky; top: 0;
}
.bk-table thead th:first-child { border-top-left-radius: 8px; }
.bk-table thead th:last-child { border-top-right-radius: 8px; }
.bk-table tbody tr { transition: background-color 0.12s ease; }
.bk-table tbody tr:last-child td { border-bottom: none; }
.bk-table tbody tr:hover td { background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
.bk-table tbody tr:hover td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.ta-right { text-align: right; }
.bk-table td:first-child { white-space: nowrap; }
.row-actions { display: inline-flex; gap: 8px; justify-content: flex-end; flex-wrap: nowrap; white-space: nowrap; align-items: center; }

/* Per-row "More" menu for the advanced/heavy actions. */
.rowmenu { position: relative; display: inline-flex; }
.rowmenu-trigger {
    background: transparent; border: 1px solid var(--border); border-radius: var(--radius-sm);
    color: var(--muted); cursor: pointer; padding: 6px 9px; font-size: 14px; line-height: 1;
}
.rowmenu-trigger:hover { border-color: var(--accent); color: var(--accent); }
.rowmenu-panel {
    position: absolute; right: 0; top: calc(100% + 6px); z-index: 30;
    min-width: 220px; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; text-align: left;
}
.rowmenu-panel[hidden] { display: none; }
/* Open upward when there isn't enough room below (set by JS on the last rows). */
.rowmenu.up .rowmenu-panel { top: auto; bottom: calc(100% + 6px); }
.rowmenu-item {
    display: flex; flex-direction: column; gap: 2px; width: 100%;
    padding: 8px 10px; border-radius: var(--radius-sm); border: none;
    background: transparent; color: var(--text); cursor: pointer; text-align: left;
    text-decoration: none; font-size: 13.5px; font-weight: 550;
}
.rowmenu-item:hover { background: var(--surface-2); }
.rowmenu-item small { font-weight: 400; color: var(--muted); font-size: 12px; }
.rowmenu-item.is-danger { color: var(--err-fg); }
.rowmenu-item.is-danger:hover { background: var(--err-bg); }

@media (max-width: 620px) {
    .table-wrap { overflow-x: visible; margin: 0; }
    .bk-table { min-width: 0; display: block; }
    .bk-table thead { display: none; }
    .bk-table tbody, .bk-table tr, .bk-table td { display: block; width: 100%; }
    .bk-table tr { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 12px; background: var(--surface); overflow: hidden; }
    .bk-table tbody tr:hover td { background: transparent; }
    .bk-table td { display: flex; align-items: center; justify-content: space-between; gap: 12px; text-align: right; padding: 10px 14px; border-bottom: none; }
    .bk-table td + td { border-top: 1px solid var(--border); }
    .bk-table td::before {
        content: attr(data-label); text-align: left; flex: 0 0 auto;
        font-size: 11px; font-weight: 600; text-transform: uppercase;
        letter-spacing: 0.04em; color: var(--muted);
    }
    .badge-db { white-space: normal; word-break: break-all; text-align: right; }
    .bk-table td[data-label]:last-child { flex-direction: column; align-items: stretch; gap: 9px; }
    .bk-table td:last-child::before { text-align: left; }
    .row-actions { flex: 1 1 auto; flex-wrap: wrap; justify-content: flex-start; white-space: normal; }
    .row-actions .btn { flex: 1 1 auto; justify-content: center; }
    .rowmenu, .rowmenu-trigger { width: 100%; }
}

.badge {
    display: inline-block; background: var(--surface-2); color: var(--muted);
    padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 500;
}
.badge-db {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px;
    background: color-mix(in srgb, var(--accent) 9%, var(--surface));
    color: color-mix(in srgb, var(--accent) 75%, var(--text));
    border: 1px solid color-mix(in srgb, var(--accent) 18%, transparent);
}
.status {
    font-weight: 600; font-size: 12.5px; display: inline-flex; align-items: center; gap: 7px;
    padding: 3px 10px 3px 9px; border-radius: 999px;
}
.status::before {
    content: ""; width: 7px; height: 7px; border-radius: 50%;
    background: currentColor; box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 22%, transparent);
}
.status-ok { color: var(--ok-fg); background: color-mix(in srgb, var(--ok-bg) 70%, transparent); }
.status-progress { color: var(--warn-fg); background: color-mix(in srgb, var(--warn-bg) 70%, transparent); }
.status-progress::before { animation: pulse 1.1s ease-in-out infinite; }
.row-progress td { opacity: 0.9; }
.row-progress-note { font-size: 12.5px; color: var(--muted); font-style: italic; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

/* === Buttons =============================================================== */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid transparent; border-radius: var(--radius-sm);
    padding: 9px 16px; font-size: 14px; font-weight: 550; cursor: pointer;
    text-decoration: none; line-height: 1;
    transition: background-color 0.15s ease, border-color 0.15s ease,
        transform 0.08s ease, box-shadow 0.15s ease, filter 0.15s ease;
}
.btn:active { transform: translateY(0); }
.btn .ic { width: 15px; height: 15px; margin-right: 7px; flex: 0 0 auto; }
.btn-sm .ic { width: 14px; height: 14px; margin-right: 6px; }
.btn-primary:hover, .btn-outline:hover, .btn-danger-outline:hover, .btn-danger-solid:hover { transform: translateY(-1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.btn-primary {
    background: var(--accent-grad); color: var(--accent-on);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08), 0 6px 16px var(--ring);
}
.btn-primary:hover { filter: brightness(1.07); box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1), 0 10px 22px var(--ring); }
.btn-primary:disabled { opacity: 0.6; cursor: default; filter: none; box-shadow: none; }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; margin-top: 8px; }
.btn-danger { color: var(--err-fg); border-color: var(--border); }
.btn-danger:hover { border-color: var(--err-fg); color: var(--err-fg); background: var(--err-bg); }
.btn-danger-outline { background: transparent; border-color: var(--border); color: var(--muted); }
.btn-danger-outline:hover { border-color: var(--err-fg); color: var(--err-fg); background: var(--err-bg); }
.btn-danger-solid { background: var(--err-fg); color: #fff; border-color: transparent; }
.btn-danger-solid:hover { filter: brightness(1.07); }
.btn-icon { padding: 9px; }
.btn-icon .ic-only { width: 16px; height: 16px; margin: 0; }
#refresh-btn .ic-only { transition: transform 0.5s cubic-bezier(0.34, 1.4, 0.5, 1); }
#refresh-btn:hover .ic-only { transform: rotate(-45deg); }
#refresh-btn.spinning .ic-only { animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* === Pagination =========================================================== */
.pagination { display: flex; gap: 6px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.pg {
    min-width: 34px; text-align: center; padding: 7px 11px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    text-decoration: none; color: var(--text); font-size: 14px;
}
.pg:hover:not(.disabled):not(.current) { border-color: var(--accent); color: var(--accent); }
.pg.current { background: var(--accent); color: var(--accent-on); border-color: var(--accent); box-shadow: 0 4px 12px var(--ring); }
.pg.disabled { color: var(--muted); opacity: 0.5; pointer-events: none; }

/* === Side panel (backups page) ============================================ */
.side-card { display: flex; flex-direction: column; gap: 12px; }
.side-card h3 { margin: 0 0 4px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.side-card .side-note { margin-top: 2px; }
.side-note { font-size: 12px; color: var(--muted); line-height: 1.5; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat-mini {
    display: flex; flex-direction: column; gap: 2px;
    padding: 13px 14px; border-radius: var(--radius-sm);
    background: var(--accent-grad); color: var(--accent-on);
    box-shadow: 0 4px 14px var(--ring);
}
.stat-mini:last-child {
    background: color-mix(in srgb, var(--surface-2) 55%, var(--surface));
    color: var(--text); border: 1px solid var(--border); box-shadow: none;
}
.stat-mini-value { font-size: 22px; font-weight: 750; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-mini-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; opacity: 0.85; font-weight: 600; }
.stat-tile {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 13px; border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--surface-2) 55%, var(--surface));
    border: 1px solid var(--border);
    transition: border-color 0.15s ease, transform 0.12s ease;
}
.stat-tile:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); transform: translateY(-1px); }
.stat-ico {
    width: 34px; height: 34px; border-radius: 10px; flex: 0 0 auto;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--accent-soft); color: var(--accent);
}
.stat-ico svg { width: 18px; height: 18px; }
.stat-body { display: flex; flex-direction: column; min-width: 0; }
.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; }
.stat-value { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }

/* === Alerts & empty states ================================================ */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 14px; line-height: 1.5; }
.alert-ok { background: var(--ok-bg); color: var(--ok-fg); }
.alert-error { background: var(--err-bg); color: var(--err-fg); }
.alert-warn { background: var(--warn-bg); color: var(--warn-fg); }
.empty { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; padding: 34px 14px; color: var(--muted); }
.empty p { margin: 0; max-width: 460px; }
.empty .empty-ico {
    width: 54px; height: 54px; border-radius: 16px; flex: 0 0 auto;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--surface-2); color: var(--muted);
}
.empty .empty-ico svg { width: 26px; height: 26px; }
.empty .btn { margin-top: 4px; }

code {
    background: var(--surface-2); color: var(--text);
    padding: 1px 6px; border-radius: 5px; font-size: 13px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* === Login ================================================================ */
.login-wrap { display: flex; justify-content: center; padding: 6vh 0; }
.login-card { width: 100%; max-width: 380px; }
.login-head { text-align: center; margin-bottom: 22px; }
.login-logo {
    width: 56px; height: 56px; border-radius: 17px; margin: 0 auto 14px;
    background: var(--accent-grad); color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    box-shadow: 0 8px 24px var(--ring);
}
.login-logo svg { width: 28px; height: 28px; }
.login-card h1 { margin: 0 0 6px; font-size: 22px; font-weight: 680; letter-spacing: -0.01em; }
.login-hint { margin: 0; color: var(--muted); font-size: 14px; }
.login-card label { display: block; margin-bottom: 14px; font-size: 13px; font-weight: 550; color: var(--text); }
.login-card input {
    width: 100%; margin-top: 6px; padding: 11px 12px;
    background: var(--surface); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 14px;
}
.login-card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-foot { margin: 18px 0 0; font-size: 13px; color: var(--muted); text-align: center; line-height: 1.6; }
.login-foot a { display: inline-block; margin-top: 4px; color: var(--accent); text-decoration: none; font-weight: 550; }
.login-foot a:hover { text-decoration: underline; }

/* === Settings & forms ===================================================== */
.settings-card { margin-bottom: 20px; }
.settings-card + .settings-card { margin-top: 0; }
.form-section { padding: 4px 0 18px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.form-section:last-of-type { border-bottom: none; margin-bottom: 6px; padding-bottom: 4px; }
.form-section h3 { margin: 0 0 6px; font-size: 15px; font-weight: 660; }
.form-note { margin: -2px 0 14px; color: var(--muted); font-size: 13px; line-height: 1.5; }

.advanced { margin-top: 14px; border-top: 1px dashed var(--border); padding-top: 12px; }
.advanced > summary {
    cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted);
    list-style: none; display: inline-flex; align-items: center; gap: 7px; user-select: none;
}
.advanced > summary::-webkit-details-marker { display: none; }
.advanced > summary::before { content: "▸"; font-size: 11px; transition: transform 0.15s ease; }
.advanced[open] > summary::before { transform: rotate(90deg); }
.advanced > summary:hover { color: var(--accent); }
.advanced .form-grid, .advanced .form-note { margin-top: 12px; }

.switch { display: inline-flex; align-items: center; gap: 11px; cursor: pointer; user-select: none; margin-bottom: 4px; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
    position: relative; width: 46px; height: 26px; flex: 0 0 auto;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}
.switch-thumb {
    position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%;
    background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.switch input:checked ~ .switch-track { background: var(--accent-grad); border-color: transparent; }
.switch input:checked ~ .switch-track .switch-thumb { transform: translateX(20px); }
.switch input:focus-visible ~ .switch-track { box-shadow: 0 0 0 3px var(--ring); }
.switch .opt { font-size: 13px; font-weight: 600; color: var(--muted); transition: color 0.15s ease; }
.switch input:not(:checked) ~ .opt-local { color: var(--text); }
.switch input:checked ~ .opt-remote { color: var(--accent); }

.remote-fields { margin-top: 16px; transition: opacity 0.2s ease; }
.remote-fields.is-local { opacity: 0.45; }
.scheduler-fields { margin-top: 16px; display: flex; flex-direction: column; gap: 14px; transition: opacity 0.2s ease; }
.scheduler-fields.is-disabled { opacity: 0.45; }
.check-field { display: flex; align-items: center; gap: 9px; font-size: 14px; cursor: pointer; }
.check-field input { width: 16px; height: 16px; flex: 0 0 auto; accent-color: var(--accent); }

.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 18px; }
.field { display: flex; flex-direction: column; font-size: 13px; font-weight: 550; color: var(--text); gap: 6px; }
.field-wide { grid-column: 1 / -1; }
.field input, .field select {
    width: 100%; padding: 10px 12px; font-size: 14px; font-weight: 400;
    background: var(--surface); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field-hint { font-size: 11.5px; font-weight: 400; color: var(--muted); }

.form-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 20px; }
.form-actions-left { display: flex; gap: 10px; flex-wrap: wrap; }

.test-list { margin: 8px 0 0; padding-left: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.test-list li { display: flex; align-items: baseline; gap: 8px; }
.test-dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; transform: translateY(-1px); }
.test-ok { background: var(--ok-fg); }
.test-err { background: var(--err-fg); }

.restart-card h3 { display: flex; align-items: center; gap: 10px; margin: 0 0 6px; font-size: 15px; }
.restart-grid { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 12px 0 0; }
.restart-grid dt { color: var(--muted); font-size: 13px; }
.restart-grid dd { margin: 0; font-size: 13px; font-weight: 550; }

/* === Modal ================================================================ */
.modal-backdrop {
    position: fixed; inset: 0; z-index: 100; background: rgba(16, 24, 40, 0.55);
    display: flex; align-items: center; justify-content: center; padding: 20px;
    animation: modal-fade 0.15s ease;
}
.modal-backdrop[hidden] { display: none; }
.modal {
    width: 100%; max-width: 440px; background: var(--surface); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-lg); padding: 22px 22px 20px;
    animation: modal-pop 0.16s ease; max-height: calc(100vh - 40px); overflow-y: auto;
}
.modal-lg { max-width: 620px; }
.modal h3 { margin: 0 0 8px; font-size: 18px; font-weight: 660; }
.modal-text { font-size: 14px; line-height: 1.5; color: var(--muted); margin: 0 0 16px; }
.modal-text strong { color: var(--text); word-break: break-all; }
.modal-warn { font-size: 12.5px; color: var(--warn-fg); margin: 4px 0 0; }
.modal-head { display: flex; align-items: center; gap: 13px; margin-bottom: 10px; }
.modal-head h3 { margin: 0; }
.modal-badge { width: 40px; height: 40px; border-radius: 12px; flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; }
.modal-badge svg { width: 21px; height: 21px; }
.modal-badge.danger { background: var(--err-bg); color: var(--err-fg); }
.modal-badge.accent { background: var(--accent-soft); color: var(--accent); }
.modal .field, .modal .check-field { margin-top: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-pop { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }

/* Restore "what will happen" summary + plan list. */
.restore-summary {
    display: flex; flex-direction: column; gap: 8px; padding: 13px 15px; margin: 0 0 14px;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
    font-size: 13.5px; line-height: 1.5;
}
.restore-summary-row { display: flex; gap: 8px; }
.restore-summary-row .k { color: var(--muted); flex: 0 0 64px; }
.restore-summary-row .v { font-weight: 600; word-break: break-all; }
.restore-plan {
    list-style: none; margin: 0 0 4px; padding: 12px 14px; font-size: 12.5px;
    line-height: 1.6; color: var(--muted); background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.restore-plan:empty { display: none; }
.restore-plan li { padding-left: 14px; position: relative; word-break: break-word; }
.restore-plan li::before { content: "•"; position: absolute; left: 0; color: var(--accent); }
.cmd-box {
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 12px 14px; margin: 0;
    max-height: 320px; overflow: auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12.5px; line-height: 1.5; white-space: pre; tab-size: 2;
}

/* === Metrics dashboard (class names consumed by metrics.js — keep them) ==== */
.metrics-grid { display: grid; gap: 18px; margin-bottom: 18px; grid-template-columns: repeat(4, 1fr); }
.metrics-grid-2 { grid-template-columns: 2fr 1fr; }
@media (max-width: 900px) { .metrics-grid, .metrics-grid-2 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .metrics-grid, .metrics-grid-2 { grid-template-columns: 1fr; } }

.metric-card { display: flex; flex-direction: column; gap: 10px; }
.metric-head { display: flex; align-items: baseline; justify-content: space-between; }
.metric-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 600; }
.metric-big { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.metric-big .unit { font-size: 14px; font-weight: 600; color: var(--muted); margin-left: 2px; }
.metric-sub { font-size: 12.5px; color: var(--muted); }

.bar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar-fill { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--accent-grad); transition: width 0.4s ease, background-color 0.2s ease; }
.bar-fill.bar-warn { background: linear-gradient(135deg, #f0a83a, #e8870c); }
.bar-fill.bar-crit { background: linear-gradient(135deg, #f0664f, #d8341c); }
.bar-sm { height: 5px; margin-top: 4px; }
.bar-fill-muted { background: var(--muted) !important; }

.metric-net { display: flex; gap: 18px; font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; }
.net-dir { white-space: nowrap; }

.kpi-row { display: flex; flex-wrap: wrap; gap: 26px; margin: 6px 0 4px; }
.kpi { display: flex; flex-direction: column; gap: 2px; }
.kpi-val { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.kpi-cap { font-size: 12px; color: var(--muted); }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; vertical-align: middle; }
.dot-ok { background: var(--ok-fg); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok-fg) 22%, transparent); }
.dot-err { background: var(--err-fg); box-shadow: 0 0 0 3px color-mix(in srgb, var(--err-fg) 22%, transparent); }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.92em; }
.metrics-foot { text-align: center; color: var(--muted); font-size: 12px; margin-top: 4px; }
.chart { width: 100%; display: block; }

.cores-grid { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.core { display: flex; flex-direction: column; align-items: center; gap: 3px; width: 22px; }
.core-bar { width: 100%; height: 34px; border-radius: 4px; background: var(--surface-2); display: flex; align-items: flex-end; overflow: hidden; }
.core-bar > span { width: 100%; background: var(--accent-grad); transition: height 0.4s ease; min-height: 2px; }
.core-n { font-size: 9px; color: var(--muted); font-variant-numeric: tabular-nums; }

.disks { display: flex; flex-direction: column; gap: 8px; }
.disk-row { display: grid; grid-template-columns: minmax(60px, 1fr) 2fr auto; gap: 10px; align-items: center; font-size: 12.5px; }
.disk-mount { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.disk-bar { height: 8px; }
.disk-val { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

.proc-table { width: 100%; border-collapse: collapse; margin-top: 6px; }
.proc-table td { padding: 5px 6px; border-bottom: 1px solid var(--border); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.proc-table td:first-child { width: 60%; }
.proc-table td:not(:first-child) { text-align: right; color: var(--muted); }
.proc-table tr:last-child td { border-bottom: none; }

.tables { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.tbl-row { display: flex; justify-content: space-between; font-size: 12.5px; gap: 12px; }
.tbl-row > span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* === "Live" auto-refresh pill ============================================= */
.autorefresh-pill {
    display: inline-flex; align-items: center; gap: 6px; vertical-align: middle;
    margin-left: 8px; padding: 2px 10px 2px 8px; border-radius: 999px;
    font-size: 11.5px; font-weight: 650; letter-spacing: 0.02em;
    color: var(--warn-fg); background: color-mix(in srgb, var(--warn-bg) 70%, transparent);
    text-transform: uppercase;
}
.autorefresh-dot {
    width: 7px; height: 7px; border-radius: 50%; background: currentColor;
    box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 22%, transparent);
    animation: pulse 1.1s ease-in-out infinite;
}

/* === Navigation progress bar ============================================== */
.nav-progress {
    position: fixed; top: 0; left: 0; height: 3px; width: 0; z-index: 200;
    background: var(--accent-grad); box-shadow: 0 0 10px var(--ring), 0 0 4px var(--accent);
    opacity: 0; pointer-events: none; transition: width 0.18s ease, opacity 0.35s ease;
}
.nav-progress.active { opacity: 1; }

.appfoot { text-align: center; color: var(--muted); font-size: 12px; padding: 20px 16px 26px; }
.appfoot-ver { font-variant-numeric: tabular-nums; opacity: 0.85; }

/* === Responsive: collapse the sidebar into a drawer ======================= */
@media (max-width: 860px) {
    .menu-btn { display: inline-flex; }
    .sidebar {
        position: fixed; top: 0; left: 0; height: 100vh; width: 280px;
        transform: translateX(-100%); transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: var(--shadow-lg);
    }
    .app-shell.nav-open .sidebar { transform: translateX(0); }
    .app-shell.nav-open .sidebar-backdrop {
        display: block; position: fixed; inset: 0; z-index: 55;
        background: rgba(16, 24, 40, 0.5);
    }
    .content { padding: 20px 18px 36px; }
    .topbar { padding: 11px 18px; }
}

@media (max-width: 520px) {
    .content { padding: 16px 14px 30px; }
    .card { padding: 18px; }
    .usermenu-name { display: none; }
    .usermenu-panel { width: 250px; }
    .form-grid { grid-template-columns: 1fr; }
    .page-head h1 { font-size: 20px; }
}

/* Respect users who prefer reduced motion. */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}

/* ============================================================================
   LIQUID GLASS — iOS 26-style translucent material, applied across every
   surface. This is an override layer: it rides on the design tokens above and
   the cascade (equal specificity, declared later) so it re-skins the surfaces
   without disturbing the existing layout, theme or accent machinery. The glass
   is tinted from --accent/--grad-*, so the user's custom accent colours the
   material. A reduced-transparency / high-contrast fallback at the very end
   restores solid surfaces (it also covers the cost of blur on long tables).
   ========================================================================== */

/* --- Glass tokens (light) ------------------------------------------------- */
/* The surface opacities derive from a single master, --glass-op, so a slider can
   scale the whole "liquid glass" intensity (airy ~0.20 → solid ~0.95). Per theme we
   only override --glass-rgb (the surface tint); the formulas below recompute. */
:root {
    --glass-rgb: 255, 255, 255;
    --glass-op: 0.55;
    --glass: rgba(var(--glass-rgb), var(--glass-op));
    --glass-2: rgba(var(--glass-rgb), calc(var(--glass-op) * 0.72));
    --glass-strong: rgba(var(--glass-rgb), min(0.98, calc(var(--glass-op) + 0.18)));
    --glass-border: rgba(255, 255, 255, 0.65);
    --glass-hi: rgba(255, 255, 255, 0.90);
    --glass-blur: 18px;
    --glass-blur-strong: 28px;
    --glass-blur-ctl: 10px;
    --glass-rim:
        0 10px 30px -10px rgba(16, 24, 40, 0.20),
        0 2px 8px rgba(16, 24, 40, 0.06),
        inset 0 1px 0 0 rgba(255, 255, 255, 0.65),
        inset 0 0 0 1px rgba(255, 255, 255, 0.16);
    --glass-rim-pop:
        0 22px 50px -16px rgba(16, 24, 40, 0.28),
        inset 0 1px 0 0 rgba(255, 255, 255, 0.7),
        inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}

/* --- Glass tokens (dark) -------------------------------------------------- */
:root[data-theme="dark"] {
    --glass-rgb: 30, 41, 61;
    --glass-border: rgba(255, 255, 255, 0.12);
    --glass-hi: rgba(255, 255, 255, 0.16);
    --glass-rim:
        0 14px 36px -12px rgba(0, 0, 0, 0.55),
        inset 0 1px 0 0 rgba(255, 255, 255, 0.10),
        inset 0 0 0 1px rgba(255, 255, 255, 0.05);
    --glass-rim-pop:
        0 26px 56px -16px rgba(0, 0, 0, 0.65),
        inset 0 1px 0 0 rgba(255, 255, 255, 0.12),
        inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --glass-rgb: 30, 41, 61;
        --glass-border: rgba(255, 255, 255, 0.12);
        --glass-hi: rgba(255, 255, 255, 0.16);
        --glass-rim:
            0 14px 36px -12px rgba(0, 0, 0, 0.55),
            inset 0 1px 0 0 rgba(255, 255, 255, 0.10),
            inset 0 0 0 1px rgba(255, 255, 255, 0.05);
        --glass-rim-pop:
            0 26px 56px -16px rgba(0, 0, 0, 0.65),
            inset 0 1px 0 0 rgba(255, 255, 255, 0.12),
            inset 0 0 0 1px rgba(255, 255, 255, 0.06);
    }
}

/* --- Scene: a soft accent-tinted mesh behind the glass -------------------- */
body {
    background:
        radial-gradient(1100px 760px at 8% -12%,
            color-mix(in srgb, var(--grad-a) 30%, transparent), transparent 58%),
        radial-gradient(1000px 720px at 102% 4%,
            color-mix(in srgb, var(--grad-b) 26%, transparent), transparent 55%),
        radial-gradient(900px 880px at 52% 118%,
            color-mix(in srgb, var(--accent) 20%, transparent), transparent 60%),
        var(--bg);
    background-attachment: fixed;
}

/* --- Panels: the primary frosted surfaces -------------------------------- */
.sidebar {
    background: var(--glass);
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(180%);
    backdrop-filter: blur(var(--glass-blur)) saturate(180%);
    border-right: 1px solid var(--glass-border);
    box-shadow: var(--glass-rim);
}
.topbar {
    background: var(--glass);
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(180%);
    backdrop-filter: blur(var(--glass-blur)) saturate(180%);
    border-bottom: 1px solid var(--glass-border);
}
.card {
    background: var(--glass);
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(180%);
    backdrop-filter: blur(var(--glass-blur)) saturate(180%);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-rim);
}

/* Diagonal specular sheen on the hero panels. isolation + z-index:-1 keeps the
   sheen above the glass fill but below the content, with no child reparenting.
   (.sidebar already gets position/isolation from its base rule above — overriding
   it here would beat the mobile drawer's `position: fixed` and break the layout.) */
.card { position: relative; isolation: isolate; }
.card::before, .sidebar::before {
    content: ""; position: absolute; inset: 0; z-index: -1;
    border-radius: inherit; pointer-events: none;
    background:
        linear-gradient(135deg, var(--glass-hi), transparent 32%),
        radial-gradient(150% 100% at 100% 0%,
            color-mix(in srgb, var(--accent) 14%, transparent), transparent 56%);
    opacity: 0.55;
}

/* --- Floating glass: menus & modal (the iOS "thick" material) -------------
   iOS Liquid Glass insight: content-bearing surfaces (menus, popovers, alerts,
   dialogs) do NOT use the airy ultra-thin material — they use a THICK, mostly
   opaque material so labels stay legible over a busy backdrop. Translucency is
   a subtle accent there, not the dominant effect. So menus get a high base
   opacity (~85%), a wider blur, a saturation + brightness "vibrancy" lift, a
   crisp specular rim and a strong separation shadow; the modal additionally
   dims the page behind it. The airy translucent look stays on the large chrome
   (sidebar, top bar, cards), which is where the glass effect reads best. */
:root {
    --glass-menu: rgba(255, 255, 255, 0.85);
    --glass-menu-blur: 30px;
    --glass-menu-shadow:
        0 24px 60px -18px rgba(16, 24, 40, 0.42),
        0 8px 18px -10px rgba(16, 24, 40, 0.22),
        inset 0 1px 0 0 rgba(255, 255, 255, 0.90),
        inset 0 0 0 1px rgba(255, 255, 255, 0.32);
}
:root[data-theme="dark"] {
    --glass-menu: rgba(24, 31, 45, 0.86);
    --glass-menu-shadow:
        0 26px 64px -18px rgba(0, 0, 0, 0.72),
        inset 0 1px 0 0 rgba(255, 255, 255, 0.14),
        inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --glass-menu: rgba(24, 31, 45, 0.86);
        --glass-menu-shadow:
            0 26px 64px -18px rgba(0, 0, 0, 0.72),
            inset 0 1px 0 0 rgba(255, 255, 255, 0.14),
            inset 0 0 0 1px rgba(255, 255, 255, 0.06);
    }
}
.usermenu-panel, .rowmenu-panel, .modal {
    background: var(--glass-menu);
    -webkit-backdrop-filter: blur(var(--glass-menu-blur)) saturate(200%) brightness(1.04);
    backdrop-filter: blur(var(--glass-menu-blur)) saturate(200%) brightness(1.04);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-menu-shadow);
}
/* Dim + frost the page behind the modal so the dialog reads clearly. */
.modal-backdrop {
    background: rgba(13, 19, 30, 0.50);
    -webkit-backdrop-filter: blur(8px) saturate(120%);
    backdrop-filter: blur(8px) saturate(120%);
}

/* Opaque dropdowns (iOS-style). An iOS context menu reads as solid — its
   translucency is imperceptible. So the two dropdowns (the per-row "More" menu and
   the user menu) drop the glass entirely for a fully opaque, maximally legible
   surface; they keep the specular rim + elevation shadow for the floating-menu look.
   The large chrome and the modal keep the translucent glass. */
:root { --menu-solid: #ffffff; --menu-solid-border: var(--border); }
:root[data-theme="dark"] { --menu-solid: #202a3c; --menu-solid-border: #33415a; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) { --menu-solid: #202a3c; --menu-solid-border: #33415a; }
}
.usermenu-panel, .rowmenu-panel {
    background: var(--menu-solid);
    border-color: var(--menu-solid-border);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}

/* --- Controls: glass buttons, pills, inputs ------------------------------ */
.usermenu-trigger, .menu-btn, .btn-outline, .btn-ghost, .btn-danger,
.btn-danger-outline, .pg, .rowmenu-trigger, .theme-seg, .lang-seg,
.switch-track, .autorefresh-pill {
    -webkit-backdrop-filter: blur(var(--glass-blur-ctl)) saturate(160%);
    backdrop-filter: blur(var(--glass-blur-ctl)) saturate(160%);
}
.usermenu-trigger, .menu-btn, .btn-outline, .btn-ghost,
.pg, .rowmenu-trigger {
    background: var(--glass-2);
    border-color: var(--glass-border);
}
.theme-seg, .lang-seg, .switch-track {
    background: var(--glass-2);
    border-color: var(--glass-border);
}
.field input, .field select, .login-card input {
    background: var(--glass-2);
    -webkit-backdrop-filter: blur(var(--glass-blur-ctl)) saturate(150%);
    backdrop-filter: blur(var(--glass-blur-ctl)) saturate(150%);
    border-color: var(--glass-border);
}

/* --- Minor frosted surfaces --------------------------------------------- */
.bk-table thead th {
    background: var(--glass-strong);
    -webkit-backdrop-filter: blur(14px) saturate(180%);
    backdrop-filter: blur(14px) saturate(180%);
}
.stat-tile, .restore-summary, .restore-plan, .cmd-box {
    background: var(--glass-2);
    border-color: var(--glass-border);
}
.badge {
    background: var(--glass-2);
}

/* --- Glossy primary button (liquid sheen over the accent gradient) ------- */
.btn-primary {
    position: relative; isolation: isolate; overflow: hidden;
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.08),
        0 8px 20px var(--ring),
        inset 0 1px 0 rgba(255, 255, 255, 0.42);
}
.btn-primary::before {
    content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.38), transparent 46%);
}
.sidebar-brand .logo, .brand .logo, .login-logo {
    position: relative; overflow: hidden;
}
.sidebar-brand .logo::after, .brand .logo::after, .login-logo::after {
    content: ""; position: absolute; inset: 0; pointer-events: none;
    background: linear-gradient(150deg, rgba(255, 255, 255, 0.55), transparent 45%);
}

/* --- Fallback: honour Reduce Transparency / Increase Contrast ------------ */
/* Not an aesthetic compromise — it only triggers for users who asked the OS
   for it, and it also drops the blur cost on long backup tables. */
@media (prefers-reduced-transparency: reduce), (prefers-contrast: more) {
    body { background: var(--bg); background-attachment: scroll; }
    .sidebar, .topbar, .card, .usermenu-panel, .rowmenu-panel, .modal,
    .usermenu-trigger, .menu-btn, .btn-outline, .btn-ghost, .btn-danger,
    .btn-danger-outline, .pg, .rowmenu-trigger, .theme-seg, .lang-seg,
    .switch-track, .autorefresh-pill, .field input, .field select,
    .login-card input, .bk-table thead th, .modal-backdrop {
        -webkit-backdrop-filter: none; backdrop-filter: none;
    }
    .sidebar, .topbar { background: var(--surface); }
    .card, .usermenu-panel, .rowmenu-panel, .modal { background: var(--surface); }
    .usermenu-trigger, .menu-btn, .btn-outline, .btn-ghost, .pg, .rowmenu-trigger,
    .theme-seg, .lang-seg, .switch-track, .field input, .field select,
    .login-card input { background: var(--surface-2); }
    .bk-table thead th { background: color-mix(in srgb, var(--surface-2) 60%, var(--surface)); }
    .stat-tile, .restore-summary, .restore-plan, .cmd-box, .badge { background: var(--surface-2); }
    .modal-backdrop { background: rgba(16, 24, 40, 0.55); }
    .card::before, .sidebar::before { display: none; }
}
