/* BackupHub dashboard. Light by default; <html data-theme="dark"> switches every colour via the tokens. */
:root {
    --bg: #f4f6fb;
    --surface: #ffffff;
    --surface-2: #f3f6fb;
    --surface-3: #e8edf5;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --text: #0f172a;
    --text-2: #334155;
    --muted: #64748b;
    --brand: #1d4ed8;
    --brand-2: #1e3a8a;
    --brand-soft: rgba(29, 78, 216, .09);
    --on-brand: #ffffff;
    --teal: #0d9488;
    --ok: #047857;
    --ok-soft: rgba(5, 150, 105, .10);
    --warn: #92400e;
    --warn-soft: rgba(217, 119, 6, .12);
    --bad: #b91c1c;
    --bad-soft: rgba(220, 38, 38, .09);
    --code: #f1f5f9;
    --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 2px 8px rgba(15, 23, 42, .05);
    --shadow-pop: 0 16px 40px rgba(15, 23, 42, .18);
    --radius: 16px;
    --radius-sm: 10px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    color-scheme: light;
}

:root[data-theme="dark"] {
    --bg: #0a1020;
    --surface: #111a2e;
    --surface-2: #17223b;
    --surface-3: #1d2a47;
    --border: #22304f;
    --border-strong: #2d4170;
    --text: #e7edf8;
    --text-2: #b7c3da;
    --muted: #8392b0;
    --brand: #4f8bff;
    --brand-2: #2563eb;
    --brand-soft: rgba(79, 139, 255, .15);
    --teal: #2dd4bf;
    --ok: #6ee7b7;
    --ok-soft: rgba(47, 211, 154, .14);
    --warn: #fcd34d;
    --warn-soft: rgba(255, 192, 77, .14);
    --bad: #fca5a5;
    --bad-soft: rgba(255, 107, 122, .14);
    --code: #0b1324;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .2);
    --shadow-pop: 0 16px 40px rgba(0, 0, 0, .5);
    color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text-2); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { color: var(--text); margin: 0; line-height: 1.25; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* Layout */
.app { display: flex; min-height: 100vh; }
.sidebar { position: sticky; top: 0; align-self: flex-start; width: 232px; height: 100vh; padding: 18px 14px; background: var(--surface); border-right: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: var(--text); font-size: 18px; font-weight: 700; }
.brand svg { width: 26px; height: 26px; color: var(--brand); }
.brand-lg { justify-content: center; font-size: 22px; padding-bottom: 10px; }
.brand-lg svg { width: 32px; height: 32px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: block; padding: 10px 14px; border-radius: var(--radius-sm); color: var(--text-2); font-weight: 500; }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--brand-soft); color: var(--brand); font-weight: 650; box-shadow: inset 3px 0 0 var(--brand); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; height: 60px; padding: 0 24px; background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.who { color: var(--muted); font-size: 13px; }
.menu-btn { display: none; }
.view { padding: 24px; max-width: 1280px; width: 100%; outline: none; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 0 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: 600 13px var(--font); cursor: pointer; white-space: nowrap; transition: background-color .15s, border-color .15s; }
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn-primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn-danger { background: var(--bad-soft); border-color: transparent; color: var(--bad); }
.btn-danger:hover { background: var(--bad); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-sm { min-height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn-block { width: 100%; min-height: 42px; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; padding: 0; border: 1px solid var(--border); border-radius: 50%; background: var(--surface-2); color: var(--text-2); cursor: pointer; }
.icon-btn svg { width: 18px; height: 18px; }
#themeBtn .i-sun, :root[data-theme="dark"] #themeBtn .i-moon { display: none; }
:root[data-theme="dark"] #themeBtn .i-sun { display: block; }

/* Cards, stats, tables */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px; }
.toolbar .spacer { flex: 1; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.stack { display: flex; flex-direction: column; gap: 18px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat { padding: 16px 18px; }
.stat-label { color: var(--muted); font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.stat-value { margin-top: 4px; color: var(--text); font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-sub { color: var(--muted); font-size: 12px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 14px; text-align: left; vertical-align: middle; white-space: nowrap; }
th { color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; border-bottom: 1px solid var(--border); }
tbody tr:nth-child(odd) td { background: var(--surface-2); }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover td { background: var(--brand-soft); }
td.wrap { white-space: normal; }
td .sub { color: var(--muted); font-size: 12px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.empty { padding: 40px 20px; color: var(--muted); text-align: center; }
.empty strong { display: block; margin-bottom: 4px; color: var(--text); font-size: 15px; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }

/* Badges and progress */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); font-size: 12px; font-weight: 600; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.badge-brand { background: var(--brand-soft); color: var(--brand); }
.progress { width: 140px; height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--brand); border-radius: inherit; transition: width .4s; }
.progress.indeterminate span { width: 35% !important; animation: slide 1.1s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(300%); } }

/* Forms */
.form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; color: var(--text); font-weight: 600; font-size: 13px; }
.field small { color: var(--muted); font-weight: 400; }
input, select, textarea { width: 100%; min-height: 40px; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text); font: 14px var(--font); }
textarea { min-height: 90px; resize: vertical; font-family: var(--mono); font-size: 12.5px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--text-2); }
.check input { width: 18px; min-height: 18px; height: 18px; accent-color: var(--brand); }
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); }
.seg button { padding: 6px 12px; border: 0; border-radius: 999px; background: transparent; color: var(--text-2); font: 600 12.5px var(--font); cursor: pointer; }
.seg button.on { background: var(--brand); color: #fff; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-weight: 600; font-size: 13px; }
.chip button { border: 0; background: transparent; color: inherit; cursor: pointer; font-size: 15px; line-height: 1; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row input[type="time"], .row select.short { width: auto; }
.form-error { min-height: 18px; margin: 0; color: var(--bad); font-size: 13px; }
.note { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text-2); font-size: 13px; }
.note-warn { background: var(--warn-soft); color: var(--warn); }
.note-bad { background: var(--bad-soft); color: var(--bad); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--text); word-break: break-all; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 16px; background: rgba(2, 6, 23, .55); overflow-y: auto; }
.modal { width: 100%; max-width: 640px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-pop); }
.modal-wide { max-width: 860px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 18px 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); }
.log { max-height: 380px; overflow: auto; margin: 0; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--code); color: var(--text-2); font: 12.5px/1.6 var(--mono); white-space: pre-wrap; word-break: break-word; }
.log .l-ok { color: var(--ok); }
.log .l-warn { color: var(--warn); }
.log .l-error { color: var(--bad); }
.log .ts { color: var(--muted); }

/* Toasts */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 60; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--text); color: var(--bg); box-shadow: var(--shadow-pop); font-size: 13.5px; }
.toast-bad { background: var(--bad); color: #fff; }

/* Auth */
.auth { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 16px; }
.auth-card { display: flex; flex-direction: column; gap: 14px; width: 100%; max-width: 380px; padding: 28px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.auth-card h2 { text-align: center; }
.auth-card .muted { margin: -6px 0 0; text-align: center; font-size: 13px; }

@media (max-width: 1100px) {
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-2 { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 820px) {
    .sidebar { position: fixed; z-index: 40; left: 0; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-pop); }
    .sidebar.open { transform: none; }
    .menu-btn { display: inline-flex; }
    .topbar { padding: 0 14px; }
    .who { display: none; }
    .view { padding: 16px; }
    .form { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}
