/* Packaging Dieline — admin console
   Brand tokens are fixed by ADMIN_SPEC.md. Do not invent new hues.
   CTA text on cyan is #00293D: white on #00B9F0 is 2.28:1 and fails AA. */

:root {
  --sky: #00B9F0;
  --blue: #006FD0;
  --blue-deep: #005E9D;
  --bg: #F4F5F8;
  --card: #FFFFFF;
  --body: #181B21;
  --muted: #4E5157;
  --ink: #000000;

  --cta-on-sky: #00293D;
  --line: #DCE0E7;
  --line-soft: #E9ECF1;
  --sky-wash: #E7F8FE;
  --blue-wash: #EAF2FC;

  --ok: #0F7A46;
  --ok-wash: #E4F5EC;
  --bad: #B3261E;
  --bad-wash: #FCEBEA;
  --warn: #8A5A00;
  --warn-wash: #FDF3E0;

  --r: 8px;
  --r-sm: 5px;
  --shadow: 0 1px 2px rgba(24, 27, 33, .06), 0 4px 14px rgba(24, 27, 33, .05);
  --sans: Lato, -apple-system, "Segoe UI", system-ui, sans-serif;
  --head: Orbitron, "Arial Black", var(--sans);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sidebar-w: 232px;
  --topbar-h: 54px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--body);
  font: 400 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, .brand { font-family: var(--head); font-weight: 700; letter-spacing: .01em; }
h1 { font-size: 19px; margin: 0; }
h2 { font-size: 15px; margin: 0 0 10px; }
h3 { font-size: 13px; margin: 0 0 8px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }

a { color: var(--blue); }
a:hover { color: var(--blue-deep); }

.num, td.num, .mono, input[type=number], code, pre, kbd {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
  border-radius: 3px;
}

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--card); padding: 10px 14px; border: 2px solid var(--blue);
}
.skip:focus { left: 8px; top: 8px; }

.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------------------------------------------------------------- login --- */
#login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1100px 460px at 50% -12%, var(--sky-wash), transparent 70%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 400px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 28px;
}
.login-card .brand { font-size: 17px; margin: 0 0 2px; }
.login-card .brand span { color: var(--blue); }
.login-sub { color: var(--muted); font-size: 13px; margin: 0 0 20px; }
.login-foot { margin: 18px 0 0; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line-soft); padding-top: 12px; }

/* ----------------------------------------------------------------- app ---- */
#app { min-height: 100vh; }

.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--topbar-h); z-index: 30;
  display: flex; align-items: center; gap: 14px;
  padding: 0 16px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.topbar .brand { font-size: 14px; width: calc(var(--sidebar-w) - 32px); flex: none; white-space: nowrap; }
.topbar .brand span { color: var(--blue); }

.gsearch { position: relative; flex: 1; max-width: 460px; }
.gsearch input { width: 100%; padding-left: 30px; }
.gsearch::before {
  content: ""; position: absolute; left: 11px; top: 50%; width: 11px; height: 11px;
  transform: translateY(-60%); border: 1.6px solid var(--muted); border-radius: 50%;
  box-shadow: 6px 6px 0 -4.4px var(--muted);
}
.gsearch kbd {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font-size: 11px; color: var(--muted); border: 1px solid var(--line);
  border-radius: 4px; padding: 1px 5px; background: var(--bg); pointer-events: none;
}
.spacer { flex: 1; }
.who { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.who .name { font-weight: 700; }
.who .email { color: var(--muted); font-size: 12px; }

.badge {
  display: inline-block; padding: 1px 7px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  border: 1px solid transparent; white-space: nowrap;
}
.badge-owner { background: var(--blue-wash); color: var(--blue-deep); border-color: #BFDBF5; }
.badge-editor { background: var(--sky-wash); color: #00527A; border-color: #B7E7F8; }
.badge-viewer { background: #EEF0F4; color: var(--muted); border-color: var(--line); }
.badge-ok { background: var(--ok-wash); color: var(--ok); border-color: #BEE3CE; }
.badge-bad { background: var(--bad-wash); color: var(--bad); border-color: #F3C9C6; }
.badge-warn { background: var(--warn-wash); color: var(--warn); border-color: #EBD7AE; }
.badge-muted { background: #EEF0F4; color: var(--muted); border-color: var(--line); }

/* --------------------------------------------------------------- sidebar -- */
.sidebar {
  position: fixed; top: var(--topbar-h); bottom: 0; left: 0; width: var(--sidebar-w);
  overflow-y: auto; padding: 12px 10px 32px;
  background: var(--card); border-right: 1px solid var(--line); z-index: 20;
}
.navgroup { margin-bottom: 14px; }
.navgroup > h3 { margin: 0 0 4px; padding: 0 8px; font-size: 10px; }
.sidebar a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 5px 8px; border-radius: var(--r-sm);
  color: var(--body); text-decoration: none; font-size: 13px;
}
.sidebar a:hover { background: var(--bg); }
.sidebar a[aria-current="page"] {
  background: var(--blue-wash); color: var(--blue-deep); font-weight: 700;
  box-shadow: inset 2px 0 0 var(--blue);
}
.sidebar a .count { font-family: var(--mono); font-size: 11px; color: var(--muted); }

.main {
  margin: var(--topbar-h) 0 0 var(--sidebar-w);
  padding: 18px 20px 60px;
  min-height: calc(100vh - var(--topbar-h));
}

/* ------------------------------------------------------------- controls --- */
input, select, textarea {
  font: inherit; color: var(--body); background: var(--card);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 6px 9px; width: 100%;
}
input[type=checkbox] { width: auto; accent-color: var(--blue); }
textarea { min-height: 84px; resize: vertical; line-height: 1.5; }
input:hover, select:hover, textarea:hover { border-color: #C4CAD4; }
input[aria-invalid="true"], textarea[aria-invalid="true"], select[aria-invalid="true"] {
  border-color: var(--bad); background: #FFF9F9;
}
label { display: block; font-size: 12px; font-weight: 700; margin-bottom: 4px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.err { font-size: 12px; color: var(--bad); margin-top: 4px; font-weight: 700; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  font: 700 13px/1 var(--sans);
  padding: 8px 13px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--card); color: var(--body);
  cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--bg); border-color: #C4CAD4; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.btn[aria-disabled="true"]:hover { background: var(--sky); }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-deep); border-color: var(--blue-deep); }
.btn-cta { background: var(--sky); border-color: var(--sky); color: var(--cta-on-sky); }
.btn-cta:hover { background: #00A6D8; border-color: #00A6D8; color: var(--cta-on-sky); }
.btn-danger { color: var(--bad); border-color: #F0C4C1; background: #fff; }
.btn-danger:hover { background: var(--bad-wash); border-color: var(--bad); }
.btn-danger-solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-danger-solid:hover { background: #8F1E17; border-color: #8F1E17; }
.btn-sm { padding: 4px 8px; font-size: 12px; }
.btn-icon { padding: 4px 7px; font-size: 12px; }

/* ----------------------------------------------------------------- page --- */
.page-head {
  display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap;
  margin-bottom: 14px;
}
.page-head .sub { color: var(--muted); font-size: 13px; margin: 3px 0 0; max-width: 70ch; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow);
}
.card + .card { margin-top: 14px; }
.grid > .card + .card { margin-top: 0; }  /* the grid gap already spaces them */
.card-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid var(--line-soft);
}
.card-head h2, .card-head h3 { margin: 0; }
.card-body { padding: 14px; }

.toolbar {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  padding: 10px 12px; border-bottom: 1px solid var(--line-soft);
}
.toolbar .search { flex: 1; min-width: 180px; max-width: 340px; }
.toolbar select { width: auto; }

/* ---------------------------------------------------------------- table --- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
/* Sticky relative to the page on desktop (the wrapper is not a scroll box there);
   on tablet the wrapper scrolls horizontally, so the header pins to its own top. */
thead th {
  position: sticky; top: 0; z-index: 5;
  background: #FAFBFC; font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); white-space: nowrap; border-bottom: 1px solid var(--line);
}
thead th button {
  all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 4px;
  font: inherit; color: inherit;
}
thead th button:hover { color: var(--blue-deep); }
thead th[aria-sort] button { color: var(--blue-deep); }
th.num, td.num { text-align: right; }
/* Leave room for the sticky header so a row scrolled into view is never under it. */
tbody tr { scroll-margin-top: calc(var(--topbar-h) + 46px); }
tbody tr:hover { background: #FBFCFD; }
tbody tr.selected { background: var(--blue-wash); }
td.actions { text-align: right; white-space: nowrap; }
td.actions .btn { margin-left: 4px; }
.col-check { width: 30px; }
.col-drag { width: 26px; color: var(--muted); }

tr.draggable td.col-drag { cursor: grab; }
tr.drag-over td { box-shadow: inset 0 2px 0 var(--blue); }
tr.dragging { opacity: .45; }

.pager {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 9px 12px; border-top: 1px solid var(--line-soft); font-size: 12px; color: var(--muted);
}
.pager .spacer { flex: 1; }

.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty h3 { color: var(--body); margin-bottom: 6px; text-transform: none; letter-spacing: 0; font-size: 14px; }
.empty p { max-width: 46ch; margin: 0 auto 14px; }

/* ------------------------------------------------------------- dashboard -- */
.grid { display: grid; gap: 14px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.stat { padding: 12px 14px; }
.stat .k { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.stat .v { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 26px; line-height: 1.15; margin-top: 4px; }
.stat .v.sm { font-size: 17px; word-break: break-all; }
.stat .n { font-size: 12px; color: var(--muted); margin-top: 4px; }
.stat .unavailable { color: var(--warn); font-size: 13px; font-family: var(--sans); margin-top: 6px; }

.bars { display: grid; gap: 7px; }
.bar-row { display: grid; grid-template-columns: 132px 1fr 46px; gap: 8px; align-items: center; font-size: 12px; }
.bar { height: 9px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--sky); }
.bar i.b-verified { background: var(--sky); }
.bar i.b-wider { background: var(--blue); }
.bar i.b-draft { background: #98A0AC; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ----------------------------------------------------------------- form --- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
fieldset { border: 1px solid var(--line-soft); border-radius: var(--r-sm); padding: 12px 14px; margin: 0 0 14px; }
legend { font-family: var(--head); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .07em; padding: 0 6px; color: var(--muted); }
.check-row { display: flex; align-items: center; gap: 8px; }
.check-row label { margin: 0; }

.editor-foot {
  position: sticky; bottom: 0; display: flex; gap: 8px; align-items: center;
  padding: 12px 14px; background: var(--card); border-top: 1px solid var(--line);
  border-radius: 0 0 var(--r) var(--r);
}
.editor-foot .spacer { flex: 1; }
.dirty-flag { font-size: 12px; color: var(--warn); font-weight: 700; }

.meta-line { font-size: 12px; color: var(--muted); display: flex; gap: 16px; flex-wrap: wrap; }
.meta-line b { font-weight: 700; color: var(--body); }

/* --------------------------------------------------------------- dialog --- */
dialog {
  border: 1px solid var(--line); border-radius: var(--r); padding: 0;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .28); max-width: 560px; width: calc(100% - 32px);
  color: var(--body); background: var(--card);
}
dialog::backdrop { background: rgba(24, 27, 33, .45); }
dialog h2 { padding: 14px 16px 0; }
dialog .dlg-body { padding: 12px 16px; }
dialog .dlg-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 16px; border-top: 1px solid var(--line-soft); }

/* --------------------------------------------------------------- notices -- */
.notice { border-radius: var(--r-sm); padding: 10px 12px; font-size: 13px; border: 1px solid; }
.notice-bad { background: var(--bad-wash); border-color: #F0C4C1; color: #7C1810; }
.notice-warn { background: var(--warn-wash); border-color: #EBD7AE; color: #5F3E00; }
.notice-ok { background: var(--ok-wash); border-color: #BEE3CE; color: #0B5733; }
.notice-info { background: var(--blue-wash); border-color: #BFDBF5; color: #084578; }
.notice + .notice, .notice + .card, .card + .notice { margin-top: 12px; }
.notice h3 { color: inherit; text-transform: none; letter-spacing: 0; font-size: 13px; }

#toasts {
  position: fixed; right: 14px; bottom: 14px; z-index: 90;
  display: flex; flex-direction: column; gap: 8px; max-width: 380px;
}
.toast {
  background: var(--body); color: #fff; padding: 10px 13px; border-radius: var(--r-sm);
  font-size: 13px; box-shadow: var(--shadow);
}
.toast.bad { background: #7C1810; }
.toast.ok { background: #0B5733; }

/* --------------------------------------------------------------- misc ----- */
pre.output {
  margin: 0; padding: 12px 14px; background: #0F1216; color: #E6E9EE;
  border-radius: var(--r-sm); overflow: auto; max-height: 420px;
  font-size: 12px; line-height: 1.55; white-space: pre-wrap; word-break: break-word;
}
.key-panel {
  font-family: var(--mono); font-size: 13px; background: #0F1216; color: #7FE3FF;
  padding: 12px 14px; border-radius: var(--r-sm); word-break: break-all; user-select: all;
}
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 12px 14px 12px 22px; border-bottom: 1px solid var(--line-soft); position: relative; }
.timeline li::before {
  content: ""; position: absolute; left: 7px; top: 18px; width: 7px; height: 7px;
  border-radius: 50%; background: var(--sky); box-shadow: 0 0 0 3px var(--sky-wash);
}
.timeline li::after { content: ""; position: absolute; left: 10px; top: 25px; bottom: -12px; width: 1px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.delta { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.delta .to { font-weight: 700; }
.delta .arrow { color: var(--muted); padding: 0 6px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  font-size: 12px; padding: 2px 8px; border-radius: 999px;
  background: var(--bg); border: 1px solid var(--line); color: var(--muted);
}
.chip.on { background: var(--sky-wash); border-color: #B7E7F8; color: #00527A; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); padding: 0 12px; }
.tabs button {
  all: unset; cursor: pointer; padding: 8px 12px; font-size: 13px; font-weight: 700;
  color: var(--muted); border-bottom: 2px solid transparent;
}
.tabs button[aria-selected="true"] { color: var(--blue-deep); border-bottom-color: var(--blue); }

.loading { padding: 30px; text-align: center; color: var(--muted); font-size: 13px; }

.truncate { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nowrap { white-space: nowrap; }

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }
  table { font-size: 12px; }
  th, td { padding: 6px 8px; }
  .sidebar {
    width: 232px; transform: translateX(-100%); transition: transform .16s ease;
    box-shadow: 8px 0 24px rgba(0, 0, 0, .12);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .main::before {
    content: ""; position: fixed; inset: var(--topbar-h) 0 0 0;
    background: rgba(24, 27, 33, .38); z-index: 15;
  }
  .main { margin-left: 0; padding: 14px; }
  .topbar .brand { width: auto; }
  .grid-4, .grid-3, .grid-2, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .gsearch kbd { display: none; }
  .who .email { display: none; }
}
@media (min-width: 901px) {
  #navtoggle { display: none; }
  .table-wrap { overflow: visible; }
  thead th { top: var(--topbar-h); }
}

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