/* Hinge — hand-written, mobile-first. Designed for a 10-inch tablet, works on phones. */

:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --text: #1d2321;
  --muted: #5d6763;
  --line: #dde2df;
  --accent: #0f6b62;
  --accent-dark: #0a4f48;
  --accent-soft: #e2f1ee;
  --green: #1f7a3a;
  --green-soft: #e3f3e7;
  --blue: #1f5fa8;
  --blue-soft: #e4eefa;
  --amber: #8a5a00;
  --amber-soft: #fbf0d9;
  --red: #a63a2c;
  --red-soft: #f9e5e1;
  --radius: 10px;
  --touch: 48px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.5;
}

a { color: var(--accent); }
a:hover { color: var(--accent-dark); }

h1 { font-size: 1.6rem; line-height: 1.25; margin: 0 0 0.75rem; }
h2 { font-size: 1.25rem; margin: 0 0 0.75rem; }
h3 { font-size: 1.05rem; margin: 1rem 0 0.5rem; }

.page { max-width: 1100px; margin: 0 auto; padding: 16px; }
body.narrow .page { max-width: 460px; padding-top: 8vh; }

.muted { color: var(--muted); }
.small { font-size: 0.9rem; }
.mono { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; }

/* ---------- Top bar ---------- */

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 10px 16px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-row {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
}
.topbar-row + .topbar-row { margin-top: 8px; }
.brand {
  font-weight: 800;
  font-size: 1.4rem;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: 0.02em;
}
.usernav { margin-left: auto; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.usernav .who { color: var(--muted); }
.usernav form { margin: 0; }
.topsearch { flex: 1; display: flex; gap: 8px; min-width: 0; }
.topsearch input { flex: 1; min-width: 0; }

/* ---------- Forms and buttons ---------- */

input[type="text"], input[type="email"], input[type="password"], input[type="search"], select, textarea {
  font: inherit;
  font-size: 17px;
  min-height: var(--touch);
  padding: 10px 12px;
  border: 1px solid #b9c2be;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  width: 100%;
}
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 3px solid var(--accent-soft);
  outline-offset: 1px;
  border-color: var(--accent);
}

label { display: block; font-weight: 600; }
label input { margin-top: 4px; font-weight: 400; }

.stack > * + * { margin-top: 14px; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--touch);
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid #b9c2be;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.button:hover { border-color: var(--accent); color: var(--accent-dark); }
.button-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.button-accent:hover { background: var(--accent-dark); color: #fff; }
.button-danger { color: var(--red); border-color: #e0b5ae; }
.button-wide { width: 100%; }
.button[aria-disabled="true"] { color: var(--muted); background: #f0f2f1; cursor: default; border-style: dashed; }
.linklike {
  background: none; border: 0; padding: 0; font: inherit; color: var(--accent);
  text-decoration: underline; cursor: pointer; min-height: var(--touch);
}

/* ---------- Cards, lists, badges ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.card + .card, .section + .section { margin-top: 16px; }
.auth-card .auth-brand { color: var(--accent); font-size: 2rem; margin-bottom: 0; }

.flash { padding: 12px 14px; border-radius: 8px; margin: 12px 0; }
.flash-ok { background: var(--green-soft); color: var(--green); }
.flash-error { background: var(--red-soft); color: var(--red); }

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1.6;
  white-space: nowrap;
  border: 1px solid transparent;
}
.tone-neutral { background: #eef0ef; color: #3d4643; border-color: #d5dad8; }
.tone-muted { background: #f1f1f1; color: #666; border-color: #ddd; }
.tone-green { background: var(--green-soft); color: var(--green); border-color: #b9dcc2; }
.tone-blue { background: var(--blue-soft); color: var(--blue); border-color: #b8cff0; }
.tone-amber { background: var(--amber-soft); color: var(--amber); border-color: #ecd59f; }
.tone-red { background: var(--red-soft); color: var(--red); border-color: #ebbcb4; }
.tone-accent { background: var(--accent-soft); color: var(--accent-dark); border-color: #b5dbd4; }

.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  min-height: 56px;
  border-top: 1px solid var(--line);
}
.list-item:first-child { border-top: 0; }
.list-main { flex: 1; min-width: 0; }
.list-main .badge { margin-left: 4px; }
a.list-item { color: inherit; text-decoration: none; }
a.list-item:hover { background: #fafbfa; }
.empty { padding: 14px 16px; color: var(--muted); }

.hid { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-weight: 700; }

/* ---------- Dashboard ---------- */

.quick-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 6px; }
.panels { display: grid; grid-template-columns: 1fr; gap: 16px; margin-top: 16px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; }
.queue { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.queue a {
  display: flex; flex-direction: column; gap: 6px;
  padding: 14px; border: 1px solid var(--line); border-radius: var(--radius);
  text-decoration: none; color: var(--text); background: #fff; min-height: 88px;
}
.queue a:hover { border-color: var(--accent); }
.queue .count { font-size: 1.8rem; font-weight: 800; line-height: 1; }
.stop-seq {
  flex: none; width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-dark);
  display: flex; align-items: center; justify-content: center; font-weight: 800;
}

/* ---------- Record pages ---------- */

.record-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 14px; }
.record-head h1 { margin: 0; }
.record-head .actions { margin-left: auto; }
.facts { display: grid; grid-template-columns: 1fr; gap: 0; margin: 0; }
.facts div { display: grid; grid-template-columns: 11rem 1fr; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.facts div:first-child { border-top: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }

.chain {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  padding: 12px 14px; background: var(--accent-soft); border-radius: var(--radius);
  margin-bottom: 16px;
}
.chain .step { background: #fff; border: 1px solid #b5dbd4; border-radius: 8px; padding: 6px 10px; }
.chain .step.here { background: var(--accent); color: #fff; border-color: var(--accent); }
.chain .step.none { color: var(--muted); background: transparent; border-style: dashed; }
.chain .arrow { color: var(--accent-dark); font-weight: 700; }
.chain .step-label { display: block; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; opacity: 0.8; }

.history { font-size: 0.95rem; }
.history .list-item { align-items: flex-start; }
.history time { color: var(--muted); white-space: nowrap; }

.two-col { display: grid; grid-template-columns: 1fr; gap: 16px; }

/* ---------- Scan ---------- */

.scan-video-wrap { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 4 / 3; max-height: 70vh; }
.scan-video-wrap video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-frame { position: absolute; inset: 15%; border: 4px solid rgba(255, 255, 255, 0.85); border-radius: 16px; pointer-events: none; }

/* ---------- Labels ---------- */

.label-sheet { display: flex; flex-wrap: wrap; gap: 12px; }
.label {
  width: 2.625in; height: 1.25in;
  display: flex; align-items: center; gap: 0.1in;
  padding: 0.08in 0.1in;
  background: #fff; border: 1px dashed #aab3af;
  overflow: hidden; break-inside: avoid; page-break-inside: avoid;
}
.label .qr { width: 1.05in; height: 1.05in; flex: none; }
.label .qr svg { width: 100%; height: 100%; display: block; }
.label .label-text { min-width: 0; }
.label .label-id { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-weight: 800; font-size: 20pt; line-height: 1.05; }
.label .label-desc { font-size: 9pt; line-height: 1.2; margin-top: 4px; color: #222; overflow-wrap: anywhere; }

@media print {
  @page { margin: 0.25in; }
  body { background: #fff; }
  .topbar, .no-print { display: none !important; }
  .page { padding: 0; max-width: none; }
  .label-sheet { gap: 0.1in; }
  .label { border: 0; }
}

/* ---------- Larger screens (tablets in landscape and up) ---------- */

@media (min-width: 720px) {
  .page { padding: 24px; }
  .quick-actions { grid-template-columns: repeat(4, 1fr); }
  .panels { grid-template-columns: 1fr 1fr; }
  .two-col { grid-template-columns: 1fr 1fr; }
  .topbar-row + .topbar-row { margin-top: 10px; }
}

@media (max-width: 560px) {
  body { font-size: 16px; }
  .facts div { grid-template-columns: 1fr; gap: 0; }
  .facts dt { font-size: 0.85rem; }
  .search-row { flex-wrap: wrap; }
  .scan-button { width: 100%; }
}

/* ---------- Small utilities ---------- */

.donation-group { margin-bottom: 12px; }
.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;
}
