:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --ink: #16181d;
  --muted: #6a6f7a;
  --line: #e2e0d8;
  --accent: #b3261e;
  --accent-ink: #ffffff;
  --gold: #a87a12;
  --ok: #1d7a46;
  --err: #b3261e;
  --shadow: 0 1px 2px rgb(0 0 0 / .05), 0 6px 24px rgb(0 0 0 / .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1114;
    --surface: #181b20;
    --ink: #eceae4;
    --muted: #9298a3;
    --line: #2a2e35;
    --accent: #e0574e;
    --gold: #d9a93a;
    --ok: #4cc584;
    --err: #ff7a70;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 6px 24px rgb(0 0 0 / .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: inherit; }
img { max-width: 100%; display: block; }
h1 { font-size: 1.75rem; line-height: 1.2; margin: 0 0 .5rem; letter-spacing: -.01em; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; }
.empty { color: var(--muted); padding: 2rem 0; }

/* header */
.top { background: #000; color: #f4f2ee; border-bottom: 3px solid #d71920; }
.top-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; height: 64px; }
.brand { text-decoration: none; font-weight: 650; display: flex; align-items: center; gap: .6rem; white-space: nowrap; }
.crest { width: 48px; height: 48px; }
nav { display: flex; align-items: center; gap: 1rem; font-size: .95rem; }
.top nav a, .top button.link { text-decoration: none; color: #b9bcc3; }
.top nav a:hover, .top button.link:hover { color: #fff; }
.inline { display: inline; margin: 0; }
button.link { background: none; border: 0; color: var(--muted); font: inherit; cursor: pointer; padding: 0; }
.foot { color: var(--muted); font-size: .85rem; padding-top: 3rem; padding-bottom: 2rem; }

/* search */
.hero { padding: 3.5rem 0 2rem; max-width: 680px; }
.hero h1 { font-size: 2.4rem; }
.search { display: flex; gap: .5rem; margin: 1.25rem 0; max-width: 680px; }
.search input { flex: 1; min-width: 0; font-size: 1.1rem; padding: .8rem 1rem; }
.search button, .btn {
  background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 8px;
  padding: .7rem 1.2rem; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-block;
}
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: transparent; color: var(--err); border: 1px solid currentColor; margin-left: auto; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: .55rem .7rem; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input[type=checkbox] { width: auto; transform: scale(1.3); margin: .6rem 0; }

.section-h { font-size: .8rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 2rem 0 .8rem; font-weight: 650; }

/* tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: .75rem; }
.tile {
  display: grid; grid-template-columns: 56px 1fr auto; gap: .9rem; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: .7rem .9rem;
  text-decoration: none; box-shadow: var(--shadow);
}
.tile:hover { border-color: var(--accent); }
.thumb { width: 56px; aspect-ratio: 5/7; background: var(--line); border-radius: 4px; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.tile-name { font-weight: 600; }
.tile-body { min-width: 0; }
.tile-body > div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-grade { font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; }

/* card page */
.card-page { display: grid; grid-template-columns: minmax(0, 380px) 1fr; gap: 2.5rem; padding-top: 2rem; }
.card-image img { border-radius: 10px; box-shadow: var(--shadow); width: 100%; }
.noimg { aspect-ratio: 5/7; display: grid; place-items: center; background: var(--surface); border: 1px dashed var(--line); border-radius: 10px; color: var(--muted); }
/* slab label: red marble wrapper, ECG wordmark, white insert (stays light in dark mode, like the printed label) */
.label { background: #d71920 url(/static/brand/marble.jpg) center / cover; border-radius: 8px; padding: .5rem .75rem .75rem; box-shadow: var(--shadow); }
.label-mark { height: 34px; width: auto; margin: 0 auto .5rem; }
.label-body { --muted: #5f646e; --line: #e2e0d8; background: #fff; color: #16181d; border-radius: 3px; padding: .9rem 1.1rem; }
.label-top { display: flex; justify-content: space-between; gap: 1rem; }
.label-name { font-weight: 750; font-size: 1.15rem; text-transform: uppercase; letter-spacing: .02em; }
.label-sub { color: var(--muted); }
.label-grade { text-align: right; }
.label-grade .big { font-size: 3.4rem; line-height: 1; font-weight: 850; color: #c8161d; font-variant-numeric: tabular-nums; }
.label-grade .word { font-size: .75rem; font-weight: 700; letter-spacing: .12em; color: #a87a12; }
.label-cert { border-top: 1px solid var(--line); margin-top: .8rem; padding-top: .5rem; font-family: ui-monospace, monospace; font-size: .85rem; letter-spacing: .05em; }
.subgrades { display: grid; gap: .55rem; }
.sg { display: grid; grid-template-columns: 90px 1fr 36px; align-items: center; gap: .75rem; }
.sg b { text-align: right; font-variant-numeric: tabular-nums; }
.bar { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); }
.details { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1.5rem; margin: 0; }
.details dt { color: var(--muted); }
.details dd { margin: 0; }

/* staff */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 1.5rem; box-shadow: var(--shadow); }
.narrow { max-width: 400px; margin: 3rem auto; display: grid; gap: 1rem; }
.narrow label { display: grid; gap: .3rem; font-size: .9rem; }
.bar-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1.5rem 0 1rem; flex-wrap: wrap; }
.bar-row h1 { margin: 0; }
.filters { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.filters input { flex: 1; min-width: 200px; }
.filters select { width: auto; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.grid { border-collapse: collapse; width: 100%; font-size: .92rem; }
.grid th { text-align: left; font-weight: 600; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }
.grid th, .grid td { padding: .55rem .8rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.grid tbody tr:last-child td { border-bottom: 0; }
.grid .num { text-align: right; }
.mini { width: 40px; }
.mini img { width: 28px; aspect-ratio: 5/7; object-fit: cover; border-radius: 2px; }
.entry-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem 1.2rem; }
.f { display: flex; flex-direction: column; gap: .3rem; font-size: .88rem; }
.f > span { color: var(--muted); font-weight: 550; }
.f-textarea, .f-image { grid-column: 1 / -1; }
.f em { color: var(--err); font-style: normal; font-size: .8rem; }
.has-err input, .has-err select { border-color: var(--err); }
.preview { max-width: 140px; border-radius: 6px; }
.actions { display: flex; gap: .6rem; margin-top: 1.5rem; flex-wrap: wrap; }
.ok { color: var(--ok); font-weight: 600; }
.err { color: var(--err); font-weight: 600; }

@media (max-width: 720px) {
  .card-page { grid-template-columns: 1fr; gap: 1.5rem; }
  .card-image { max-width: 320px; }
  .hero { padding-top: 2rem; }
  .hero h1 { font-size: 1.8rem; }
  .tiles { grid-template-columns: 1fr; }
  .brand span { display: none; }
}
@media (max-width: 380px) {
  .brand { font-size: .9rem; }
}
