/* ============================================================================
   Cairn — "the property ledger"

   The look is drawn from the subject rather than a UI kit: property manifests,
   evidence logs, card catalogues, luggage tags. That means ruled registers
   instead of floating cards, near-square corners like a filing card, stamped
   small-caps labels, and item codes set in a real monospace because the code
   *is* the record's identity.

   Type does the heavy lifting:
     Archivo     — display. A grotesque with signage and wayfinding roots.
     Public Sans — body and UI. Built by the US government for dense records
                   interfaces, which is precisely what this is.
     DM Mono     — codes, counts, anything that should line up in a column.

   Colour stays strictly black / paper / Long Beach gold. Gold behaves like a
   marker pen: it highlights the live thing and fills the data. It is never a
   decorative rail on a rounded card, and it never carries text.
   ========================================================================= */

:root {
  /* Paper, faintly warm, well clear of the usual cream. */
  --background: 40 14% 97%;
  --foreground: 30 6% 9%;

  --card: 0 0% 100%;
  --card-foreground: 30 6% 9%;

  --popover: 0 0% 100%;
  --popover-foreground: 30 6% 9%;

  --primary: 43 100% 50%;
  --primary-foreground: 30 8% 8%;

  --secondary: 40 10% 93%;
  --secondary-foreground: 30 6% 14%;

  --muted: 40 10% 93%;
  --muted-foreground: 35 5% 40%;

  --accent: 43 90% 92%;
  --accent-foreground: 30 6% 12%;

  --destructive: 4 68% 42%;
  --destructive-foreground: 0 0% 100%;

  --success: 150 55% 27%;
  --success-foreground: 0 0% 100%;

  --border: 38 12% 86%;
  --rule: 36 10% 78%;           /* the darker hairline used for ledger rules */
  --input: 38 12% 80%;
  --ring: 43 100% 42%;

  /* Filing-card square, not app-store round. */
  --radius: 3px;

  --shadow-sm: 0 1px 0 0 hsl(36 10% 84%);
  --shadow: 0 1px 2px hsl(30 10% 20% / .07);
  --shadow-md: 0 2px 6px hsl(30 10% 20% / .09);
  --shadow-lg: 0 12px 34px hsl(30 10% 15% / .17);

  /* The fallbacks are metric-matched below, so the page does not jump when the
     webfonts arrive. Before that, "Public Sans" swapping to Arial moved every
     line of every table a few pixels -- small, constant, and the exact kind of
     thing that reads as unfinished without anyone being able to say why. */
  --font-display: "Archivo", "Archivo Fallback", "Helvetica Neue", Arial, sans-serif;
  --font-body: "Public Sans", "Public Sans Fallback", -apple-system, "Segoe UI", system-ui, sans-serif;
  --font-mono: "DM Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

  /* ── type scale ──────────────────────────────────────────────────────
     A scale rather than a pile of one-off pixel values. Every size in the
     app comes from here, which is what stops a heading on one screen being
     27px and 26px on the next. */
  --t-display: 27px;    /* h1 */
  --t-section: 17px;    /* h2 */
  --t-body:    14px;
  --t-small:   12.5px;
  --t-tiny:    11.5px;
  --t-stamp:   10.5px;  /* the small-caps ledger labels */

  /* ── motion ──────────────────────────────────────────────────────────
     One curve and three durations, so everything decelerates the same way.
     `--ease` is a soft overshoot-free ease-out; things arrive, they do not
     bounce. A register does not bounce. */
  --ease: cubic-bezier(.2, .85, .3, 1);
  --fast: .16s;
  --mid:  .28s;
  --slow: .44s;
}

/* Metric-matched fallbacks. The adjustments make Arial occupy very nearly the
   same space as the real face, so the swap is a change of shape rather than a
   reflow. Measured against each family's own metrics. */
@font-face {
  font-family: "Public Sans Fallback";
  src: local("Arial"), local("Helvetica"), local("Liberation Sans");
  size-adjust: 100.5%; ascent-override: 92%; descent-override: 24%; line-gap-override: 0%;
}
@font-face {
  font-family: "Archivo Fallback";
  src: local("Arial"), local("Helvetica"), local("Liberation Sans");
  size-adjust: 101%; ascent-override: 94%; descent-override: 24%; line-gap-override: 0%;
}

.dark {
  /* Carbon paper rather than pure black: it stops the gold glaring. */
  --background: 36 8% 7%;
  --foreground: 40 10% 94%;

  --card: 36 7% 10%;
  --card-foreground: 40 10% 94%;

  --popover: 36 7% 11%;
  --popover-foreground: 40 10% 94%;

  --primary: 43 96% 57%;
  --primary-foreground: 30 10% 7%;

  --secondary: 36 6% 16%;
  --secondary-foreground: 40 10% 94%;

  --muted: 36 6% 15%;
  --muted-foreground: 38 6% 60%;

  --accent: 43 30% 16%;
  --accent-foreground: 43 90% 72%;

  --destructive: 4 62% 56%;
  --destructive-foreground: 0 0% 100%;

  --success: 150 45% 55%;
  --success-foreground: 30 10% 7%;

  --border: 36 6% 19%;
  --rule: 36 6% 26%;
  --input: 36 6% 24%;
  --ring: 43 96% 57%;

  --shadow-sm: 0 1px 0 0 hsl(36 6% 16%);
  --shadow: 0 1px 2px hsl(0 0% 0% / .5);
  --shadow-md: 0 2px 8px hsl(0 0% 0% / .55);
  --shadow-lg: 0 14px 38px hsl(0 0% 0% / .62);
}

* { box-sizing: border-box; border-color: hsl(var(--border)); }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: var(--font-body);
  font-size: var(--t-body);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  font-optical-sizing: auto;
  /* Both faces have proper old-style/lining sets; lining suits a ledger. */
  font-variant-numeric: lining-nums;
}

h1, h2, h3, h4 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -.021em;
  text-wrap: balance;
}
/* Larger type needs tighter tracking to look evenly set; smaller type needs
   looser. One rule each rather than eyeballing it per heading. */
h1 { font-size: var(--t-display); letter-spacing: -.028em; }
h2 { font-size: var(--t-section); letter-spacing: -.018em; }

/* Explanatory paragraphs read better with a shorter measure and pretty
   wrapping -- no orphaned last word hanging under a full line. */
p { text-wrap: pretty; }
a { color: inherit; }
code, .mono, .tnum { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid hsl(var(--ring)); outline-offset: 2px; }
[hidden] { display: none !important; }
::selection { background: hsl(var(--primary) / .4); }

/**
 * Stamped label. Small caps, tracked out — the way a field is titled on a
 * printed manifest. Shared by section headings, statistic captions, table
 * headers and buttons, which is what gives the whole thing one voice.
 */
.stamp, .stat .k, table.dg thead th, .modal header h2 {
  font-family: var(--font-body);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .13em;
  text-transform: uppercase;
}

/* ── logo ───────────────────────────────────────────────────────────── */
.logo { display: block; }
.logo .lf-text   { fill: hsl(var(--foreground)); }
.logo .lf-sub    { fill: hsl(var(--muted-foreground)); }
.logo .lf-gold   { fill: hsl(var(--primary)); }
.logo .lf-stroke { stroke: hsl(var(--foreground) / .78); }

/* ── chrome ─────────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: hsl(var(--background));
  border-bottom: 2px solid hsl(var(--foreground));
  display: flex; align-items: stretch; gap: 0; padding: 0 18px; flex-wrap: wrap;
}
.topbar .brand {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 20px 11px 0; margin-right: 4px;
  border-right: 1px solid hsl(var(--rule));
}
.nav { display: flex; gap: 0; flex-wrap: wrap; }
.nav a {
  position: relative; display: flex; align-items: center; isolation: isolate;
  padding: 0 14px; text-decoration: none; border-radius: 0;
  font-family: var(--font-body); font-size: 13px; font-weight: 600;
  letter-spacing: .01em; color: hsl(var(--muted-foreground));
}
.nav a:hover { color: hsl(var(--foreground)); background: hsl(var(--muted)); }
/* The live tab is marked with a highlighter swipe, not a filled pill. */
.nav a.on { color: hsl(var(--foreground)); background: transparent; }
.nav a.on::after {
  content: ""; position: absolute; left: 8px; right: 8px; bottom: 8px; height: 9px;
  background: hsl(var(--primary) / .6); z-index: -1;
}
.spacer { flex: 1 1 auto; }
.who {
  display: flex; align-items: center; gap: 12px;
  font-size: 11.5px; color: hsl(var(--muted-foreground));
  padding: 10px 0 10px 18px; border-left: 1px solid hsl(var(--rule));
}
.who b { color: hsl(var(--foreground)); font-weight: 700; }

main { max-width: 1360px; margin: 0 auto; padding: 30px 22px 96px; }
main.wide { max-width: none; }

.head { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.head h1 { font-size: var(--t-display); font-weight: 650; letter-spacing: -.028em; }
.head h2 { font-size: var(--t-section); font-weight: 650; letter-spacing: -.018em; }
.head p {
  margin: 4px 0 0; font-size: var(--t-small); line-height: 1.5;
  color: hsl(var(--muted-foreground)); max-width: 66ch;
}

/* ── theme switch ───────────────────────────────────────────────────── */
.seg {
  display: inline-flex; padding: 0; gap: 0;
  border: 1px solid hsl(var(--rule)); border-radius: var(--radius); overflow: hidden;
}
.seg button {
  display: grid; place-items: center; width: 28px; height: 23px; padding: 0;
  border: 0; border-right: 1px solid hsl(var(--rule)); background: transparent;
  color: hsl(var(--muted-foreground)); cursor: pointer; border-radius: 0;
}
.seg button:last-child { border-right: 0; }
.seg button:hover { color: hsl(var(--foreground)); background: hsl(var(--muted)); }
.seg button[aria-pressed="true"] {
  background: hsl(var(--primary)); color: hsl(var(--primary-foreground));
}

/* ── surfaces ───────────────────────────────────────────────────────── */
.card {
  background: hsl(var(--card)); color: hsl(var(--card-foreground));
  border: 1px solid hsl(var(--border)); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 20px;
}
.card.flush { padding: 0; }

/* ── forms ──────────────────────────────────────────────────────────── */
.grid { display: grid; gap: 15px; }
.grid.two   { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* Choice of entry style: deliberately reads as a small view switch rather
   than two competing calls to action. */
.entry-switch { margin: 0 0 18px; }
.entry-switch button { width: auto; padding: 7px 12px; font-size: 10.5px; }
.entry-switch button[aria-pressed="true"] { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.entry-grid-note { display: flex; align-items: baseline; gap: 10px; margin: 0 0 10px; color: hsl(var(--muted-foreground)); font-size: var(--t-small); }
.entry-grid-note .stamp { color: hsl(var(--foreground)); white-space: nowrap; }

label {
  display: block; font-size: 10.5px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: hsl(var(--muted-foreground)); margin-bottom: 6px;
}
label .opt { font-weight: 500; letter-spacing: .04em; text-transform: none; }

input, select, textarea {
  width: 100%; font-family: var(--font-body); font-size: 13.5px;
  color: hsl(var(--foreground)); background: hsl(var(--card));
  border: 1px solid hsl(var(--input)); border-radius: var(--radius);
  padding: 9px 11px; outline: none; transition: border-color .1s, box-shadow .1s;
}
input::placeholder, textarea::placeholder { color: hsl(var(--muted-foreground) / .75); }
/* Focus reads as an underlined field on a form, not a glowing ring. */
input:focus, select:focus, textarea:focus {
  border-color: hsl(var(--foreground)); box-shadow: inset 0 -2px 0 hsl(var(--primary));
}
textarea { resize: vertical; min-height: 74px; }
select {
  appearance: none; padding-right: 30px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 15px) 53%, calc(100% - 10px) 53%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}

button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-family: var(--font-body); font-size: 12px; font-weight: 700;
  letter-spacing: .07em; text-transform: uppercase; white-space: nowrap;
  border: 1px solid hsl(var(--foreground) / .82); background: transparent;
  color: hsl(var(--foreground)); border-radius: var(--radius);
  padding: 9px 15px; cursor: pointer; text-decoration: none;
  transition: background .1s, color .1s, border-color .1s;
}
button:hover, .btn:hover { background: hsl(var(--foreground)); color: hsl(var(--background)); }
button.primary, .btn.primary {
  background: hsl(var(--primary)); border-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}
button.primary:hover, .btn.primary:hover {
  background: hsl(var(--foreground)); border-color: hsl(var(--foreground));
  color: hsl(var(--background));
}
button.ghost { border-color: transparent; }
button.ghost:hover { background: hsl(var(--muted)); color: hsl(var(--foreground)); }
button.destructive { color: hsl(var(--destructive)); border-color: hsl(var(--destructive) / .6); }
button.destructive:hover { background: hsl(var(--destructive)); color: #fff; }
button.sm, .btn.sm { padding: 6px 10px; font-size: 10.5px; letter-spacing: .08em; }
button:disabled { opacity: .45; cursor: not-allowed; }
button:active, .btn:active { transform: translateY(1px); }

/* ── badges ─────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; font-family: var(--font-body);
  font-size: 10px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 2px; white-space: nowrap; line-height: 1.6;
  background: transparent; color: hsl(var(--muted-foreground));
  border: 1px solid hsl(var(--rule));
}
.badge.gold    { border-color: hsl(var(--primary)); background: hsl(var(--primary) / .3);
                 color: hsl(var(--foreground)); }
.badge.success { border-color: hsl(var(--success) / .5); color: hsl(var(--success)); }
.badge.danger  { border-color: hsl(var(--destructive) / .5); color: hsl(var(--destructive)); }
.badge.outline { border-style: dashed; }
.tag {
  display: inline-block; font-family: var(--font-body); font-size: 11px;
  font-weight: 600; line-height: 1.6; padding: 1px 7px; border-radius: 2px;
  white-space: nowrap; background: hsl(var(--muted)); color: hsl(var(--foreground));
  border: 1px solid hsl(var(--rule));
}

/* ── the tally row ──────────────────────────────────────────────────── */
/* Caption above, figure below, hairline between — a tally sheet rather than a
   row of cards. No accent rail: that pattern is the tell of a generated
   layout, and it is doing no work here. */
.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 0; border-top: 2px solid hsl(var(--foreground));
  border-bottom: 1px solid hsl(var(--rule)); background: transparent;
}
.stat {
  display: flex; flex-direction: column;
  padding: 13px 18px 15px; border-right: 1px solid hsl(var(--rule));
  background: transparent; border-radius: 0; box-shadow: none; position: static;
}
.stat:last-child { border-right: 0; }
.stat .k { color: hsl(var(--muted-foreground)); margin: 0 0 5px; display: block; order: -1; }
.stat .n {
  font-family: var(--font-display); font-size: 29px; font-weight: 600;
  letter-spacing: -.035em; line-height: 1; font-variant-numeric: tabular-nums;
}

/* ── bars ───────────────────────────────────────────────────────────── */
.bars { display: grid; gap: 0; }
.bar {
  display: grid; grid-template-columns: 168px 1fr 56px; gap: 14px;
  align-items: center; font-size: 12.5px;
  padding: 5px 0; border-bottom: 1px solid hsl(var(--border));
}
.bar:last-child { border-bottom: 0; }
.bar .lbl {
  display: flex; align-items: center; gap: 8px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; color: hsl(var(--foreground));
}
.bar .swatch { width: 9px; height: 9px; border-radius: 1px; flex: 0 0 auto;
               border: 1px solid hsl(var(--rule)); }
.bar .track { display: block; background: transparent; height: 15px; overflow: hidden; }
.bar .fill {
  /* display:block is load-bearing: width does not apply to an inline box. */
  display: block; height: 100%; min-width: 3px; background: hsl(var(--primary));
  transition: width .34s cubic-bezier(.2,.8,.3,1);
}
.bar .v {
  text-align: right; font-family: var(--font-mono); font-size: 12px;
  font-variant-numeric: tabular-nums; color: hsl(var(--muted-foreground));
}

/* ── the register (data grid) ───────────────────────────────────────── */
.gridwrap {
  border-top: 2px solid hsl(var(--foreground));
  border-bottom: 1px solid hsl(var(--rule));
  background: transparent; overflow: auto; max-height: 76vh; position: relative;
}
table.dg { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; }
table.dg th, table.dg td {
  border-bottom: 1px solid hsl(var(--border));
  padding: 0; text-align: left; vertical-align: middle;
}
table.dg thead th {
  position: sticky; top: 0; z-index: 3;
  background: hsl(var(--background)); color: hsl(var(--muted-foreground));
  border-bottom: 1px solid hsl(var(--rule)); white-space: nowrap;
}
table.dg thead tr.filters th { top: 31px; z-index: 2; }
.dg .hcell {
  display: flex; align-items: center; gap: 6px; padding: 8px 12px;
  cursor: pointer; user-select: none;
}
.dg .hcell:hover { color: hsl(var(--foreground)); }
.dg .sort { opacity: .3; font-size: 9px; }
.dg .hcell[data-dir] { color: hsl(var(--foreground)); }
.dg .hcell[data-dir] .sort { opacity: 1; }
.dg .filter input, .dg .filter select {
  border: 0; border-radius: 0; background: transparent; padding: 6px 11px;
  font-size: 12px; font-weight: 500; text-transform: none; letter-spacing: 0;
}
.dg .filter input:focus, .dg .filter select:focus {
  box-shadow: inset 0 -2px 0 hsl(var(--primary)); background: hsl(var(--muted) / .5);
}
table.dg tbody td { padding: 8px 12px; }
/* Faint banding, the way ruled ledger paper alternates. */
table.dg tbody tr:nth-child(even) td { background: hsl(var(--muted) / .38); }
table.dg tbody tr:hover td { background: hsl(var(--primary) / .16); }
table.dg tbody tr.sel td { background: hsl(var(--primary) / .26); }
table.dg td.num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
/* The item code identifies the record, so it gets a real face. */
table.dg td.code {
  font-family: var(--font-mono); font-size: 12px; font-weight: 500;
  letter-spacing: .02em; color: hsl(var(--foreground)); white-space: nowrap;
}
/* The item code is the one thing on the intake form that has to match a
   physical label, so it is typeset like the tag itself rather than like a
   field among fields. */
.codetag {
  border: 1px solid hsl(var(--rule)); border-radius: 3px;
  background: hsl(var(--muted) / .5); padding: 12px 14px;
}
.codetag label { margin-bottom: 4px; }
input.codefield {
  font-family: var(--font-mono); font-size: 22px; font-weight: 600;
  letter-spacing: .02em; padding: 6px 10px; max-width: 220px;
  background: hsl(var(--background));
}
.codetag p { margin: 8px 0 0; }

/* Signature thumbnails are captured on a paper-white pad in both themes, so
   they carry their own ground and only need a rule around them. */
.sigcell { display: block; line-height: 0; }
.sigcell img {
  height: 26px; width: auto; max-width: 100%; background: #fff;
  border: 1px solid hsl(var(--rule)); border-radius: 2px; padding: 1px;
}
.sigcell:hover img { border-color: hsl(var(--primary)); }
table.dg td.trunc { max-width: 640px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

table.dg td.edit { padding: 0; }
table.dg td.edit input, table.dg td.edit select {
  border: 0; border-radius: 0; background: transparent; padding: 8px 11px; font-size: 13px;
}
table.dg td.edit input:focus, table.dg td.edit select:focus {
  box-shadow: inset 0 0 0 2px hsl(var(--primary)); background: hsl(var(--card));
}
table.dg td.bad input { background: hsl(var(--destructive) / .14); }

.gridbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 11px 0; font-size: 12px; color: hsl(var(--muted-foreground));
}
.gridbar b { font-family: var(--font-mono); color: hsl(var(--foreground)); }

/* ── feedback ───────────────────────────────────────────────────────── */
/* Confirmations and errors.
   Previously set in tracked-out uppercase, which is fine for "SAVED." and
   close to unreadable for "Windows has no printer called 'Brother QL-1050'.
   It can see: …". The stamped label keeps the ledger voice; the message
   itself is left in a sentence case a person can actually read at a glance. */
.toast {
  position: fixed; bottom: 24px; left: 50%; z-index: 100;
  display: flex; align-items: flex-start; gap: 11px;
  transform: translateX(-50%) translateY(160%);
  background: hsl(var(--foreground)); color: hsl(var(--background));
  padding: 11px 17px; border-radius: var(--radius);
  font-size: var(--t-small); font-weight: 500; line-height: 1.45;
  text-align: left; box-shadow: var(--shadow-lg);
  transition: transform var(--mid) var(--ease), opacity var(--mid) var(--ease);
  opacity: 0; max-width: min(560px, 92vw);
}
.toast.on { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.bad { background: hsl(var(--destructive)); color: #fff; }
.toast .tlabel {
  flex: 0 0 auto; font-size: var(--t-stamp); font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase; padding-top: 1px;
  color: hsl(var(--primary));
}
.toast.bad .tlabel { color: #fff; opacity: .85; }
.toast .tmsg { flex: 1 1 auto; min-width: 0; }

.msg {
  padding: 11px 14px; border-radius: var(--radius); font-size: 13px; margin-bottom: 15px;
  border-left: 3px solid transparent;
}
.msg.bad  { background: hsl(var(--destructive) / .1); color: hsl(var(--destructive));
            border-left-color: hsl(var(--destructive)); }
.msg.good { background: hsl(var(--success) / .12); color: hsl(var(--success));
            border-left-color: hsl(var(--success)); }
.msg.gold { background: hsl(var(--primary) / .2); color: hsl(var(--foreground));
            border-left-color: hsl(var(--primary)); }

.empty {
  text-align: center; color: hsl(var(--muted-foreground)); padding: 46px 20px;
  font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
}
/* The richer version: an empty screen should say why it is empty and what to
   do about it, not just stamp NOTHING TO SHOW and leave you there. */
.emptybox {
  display: grid; justify-items: center; gap: 12px; text-align: center;
  padding: 46px 22px; color: hsl(var(--muted-foreground));
}
.emptybox h3 {
  font-family: var(--font-display); font-size: 16px; font-weight: 650;
  letter-spacing: -.015em; color: hsl(var(--foreground));
}
.emptybox p { margin: 0; max-width: 46ch; font-size: var(--t-small); line-height: 1.5; }
.emptybox .row { justify-content: center; }

/* "Load more" under a register. Deliberately full width and quiet — it is a
   continuation of the table, not a call to action. */
.loadmore {
  width: 100%; border: 1px solid hsl(var(--border)); border-top: 0;
  background: hsl(var(--muted) / .4); color: hsl(var(--muted-foreground));
  padding: 12px; border-radius: 0;
}
.loadmore:hover { background: hsl(var(--muted)); color: hsl(var(--foreground)); }
.muted { color: hsl(var(--muted-foreground)); }
.tiny  { font-size: var(--t-tiny); line-height: 1.5; }
kbd {
  font-family: var(--font-mono); font-size: 10.5px; padding: 2px 5px;
  border: 1px solid hsl(var(--rule)); border-bottom-width: 2px; border-radius: 2px;
  background: hsl(var(--card)); color: hsl(var(--muted-foreground));
}
details > summary {
  cursor: pointer; font-family: var(--font-body); font-size: 11px; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
}
details > summary::marker { color: hsl(var(--primary)); }

/* ── branding ───────────────────────────────────────────────────────── */
/* The logo's own gold underline with its triangular notch, reused as a rule. */
.brandrule {
  position: relative; height: 5px; margin: 32px 0 6px;
  background: hsl(var(--primary)); border-radius: 0;
}
.brandrule::after {
  content: ""; position: absolute; right: 24px; bottom: 100%;
  border-left: 12px solid transparent; border-right: 12px solid transparent;
  border-bottom: 14px solid hsl(var(--primary));
}
.brandrule:first-child { margin-top: 0; }
.brandmark { display: grid; place-items: center; gap: 12px; padding: 42px 20px;
             color: hsl(var(--muted-foreground)); }
.brandmark .logo { opacity: .3; }

.danger-hint { color: hsl(var(--muted-foreground)); border-color: transparent; }
.danger-hint:hover { color: #fff; background: hsl(var(--destructive)) !important; }

/* ── modal ──────────────────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0; z-index: 150; display: grid; place-items: center;
  background: hsl(30 10% 8% / .55); padding: 18px; animation: fadeIn .14s ease-out;
}
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
.modal .sheet {
  width: min(720px, 100%); max-height: 88vh; display: flex; flex-direction: column;
  background: hsl(var(--card)); border: 1px solid hsl(var(--foreground) / .5);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); overflow: hidden;
  animation: sheetPop .26s cubic-bezier(.2,.9,.3,1);
}
@keyframes sheetPop {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .modal, .modal .sheet { animation: none; }
  button:active, .btn:active { transform: none; }
  .bar .fill { transition: none; }
}
.modal header, .modal footer {
  display: flex; align-items: center; gap: 10px; padding: 14px 20px;
}
.modal header {
  border-bottom: 2px solid hsl(var(--foreground));
  background: hsl(var(--primary) / .22);
}
.modal header h2 { font-size: 11px; letter-spacing: .14em; }
.modal footer { border-top: 1px solid hsl(var(--rule)); background: hsl(var(--muted) / .5); }
.sheetbody { overflow: auto; padding: 22px; }

/* A printer setup guide needs to be easy to use while standing at the machine. */
.print-setup-sheet { width: min(780px, 100%); }
.setup-lead { margin: 0 0 17px; max-width: 68ch; color: hsl(var(--muted-foreground)); }
.setup-steps { display: grid; gap: 12px; margin: 0; padding-left: 25px; }
.setup-steps li { padding-left: 4px; font-size: var(--t-small); line-height: 1.55; }
.setup-steps b { display: block; color: hsl(var(--foreground)); }
.setup-steps code { display: inline-block; margin-top: 4px; padding: 2px 5px; background: hsl(var(--muted)); border: 1px solid hsl(var(--rule)); border-radius: 2px; font-size: 10.5px; overflow-wrap: anywhere; }
.setup-steps em { font-style: normal; font-weight: 700; }
.print-setup-sheet .msg { margin: 18px 0 0; font-size: var(--t-small); }

/* ── sign-in ────────────────────────────────────────────────────────── */
.authwrap { position: relative; }
.authwrap::before {
  content: ""; position: absolute; left: 50%; top: -110px; width: 440px; height: 440px;
  transform: translateX(-50%); pointer-events: none;
  background: radial-gradient(circle, hsl(var(--primary) / .18), transparent 66%);
}
.authwrap > * { position: relative; }

/* ── new-report signal ──────────────────────────────────────────────── */
.navbadge {
  display: inline-block; margin-left: 7px; min-width: 17px; padding: 0 5px;
  border-radius: 2px; background: hsl(var(--primary)); color: hsl(var(--primary-foreground));
  font-family: var(--font-mono); font-size: 10px; font-weight: 500;
  line-height: 17px; text-align: center;
}
.alertcard {
  display: flex; align-items: center; gap: 14px; margin-bottom: 20px;
  background: hsl(var(--primary) / .18);
  border-top: 2px solid hsl(var(--foreground));
  border-bottom: 1px solid hsl(var(--rule));
  padding: 14px 16px;
}
.alertdot {
  width: 8px; height: 8px; background: hsl(var(--primary)); flex: 0 0 auto;
  box-shadow: 0 0 0 4px hsl(var(--primary) / .3); animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse { 50% { box-shadow: 0 0 0 8px hsl(var(--primary) / .08); } }
@media (prefers-reduced-motion: reduce) { .alertdot { animation: none; } }
.newdot {
  display: inline-block; width: 6px; height: 6px; background: hsl(var(--primary));
  margin-right: 8px; vertical-align: middle;
}

.appfoot {
  display: flex; align-items: center; gap: 12px; max-width: 1360px;
  margin: 0 auto; padding: 18px 22px 34px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .13em; text-transform: uppercase;
  color: hsl(var(--muted-foreground)); border-top: 1px solid hsl(var(--rule));
}
.appfoot .logo { opacity: .55; }

@media (max-width: 760px) {
  main { padding: 18px 13px 72px; }
  .bar { grid-template-columns: 104px 1fr 44px; }
  .topbar { padding: 0 11px; }
  .topbar .brand { border-right: 0; padding-right: 10px; }
  .nav a { padding: 10px 10px; }
  .stats { grid-template-columns: repeat(auto-fit, minmax(112px, 1fr)); }
}

/* ============================================================================
   GUIDANCE — tooltips, skeletons, the tour, the getting-started checklist

   Everything here exists to answer a question a new person would otherwise
   have to ask someone. Student assistants turn over every semester, so the
   interface has to teach itself; "ask Dave" is not a feature.
   ========================================================================= */

/* ── tooltips ───────────────────────────────────────────────────────── */
/* One floating element reused for every tip, positioned in JS. A tooltip per
   trigger would mean hundreds of absolutely-positioned nodes in a 100-row
   grid, and they would each need clipping out of the scroll container. */
#tip {
  position: fixed; z-index: 400; max-width: 280px; pointer-events: none;
  background: hsl(var(--foreground)); color: hsl(var(--background));
  font-family: var(--font-body); font-size: var(--t-tiny); font-weight: 500;
  line-height: 1.45; letter-spacing: 0; text-transform: none; text-align: left;
  padding: 7px 10px; border-radius: var(--radius); box-shadow: var(--shadow-md);
  opacity: 0; transform: translateY(3px);
  transition: opacity var(--fast) var(--ease), transform var(--fast) var(--ease);
}
#tip.on { opacity: 1; transform: none; }
#tip kbd {
  background: hsl(var(--background) / .18); color: inherit;
  border-color: hsl(var(--background) / .3);
}
#tip b { color: hsl(var(--primary)); font-weight: 700; }

/* ── skeletons ──────────────────────────────────────────────────────── */
/* A shape where the content will be, rather than the word "Loading…". The
   difference is whether the screen looks broken for 400ms or merely busy. */
.sk { display: block; background: hsl(var(--muted)); border-radius: 2px; position: relative;
      overflow: hidden; }
.sk::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, hsl(var(--foreground) / .06), transparent);
  transform: translateX(-100%);
  animation: shimmer 1.25s ease-in-out infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }
.sk-head { display: grid; gap: 9px; margin-bottom: 22px; }
.sk-rows { border-top: 2px solid hsl(var(--foreground)); }
.sk-rows .sk-row {
  display: grid; grid-template-columns: 108px 1fr 128px 92px; gap: 18px;
  align-items: center; padding: 11px 12px; border-bottom: 1px solid hsl(var(--border));
}
.sk-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
            border-top: 2px solid hsl(var(--foreground));
            border-bottom: 1px solid hsl(var(--rule)); }
.sk-tiles > div { padding: 13px 18px 15px; border-right: 1px solid hsl(var(--rule)); }
.sk-tiles > div:last-child { border-right: 0; }

/* Skeletons must not outlive their purpose. If the fetch is quick the shimmer
   never gets a chance to look like a stuck page, so it fades in rather than
   appearing instantly. */
.skwrap { animation: skIn .18s var(--ease) both; animation-delay: .12s; }
@keyframes skIn { from { opacity: 0 } to { opacity: 1 } }

/* ── the getting-started checklist ──────────────────────────────────── */
.checklist { border-top: 2px solid hsl(var(--foreground)); margin-bottom: 24px; }
.checklist .ck {
  display: flex; align-items: flex-start; gap: 14px; padding: 13px 4px;
  border-bottom: 1px solid hsl(var(--border));
}
.checklist .ck:last-child { border-bottom: 1px solid hsl(var(--rule)); }
.checklist .box {
  flex: 0 0 auto; width: 17px; height: 17px; margin-top: 2px;
  border: 1.5px solid hsl(var(--rule)); border-radius: 2px;
  display: grid; place-items: center; font-size: 11px; color: transparent;
}
.checklist .ck.done .box {
  background: hsl(var(--primary)); border-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}
.checklist .ck.done .what { color: hsl(var(--muted-foreground)); text-decoration: line-through;
                            text-decoration-color: hsl(var(--rule)); }
.checklist .body { flex: 1 1 auto; min-width: 0; }
.checklist .what { font-weight: 650; font-size: var(--t-small); }
.checklist .why { margin: 2px 0 0; font-size: var(--t-tiny); color: hsl(var(--muted-foreground)); }

/* A one-time, route-specific nudge. It is intentionally part of the page
   flow—not a toast—so there is time to read it without blocking the task. */
.context-hint {
  display: flex; align-items: flex-start; gap: 18px; margin: -4px 0 22px;
  padding: 13px 15px; border-left: 3px solid hsl(var(--primary));
  border-bottom: 1px solid hsl(var(--rule)); background: hsl(var(--primary) / .1);
  animation: hintIn var(--mid) var(--ease) both;
}
.context-hint > div { flex: 1 1 auto; min-width: 0; }
.context-hint .stamp { display: block; margin-bottom: 3px; color: hsl(var(--muted-foreground)); }
.context-hint strong { display: block; font-size: var(--t-small); font-weight: 700; }
.context-hint p { max-width: 76ch; margin: 2px 0 0; font-size: var(--t-small); line-height: 1.48; color: hsl(var(--muted-foreground)); }
.context-hint button { flex: 0 0 auto; margin-top: 3px; }
@keyframes hintIn { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: none; } }

/* ── the tour ───────────────────────────────────────────────────────── */
/* A hole cut in a dimming layer, rather than a modal that describes the thing
   it is covering up. The hole is drawn with a very large spread shadow so
   there is one element to position and nothing to keep in sync. */
#tourveil {
  position: fixed; inset: 0; z-index: 500; pointer-events: auto;
  animation: fadeIn var(--fast) ease-out;
}
#tourhole {
  position: fixed; border-radius: var(--radius); pointer-events: none;
  box-shadow: 0 0 0 9999px hsl(30 10% 8% / .62), 0 0 0 2px hsl(var(--primary));
  transition: top var(--mid) var(--ease), left var(--mid) var(--ease),
              width var(--mid) var(--ease), height var(--mid) var(--ease);
}
#tourstep {
  position: fixed; z-index: 501; width: min(360px, calc(100vw - 28px));
  background: hsl(var(--card)); color: hsl(var(--card-foreground));
  border: 1px solid hsl(var(--foreground) / .5); border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  transition: top var(--mid) var(--ease), left var(--mid) var(--ease);
}
#tourstep header {
  display: flex; align-items: center; gap: 10px; padding: 11px 16px;
  border-bottom: 2px solid hsl(var(--foreground)); background: hsl(var(--primary) / .22);
}
#tourstep header h2 {
  font-size: var(--t-stamp); letter-spacing: .14em; text-transform: uppercase;
  font-family: var(--font-body); font-weight: 700;
}
#tourstep .tourbody { padding: 15px 16px; font-size: var(--t-small); line-height: 1.55; }
#tourstep .tourbody p { margin: 0 0 9px; }
#tourstep .tourbody p:last-child { margin-bottom: 0; }
#tourstep footer {
  display: flex; align-items: center; gap: 9px; padding: 11px 16px;
  border-top: 1px solid hsl(var(--rule)); background: hsl(var(--muted) / .5);
}
#tourstep .dots { display: flex; gap: 5px; margin-right: auto; }
#tourstep .dots i {
  width: 6px; height: 6px; border-radius: 50%; background: hsl(var(--rule));
  transition: background var(--fast) var(--ease);
}
#tourstep .dots i.on { background: hsl(var(--primary)); }

/* The help control that restarts it. Never hide the way back in. */
.helpbtn {
  border: 1px solid hsl(var(--rule)); background: transparent; padding: 0;
  width: 23px; height: 23px; border-radius: var(--radius);
  font-family: var(--font-body); font-size: 12px; font-weight: 700;
  color: hsl(var(--muted-foreground)); letter-spacing: 0; text-transform: none;
}
.helpbtn:hover { background: hsl(var(--primary)); border-color: hsl(var(--primary));
                 color: hsl(var(--primary-foreground)); }

@media (prefers-reduced-motion: reduce) {
  .sk::after { animation: none; }
  .skwrap { animation: none; }
  .context-hint { animation: none; }
  #tourhole, #tourstep { transition: none; }
  #tip { transition: none; }
}

/* ============================================================================
   MOTION & CHARACTER

   Rules this layer follows, because this is a tool somebody uses forty times a
   shift and not a landing page:

     1. Animate on ARRIVAL, never on repetition. A view entering may flourish;
        a button clicked for the ninetieth time may not.
     2. Transform and opacity only. Nothing here causes a reflow.
     3. Nothing blocks input. Every animation is decorative; a row is clickable
        before it has finished settling.
     4. All of it collapses under prefers-reduced-motion.

   The vocabulary comes from the same place as the rest: rubber stamps, marker
   pens, a register being filled in by hand.
   ========================================================================= */

/* ── the marker pen ─────────────────────────────────────────────────── */
/* The gold swipe behind the live nav tab is drawn, not merely shown: a stroke
   pulled left to right, with the slightly uneven ends a real marker leaves. */
.nav a.on::after {
  transform-origin: left center;
  animation: swipe .34s cubic-bezier(.3,.9,.35,1) both;
  border-radius: 1px 3px 2px 1px;
}
@keyframes swipe {
  from { transform: scaleX(0) skewX(-12deg); opacity: .5; }
  to   { transform: scaleX(1) skewX(0);      opacity: 1; }
}
.nav a:not(.on)::after {
  content: ""; position: absolute; left: 8px; right: 8px; bottom: 8px; height: 9px;
  background: hsl(var(--primary) / .5); z-index: -1;
  transform: scaleX(0); transform-origin: left center;
  transition: transform .22s cubic-bezier(.3,.9,.35,1);
  border-radius: 1px 3px 2px 1px;
}
.nav a:not(.on):hover::after { transform: scaleX(1); }
.nav a:hover { background: transparent; }

/* ── the view settles in ────────────────────────────────────────────── */
/* The resting state is the FINISHED state and the animation only ever adds to
   it. `both` would leave opacity:0 painted during the delay, so a tab that
   never gets to run the animation -- restored from bfcache, or a browser that
   drops it -- would show a blank page. `backwards` alone has the same hazard,
   so the rule sets no starting opacity of its own: `rise` fades in from 0 and
   the element's own default is already 1. */
#view > * { animation: rise var(--slow) var(--ease) backwards; }
#view > *:nth-child(1) { animation-delay: 0ms; }
#view > *:nth-child(2) { animation-delay: 40ms; }
#view > *:nth-child(3) { animation-delay: 75ms; }
#view > *:nth-child(4) { animation-delay: 105ms; }
#view > *:nth-child(n+5) { animation-delay: 130ms; }
@keyframes rise {
  from { opacity: 0; transform: translateY(9px); }
  to   { opacity: 1; transform: none; }
}

/* ── the register fills in ──────────────────────────────────────────── */
/* Rows arrive in sequence, the way a ledger is written down a page. Capped at
   twelve: past that the stagger stops reading as intent and starts reading as
   lag. */
table.dg tbody tr { animation: rowin .3s cubic-bezier(.2,.85,.3,1) both; }
@keyframes rowin {
  from { opacity: 0; transform: translateY(-3px); }
  to   { opacity: 1; transform: none; }
}
table.dg tbody tr:nth-child(1)  { animation-delay: 0ms }
table.dg tbody tr:nth-child(2)  { animation-delay: 14ms }
table.dg tbody tr:nth-child(3)  { animation-delay: 28ms }
table.dg tbody tr:nth-child(4)  { animation-delay: 42ms }
table.dg tbody tr:nth-child(5)  { animation-delay: 56ms }
table.dg tbody tr:nth-child(6)  { animation-delay: 70ms }
table.dg tbody tr:nth-child(7)  { animation-delay: 84ms }
table.dg tbody tr:nth-child(8)  { animation-delay: 98ms }
table.dg tbody tr:nth-child(9)  { animation-delay: 112ms }
table.dg tbody tr:nth-child(10) { animation-delay: 126ms }
table.dg tbody tr:nth-child(11) { animation-delay: 140ms }
table.dg tbody tr:nth-child(12) { animation-delay: 154ms }
table.dg tbody tr:nth-child(n+13) { animation-delay: 168ms }

/* A gold marker slides down the gutter of the row under the cursor. */
table.dg tbody tr { position: relative; }
table.dg tbody tr td:first-child { position: relative; }
table.dg tbody tr td:first-child::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: hsl(var(--primary)); transform: scaleY(0); transform-origin: top;
  transition: transform .16s cubic-bezier(.3,.9,.35,1);
}
table.dg tbody tr:hover td:first-child::before { transform: scaleY(1); }
table.dg tbody tr.rowactivatable { cursor: pointer; }
table.dg tbody tr.rowactivatable:focus-visible { outline: 2px solid hsl(var(--ring)); outline-offset: -2px; }

/* A claim opens the actual inventory record in place, so the office never
   loses its place in the claims register while checking an item. */
.item-record-sheet { width: min(940px, 100%); }
.item-record-sheet header h2 { margin-top: 2px; }
.item-record-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(210px, 300px); gap: 22px; }
.item-record-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; border-top: 2px solid hsl(var(--foreground)); }
.record-field { min-width: 0; padding: 11px 12px; border-bottom: 1px solid hsl(var(--rule)); border-right: 1px solid hsl(var(--rule)); }
.record-field:nth-child(even) { border-right: 0; }
.record-field.wide { grid-column: 1 / -1; border-right: 0; }
.record-field span { display: block; margin-bottom: 3px; font-size: var(--t-stamp); font-weight: 700; letter-spacing: .11em; text-transform: uppercase; color: hsl(var(--muted-foreground)); }
.record-field strong { display: block; font-size: var(--t-small); font-weight: 600; overflow-wrap: anywhere; }
.item-record-photo { min-height: 200px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; padding: 10px; border: 1px solid hsl(var(--rule)); background: hsl(var(--muted) / .45); text-align: center; text-decoration: none; font-size: var(--t-small); font-weight: 700; }
.item-record-photo img { display: block; max-width: 100%; max-height: 310px; object-fit: contain; }
.item-record-photo small { font-weight: 500; color: hsl(var(--muted-foreground)); }
.item-record-photo.empty { color: hsl(var(--muted-foreground)); font-weight: 500; }
.item-record-history { margin-top: 25px; }
.item-record-history > .stamp { display: block; margin-bottom: 8px; }
.mini-register { border-top: 2px solid hsl(var(--foreground)); }
.mini-register > div { display: grid; grid-template-columns: 110px minmax(140px, 1fr) 110px 120px; align-items: center; gap: 10px; padding: 9px 10px; border-bottom: 1px solid hsl(var(--rule)); font-size: var(--t-small); }
@media (max-width: 650px) { .item-record-layout { grid-template-columns: 1fr; } .mini-register > div { grid-template-columns: 1fr 1fr; } }

/* ── the tally ticks over ───────────────────────────────────────────── */
.stat { position: relative; overflow: hidden; }
.stat .n { transition: color .2s; }
/* A hairline sweeps under the figure as the count lands. */
.stat::after {
  content: ""; position: absolute; left: 18px; right: 18px; bottom: 0; height: 2px;
  background: hsl(var(--primary)); transform: scaleX(0); transform-origin: left;
  transition: transform .4s cubic-bezier(.2,.85,.3,1);
}
.stat.counted::after { transform: scaleX(1); }
.stat:hover .n { color: hsl(var(--primary)); }

/* ── data draws itself ──────────────────────────────────────────────── */
.bar .fill { transform-origin: left center; transform: scaleX(1); }
.bars.drawn .fill { animation: draw .55s cubic-bezier(.2,.85,.25,1) backwards; }
@keyframes draw { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.bars.drawn .bar:nth-child(1)  .fill { animation-delay: 30ms }
.bars.drawn .bar:nth-child(2)  .fill { animation-delay: 60ms }
.bars.drawn .bar:nth-child(3)  .fill { animation-delay: 90ms }
.bars.drawn .bar:nth-child(4)  .fill { animation-delay: 120ms }
.bars.drawn .bar:nth-child(5)  .fill { animation-delay: 150ms }
.bars.drawn .bar:nth-child(6)  .fill { animation-delay: 180ms }
.bars.drawn .bar:nth-child(7)  .fill { animation-delay: 210ms }
.bars.drawn .bar:nth-child(8)  .fill { animation-delay: 240ms }
.bars.drawn .bar:nth-child(n+9) .fill { animation-delay: 270ms }
.bar { transition: background .14s; }
.bar:hover { background: hsl(var(--primary) / .09); }
.bar:hover .v { color: hsl(var(--foreground)); font-weight: 500; }

/* ── the returned stamp ─────────────────────────────────────────────── */
/* An item that has gone home is stamped, not badged: slight rotation, a
   doubled rule, letters pushed apart. The look of an inked hand stamp. */
.badge.success {
  transform: rotate(-1.6deg);
  border: 1.5px solid hsl(var(--success) / .55);
  box-shadow: 0 0 0 1.5px hsl(var(--background)), 0 0 0 2.5px hsl(var(--success) / .22);
  letter-spacing: .14em; padding: 2px 8px;
}
tr:hover .badge.success { animation: stamp .4s cubic-bezier(.2,1.4,.4,1); }
@keyframes stamp {
  0%   { transform: rotate(-1.6deg) scale(1); }
  35%  { transform: rotate(-4deg) scale(1.09); }
  100% { transform: rotate(-1.6deg) scale(1); }
}

/* ── the toast stamps down ──────────────────────────────────────────── */
.toast {
  transition: transform .26s cubic-bezier(.2,1.25,.35,1), opacity .18s;
  opacity: 0;
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0) rotate(-.5deg); }

/* ── item codes read as tags ────────────────────────────────────────── */
/* A punched eyelet on the left, the way a luggage tag is threaded. */
table.dg td.code { position: relative; padding-left: 22px; }
table.dg td.code::before {
  content: ""; position: absolute; left: 11px; top: 50%; width: 5px; height: 5px;
  margin-top: -2.5px; border-radius: 50%;
  border: 1px solid hsl(var(--muted-foreground) / .55);
  transition: border-color .16s, background .16s;
}
table.dg tbody tr:hover td.code::before {
  border-color: hsl(var(--primary)); background: hsl(var(--primary));
}

/* ── loading has a pulse ────────────────────────────────────────────── */
.empty { animation: breathe 2.4s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: .5 } }

/* ── the brand rule draws out ───────────────────────────────────────── */
.brandrule {
  transform-origin: left center;
  animation: rule .5s cubic-bezier(.2,.85,.25,1) both;
}
@keyframes rule { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* ── buttons acknowledge ────────────────────────────────────────────── */
button, .btn { position: relative; overflow: hidden; isolation: isolate; }
button.primary::after, .btn.primary::after {
  content: ""; position: absolute; inset: 0; background: hsl(var(--foreground));
  transform: scaleX(0); transform-origin: left; z-index: -1;
  transition: transform .2s cubic-bezier(.3,.9,.35,1);
}
button.primary:hover::after, .btn.primary:hover::after { transform: scaleX(1); }

/* ── scrollbars are part of the surface ─────────────────────────────── */
* { scrollbar-width: thin; scrollbar-color: hsl(var(--rule)) transparent; }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: hsl(var(--rule)); border: 3px solid hsl(var(--background));
  border-radius: 6px;
}
::-webkit-scrollbar-thumb:hover { background: hsl(var(--primary)); }
::-webkit-scrollbar-corner { background: transparent; }

.alertcard { animation: rise .38s cubic-bezier(.2,.85,.3,1) both; }

/* ── everything off, on request ─────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  #view > *, table.dg tbody tr, .bars.drawn .fill, .brandrule,
  .nav a.on::after, .alertcard, .empty, tr:hover .badge.success {
    animation: none !important;
  }
  table.dg tbody tr td:first-child::before,
  .nav a:not(.on)::after,
  button.primary::after, .btn.primary::after { transition: none; }
  .stat::after { transition: none; transform: scaleX(1); }
}

/* ── command palette ────────────────────────────────────────────────── */
/* shadcn's Command behaviour, wearing this project's clothes: a terminal
   prompt rather than a rounded search card. */
.cmdk {
  position: fixed; inset: 0; z-index: 300; display: grid;
  place-items: start center; padding: 12vh 18px 18px;
  background: hsl(30 10% 8% / .5); animation: fadeIn .12s ease-out;
}
.cmdk[hidden] { display: none; }
.cmdk-sheet {
  width: min(660px, 100%); display: flex; flex-direction: column;
  background: hsl(var(--card)); border: 2px solid hsl(var(--foreground));
  border-radius: var(--radius); box-shadow: var(--shadow-lg); overflow: hidden;
  animation: cmdkIn .22s cubic-bezier(.2,.95,.3,1);
}
@keyframes cmdkIn {
  from { opacity: 0; transform: translateY(-10px) scale(.985); }
  to   { opacity: 1; transform: none; }
}
.cmdk-input {
  display: flex; align-items: center; gap: 10px; padding: 0 14px;
  border-bottom: 1px solid hsl(var(--rule)); background: hsl(var(--primary) / .16);
}
.cmdk-prompt {
  font-family: var(--font-mono); font-size: 15px; font-weight: 500;
  color: hsl(var(--foreground)); opacity: .55;
}
.cmdk-input input {
  flex: 1; border: 0; background: transparent; padding: 15px 0;
  font-family: var(--font-body); font-size: 15px; border-radius: 0;
}
.cmdk-input input:focus { box-shadow: none; border: 0; }
.cmdk-list { overflow: auto; max-height: 52vh; padding: 6px 0; }
.cmdk-group {
  padding: 9px 15px 5px; font-size: 9.5px; font-weight: 700;
  letter-spacing: .15em; text-transform: uppercase;
  color: hsl(var(--muted-foreground));
}
.cmdk-row {
  display: flex; align-items: baseline; gap: 11px; width: 100%;
  padding: 9px 15px; border: 0; border-radius: 0; background: transparent;
  text-align: left; text-transform: none; letter-spacing: 0;
  font-family: var(--font-body); font-size: 13.5px; font-weight: 500;
  color: hsl(var(--foreground)); cursor: pointer; overflow: hidden;
}
.cmdk-row:hover { background: transparent; color: hsl(var(--foreground)); }
/* One highlight, driven by the keyboard, so hover never fights the caret. */
.cmdk-row.on { background: hsl(var(--primary) / .26); }
.cmdk-row.on::before {
  content: ""; position: absolute; left: 0; width: 3px; height: 22px;
  background: hsl(var(--primary));
}
.cmdk-row { position: relative; }
.cmdk-code {
  font-family: var(--font-mono); font-size: 12px; color: hsl(var(--muted-foreground));
  flex: 0 0 auto; min-width: 62px;
}
.cmdk-row.on .cmdk-code { color: hsl(var(--foreground)); }
.cmdk-main { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmdk-hint {
  font-size: 11.5px; color: hsl(var(--muted-foreground));
  flex: 0 0 auto; max-width: 42%; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.cmdk-empty {
  padding: 28px 15px; text-align: center; font-size: 10.5px; font-weight: 700;
  letter-spacing: .13em; text-transform: uppercase; color: hsl(var(--muted-foreground));
}
.cmdk-foot {
  display: flex; align-items: center; gap: 14px; padding: 8px 15px;
  border-top: 1px solid hsl(var(--rule)); background: hsl(var(--muted) / .5);
  font-size: 10.5px; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: hsl(var(--muted-foreground));
}
.cmdk-foot kbd { margin-right: 3px; }

/* The hint in the top bar that the palette exists at all. */
.cmdk-cue {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  border: 1px solid hsl(var(--rule)); border-radius: var(--radius);
  padding: 4px 9px; background: transparent;
  font-family: var(--font-body); font-size: 10.5px; font-weight: 600;
  letter-spacing: .07em; text-transform: uppercase;
  color: hsl(var(--muted-foreground));
}
.cmdk-cue:hover { border-color: hsl(var(--foreground)); color: hsl(var(--foreground));
                  background: transparent; }
.cmdk-cue kbd { font-size: 9.5px; padding: 1px 4px; }

@media (prefers-reduced-motion: reduce) {
  .cmdk, .cmdk-sheet { animation: none; }
}
@media (max-width: 640px) { .cmdk-hint { display: none; } }
