/* Shared look for the Card Asylum web admin.
 * Every admin page links this before its own <style>; page-specific rules
 * (calendar, sparklines, bin grid, status badges…) stay in the page and
 * override these. Brand colours follow the storefront (deep green + cream +
 * gold); page bodies stay light/neutral so dense tables are easy to scan.
 * Light/dark follows the system setting. */

:root {
  color-scheme: light dark;
  --page-w: 1200px;
  --display: "Barlow Condensed", "Arial Narrow", Impact, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --brand: #0b3118;
  --brand-2: #154a27;
  --on-brand: #f2e9dd;
  --gold: #f0c96a;

  --bg: #f5f4ef;
  --surface: #ffffff;
  --surface-2: #f0efe8;
  --text: #1b261f;
  --muted: #5f6b63;
  --line: #e3e2d9;
  --line-strong: #cac9bc;
  --row-hover: #f7f6f1;
  --accent: #1f6b3a;
  --accent-hover: #185a30;
  --on-accent: #ffffff;
  --accent-soft: rgba(31, 107, 58, .12);
  --link: #1f6b3a;
  --danger: #c62828;
  --ok: #15803d;
  --warn: #b45309;
  --shadow: 0 1px 2px rgba(16, 40, 24, .05), 0 1px 3px rgba(16, 40, 24, .06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1310;
    --surface: #151c17;
    --surface-2: #1c251f;
    --text: #e8e6df;
    --muted: #9ba69d;
    --line: #26312a;
    --line-strong: #38453c;
    --row-hover: #19211b;
    --accent: #3f9a5f;
    --accent-hover: #4cae6d;
    --on-accent: #06140b;
    --accent-soft: rgba(63, 154, 95, .2);
    --link: #74c792;
    --danger: #f87171;
    --ok: #4ade80;
    --warn: #fbbf24;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}

/* ── page frame ─────────────────────────────────────────────────────────── */
/* Content is centred by the side padding (not a max-width) so the header bar
 * can bleed edge to edge with a matching negative margin. */
body {
  --gutter: max(1rem, calc((100vw - var(--page-w)) / 2));
  margin: 0;
  padding: 0 var(--gutter) 3rem;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: .9375rem;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
body.wide { --page-w: 1500px; }
body.narrow { --page-w: 820px; }

a { color: var(--link); }
h1 {
  font: 700 1.9rem/1.1 var(--display);
  letter-spacing: .01em;
  margin: 1.4rem 0 .9rem;
}
h2 { font-size: 1.05rem; font-weight: 650; margin: .25rem 0 .5rem; }
h3 { font-size: .95rem; font-weight: 650; margin: 1rem 0 .3rem; }

/* ── header bar (rendered by shell.js) ──────────────────────────────────── */
/* Two rows: logo row, then a darker tab strip with every page one click away. */
admin-header {
  display: block;
  margin-inline: calc(-1 * var(--gutter));
  background: var(--brand);
  color: var(--on-brand);
  box-shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 10px 24px -18px rgba(0, 0, 0, .6);
}
.ah-top {
  display: flex;
  align-items: center;
  gap: .85rem;
  height: 60px;
  padding-inline: var(--gutter);
}
.ah-logo { display: flex; align-items: center; }
.ah-logo img { display: block; height: 22px; width: auto; }
.ah-logo:hover img { opacity: .85; }
.ah-tag {
  font: 700 .6rem/1 system-ui, sans-serif;
  letter-spacing: .16em;
  color: var(--gold);
  padding: .3rem .55rem .28rem;
  border: 1px solid rgba(240, 201, 106, .45);
  border-radius: 999px;
}
.ah-site {
  margin-left: auto;
  font-size: .8rem;
  font-weight: 550;
  color: rgba(242, 233, 221, .7);
  text-decoration: none;
  padding: .35rem .65rem;
  border-radius: 6px;
  white-space: nowrap;
}
.ah-site:hover { color: var(--on-brand); background: rgba(255, 255, 255, .08); }
.ah-tabs {
  background: #072511;
  border-top: 1px solid rgba(242, 233, 221, .07);
  padding-inline: var(--gutter);
}
.ah-nav {
  display: flex;
  align-items: stretch;
  height: 44px;
  overflow-x: auto;
  scrollbar-width: none;
}
.ah-nav::-webkit-scrollbar { display: none; }
.ah-group { display: flex; align-items: stretch; flex: none; }
.ah-group + .ah-group { position: relative; margin-left: .9rem; padding-left: .9rem; }
.ah-group + .ah-group::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 1px;
  height: 16px;
  margin-top: -8px;
  background: rgba(242, 233, 221, .14);
}
.ah-label {
  align-self: center;
  margin-right: .45rem;
  font-size: .58rem;
  font-weight: 650;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: rgba(242, 233, 221, .38);
}
.ah-nav a {
  display: flex;
  align-items: center;
  padding: 0 .7rem;
  border-bottom: 2px solid transparent;
  color: rgba(242, 233, 221, .72);
  text-decoration: none;
  font-size: .85rem;
  font-weight: 550;
  white-space: nowrap;
  transition: color .12s, border-color .12s;
}
.ah-nav a:hover { color: var(--on-brand); border-bottom-color: rgba(242, 233, 221, .28); }
.ah-nav a[aria-current="page"] { color: #fff; border-bottom-color: var(--gold); }
.ah-nav a:focus-visible, .ah-site:focus-visible, .ah-logo:focus-visible { outline-offset: -2px; }
@media (max-width: 1100px) { .ah-label { display: none; } }
@media (max-width: 820px) {
  .ah-top { height: 52px; }
  .ah-logo img { height: 18px; }
  /* Tabs swipe sideways on a phone; the fade hints there's more. */
  .ah-nav {
    margin-inline: -.7rem;
    -webkit-mask-image: linear-gradient(to right, #000 88%, transparent);
    mask-image: linear-gradient(to right, #000 88%, transparent);
  }
}
@media print { admin-header { display: none; } }

/* ── building blocks ────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1rem 1.1rem;
  margin: .9rem 0;
  box-shadow: var(--shadow);
}
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.row > label {
  display: flex;
  flex-direction: column;
  gap: .2rem;
  font-size: .72rem;
  font-weight: 600;
  color: var(--muted);
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: .85rem; }
.nowrap { white-space: nowrap; }
.tblwrap { overflow-x: auto; }
.err { color: var(--danger); }
.ok { color: var(--ok); }
.warn { color: var(--warn); }
.status-msg { font-size: .85rem; margin-top: .5rem; min-height: 1.1em; }
.status-msg.err { color: var(--danger); }
.status-msg.ok { color: var(--ok); }
details summary { cursor: pointer; }
code { font-family: var(--mono); font-size: .8rem; }
hr { border: 0; border-top: 1px solid var(--line); }

/* Sign-in card: #login is rendered by admin.js, #loginCard is index.html's own. */
#login, #loginCard { max-width: 380px; margin: 3rem auto; padding: 1.5rem; }
#login::before, #loginCard::before {
  content: "Sign in";
  display: block;
  margin-bottom: .9rem;
  font: 700 1.5rem/1 var(--display);
}
#login .row, #loginCard .row { flex-direction: column; align-items: stretch; gap: .6rem; }
#login .row button, #loginCard .row button { padding-block: .55rem; }

/* ── controls ───────────────────────────────────────────────────────────── */
button {
  font: inherit;
  font-size: .86rem;
  font-weight: 550;
  line-height: 1.3;
  padding: .45rem .9rem;
  border-radius: 7px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background-color .12s, border-color .12s;
}
button:hover { background: var(--surface-2); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.danger { color: var(--danger); border-color: currentColor; }
button.small { padding: .2rem .55rem; font-size: .78rem; border-radius: 6px; }
button:disabled { opacity: .45; cursor: not-allowed; }

input, select, textarea {
  font: inherit;
  font-size: .875rem;
  padding: .42rem .55rem;
  border-radius: 7px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
}
textarea { line-height: 1.4; }
::placeholder { color: var(--muted); opacity: .75; }
input[type="checkbox"], input[type="radio"] { padding: 0; width: 1rem; height: 1rem; accent-color: var(--accent); }
select.small { padding: .2rem .3rem; font-size: .8rem; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* ── tables ─────────────────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
td, th {
  text-align: left;
  padding: .45rem .55rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
th {
  font-size: .7rem;
  font-weight: 650;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surface-2);
  border-bottom-color: var(--line-strong);
}
thead th { position: sticky; top: 0; z-index: 1; }
/* Zero specificity so page row states (selected, found, past…) always win. */
:where(tbody tr:hover) { background: var(--row-hover); }
td.num, th.num, .num { text-align: right; font-variant-numeric: tabular-nums; }
td.num { white-space: nowrap; }

/* ── pills ──────────────────────────────────────────────────────────────── */
.badge, .chip {
  display: inline-block;
  padding: .06rem .45rem;
  border-radius: 999px;
  font-size: .7rem;
  font-weight: 600;
  line-height: 1.5;
  border: 1px solid var(--line-strong);
}
.chip { margin: 0 .25rem .15rem 0; }
.chip.warn, .chip.flag { color: var(--warn); border-color: currentColor; }
.chip.err { color: var(--danger); border-color: currentColor; }

/* ── dialogs ────────────────────────────────────────────────────────────── */
dialog {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.1rem;
  max-width: 900px;
  width: calc(100% - 2rem);
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .28);
}
dialog::backdrop { background: rgba(0, 0, 0, .45); }
