/* cpbackup central dashboard. No inline styles (CSP), light and dark. */
:root {
  --bg: #f4f6f9; --panel: #fff; --panel-2: #f9fafc; --text: #18202e; --muted: #687387; --line: #e4e8ef; --line-2: #eef1f5;
  --side: #fff; --side-text: #475165; --side-hover: #f1f4f8; --side-on: #eaf0ff; --side-on-text: #1d4ed8;
  --accent: #2563eb; --accent-hover: #1d4ed8; --accent-text: #fff; --accent-soft: #eaf0ff;
  --ok: #15803d; --warn: #b45309; --bad: #c62828; --info: #475569;
  --ok-bg: #e6f6ec; --warn-bg: #fdf2df; --bad-bg: #fdecec; --info-bg: #eef1f6;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .04);
  --shadow-lg: 0 10px 30px rgba(16, 24, 40, .12);
  --radius: 10px; --side-w: 236px;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 14px; line-height: 1.45;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117; --panel: #151b24; --panel-2: #121821; --text: #e6e9ef; --muted: #8d97a8; --line: #252e3c; --line-2: #1d2531;
    --side: #10151d; --side-text: #a3adbd; --side-hover: #18202b; --side-on: #1b2740; --side-on-text: #9cbcff;
    --accent: #5b8cff; --accent-hover: #7aa2ff; --accent-text: #0b1020; --accent-soft: #1b2740;
    --ok: #4ade80; --warn: #fbbf24; --bad: #f87171; --info: #a3b1c6;
    --ok-bg: #11291b; --warn-bg: #33270f; --bad-bg: #351719; --info-bg: #1e2632;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3); --shadow-lg: 0 10px 30px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
b { font-weight: 600; }

/* ---- shell ---- */
.app { display: flex; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; width: var(--side-w); flex: none; display: flex; flex-direction: column;
  background: var(--side); border-right: 1px solid var(--line); padding: 16px 12px; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 16px; color: var(--text); letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.side .brand { padding: 4px 10px 18px; }
.logo { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: var(--accent-text); flex: none; }
.logo .ic { width: 19px; height: 19px; }
.ic { width: 18px; height: 18px; flex: none; }
nav { flex: 1; }
.navgroup { margin-bottom: 14px; }
.navtitle { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 0 10px 6px; }
nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; margin-bottom: 1px; border-radius: 7px; color: var(--side-text); font-weight: 500; }
nav a:hover { text-decoration: none; background: var(--side-hover); color: var(--text); }
nav a.on { background: var(--side-on); color: var(--side-on-text); }
nav a .ic { opacity: .85; }
.side-foot { padding-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.who { display: flex; gap: 10px; align-items: center; padding: 0 4px; }
.who:empty { display: none; }
.avatar { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--accent-soft); color: var(--side-on-text); font-weight: 700; flex: none; }
.whoname { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.25; }
.whoname b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
main { padding: 28px 32px 48px; width: 100%; max-width: 1480px; margin: 0 auto; }
.mbar { display: none; }
.scrim { display: none; }
.iconbtn { display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 1px solid transparent; background: none; color: var(--muted); border-radius: 8px; }
.iconbtn:hover { background: var(--side-hover); color: var(--text); border-color: transparent; }
.lang { width: 100%; font-size: 13px; color: var(--muted); padding: 6px 8px; }

/* logged out: no sidebar */
.anon .side, .anon .mbar { display: none; }
.anon main { max-width: none; padding: 0 16px; }

/* ---- type ---- */
h1 { font-size: 22px; font-weight: 650; letter-spacing: -.015em; margin: 0 0 20px; }
h2 { font-size: 15px; font-weight: 600; margin: 32px 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.right { margin-left: auto; }

/* ---- surfaces ---- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
.panel.muted { text-align: center; padding: 28px 18px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; margin-bottom: 8px; }
.tile {
  display: block; color: var(--text); background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 16px 14px; box-shadow: var(--shadow);
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.tile .l { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.tile .v { font-size: 26px; font-weight: 650; margin-top: 6px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
a.tile:hover { text-decoration: none; border-color: var(--muted); box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.tile.bad { border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); background: color-mix(in srgb, var(--bad-bg) 55%, var(--panel)); }
.tile.bad .v { color: var(--bad); }
.tile.warn { border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); background: color-mix(in srgb, var(--warn-bg) 55%, var(--panel)); }
.tile.warn .v { color: var(--warn); }
.tile.ok .v { color: var(--ok); }

/* ---- tables ---- */
.tablewrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
th {
  font-weight: 600; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap;
  background: var(--panel-2); border-bottom-color: var(--line); position: sticky; top: 0;
}
tbody tr:hover td { background: var(--panel-2); }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tablewrap + .panel, .tablewrap + .bar { margin-top: 14px; }
td span[title] { white-space: nowrap; } /* dates from when() */
td.err { color: var(--bad); max-width: 420px; overflow-wrap: anywhere; }
pre.detail { white-space: pre-wrap; margin: 6px 0 0; font-size: 12px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ---- badges ---- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 500;
  background: var(--info-bg); color: var(--info); white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.badge.ok, .badge.done, .badge.online, .badge.resolved { background: var(--ok-bg); color: var(--ok); }
.badge.warning, .badge.partial, .badge.queued, .badge.stale, .badge.running { background: var(--warn-bg); color: var(--warn); }
.badge.failed, .badge.error, .badge.critical, .badge.offline, .badge.expired, .badge.revoked { background: var(--bad-bg); color: var(--bad); }

/* ---- controls ---- */
.bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
input, select, button {
  font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 7px; padding: 7px 11px;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
input::placeholder { color: var(--muted); }
input:hover, select:hover { border-color: var(--muted); }
input:focus, select:focus, button:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
button { cursor: pointer; font-weight: 500; }
button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.danger { color: var(--bad); }
button.danger:hover { background: var(--bad-bg); border-color: var(--bad); }
button.link { border: 0; background: none; color: var(--accent); padding: 0 4px; }
button:disabled { opacity: .5; cursor: default; }
td button { padding: 3px 9px; font-size: 12px; }
form.inline { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
form.inline label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 500; color: var(--muted); }
form.inline input { width: 9em; }
form.inline input.wide { width: 16em; }

/* ---- login ---- */
.login { max-width: 380px; margin: 12vh auto 0; padding: 28px; box-shadow: var(--shadow-lg); }
.loginhead { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.loginhead .logo { width: 42px; height: 42px; border-radius: 11px; }
.loginhead .logo .ic { width: 25px; height: 25px; }
.loginhead h1 { margin: 0; font-size: 20px; }
.login label { display: block; margin: 14px 0 5px; color: var(--muted); font-size: 13px; font-weight: 500; }
.login input { width: 100%; padding: 9px 12px; }
.login button.primary { width: 100%; margin-top: 20px; padding: 9px; }
.loginfoot { margin-top: 16px; }
.msg { margin-top: 10px; }
.msg:empty { display: none; }
.msg.err { color: var(--bad); }
.panel.msg.err { background: var(--bad-bg); border-color: transparent; }

/* ---- misc ---- */
.secret {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--info-bg); padding: 10px 12px; border-radius: 7px;
  overflow-wrap: anywhere; user-select: all; margin-top: 8px;
}
.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 50; background: var(--text); color: var(--bg); padding: 11px 16px;
  border-radius: 9px; max-width: 420px; box-shadow: var(--shadow-lg); font-weight: 500;
}
.toast.err { background: var(--bad); color: #fff; }
.lang:not(.side-foot .lang):not(.loginfoot .lang) { display: none; }

/* ---- narrow screens: off-canvas sidebar ---- */
@media (max-width: 900px) {
  .mbar {
    display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 20; height: 54px; padding: 0 12px;
    background: var(--side); border-bottom: 1px solid var(--line);
  }
  .mbar .logo { width: 26px; height: 26px; }
  .mbar .logo .ic { width: 17px; height: 17px; }
  .side {
    position: fixed; z-index: 40; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s ease;
    box-shadow: var(--shadow-lg);
  }
  .menu-open .side { transform: none; }
  .menu-open .scrim { display: block; position: fixed; inset: 0; z-index: 30; background: rgba(10, 14, 20, .45); }
  main { padding: 20px 16px 40px; }
  h1 { font-size: 20px; margin-bottom: 16px; }
  .tiles { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .tile .v { font-size: 22px; }
  th, td { padding: 8px 10px; }
  .login { margin-top: 8vh; }
}
@media (prefers-reduced-motion: reduce) {
  .side, .tile { transition: none; }
}
