/* TagTrail MVP: brand tokens from the TagTrail design system. */
@font-face { font-family: "Archivo"; font-weight: 700; font-display: swap; src: url(/fonts/archivo-latin-700-normal.woff2) format("woff2"); }
@font-face { font-family: "Archivo"; font-weight: 800; font-display: swap; src: url(/fonts/archivo-latin-800-normal.woff2) format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible"; font-weight: 400; font-display: swap; src: url(/fonts/atkinson-hyperlegible-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible"; font-weight: 700; font-display: swap; src: url(/fonts/atkinson-hyperlegible-latin-700-normal.woff2) format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 500; font-display: swap; src: url(/fonts/ibm-plex-mono-latin-500-normal.woff2) format("woff2"); }

:root {
  --surface: #F2F4F5; --raised: #FFFFFF; --line: #DADFE2; --line-strong: #7B858C;
  --ink: #121417; --muted: #59636A;
  --signal: #F2520F; --on-signal: #121417; --signal-text: #C2410C;
  --blueprint: #1849C6; --blueprint-soft: #E3EAFC; --deep: #0B2545; --grid: #1E4270;
  --ok: #0F7B4B; --ok-soft: #DFF3E8; --due: #8A5300; --due-soft: #FBF0D5; --over: #C0261A; --over-soft: #FCE7E4;
  --display: "Archivo", "Arial Narrow", system-ui, sans-serif;
  --body: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --r-sm: 4px; --r-md: 8px; --r-lg: 16px;
  --focus: 0 0 0 2px var(--surface), 0 0 0 4px var(--blueprint);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--surface); color: var(--ink); font: 16px/24px var(--body); min-height: 100vh; }
a { color: var(--blueprint); }
.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* Header */
.bar { position: sticky; top: 0; z-index: 10; background: var(--ink); color: #fff; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px)); }
.brand img { height: 30px; display: block; }
.bar-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn { color: #fff; width: 48px; height: 48px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--r-md); }
.icon-btn:focus-visible { outline: 2px solid #fff; }

main { max-width: 760px; margin: 0 auto; padding: 20px max(16px, env(safe-area-inset-left, 0px)) 64px; outline: none; }
.loading, .empty { color: var(--muted); }

/* Type */
h1 { font: 800 28px/34px var(--display); letter-spacing: -0.01em; margin: 0; text-wrap: balance; }
h2 { font: 700 20px/26px var(--display); margin: 0; }
.label { font: 700 12px/16px var(--display); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.mono { font-family: var(--mono); font-weight: 500; letter-spacing: .02em; }
.muted { color: var(--muted); }
.stack { display: grid; gap: 16px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.spread { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; }

/* Buttons */
.btn { font: 700 16px/1 var(--body); min-height: 48px; padding: 0 20px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: var(--r-md); border: 1.5px solid var(--line-strong); background: var(--raised); color: var(--ink); text-decoration: none; cursor: pointer; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .asset:focus-visible { outline: 2px solid transparent; box-shadow: var(--focus); }
.btn-signal { background: var(--signal); border-color: var(--signal); color: var(--on-signal); }
.btn-ink { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-quiet { border-color: transparent; background: transparent; color: var(--blueprint); padding: 0 8px; }
.btn[disabled] { opacity: .55; cursor: progress; }
.bar .btn-signal { min-height: 44px; padding: 0 16px; }

/* Status badges: always icon + word */
.status { display: inline-flex; align-items: center; gap: 4px; font: 700 12px/16px var(--display); letter-spacing: .08em; text-transform: uppercase; padding: 6px 8px 6px 6px; border-radius: var(--r-sm); white-space: nowrap; }
.status .i { width: 16px; height: 16px; stroke-width: 2.25; }
.status-in-date { background: var(--ok-soft); color: var(--ok); }
.status-due-soon { background: var(--due-soft); color: var(--due); }
.status-overdue { background: var(--over-soft); color: var(--over); }
.status-unknown { background: #E9ECEE; color: var(--muted); }

/* Summary + list */
.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.summary button { font: inherit; text-align: left; background: var(--raised); border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px; cursor: pointer; color: var(--ink); }
.summary button[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.summary b { display: block; font: 800 28px/32px var(--display); font-variant-numeric: tabular-nums; }
.search { width: 100%; }
.list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.asset { display: flex; justify-content: space-between; gap: 12px; align-items: center; background: var(--raised); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 14px 16px; text-decoration: none; color: inherit; min-height: 72px; }
.asset:hover { border-color: var(--line-strong); }
.asset-name { font: 700 17px/22px var(--display); }
.asset-meta { font-size: 14px; line-height: 20px; color: var(--muted); }
.asset-right { display: grid; justify-items: end; gap: 4px; text-align: right; }

/* Cards */
.card { background: var(--raised); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px; }
.next { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.next b { display: block; font: 800 22px/28px var(--display); }
.details { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px 16px; margin: 0; }
.details dt { font: 700 12px/16px var(--display); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.details dd { margin: 2px 0 0; overflow-wrap: anywhere; }

/* Trail */
.trail { list-style: none; margin: 0; padding: 0; display: grid; gap: 20px; }
.trail li { position: relative; display: grid; grid-template-columns: 20px 1fr; gap: 12px; }
.trail li::before { content: ""; position: absolute; left: 9px; top: 22px; bottom: -22px; width: 2px; background: var(--line-strong); }
.trail li:last-child::before { display: none; }
.node { width: 12px; height: 12px; margin: 6px 0 0 4px; border-radius: 50%; background: var(--raised); border: 2.5px solid var(--ink); position: relative; z-index: 1; }
.trail li:first-child .node { width: 20px; height: 20px; margin: 2px 0 0; background: var(--signal); border: 0; }
.rec-title { font: 700 17px/24px var(--display); margin: 0; }
.rec-meta { font-size: 14px; line-height: 20px; color: var(--muted); margin: 2px 0 0; }
.rec-notes { margin: 6px 0 0; white-space: pre-wrap; }
.files { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.file { font: 500 13px/1 var(--mono); padding: 8px 10px; border-radius: var(--r-sm); background: var(--blueprint-soft); color: var(--blueprint); border: 0; cursor: pointer; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Forms */
form.stack { gap: 14px; }
label.field { display: grid; gap: 6px; font-weight: 700; }
label.field small { font-weight: 400; color: var(--muted); }
input, select, textarea { font: 16px/24px var(--body); color: var(--ink); background: var(--raised); border: 1.5px solid var(--line-strong); border-radius: var(--r-sm); padding: 11px 12px; width: 100%; min-height: 48px; }
textarea { min-height: 96px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } .summary b { font-size: 24px; } }
.error { background: var(--over-soft); color: var(--over); border-radius: var(--r-md); padding: 12px 14px; font-weight: 700; }
.note { background: var(--blueprint-soft); border-radius: var(--r-md); padding: 12px 14px; }

/* Scanner */
.scanner { position: relative; background: var(--deep); border-radius: var(--r-lg); overflow: hidden; aspect-ratio: 3 / 4; max-height: 70vh; width: 100%; }
.scanner video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scanner .frame { position: absolute; inset: 18% 14%; }
.scanner .frame i { position: absolute; width: 44px; height: 44px; border: 6px solid #fff; }
.scanner .frame i:nth-child(1) { left: 0; top: 0; border-right: 0; border-bottom: 0; border-radius: 12px 0 0 0; }
.scanner .frame i:nth-child(2) { right: 0; top: 0; border-left: 0; border-bottom: 0; border-radius: 0 12px 0 0; }
.scanner .frame i:nth-child(3) { left: 0; bottom: 0; border-right: 0; border-top: 0; border-radius: 0 0 0 12px; }
.scanner .frame i:nth-child(4) { right: 0; bottom: 0; border-left: 0; border-top: 0; border-radius: 0 0 12px 0; border-color: var(--signal); }

/* Printed tag: 50 x 30 mm */
.tag-sheet { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.tag { width: 50mm; height: 30mm; background: #fff; color: #121417; border: 1px solid var(--line); border-radius: 3mm; position: relative; overflow: hidden;
  display: grid; grid-template-columns: 22mm 1fr; gap: 2.5mm; padding: 3mm; align-items: center; }
.tag::after { content: ""; position: absolute; right: -4mm; bottom: -4mm; width: 9mm; height: 9mm; border-radius: 50%; background: #F2520F; }
.tag .qr svg { width: 22mm; height: 22mm; display: block; }
.tag-info { display: grid; gap: 1.2mm; align-content: center; min-width: 0; }
.tag-info img { width: 20mm; }
.tag-cta { font: 800 6pt/1.1 var(--display); letter-spacing: .08em; text-transform: uppercase; }
.tag-id { font: 500 9.5pt/1 var(--mono); }
@media print {
  .bar, .no-print { display: none !important; }
  body { background: #fff; }
  main { padding: 0; }
  .tag { border: 0.2mm solid #ccc; }
}

#toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px;
  border-radius: var(--r-md); font-weight: 700; z-index: 20; max-width: calc(100% - 32px); }

/* Section tabs */
.tabs { position: sticky; top: calc(64px + env(safe-area-inset-top, 0px)); z-index: 9; display: flex; gap: 4px; background: var(--raised); border-bottom: 1px solid var(--line);
  padding: 0 max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px)); overflow-x: auto; }
.tabs a { font: 700 15px/1 var(--body); color: var(--muted); text-decoration: none; padding: 14px 12px 12px; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--signal); }

/* Filters */
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 520px) { .filters { grid-template-columns: 1fr; } }
.newname { margin-top: 6px; }

/* Gallery */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.gallery a, .gallery .vid { position: relative; display: block; aspect-ratio: 1; border-radius: var(--r-md); overflow: hidden; background: var(--deep); }
.gallery img, .gallery video { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery .vid video { object-fit: contain; background: #000; }
.gallery .pdf { display: flex; align-items: center; justify-content: center; color: #fff; font: 700 14px/1.2 var(--display); padding: 8px; text-align: center; }
.gallery .tagline { position: absolute; left: 6px; bottom: 6px; background: rgba(18,20,23,.75); color: #fff; font: 700 11px/1 var(--display); letter-spacing: .06em; text-transform: uppercase; padding: 4px 6px; border-radius: 4px; pointer-events: none; }

/* Registered location (website only) */
.map { width: 100%; height: 260px; border: 0; border-radius: var(--r-md); display: block; background: var(--line); }
.coords { font: 500 15px/22px var(--mono); }

/* Upload progress */
progress { width: 100%; height: 10px; accent-color: var(--signal); }

/* Blank tag sheets: A4, 4 x 9 labels of 50 x 30 mm */
.sheet { width: 210mm; height: 297mm; background: #fff; margin: 0 auto 16px; padding: 13.5mm 5mm; box-shadow: 0 2px 12px rgba(0,0,0,.12);
  display: grid; grid-template-columns: repeat(4, 50mm); grid-auto-rows: 30mm; transform-origin: top left; }
.sheet .tag { border: 0; border-radius: 0; outline: 0.2mm dashed #c9cfd3; outline-offset: -0.1mm; }
.sheet-wrap { overflow-x: auto; max-width: 100%; }
.tag-code { font: 500 7pt/1 var(--mono); letter-spacing: .02em; }
@media print {
  @page { size: A4; margin: 0; }
  .tabs { display: none !important; }
  .sheet { margin: 0; box-shadow: none; page-break-after: always; break-after: page; }
  .sheet-wrap { overflow: visible; }
}

[hidden] { display: none !important; }
h2.sub { font: 700 13px/18px var(--display); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 10px 0 -4px; padding-top: 12px; border-top: 1px solid var(--line); }
.field > span { font-weight: 700; }
div.field { display: grid; gap: 6px; }
fieldset.checks { border: 1.5px solid var(--line); border-radius: var(--r-md); padding: 10px 14px 12px; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 4px 12px; }
fieldset.checks legend { font-weight: 700; padding: 0 4px; }
fieldset.checks label { display: flex; align-items: center; gap: 8px; min-height: 40px; font-weight: 400; }
fieldset.checks input { width: 20px; height: 20px; min-height: 0; accent-color: var(--ink); }
input[disabled] { background: #E9ECEE; color: var(--muted); }
