/* Blue Sky Backups admin. Tokens: /design/README.md section 14. No raw hex below the token block. */
:root {
  --navy: #1b365d; --paper: #f7efe6; --sand: #e1dcd6; --coral: #ea5440; --coral-deep: #c93f2b; --slate: #4b5f7d;
  --line: #cfc6ba; --line-strong: #8a8279; --navy-raised: #294873; --on-navy: #ffffff; --on-navy-muted: #b9c4d6;
  --ok: #1f6b45; --ok-tint: #cfe3d6; --warn: #7a5200; --warn-tint: #f1dfb5;
  --danger: #9a2a1c; --danger-hover: #842316; --danger-tint: #f2c9c0; --coral-deep-hover: #b03524;
  --scrim: rgba(27, 54, 93, 0.6);
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --text-title: 700 1.75rem/2.125rem var(--font-ui);
  --text-heading: 700 1.25rem/1.75rem var(--font-ui);
  --text-lead: 400 1rem/1.5rem var(--font-ui);
  --text-body: 400 0.875rem/1.25rem var(--font-ui);
  --text-meta: 400 0.75rem/1rem var(--font-ui);
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 24px; --space-6: 32px; --space-7: 48px;
  --radius-surface: 0; --radius-control: 3px;
  --row-height: 40px; --row-height-fleet: 48px; --control-height: 40px; --frame-height: 56px;
  --cell-width: 88px; --content-max: 1440px;
  --ease-out: cubic-bezier(0.2, 0, 0, 1); --dur-fast: 150ms; --dur-enter: 200ms; --dur-exit: 120ms;
}
@media (pointer: coarse) { :root { --row-height: 44px; --control-height: 44px; } }
@media (prefers-reduced-motion: reduce) { :root { --dur-fast: 0ms; --dur-enter: 0ms; --dur-exit: 0ms; } }

/* ------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 100%; }
body { margin: 0; background: var(--paper); color: var(--navy); font: var(--text-body); }
::selection { background: var(--navy); color: var(--on-navy); }
:root { accent-color: var(--navy); caret-color: var(--navy); scrollbar-color: var(--line-strong) var(--sand); }
main a { color: var(--navy); text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
main a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }
.frame :focus-visible, .auth :focus-visible.on-navy { outline-color: var(--on-navy); }
h1 { font: var(--text-title); margin: 0 0 var(--space-2); }
h2 { font: var(--text-heading); margin: 0 0 var(--space-3); }
p { margin: 0 0 var(--space-3); max-width: 70ch; }
.meta { font: var(--text-meta); color: var(--slate); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
table, .num { font-variant-numeric: tabular-nums; }
.skip { position: absolute; left: var(--space-4); top: -100px; background: var(--paper); padding: var(--space-2) var(--space-4); z-index: 50; }
.skip:focus { top: var(--space-2); }

/* ------------------------------------------------------------ frame (7.1, 7.2) */
.frame { position: relative; height: var(--frame-height); background: var(--navy); color: var(--on-navy);
  display: flex; align-items: center; padding: 0 var(--space-6); gap: var(--space-4); }
.frame .home { display: flex; align-items: center; padding: 4px 0; }
.frame .logo { height: 24px; width: 120px; display: block; }
.frame .rule { width: 1px; height: 24px; background: var(--navy-raised); }
.frame .product { font-weight: 600; color: var(--on-navy); }
.frame nav { display: flex; height: 100%; margin-left: var(--space-5); }
.frame nav a { display: flex; align-items: center; padding: 0 var(--space-4); color: var(--on-navy-muted);
  text-decoration: none; border-bottom: 3px solid transparent; border-top: 3px solid transparent;
  transition: background-color var(--dur-fast) var(--ease-out); }
.frame nav a:hover { background: var(--navy-raised); color: var(--on-navy); }
.frame nav a[aria-current=page], .frame nav a[aria-current=page]:hover { background: none; color: var(--on-navy);
  font-weight: 600; border-bottom-color: var(--coral); }
.frame .usermenu { margin-left: auto; }
.frame .userbtn { background: none; border: 0; color: var(--on-navy-muted); font: var(--text-body); height: var(--control-height);
  padding: 0 var(--space-3); cursor: pointer; display: inline-flex; align-items: center; gap: var(--space-2); }
.frame .userbtn:hover { background: var(--navy-raised); color: var(--on-navy); }
.menu { margin: 0; inset: auto; position: fixed; top: calc(var(--frame-height) - 4px); right: var(--space-6); left: auto;
  background: var(--paper); border: 1px solid var(--navy); padding: 0; min-width: 160px; color: var(--navy); }
.menu form { margin: 0; }
.menu button { display: block; width: 100%; text-align: left; height: var(--control-height); padding: 0 var(--space-4);
  background: none; border: 0; font: var(--text-body); color: var(--navy); cursor: pointer; }
.menu button:hover { background: var(--sand); }

main { padding: var(--space-6); max-width: var(--content-max); }
@media (max-width: 1279px) { main { padding: var(--space-4); } .frame { padding: 0 var(--space-4); } }

/* ------------------------------------------------------------ buttons (9.1) */
.btn { display: inline-flex; align-items: center; justify-content: center; height: var(--control-height);
  padding: 0 var(--space-4); border-radius: var(--radius-control); border: 1px solid transparent;
  font: var(--text-body); font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color var(--dur-fast) var(--ease-out); }
main a.btn { text-decoration: none; }
.btn-primary { background: var(--navy); color: var(--on-navy); }
.btn-primary:hover { background: var(--navy-raised); }
.btn-secondary { background: transparent; border-color: var(--line-strong); color: var(--navy); }
.btn-secondary:hover { background: var(--sand); }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger-tint); }
.btn-danger-filled { background: var(--danger); color: var(--on-navy); }
.btn-danger-filled:hover { background: var(--danger-hover); }
.btn-signin { background: var(--coral-deep); color: var(--on-navy); width: 100%; }
.btn-signin:hover { background: var(--coral-deep-hover); }
.btn[aria-disabled=true], .btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-small { height: 32px; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--navy); text-decoration: underline;
  text-decoration-thickness: 1px; text-underline-offset: .2em; cursor: pointer; }
.actions { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }

/* ------------------------------------------------------------ marks (9.3) */
.mark { width: 10px; height: 10px; flex: none; }
.state { display: inline-flex; align-items: center; gap: var(--space-1); }
.s-stored .mark { color: var(--slate); }
.s-failed { color: var(--danger); }
.s-muted { color: var(--slate); }
.s-warn .mark { color: var(--warn); }
.s-ok .mark { color: var(--ok); }

/* ------------------------------------------------------------ inputs (9.5, 9.6) */
.field { margin-bottom: var(--space-4); }
.field > label, .field > .label, fieldset > legend { display: block; font-weight: 600; margin-bottom: var(--space-1); padding: 0; }
.field input[type=text], .field input[type=email], .field input[type=password], .field input[type=search],
.field input[type=number], .field select, .field textarea {
  display: block; width: 100%; min-height: var(--control-height); padding: 0 var(--space-3); background: var(--sand);
  border: 0; border-bottom: 1px solid var(--line-strong); border-radius: var(--radius-surface); color: var(--navy);
  font: var(--text-lead); }
.field textarea { padding: var(--space-2) var(--space-3); min-height: 96px; resize: vertical; }
.field input[aria-invalid=true], .field textarea[aria-invalid=true], .field select[aria-invalid=true] { border-bottom: 2px solid var(--danger); }
.field .help { font: var(--text-meta); color: var(--slate); margin-top: var(--space-1); max-width: 70ch; }
.field .error { font: var(--text-meta); color: var(--danger); margin-top: var(--space-1); font-weight: 600; }
.field > label.check, .check { font-weight: 400; display: flex; align-items: center; gap: var(--space-2); min-height: var(--control-height); }
.check input { width: 18px; height: 18px; margin: 0; }
fieldset { border: 0; margin: 0 0 var(--space-4); padding: 0; }
.inline-fields { display: flex; flex-wrap: wrap; gap: var(--space-4); align-items: flex-end; }
.inline-fields .field { margin-bottom: 0; }

/* ------------------------------------------------------------ notices (9.9) */
.notice { display: flex; gap: var(--space-2); align-items: flex-start; padding: var(--space-3) var(--space-4);
  border: 1px solid; color: var(--navy); margin-bottom: var(--space-4); max-width: 100%; }
.notice .mark { margin-top: 5px; }
.notice p { margin: 0; }
.notice strong { font-weight: 600; }
.notice-warn { background: var(--warn-tint); border-color: var(--warn); } .notice-warn .mark { color: var(--warn); }
.notice-danger { background: var(--danger-tint); border-color: var(--danger); } .notice-danger .mark { color: var(--danger); }
.notice-ok { background: var(--ok-tint); border-color: var(--ok); } .notice-ok .mark { color: var(--ok); }
.notice .body { flex: 1; min-width: 0; }
.notice .dismiss { margin-left: auto; }
.toasts { position: fixed; left: var(--space-4); bottom: var(--space-4); z-index: 40; display: flex; flex-direction: column;
  gap: var(--space-2); max-width: min(480px, calc(100vw - 32px)); }
.toasts .notice { margin: 0; }
.copyrow { display: flex; gap: var(--space-2); margin-top: var(--space-2); }
.copyrow input { flex: 1; min-width: 0; height: var(--control-height); padding: 0 var(--space-3); background: var(--paper);
  border: 0; border-bottom: 1px solid var(--line-strong); font: var(--text-body); color: var(--navy); }

/* ------------------------------------------------------------ tables (9.4) */
.scroll { overflow-x: auto; }
table { border-collapse: collapse; }
caption { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
thead th { background: var(--sand); text-align: left; font-weight: 600; height: var(--row-height);
  padding: 0 var(--space-3); white-space: nowrap; }
tbody tr { border-bottom: 1px solid var(--line); }
tbody tr:hover { background: var(--sand); }
tbody th, tbody td { padding: 0 var(--space-3); height: var(--row-height); text-align: left; }
tbody th { font-weight: 600; }
tbody th a, td a.name { font-weight: 600; }
td.n, th.n { text-align: right; }
table.data { width: 100%; }
table.data td, table.data th { padding-top: var(--space-2); padding-bottom: var(--space-2); vertical-align: middle; }
.pager { display: flex; gap: var(--space-2); margin-top: var(--space-4); }

/* ------------------------------------------------------------ fleet (7.2, 8.1) */
.bar { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--space-5); margin-bottom: var(--space-5); flex-wrap: wrap; }
.status { font: var(--text-lead); margin: 0; }
.fresh { display: flex; align-items: center; gap: var(--space-3); margin: var(--space-2) 0 0; font: var(--text-meta); color: var(--slate); }
.search { width: 280px; margin-bottom: 0; }
.filters { display: flex; gap: var(--space-5); margin-bottom: var(--space-4); }
.filters button { background: none; border: 0; border-bottom: 3px solid transparent; padding: var(--space-2) 0;
  font: var(--text-body); color: var(--slate); cursor: pointer; }
.filters button[aria-pressed=true] { color: var(--navy); font-weight: 600; border-bottom-color: var(--navy); }
table.fleet { table-layout: fixed; width: 1056px; }
table.fleet thead th { height: 48px; vertical-align: bottom; padding-bottom: var(--space-2); }
table.fleet thead th.c-install { width: 260px; }
table.fleet thead th.c-latest { width: 180px; }
table.fleet thead th.c-count { display: none; width: 140px; }
table.fleet thead th.day { width: var(--cell-width); font-weight: 400; }
table.fleet thead th.day span { display: block; font-weight: 700; }
table.fleet thead th.today { font-weight: 700; }
table.fleet tbody th { height: var(--row-height-fleet); max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.fleet td { height: var(--row-height-fleet); white-space: nowrap; }
table.fleet td.latest { line-height: 1rem; }
table.fleet td.latest .meta { display: block; }
table.fleet td.c-count { display: none; }
table.fleet td:focus-visible, table.fleet th:focus-visible { outline-offset: -2px; }
td.day { padding: 0; width: var(--cell-width); }
td.day.failed { background: var(--danger-tint); }
td.day button { display: flex; align-items: center; width: 100%; height: var(--row-height-fleet); padding: 0 var(--space-3);
  background: none; border: 0; color: var(--navy); font: inherit; font-variant-numeric: tabular-nums; cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out); }
td.day button:focus-visible { outline-offset: -2px; }
td.day button:hover { background: var(--line); }
td.day.failed button { color: var(--danger); }
td.day.failed button:hover { background: none; outline: 1px solid var(--danger); outline-offset: -1px; }
td.day button[aria-pressed=true], td.day button[aria-pressed=true]:hover { background: var(--paper); outline: 2px solid var(--coral); outline-offset: -2px; }
.legend { display: flex; flex-wrap: wrap; gap: var(--space-5); margin: var(--space-4) 0 0; padding: 0; list-style: none; font: var(--text-meta); color: var(--slate); }
.sortbtn { background: none; border: 0; padding: 0; font: inherit; font-weight: 600; color: var(--navy); cursor: pointer; }
.empty { padding: var(--space-5) 0; }
@media (min-width: 1120px) {
  table.fleet thead th { position: sticky; top: 0; z-index: 2; }
  .fleet-scroll { overflow: visible; }
}
@media (max-width: 1119px) {
  .fleet-scroll { overflow-x: auto; }
  table.fleet tbody th { position: sticky; left: 0; background: var(--paper); z-index: 1; }
  table.fleet tbody tr:hover th { background: var(--sand); }
}
@media (max-width: 899px) {
  table.fleet { width: 100%; min-width: 0; }
  table.fleet .day { display: none; }
  table.fleet thead th.c-count, table.fleet td.c-count { display: table-cell; }
  table.fleet thead th.c-install { width: auto; }
  .search { width: 100%; }
}

/* ------------------------------------------------------------ backup panel (8.3) */
.panel { position: fixed; top: var(--frame-height); right: 0; bottom: 0; width: 420px; max-width: 100%; background: var(--paper);
  border-left: 1px solid var(--navy); padding: var(--space-5); overflow-y: auto; z-index: 30;
  animation: panel-in var(--dur-enter) var(--ease-out); }
@keyframes panel-in { from { transform: translateX(16px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (max-width: 899px) { .panel { width: 100%; border-left: 0; } }
.panel h2:focus { outline: none; }
.panel h2:focus-visible { outline: 2px solid var(--navy); }
.panel dl { display: grid; grid-template-columns: max-content 1fr; gap: var(--space-2) var(--space-4); margin: 0 0 var(--space-5); }
.panel dt { color: var(--slate); }
.panel dd { margin: 0; overflow-wrap: anywhere; }
.panel .actions { margin-bottom: var(--space-5); }
.placeholder { background: var(--sand); height: 20px; margin-bottom: var(--space-3); }
.placeholder.w60 { width: 60%; } .placeholder.w80 { width: 80%; } .placeholder.h40 { height: 40px; width: 50%; }

/* ------------------------------------------------------------ dialog (9.8) */
dialog { width: 480px; max-width: calc(100vw - 32px); background: var(--paper); border: 1px solid var(--navy);
  padding: var(--space-5); color: var(--navy); border-radius: var(--radius-surface); }
dialog::backdrop { background: var(--scrim); }
dialog[open] { animation: dialog-in var(--dur-enter) var(--ease-out); }
@keyframes dialog-in { from { opacity: 0; } to { opacity: 1; } }
dialog .what { font-weight: 600; }
dialog .dialog-actions { display: flex; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-5); flex-wrap: wrap; }

/* ------------------------------------------------------------ install detail (8.2) */
.crumbs { font: var(--text-body); margin: 0 0 var(--space-2); color: var(--slate); }
.titlebar { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-4); flex-wrap: wrap; }
table.days { width: 100%; max-width: 1056px; }
table.days td { padding-top: var(--space-2); padding-bottom: var(--space-2); height: var(--row-height); }
table.days td.msg { white-space: normal; max-width: 480px; }

/* ------------------------------------------------------------ sections / forms on paper */
.section { margin-top: var(--space-7); }
.section:first-of-type { margin-top: 0; }
.formpanel { max-width: 640px; }
.settings-group { border-top: 1px solid var(--line); padding-top: var(--space-5); margin-top: var(--space-5); max-width: 640px; }
.settings-group h2 { margin-bottom: var(--space-4); }
.source { font: var(--text-meta); color: var(--slate); margin-top: var(--space-1); }
.savebar { border-top: 1px solid var(--line); margin-top: var(--space-6); padding-top: var(--space-5); max-width: 640px; }
.userrow-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.userrow-actions form { margin: 0; display: inline-flex; gap: var(--space-2); align-items: center; }
.userrow-actions select { height: 32px; background: var(--sand); border: 0; border-bottom: 1px solid var(--line-strong); color: var(--navy); font: var(--text-body); padding: 0 var(--space-2); }
.tag { font-weight: 600; }
.codes { columns: 2; list-style: none; padding: 0; margin: 0 0 var(--space-4); font: var(--text-lead); font-variant-numeric: tabular-nums; }
.codes li { padding: var(--space-1) 0; }

/* ------------------------------------------------------------ sign in (8.6) */
body.auth { background: var(--navy); min-height: 100vh; }
.auth-wrap { display: flex; flex-direction: column; align-items: center; padding: var(--space-7) var(--space-4); }
.auth-wrap .logo { height: 32px; width: 160px; margin-bottom: var(--space-6); }
.auth-panel { width: 320px; max-width: 100%; background: var(--paper); padding: var(--space-5); color: var(--navy); }
.auth-panel.wide { width: 440px; }
.auth-panel h1 { font: var(--text-heading); margin-bottom: var(--space-4); }
.auth-panel p { font: var(--text-body); }
.auth-panel .alt { margin-top: var(--space-4); }
.qr { display: block; width: 200px; height: 200px; margin: 0 0 var(--space-3); image-rendering: pixelated; }
.secret { font: var(--text-lead); font-variant-numeric: tabular-nums; letter-spacing: 0; word-break: break-all; margin-bottom: var(--space-4); }

/* ------------------------------------------------------------ utilities (CSP forbids inline styles) */
.mt-4 { margin-top: var(--space-4); }
.mt-5 { margin-top: var(--space-5); }
.w-code { max-width: 200px; }

/* hidden must win over component display rules */
[hidden] { display: none !important; }

/* ------------------------------------------------------------ narrow screens: frame wraps, nav scrolls */
@media (max-width: 899px) {
  .frame { height: auto; flex-wrap: wrap; padding-top: var(--space-2); row-gap: 0; }
  .frame nav { order: 3; width: 100%; margin-left: 0; height: 44px; overflow-x: auto; }
  .frame nav a { padding: 0 var(--space-3); white-space: nowrap; }
  .menu { top: 52px; right: var(--space-4); }
  .panel { top: 0; }
  table.fleet { table-layout: auto; }
  table.fleet tbody th { max-width: 160px; }
}
