/* CRWN Gems certificates: the one stylesheet (CLAUDE.md). "Atelier" design (D-83): warm ivory,
   charcoal ink, CRWN maroon as the only accent. Phone first (D-33); self-hosted fonts; no inline
   styles anywhere (strict CSP, docs/08). */
@font-face { font-family: "Inter"; font-weight: 400; font-display: swap; src: url("../fonts/Inter-Regular.3875f8357497.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 600; font-display: swap; src: url("../fonts/Inter-SemiBold.b72fa2728a8e.woff2") format("woff2"); }
@font-face { font-family: "Montserrat"; font-weight: 400; font-display: swap; src: url("../fonts/Montserrat-Regular.618651a1ea85.woff2") format("woff2"); }

:root {
  --ink: #1f2124;
  --ink-2: #2e3135;
  --charcoal: #3d4043;
  --muted: #5f6266;
  --subtle: #6a6d71;
  --maroon: #7a1428;
  --maroon-dark: #5e0f1f;
  --maroon-tint: #f1e4e7;
  --page: #faf8f5;
  --card: #ffffff;
  --wash: #f3f0eb;
  --line: #e7e2db;
  --line-soft: #efebe5;
  --field: #cfc8bf;
  --ok: #1d6b3a;
  --ok-ink: #14532b;
  --ok-bg: #e9f3ec;
  --ok-line: #cfe3d5;
  --warn: #6b3a00;
  --warn-strong: #b4541b;
  --warn-bg: #fbf0e0;
  --warn-line: #eed6b3;
  --info: #1f4e79;
  --info-bg: #e7eef6;
  --info-line: #c9d8ea;
  --error: #a3162b;
  --error-bg: #fbedef;
  --error-line: #ecc5cb;
  --nav: #1f2124;
  --nav-ink: #c8cacd;
  --nav-active: #34363a;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(31, 33, 36, 0.04), 0 10px 30px rgba(31, 33, 36, 0.05);
  --shadow-lift: 0 1px 2px rgba(31, 33, 36, 0.04), 0 14px 40px rgba(31, 33, 36, 0.08);
  --tabbar: 0px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--page); color: var(--ink);
  font: 400 16px/1.55 "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--maroon); text-underline-offset: 2px; }
a:hover { color: var(--maroon-dark); }
:focus-visible { outline: 3px solid var(--maroon); outline-offset: 2px; border-radius: 4px; }
img { max-width: 100%; }
h1, h2, h3 { font-family: "Montserrat", sans-serif; font-weight: 400; color: var(--ink); line-height: 1.2; }
h1 { font-size: 1.75rem; margin: 0 0 0.5rem; letter-spacing: -0.01em; }
h2 { font-size: 1.2rem; margin: 1.75rem 0 0.75rem; }
h3 { font-size: 1.05rem; margin: 1.25rem 0 0.5rem; }
p { margin: 0 0 0.85rem; }
.muted { color: var(--muted); }
.center { text-align: center; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.eyebrow { margin: 0 0 6px; font: 600 11px/1.3 "Inter", sans-serif; letter-spacing: 0.14em; text-transform: uppercase; color: var(--maroon); }
.lede { color: var(--muted); font-size: 1rem; max-width: 40rem; }
.num { font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }

/* ------------------------------------------------------------------------------------------
   Page shells
   ------------------------------------------------------------------------------------------ */

/* Public pages and sign-in: a white bar, the page, a quiet footer */
.site-header { background: var(--card); border-bottom: 1px solid var(--line); }
.site-header .bar { max-width: 64rem; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 12px; min-height: 60px; }
.brand { display: inline-flex; align-items: center; }
.brand img { height: 36px; width: auto; display: block; }
.site-header .nav { margin-left: auto; display: flex; gap: 4px 16px; align-items: center; flex-wrap: wrap; font-size: 15px; }
.site-header .nav a { color: var(--ink); text-decoration: none; font-weight: 600; padding: 10px 2px; }
.site-header .nav a:hover { color: var(--maroon); }
.site-header .nav form { margin: 0; }
.link-button { background: none; border: 0; min-height: 44px; padding: 8px 2px; font: inherit; color: var(--ink); cursor: pointer; }
.link-button:hover { color: var(--maroon); }

.site-main { flex: 1; width: 100%; max-width: 64rem; margin: 0 auto; padding: 24px 16px 48px; }
.site-main.narrow { max-width: 30rem; }
.site-main.public { max-width: 36rem; }
.site-footer { color: var(--subtle); font-size: 0.8125rem; padding: 12px 16px 20px; text-align: center; }
.site-footer p { margin: 0; }
.site-footer a { color: var(--subtle); }

/* Staff: a dark sidebar on a desktop; a top bar (and, for gemologists, a tab bar) on a phone */
.app { flex: 1; display: flex; flex-direction: column; min-height: 100vh; }
.side-nav { display: none; }
.top-bar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  min-height: 58px; padding: 6px 8px 6px 16px; background: var(--card); border-bottom: 1px solid var(--line);
}
.top-bar .brand img { height: 32px; }
.top-bar .menu { margin-left: auto; position: relative; }
.top-bar .menu > summary {
  list-style: none; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 12px; font-weight: 600; font-size: 15px; cursor: pointer; color: var(--ink);
}
.top-bar .menu > summary::-webkit-details-marker { display: none; }
.top-bar .menu > summary svg { width: 20px; height: 20px; }
.top-bar .menu .sheet {
  position: absolute; right: 0; top: calc(100% + 8px); width: min(300px, calc(100vw - 24px));
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lift);
  padding: 8px; display: flex; flex-direction: column; gap: 2px; max-height: calc(100vh - 76px); overflow-y: auto;
}
.nav-link {
  display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 10px;
  color: var(--ink); text-decoration: none; font-size: 15px;
}
.nav-link svg { width: 20px; height: 20px; flex: none; }
.nav-link .count { margin-left: auto; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--maroon); color: #fff; }
.nav-link .count.quiet { background: var(--wash); color: var(--ink); }
.sheet .nav-link:hover, .sheet .nav-link[aria-current="page"] { background: var(--wash); color: var(--ink); }
.sheet .nav-link[aria-current="page"] { font-weight: 600; }
.nav-divider { height: 1px; background: var(--line-soft); margin: 6px 8px; border: 0; }
.nav-person { display: flex; align-items: center; gap: 10px; padding: 10px 12px 6px; }
.avatar { width: 34px; height: 34px; border-radius: 17px; background: var(--maroon-tint); color: var(--maroon); display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: 14px; flex: none; text-transform: uppercase; }
.nav-person strong { display: block; font-size: 14px; }
.nav-person span { font-size: 12px; color: var(--subtle); }
.nav-signout { margin: 0; }
.nav-signout button { width: 100%; justify-content: flex-start; background: none; border: 0; color: var(--ink); font: inherit; font-size: 15px; min-height: 44px; padding: 0 12px; border-radius: 10px; cursor: pointer; display: flex; align-items: center; gap: 12px; }
.nav-signout button:hover { background: var(--wash); }
.nav-signout svg { width: 20px; height: 20px; }

.tab-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--card); border-top: 1px solid var(--line); padding: 4px 4px calc(6px + env(safe-area-inset-bottom));
}
.tab-bar a {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 0 4px;
  color: var(--subtle); text-decoration: none; font-size: 11px; font-weight: 600; min-height: 52px;
}
.tab-bar a svg { width: 24px; height: 24px; }
.tab-bar a[aria-current="page"] { color: var(--maroon); }
.tab-bar .dot { position: absolute; top: 3px; left: calc(50% + 7px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--warn-strong); color: #fff; font-size: 11px; line-height: 18px; text-align: center; }
body.has-tabbar { --tabbar: calc(68px + env(safe-area-inset-bottom)); }
body.has-tabbar .app .site-main { padding-bottom: calc(var(--tabbar) + 32px); }

.app .site-main { max-width: 68rem; }
.app .site-main.narrow { max-width: 32rem; }
.app .site-main.wide { max-width: 76rem; }

@media (min-width: 1024px) {
  .app { display: grid; grid-template-columns: 248px minmax(0, 1fr); }
  .top-bar, .tab-bar { display: none; }
  body.has-tabbar { --tabbar: 0px; }
  body.has-tabbar .app .site-main { padding-bottom: 56px; }
  .side-nav {
    display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
    background: var(--nav); color: #fff; padding: 18px 12px 16px;
  }
  .side-nav .brand-row { display: flex; align-items: center; gap: 10px; padding: 4px 10px 20px; color: #fff; text-decoration: none; }
  .side-nav .brand-chip { width: 38px; height: 38px; border-radius: 10px; background: #fff; display: inline-flex; align-items: center; justify-content: center; }
  .side-nav .brand-chip img { width: 30px; height: auto; display: block; }
  .side-nav .brand-name { font-family: "Montserrat", sans-serif; font-size: 15px; line-height: 1.2; }
  .side-nav .nav-link { color: var(--nav-ink); }
  .side-nav .nav-link:hover { background: var(--nav-active); color: #fff; }
  .side-nav .nav-link[aria-current="page"] { background: var(--nav-active); color: #fff; font-weight: 600; }
  .side-nav .nav-link .count.quiet { background: #3e4146; color: #fff; }
  .side-nav .nav-divider { background: var(--nav-active); }
  .side-nav .nav-foot { margin-top: auto; padding-top: 12px; }
  .side-nav .nav-person strong { color: #fff; }
  .side-nav .nav-person span { color: #a9acb0; }
  .side-nav .nav-signout button { color: var(--nav-ink); }
  .side-nav .nav-signout button:hover { background: var(--nav-active); color: #fff; }
  .app .site-main { padding: 32px 40px 56px; margin: 0; }
  .app .site-main.narrow { margin: 0; }
}

/* ------------------------------------------------------------------------------------------
   Messages, cards, page heads
   ------------------------------------------------------------------------------------------ */
.messages { list-style: none; padding: 0; margin: 0 0 18px; display: flex; flex-direction: column; gap: 8px; }
.messages li {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--card); border: 1px solid var(--line); font-size: 15px;
}
.messages li::before { content: ""; width: 8px; height: 8px; border-radius: 4px; margin-top: 8px; flex: none; background: var(--charcoal); }
.messages .success { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok-ink); }
.messages .success::before { background: var(--ok); }
.messages .error { background: var(--error-bg); border-color: var(--error-line); color: var(--error); }
.messages .error::before { background: var(--error); }
.messages .warning { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn); }
.messages .warning::before { background: var(--warn-strong); }

.page-head { margin: 0 0 22px; }
.page-head h1 { margin: 0 0 6px; }
.page-head p { margin: 0; }
.page-head.split { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; }
.back { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; margin: -6px 0 6px; font-size: 14px; font-weight: 600; text-decoration: none; }
p:has(> .back:only-child), p:has(> a:only-child[href]) { margin-bottom: 6px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 16px;
  margin-bottom: 16px; box-shadow: var(--shadow);
}
.card > h2:first-child, .card h2:first-child { margin-top: 0; }
.card.attention { border-color: var(--warn-line); background: var(--warn-bg); box-shadow: none; }
.card.attention h2 { color: var(--warn); font-family: "Inter", sans-serif; font-weight: 600; font-size: 1rem; }
.card.lift { box-shadow: var(--shadow-lift); }
.card.good { border-color: var(--ok-line); background: var(--ok-bg); color: var(--ok-ink); box-shadow: none; }
.card.good p { margin: 0; }
@media (min-width: 640px) { .card { padding: 22px 22px; } }

/* Small uppercase section titles inside forms and panels */
.form-section > h2, .section-title {
  font: 600 12px/1.3 "Inter", sans-serif; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin: 0 0 14px;
}

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 0 0 22px; }
.stat {
  display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); text-decoration: none; color: var(--ink); box-shadow: var(--shadow);
}
.stat:hover { border-color: var(--field); color: var(--ink); }
.stat .label { font-size: 13px; color: var(--muted); }
.stat .value { font-family: "Montserrat", sans-serif; font-size: 1.75rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat.accent .value { color: var(--maroon); }

/* Big tappable choices on the home screen */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 12px; margin: 0 0 18px; }
.tile {
  display: flex; align-items: center; gap: 14px; min-height: 64px; padding: 14px 16px; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--line); text-decoration: none; color: var(--ink); box-shadow: var(--shadow);
}
.tile:hover { border-color: var(--field); color: var(--ink); }
.tile svg { width: 24px; height: 24px; flex: none; color: var(--maroon); }
.tile strong { display: block; font-size: 15px; }
.tile span span { display: block; font-size: 13px; color: var(--muted); }
.tile.primary { background: var(--maroon); border-color: var(--maroon); color: #fff; box-shadow: 0 6px 18px rgba(122, 20, 40, 0.22); }
.tile.primary svg, .tile.primary span span { color: #fff; }
.tile .badge { margin-left: auto; }

/* ------------------------------------------------------------------------------------------
   Lists, rows, badges
   ------------------------------------------------------------------------------------------ */
.badge {
  display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; line-height: 1.3; padding: 4px 10px;
  border-radius: 999px; background: #f1efec; color: #45484c; border: 0; white-space: nowrap;
}
.badge.off { color: var(--error); background: var(--error-bg); }
.badge.count { background: var(--maroon); color: #fff; margin-left: 6px; }
.status-draft { background: #f1efec; color: #45484c; }
.status-submitted { background: var(--info-bg); color: var(--info); }
.status-changes_requested { background: var(--warn-bg); color: var(--warn); }
.status-issued { background: var(--ok-bg); color: var(--ok-ink); }
.status-void { background: var(--error-bg); color: var(--error); }

.list {
  list-style: none; padding: 0; margin: 0 0 18px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}
.list > li { border-bottom: 1px solid var(--line-soft); }
.card .list { border: 0; box-shadow: none; border-radius: 0; background: transparent; margin: 0; }
.card .list .history-row { padding-left: 0; padding-right: 0; }
.list > li:last-child { border-bottom: 0; }
.list a.row {
  display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 14px 16px; min-height: 64px;
  text-decoration: none; color: inherit;
}
.list a.row:hover { background: #fcfbf9; }
.list .row strong { display: block; font-weight: 600; overflow-wrap: break-word; }
.list .row .muted { font-size: 13.5px; display: block; }
.list .row .grow { flex: 1 1 auto; min-width: 0; }
.list .row > .badge { flex: 0 1 auto; max-width: 10rem; text-align: center; white-space: normal; }
.list li.empty { padding: 18px 16px; color: var(--muted); }
.list .row::after { content: ""; width: 8px; height: 8px; flex: none; border-right: 2px solid #b9b3ab; border-top: 2px solid #b9b3ab; transform: rotate(45deg); margin-left: 2px; }
.counts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 479px) {
  .list a.row:has(.thumb) { flex-wrap: wrap; row-gap: 6px; }
  .list a.row:has(.thumb) .grow { flex: 1 1 calc(100% - 100px); }
  .list a.row:has(.thumb)::after { order: 2; }
  .list a.row:has(.thumb) > .badge { order: 3; margin-left: 66px; max-width: none; }
  .select-row .list a.row:has(.thumb) > .badge { margin-left: 54px; }
}
.thumb {
  flex: none; width: 52px; height: 52px; border-radius: 12px; background: radial-gradient(circle at 50% 45%, #fff 0%, var(--wash) 100%);
  overflow: hidden; display: flex; align-items: center; justify-content: center;
}
.thumb img { width: 88%; height: 88%; object-fit: contain; }
.marker { display: block; font-size: 13px; margin-top: 2px; font-weight: 600; }
.marker.complete { color: var(--ok); }
.marker.complete::before { content: "\2713\00a0"; }
.marker.incomplete { color: var(--warn); }
.badge.sale { margin-top: 6px; background: var(--maroon-tint); color: var(--maroon-dark); }

/* Show-only chips (the batch's sale filter, D-86) */
.filter-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.filter-chips a {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border: 1px solid var(--field);
  border-radius: 999px; background: var(--card); color: var(--ink); font-size: 14px; text-decoration: none;
}
.filter-chips a[aria-current] { background: var(--maroon); border-color: var(--maroon); color: #fff; font-weight: 600; }

/* A MaxSold listing as it will read (D-88); lots that aren't ready get the red frame */
.listing { white-space: pre-line; background: var(--wash); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 14px; line-height: 1.55; overflow-wrap: anywhere; margin: 0 0 10px; }
.card.blocked { border: 2px solid var(--error); }
.problems.error { color: var(--error); font-weight: 600; margin-bottom: 12px; }
.facts.compact { margin-bottom: 14px; }

/* Rows with a checkbox in front (batch, queue, print screen) */
.select-row { display: flex; align-items: center; gap: 0; padding-left: 14px; }
.select-row > input[type="checkbox"] { margin: 0; }
.select-row .list.inner { flex: 1; min-width: 0; margin: 0; border: 0; border-radius: 0; box-shadow: none; background: transparent; }
.select-row .list.inner > li { border: 0; }
.select-row:has(input:checked) { background: #fcf8f9; }
.select-row .list a.row { padding-left: 10px; gap: 10px; }
.select-row .row::after { display: none; }
.select-row .thumb { width: 44px; height: 44px; border-radius: 10px; }
@media (max-width: 479px) { .select-row .row > .badge { max-width: 5.5rem; } }
.note-row { padding: 0 16px 14px 82px; font-size: 14px; color: var(--ink-2); }
.note-row strong { color: var(--warn); }
.actions-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 0 0 16px; }
.actions-row.end { justify-content: flex-end; }

/* Reference lists: row link plus up/down buttons */
.vocab-row { display: flex; align-items: center; gap: 8px; padding-right: 10px; }
.vocab-row .row { flex: 1; min-width: 0; }
.move { display: flex; gap: 6px; }
.move form { margin: 0; }
.site-main .move button { width: 44px; min-height: 44px; padding: 0; }
.site-main .move button:disabled { opacity: 0.35; cursor: default; }

/* Facts: label and value rows with hairlines */
.facts { display: grid; grid-template-columns: minmax(7.5rem, 40%) 1fr; margin: 0; }
.facts dt, .facts dd { padding: 11px 0; border-bottom: 1px solid var(--line-soft); }
.facts dt { color: var(--muted); font-size: 14px; padding-right: 12px; }
.facts dd { margin: 0; font-weight: 600; font-size: 14.5px; overflow-wrap: anywhere; text-align: right; }
.facts dt:last-of-type, .facts dd:last-of-type { border-bottom: 0; }
.facts.diff dd { text-align: left; font-weight: 400; }
.note { background: var(--wash); border-radius: var(--radius-sm); padding: 12px 14px; }
.problems { margin: 0; padding-left: 20px; }
.problems li { margin: 6px 0; }
.flag { color: var(--warn); background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 14px; }
.error-text { color: var(--error); }

/* ------------------------------------------------------------------------------------------
   Forms: one column, large tap targets
   ------------------------------------------------------------------------------------------ */
.field { margin: 0 0 18px; }
label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; color: var(--ink); }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="search"],
input[type="date"], input[type="tel"], input[type="url"], select, textarea {
  width: 100%; min-height: 50px; padding: 11px 14px; font: inherit; font-size: 16px; color: var(--ink);
  background: var(--card); border: 1px solid var(--field); border-radius: 10px; transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { min-height: 110px; line-height: 1.55; resize: vertical; }
select {
  appearance: none; padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%235f6266' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}
input:hover, select:hover, textarea:hover { border-color: #b9b1a7; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--maroon); box-shadow: 0 0 0 3px rgba(122, 20, 40, 0.14); }
/* A field with a problem: a red frame round the whole field (inputs, dropdowns and pill choices
   alike) and the message in red above it, everywhere in the system. */
.field:has(.errorlist li) {
  padding: 12px 12px 14px; margin-left: -12px; margin-right: -12px; border: 2px solid var(--error);
  border-radius: 14px; background: var(--error-bg); scroll-margin-top: 90px;
}
.field:has(.errorlist li) > label, .field:has(.errorlist li) > legend { color: var(--error); }
input[aria-invalid="true"], .field:has(.errorlist li) input:not([type="checkbox"]):not([type="radio"]),
.field:has(.errorlist li) select, .field:has(.errorlist li) textarea {
  border: 2px solid var(--error); background: #fff;
}
.choices.radioselect:has(.errorlist li) label { border-color: #e2a3ad; }
.field:has(.errorlist li) .with-action { border: 2px solid var(--error); }
.field:has(.errorlist li) .with-action input:not([type="checkbox"]):not([type="radio"]) { border: 0; }
input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; margin: 0 10px 0 0; flex: none; accent-color: var(--maroon); }
.check label, label.check { display: flex; align-items: center; font-weight: 400; font-size: 15px; min-height: 44px; margin: 0; }
.helptext, .help { display: block; font-size: 13px; color: var(--subtle); margin-top: 6px; line-height: 1.45; }
.errorlist { list-style: none; padding: 0; margin: 2px 0 8px; color: var(--error); font-size: 14px; font-weight: 600; }
.errorlist li { display: flex; align-items: flex-start; gap: 6px; }
.errorlist li::before { content: "!"; flex: none; width: 18px; height: 18px; margin-top: 1px; border-radius: 9px; background: var(--error); color: #fff; font-size: 12px; line-height: 18px; text-align: center; }
.errorlist:empty { display: none; }
fieldset.field { border: 0; padding: 0; min-width: 0; }
fieldset.field legend { font-weight: 600; font-size: 14px; margin-bottom: 8px; padding: 0; }
.three-up { display: grid; grid-template-columns: 1fr; gap: 0 12px; }
@media (min-width: 480px) { .three-up { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* Radio choices as pills; checkboxes as chips (equipment) */
.choices.radioselect > div { display: flex; flex-wrap: wrap; gap: 8px; }
.choices.radioselect > div > div { display: contents; }
.choices.radioselect label {
  font-weight: 400; display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border: 1px solid var(--field);
  border-radius: 999px; background: var(--card); cursor: pointer; margin: 0; font-size: 15px;
}
.choices.radioselect input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.choices.radioselect label:has(input:checked) { background: var(--maroon); border-color: var(--maroon); color: #fff; font-weight: 600; }
.choices.radioselect label:has(input:focus-visible) { outline: 3px solid var(--maroon); outline-offset: 2px; }
.choices.checkboxselectmultiple > div { display: flex; flex-wrap: wrap; gap: 8px; }
.choices.checkboxselectmultiple > div > div { display: contents; }
.choices.checkboxselectmultiple label {
  font-weight: 400; display: inline-flex; align-items: center; min-height: 42px; padding: 0 14px 0 10px; margin: 0;
  border: 1px solid var(--field); border-radius: 999px; background: var(--card); cursor: pointer; font-size: 14px;
}
.choices.checkboxselectmultiple input { width: 18px; height: 18px; margin: 0 8px 0 0; }
.choices.checkboxselectmultiple label:has(input:checked) { background: var(--maroon-tint); border-color: #e0c3ca; color: var(--maroon-dark); font-weight: 600; }

/* Buttons */
.button, .site-main button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; padding: 10px 20px;
  border-radius: var(--radius-sm); border: 1px solid var(--maroon); background: var(--maroon); color: #fff;
  font: 600 16px/1.2 "Inter", sans-serif; text-decoration: none; cursor: pointer; width: 100%; transition: background 0.15s, border-color 0.15s;
}
.button:hover, .site-main button:hover { background: var(--maroon-dark); border-color: var(--maroon-dark); color: #fff; }
.button.secondary, .site-main button.secondary { background: var(--card); color: var(--ink); border-color: var(--field); }
.button.secondary:hover, .site-main button.secondary:hover { background: var(--wash); border-color: #b9b1a7; color: var(--ink); }
.button.dark, .site-main button.dark { background: var(--ink); border-color: var(--ink); }
.button.danger, .site-main button.danger { background: var(--card); color: var(--error); border-color: var(--error-line); }
.button.danger:hover, .site-main button.danger:hover { background: var(--error-bg); color: var(--error); }
.site-main button:disabled, .site-main button[disabled] { background: var(--line); border-color: var(--line); color: var(--subtle); cursor: not-allowed; }
.site-main button.small, .button.small { min-height: 42px; padding: 6px 14px; font-size: 14px; }
.site-main .link-button { width: auto; min-height: 44px; background: none; border: 0; color: var(--maroon); padding: 0 2px; }
@media (min-width: 640px) { .button, .site-main button { width: auto; } }
.button svg, .site-main button svg { width: 20px; height: 20px; flex: none; }

/* The bottom action bar on long forms; sits above the tab bar on a phone */
.save-bar {
  position: sticky; bottom: var(--tabbar); z-index: 10; display: flex; gap: 10px; flex-wrap: wrap; margin: 8px -16px 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid var(--line); box-shadow: 0 -8px 24px rgba(31, 33, 36, 0.06);
}
.save-bar button, .save-bar .button { flex: 1; width: auto; }
@media (min-width: 1024px) { .save-bar { margin: 8px 0 0; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; } }
.save-status { font-size: 13px; color: var(--ok); font-weight: 600; }
.danger-zone { margin: 28px 0 8px; }
.fill-notes summary { cursor: pointer; font-weight: 600; color: var(--maroon); }
.fill-notes[open] summary { margin-bottom: 8px; }
.fill-notes form { display: grid; gap: 10px; justify-items: start; }
.fill-notes textarea { width: 100%; }
.danger-zone summary { cursor: pointer; color: var(--error); padding: 10px 0; font-weight: 600; font-size: 14px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline-form label { margin: 0; }
.inline-form select { width: auto; flex: 1; min-width: 12rem; }

/* Show-password and copy buttons (ui.js, D-82) */
.with-action { display: flex; align-items: center; gap: 6px; border: 1px solid var(--field); border-radius: 10px; background: var(--card); padding: 0 4px 0 0; }
.with-action:focus-within { border-color: var(--maroon); box-shadow: 0 0 0 3px rgba(122, 20, 40, 0.14); }
.with-action input { border: 0; box-shadow: none; flex: 1; min-width: 0; }
.with-action input:focus { box-shadow: none; }
.site-main .icon-button, .icon-button {
  width: 44px; min-width: 44px; min-height: 44px; height: 44px; padding: 0; border: 0; border-radius: 10px; background: transparent; color: var(--muted);
}
.site-main .icon-button:hover { background: var(--wash); color: var(--ink); }
.icon-button svg { width: 22px; height: 22px; }
.strength { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; margin-top: 8px; }
.strength span { height: 4px; border-radius: 2px; background: var(--line); }
.strength[data-score="1"] span:nth-child(-n+1) { background: var(--error); }
.strength[data-score="2"] span:nth-child(-n+2) { background: var(--warn-strong); }
.strength[data-score="3"] span:nth-child(-n+3) { background: #5a8f3c; }
.strength[data-score="4"] span { background: var(--ok); }
.strength-label { font-size: 12px; font-weight: 600; color: var(--subtle); margin-top: 4px; min-height: 1.2em; }
.rules { list-style: none; margin: 0 0 18px; padding: 14px 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.rules li { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.rules li::before { content: ""; width: 18px; height: 18px; border-radius: 9px; border: 2px solid var(--field); flex: none; }
.rules li.met { color: var(--ink); }
.rules li.met::before { border-color: var(--ok); background: var(--ok) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 12px no-repeat; }

/* ------------------------------------------------------------------------------------------
   The stone form (M3) and photos (M4)
   ------------------------------------------------------------------------------------------ */
/* Rough stones need no shape; show only the measurement inputs the chosen mode uses (D-34). */
.stone:has(input[name="cutting_style"][value="rough"]:checked) .shape-field { display: none; }
/* Other (D-100): the typed line replaces the shape; its box shows only with Other. */
.stone:has(input[name="cutting_style"][value="other"]:checked) .shape-field { display: none; }
.stone:not(:has(input[name="cutting_style"][value="other"]:checked)) .other-field { display: none; }
.measure:has(input[name="measurement_mode"][value="range"]:checked) .single-fields,
.measure:has(input[name="measurement_mode"][value="not_recorded"]:checked) .single-fields,
.measure:not(:has(input[name="measurement_mode"][value="range"]:checked)) .range-fields { display: none; }
.stone-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 0 0 18px; font-size: 14px; color: var(--muted); }
.stone-head h1 { flex: 1 1 100%; margin: 0; }
#missing:has(.problems) { border-color: var(--warn-line); background: var(--warn-bg); box-shadow: none; }
#missing h2 { margin: 0 0 6px; font: 600 15px/1.3 "Inter", sans-serif; color: var(--warn); }
#missing .problems { list-style: none; padding: 0; }
#missing .problems a { display: flex; align-items: center; justify-content: space-between; min-height: 40px; color: var(--warn); font-weight: 600; text-decoration: none; border-top: 1px solid var(--warn-line); }
#missing .problems a::after { content: "\2192"; }
#missing .marker.complete { margin: 0; font-size: 15px; }
#prints-as h2 { margin-top: 0; }

.js .upload-fallback, .js .js-hidden { display: none; }
.upload-form.busy { opacity: 0.6; pointer-events: none; }
.busy-text { font-weight: 600; color: var(--maroon); }
.upload-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 0 0 8px; }
.upload-actions .button { width: 100%; padding: 10px 10px; font-size: 15px; white-space: nowrap; }
.photo-grid { list-style: none; padding: 0; margin: 0 0 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.photo-tile { display: flex; flex-direction: column; gap: 8px; }
.photo-frame {
  display: block; aspect-ratio: 1; border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
  background: radial-gradient(circle at 50% 45%, #fff 0%, var(--wash) 100%);
}
.photo-frame img { width: 100%; height: 100%; object-fit: contain; display: block; padding: 8%; }
.tile-badges { display: flex; gap: 4px; flex-wrap: wrap; }
.tile-actions { display: flex; flex-direction: column; gap: 6px; }
.tile-actions form { margin: 0; }
.tile-actions .button, .tile-actions button { width: 100%; }
.photo-approved { background: var(--ok-bg); color: var(--ok-ink); }
.photo-ready { background: var(--warn-bg); color: var(--warn); }
.for-print { background: var(--ink); color: #fff; }
.for-records { background: var(--info-bg); color: var(--info); }
.photo-frame.record img { padding: 0; object-fit: cover; }

.touchup { display: grid; grid-template-columns: 1fr; gap: 16px; margin-bottom: 16px; }
@media (min-width: 720px) { .touchup { grid-template-columns: 1fr 1fr; } }
.touchup .pane { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.touchup .pane h2 { margin: 0 0 10px; font: 600 12px/1.3 "Inter", sans-serif; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.touchup.busy .after { opacity: 0.5; }
.stage { position: relative; background: #fff; border-radius: 12px; overflow: hidden; }
.stage img { display: block; width: 100%; height: auto; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0.45; touch-action: none; cursor: crosshair; }
.stage canvas.crop-box { opacity: 1; pointer-events: none; }
.after-frame { background: #fff; border-radius: 12px; overflow: hidden; aspect-ratio: 1; display: flex; align-items: center; justify-content: center; }
.after-frame img { max-width: 100%; max-height: 100%; display: block; }
.touchup:has(#show-transparency:checked) .after-frame {
  background-color: #2a2c30;
  background-image: linear-gradient(45deg, #36393e 25%, transparent 25%), linear-gradient(-45deg, #36393e 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #36393e 75%), linear-gradient(-45deg, transparent 75%, #36393e 75%);
  background-size: 20px 20px; background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}
.warning-list { margin: 8px 0; padding-left: 28px; }
.brush-tools { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.site-main .brush-tools button { width: 100%; }
.site-main .brush-tools button[data-mode="keep"][aria-pressed="true"] { background: var(--ok); border-color: var(--ok); color: #fff; }
.site-main .brush-tools button[data-mode="remove"][aria-pressed="true"],
.site-main .brush-tools button[data-mode="crop"][aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
input[type="range"] { width: 100%; min-height: 44px; accent-color: var(--maroon); }

/* ------------------------------------------------------------------------------------------
   Review (M5), print (M6)
   ------------------------------------------------------------------------------------------ */
.review-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 24px; align-items: start; }
@media (min-width: 1100px) { .review-layout { grid-template-columns: minmax(0, 1fr) 360px; } .review-layout > aside { position: sticky; top: 24px; max-height: calc(100vh - 48px); overflow-y: auto; border-radius: var(--radius); } }
.admin-panel { box-shadow: var(--shadow-lift); }
.admin-panel h2 { font-size: 1.15rem; }
.admin-panel h3 { margin-top: 1.4rem; font: 600 12px/1.3 "Inter", sans-serif; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.admin-panel form { margin-bottom: 12px; }
.number-chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 10px; background: var(--wash); font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.review-group { padding: 0; overflow: hidden; }
.review-group > h2 { margin: 0; padding: 16px 18px 2px; font-size: 1.05rem; }
.review-group > .muted { padding: 0 18px; font-size: 14px; }
.review-group .list.selectable { border: 0; border-radius: 0; box-shadow: none; border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); margin: 0; }
.review-group .actions-row, .review-group details { padding: 0 18px; }
.review-group .actions-row { margin: 14px 0 8px; }
.review-group details { padding-bottom: 14px; }
.review-group summary, .search-form summary { cursor: pointer; padding: 8px 0; font-weight: 600; font-size: 14px; color: var(--maroon); }
.history-row { padding: 12px 16px; }
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 36px 20px; background: var(--card); border: 1px dashed var(--field); border-radius: var(--radius); color: var(--muted); }
.empty-state svg { width: 32px; height: 32px; color: var(--ok); }
.empty-state strong { color: var(--ink); font-size: 16px; }
.instructions ul { margin: 0 0 10px; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.instructions li { padding-left: 26px; position: relative; font-size: 14.5px; }
.instructions li::before { content: ""; position: absolute; left: 0; top: 3px; width: 16px; height: 16px; border-radius: 8px; background: var(--ok) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 10px no-repeat; }
.print-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 24px; align-items: start; }
@media (min-width: 1100px) { .print-layout { grid-template-columns: minmax(0, 1fr) 340px; } .print-layout > aside { position: sticky; top: 24px; order: 2; max-height: calc(100vh - 48px); overflow-y: auto; } }
.filter-form { margin-bottom: 14px; padding: 12px 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.filter-form .check { margin: 0; }

/* ------------------------------------------------------------------------------------------
   Public pages (M7): phone first, no scripts needed, no inline styles
   ------------------------------------------------------------------------------------------ */
.hero { text-align: center; margin: 8px 0 22px; }
.hero .seal { width: 76px; height: 76px; display: block; margin: 0 auto 12px; }
.hero h1 { font-size: 1.85rem; margin-bottom: 10px; }
.hero p { color: var(--muted); max-width: 26rem; margin: 0 auto; }
.public-section h1, .public-section h2 { margin-top: 0; }
.lookup-form button { width: 100%; }
.points { padding-left: 20px; }
.points li { margin: 6px 0; }
.hp { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }
.contact-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 0 0 16px; }
.contact-row .button { width: 100%; }
.banner { border-radius: var(--radius); padding: 14px 16px; margin: 0 0 16px; border: 1px solid var(--line); background: var(--card); }
.banner p { margin: 0 0 4px; }
.banner p:last-child { margin-bottom: 0; }
.banner .small { font-size: 13px; }
.banner.valid { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok-ink); }
.banner.valid strong { font-size: 1.05rem; }
.banner.void { background: var(--error-bg); border-color: #b00020; color: #7a0016; }
.banner.neutral { background: var(--card); color: var(--ink-2); }
.record-card { padding: 0; overflow: hidden; }
.record-photo {
  display: flex; align-items: center; justify-content: center; height: 300px; margin: 0;
  background: radial-gradient(circle at 50% 45%, #fff 0%, #f1ede7 100%);
}
.record-photo img { max-width: 82%; max-height: 260px; object-fit: contain; display: block; }
.record-body { padding: 18px 18px 8px; }
.report-type { margin: 0 0 4px; font: 600 11px/1.3 "Inter", sans-serif; letter-spacing: 0.14em; text-transform: uppercase; color: var(--maroon); }
.report-number { color: var(--ink); font-family: "Montserrat", sans-serif; font-weight: 400; margin: 0 0 4px; overflow-wrap: anywhere; letter-spacing: 0.02em; }
.record-facts { margin: 8px 0 0; }
.record-body h2 { font: 600 12px/1.3 "Inter", sans-serif; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin: 22px 0 8px; }
.equipment { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; margin: 0 0 12px; }
.equipment li { font-size: 13px; padding: 6px 10px; border-radius: 999px; background: var(--page); border: 1px solid var(--line); }

/* Legacy import (M9) */
.table-wrap { overflow-x: auto; }
table.printed { width: 100%; border-collapse: collapse; font-size: 14px; }
table.printed th, table.printed td { text-align: left; vertical-align: top; padding: 8px 10px; border-bottom: 1px solid var(--line-soft); }
table.printed thead th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
table.printed tbody th { color: var(--muted); font-weight: 400; width: 30%; }
.legacy-photos { margin-top: 12px; }

/* Sign-in and the sign-in link (D-79) */
.login-help { margin-top: 20px; display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 14px; color: var(--muted); }
.login-help svg { width: 24px; height: 24px; flex: none; color: var(--maroon); }
.login-help p { margin: 0; }
.link-box { display: flex; align-items: center; gap: 8px; background: var(--page); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 6px 8px 12px; margin: 0 0 14px; }
.link-box code { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: 0.8rem; color: var(--ink-2); }
.link-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.link-actions .button { width: 100%; }
.person-head { display: flex; align-items: center; gap: 14px; margin: 0 0 18px; }
.person-head .avatar { width: 56px; height: 56px; border-radius: 28px; font-size: 22px; font-family: "Montserrat", sans-serif; font-weight: 400; }
.person-head h1 { margin: 0; }
.person-head p { margin: 0; }

/* Help (M10): one page per role, printable */
.guide h2 { font-size: 1.1rem; margin: 1rem 0 0.4rem; }
.guide .card h2:first-child { margin-top: 0; }
.guide ul { padding-left: 20px; margin: 0 0 8px; }
.guide li { margin: 4px 0; }
@media print {
  .site-header, .site-footer, .messages, .side-nav, .top-bar, .tab-bar { display: none; }
  body { background: #fff; font-size: 11pt; }
  .app { display: block; }
  .card { border: 0; padding: 0; margin: 0 0 8px; box-shadow: none; }
  .site-main, .app .site-main { padding: 0; max-width: none; }
}
