/* Bettergrow order bot — admin panel
   One shared stylesheet. No build step. System font stack.
   Sections: 1 tokens · 2 base · 3 layout · 4 components · 5 page bits · 6 mobile */

/* 1 ─ TOKENS ─────────────────────────────────────────── */
:root {
  /* neutrals (cool, low chroma) */
  --bg: #F6F6F8;
  --surface: #FFFFFF;
  --surface-2: #F0F0F4;
  --surface-3: #FAFAFC;
  --ink: #14131F;
  --muted: #4F4F5A;      /* 8.3:1 on white */
  --subtle: #676772;     /* 5.6:1 on white */
  --border: #E2E2E9;
  --border-strong: #C4C4CF;

  /* accent */
  --accent: #5A53CB;     /* 5.6:1 on white */
  --accent-hover: #3F39A8;
  --accent-soft: #ECEBFB;

  /* status (text colours all ≥ 5.5:1 on their tint) */
  --info-bg: #EEEFFB;  --info-fg: #2F2A8A;  --info-bd: #CBC8F2;
  --warn-bg: #FFF4DC;  --warn-fg: #6B4400;  --warn-bd: #EBC877;
  --err-bg:  #FCEBED;  --err-fg:  #98192A;  --err-bd:  #EFB5BD;
  --ok-bg:   #E5F4EB;  --ok-fg:   #1A5E36;  --ok-bd:   #A6D8B9;
  --neu-bg:  #EEEEF2;  --neu-fg:  #474752;  --neu-bd:  #D2D2DB;

  /* type */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --fs-xs: 12px;   /* labels, meta */
  --fs-sm: 13px;   /* secondary text, table headers */
  --fs-base: 14px; /* tables, forms */
  --fs-md: 15px;   /* body */
  --fs-lg: 17px;   /* card titles */
  --fs-xl: 20px;   /* section titles */
  --fs-2xl: 26px;  /* page title */
  --fs-3xl: 30px;  /* stat numbers */

  /* spacing — 4px grid */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px;
  --s-6: 24px; --s-8: 32px; --s-10: 40px; --s-12: 48px;

  /* radius */
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-pill: 999px;

  --shadow: 0 1px 2px rgba(20, 19, 31, .05);
  --container: 1280px;
}

/* 2 ─ BASE ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: var(--fs-md)/1.5 var(--font); }
h1, h2, h3 { margin: 0; line-height: 1.25; text-wrap: balance; }
p { margin: 0; text-wrap: pretty; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
code, .mono { font-family: var(--mono); font-size: .92em; }
.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; }
.muted { color: var(--muted); }
.subtle { color: var(--subtle); }
.nowrap { white-space: nowrap; }
.skip { position: absolute; left: 8px; top: -60px; background: var(--ink); color: #fff; padding: 8px 12px; border-radius: var(--r-sm); z-index: 10; }
.skip:focus { top: 8px; color: #fff; }

/* 3 ─ LAYOUT ─────────────────────────────────────────── */
.container { max-width: var(--container); margin: 0 auto; padding: 0 var(--s-6); }
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar__inner { display: flex; align-items: center; gap: var(--s-2) var(--s-8); min-height: 60px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 700; font-size: var(--fs-md); }
.brand:hover { color: var(--ink); }
.brand__mark { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 14px; font-weight: 800; }
.brand__sub { color: var(--subtle); font-weight: 500; }
.nav { display: flex; gap: var(--s-1); }
.nav a { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 14px; border-radius: 8px; color: var(--muted); font-weight: 500; font-size: var(--fs-base); text-decoration: none; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-hover); font-weight: 650; }
.nav__count { min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--r-pill); background: var(--err-fg); color: #fff; font-size: 11.5px; font-weight: 700; display: inline-grid; place-items: center; }
.topbar__meta { margin-left: auto; font-size: var(--fs-sm); color: var(--subtle); }

.banner-slot { display: flex; flex-direction: column; gap: var(--s-2); padding-top: var(--s-4); }
.banner-slot:empty { display: none; }
main { padding-bottom: var(--s-12); }
.foot { font-size: var(--fs-xs); color: var(--subtle); padding-top: var(--s-6); padding-bottom: var(--s-8); border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-4); }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s-3) var(--s-6); margin: var(--s-6) 0 var(--s-5); }
.page-head h1 { font-size: var(--fs-2xl); font-weight: 700; letter-spacing: -.01em; display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3); }
.page-meta { margin-top: 6px; font-size: var(--fs-sm); color: var(--muted); display: flex; flex-wrap: wrap; gap: 2px 0; }
.page-meta > * + *::before { content: "·"; margin: 0 8px; color: var(--subtle); }
.page-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.crumbs { font-size: var(--fs-sm); margin-bottom: 6px; display: flex; flex-wrap: wrap; gap: 6px; color: var(--subtle); }

.stack { display: flex; flex-direction: column; gap: var(--s-4); }
.stack-lg { display: flex; flex-direction: column; gap: var(--s-6); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-4); align-items: start; }
.grid-main-side { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: var(--s-4); align-items: start; }
.section-title { font-size: var(--fs-xl); font-weight: 700; display: flex; align-items: baseline; gap: var(--s-3); margin-bottom: var(--s-3); }
.section-title small { font-size: var(--fs-sm); font-weight: 400; color: var(--muted); }

/* 4 ─ COMPONENTS ─────────────────────────────────────── */

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink); font: inherit; font-size: var(--fs-base); font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn--ghost { border-color: transparent; background: transparent; color: var(--accent); }
.btn--ghost:hover { background: var(--accent-soft); color: var(--accent-hover); }
.btn--sm { min-height: 32px; padding: 0 12px; font-size: var(--fs-sm); }

/* Card / form card */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow); min-width: 0; }
.card__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-2) var(--s-4); padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--border); }
.card__title { font-size: var(--fs-lg); font-weight: 650; display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.card__desc { font-size: var(--fs-sm); color: var(--muted); margin-top: 2px; }
.card__body { padding: var(--s-5); }
.card__body > * + * { margin-top: var(--s-4); }
.card__foot { padding: var(--s-3) var(--s-5); border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; background: var(--surface-3); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.card--flush > .card__body { padding: 0; }

/* Status icon shapes (shape + colour + text — never colour alone) */
.icon { width: 18px; height: 18px; flex: none; display: inline-grid; place-items: center; color: #fff; font-size: 11px; font-weight: 800; line-height: 1; font-family: var(--font); }
.icon--info { background: var(--info-fg); border-radius: 50%; }
.icon--warn { background: var(--warn-fg); clip-path: polygon(50% 0, 100% 100%, 0 100%); padding-top: 5px; }
.icon--error { background: var(--err-fg); clip-path: polygon(30% 0, 70% 0, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0 70%, 0 30%); }
.icon--ok { background: var(--ok-fg); border-radius: 50%; }

/* Banners: info / warning / error / success */
.banner { display: flex; align-items: flex-start; gap: var(--s-3); padding: var(--s-3) var(--s-4); border: 1px solid; border-radius: var(--r-md); font-size: var(--fs-base); }
.banner .icon { margin-top: 2px; }
.banner__body { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; gap: 2px var(--s-2); align-items: baseline; }
.banner__title { font-weight: 700; }
.banner__action { margin-left: auto; white-space: nowrap; font-weight: 600; }
.banner--info    { background: var(--info-bg); border-color: var(--info-bd); color: var(--info-fg); }
.banner--warning { background: var(--warn-bg); border-color: var(--warn-bd); color: var(--warn-fg); }
.banner--error   { background: var(--err-bg);  border-color: var(--err-bd);  color: var(--err-fg); }
.banner--success { background: var(--ok-bg);   border-color: var(--ok-bd);   color: var(--ok-fg); }
.banner--neutral { background: var(--neu-bg);  border-color: var(--neu-bd);  color: var(--neu-fg); }
.banner a { color: inherit; }
.banner pre { flex-basis: 100%; margin: 6px 0 0; font-family: var(--mono); font-size: 12.5px; white-space: pre-wrap; background: rgba(255,255,255,.6); padding: 8px 10px; border-radius: var(--r-sm); color: var(--ink); }

/* Status pill — reading · questions_open · awaiting_confirmation · confirmed · discarded · superseded · failed */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 1px 10px 1px 8px; border-radius: var(--r-pill); border: 1px solid transparent; font-size: 12.5px; font-weight: 600; line-height: 20px; white-space: nowrap; vertical-align: middle; }
.pill::before { content: ""; width: 8px; height: 8px; flex: none; background: currentColor; border-radius: 50%; }
.pill--reading { background: var(--info-bg); color: var(--info-fg); }
.pill--reading::before { background: transparent; border: 2px solid currentColor; }            /* ring */
.pill--questions_open { background: var(--warn-bg); color: var(--warn-fg); border-color: var(--warn-bd); }
.pill--questions_open::before { border-radius: 1px; transform: rotate(45deg); width: 7px; height: 7px; } /* diamond */
.pill--awaiting_confirmation { background: var(--accent-soft); color: var(--accent-hover); }
.pill--awaiting_confirmation::before { background: linear-gradient(90deg, currentColor 50%, transparent 50%); border: 1.5px solid currentColor; } /* half */
.pill--confirmed { background: var(--ok-bg); color: var(--ok-fg); }                            /* dot */
.pill--discarded { background: var(--neu-bg); color: var(--neu-fg); }
.pill--discarded::before { width: 8px; height: 2px; border-radius: 1px; }                       /* dash */
.pill--superseded { background: transparent; color: var(--neu-fg); border: 1px dashed var(--border-strong); }
.pill--superseded::before { width: 8px; height: 5px; border-radius: 0; background: none; border-top: 2px solid currentColor; border-bottom: 2px solid currentColor; } /* double bar */
.pill--failed { background: var(--err-bg); color: var(--err-fg); border-color: var(--err-bd); }
.pill--failed::before { border-radius: 1px; }                                                    /* square */
.pill--sm { font-size: 12px; line-height: 18px; padding: 0 8px 0 6px; }

/* Stale-data badge */
.stale { display: inline-flex; align-items: center; gap: 5px; padding: 0 7px; border: 1px dashed var(--warn-fg); border-radius: var(--r-sm); background: var(--warn-bg); color: var(--warn-fg); font-size: 12px; font-weight: 600; line-height: 20px; white-space: nowrap; vertical-align: middle; }
.stale::before { content: ""; width: 9px; height: 9px; border: 1.5px solid currentColor; border-radius: 50%; background: linear-gradient(currentColor, currentColor) 50% 1px / 1.5px 4px no-repeat; }

/* Generic tags */
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 0 7px; border-radius: 5px; background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 500; line-height: 20px; white-space: nowrap; }
.tag--code { font-family: var(--mono); font-size: 11.5px; }
.tag--accent { background: var(--accent-soft); color: var(--accent-hover); }

/* ERPNext push status */
.push { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); white-space: nowrap; }
.push::before { content: ""; width: 8px; height: 8px; flex: none; }
.push--pushed { color: var(--ok-fg); font-weight: 600; }
.push--pushed::before { background: currentColor; border-radius: 50%; }
.push--not_pushed { color: var(--muted); }
.push--not_pushed::before { border: 1.5px solid currentColor; border-radius: 50%; }
.push--failed { color: var(--err-fg); font-weight: 600; }
.push--failed::before { background: currentColor; border-radius: 1px; }
.push--na { color: var(--subtle); }
.push--na::before { display: none; }

/* Stat tile */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--s-3); }
.stat { display: flex; flex-direction: column; gap: 6px; padding: var(--s-3) var(--s-4) var(--s-4); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); color: var(--ink); text-decoration: none; min-width: 0; }
a.stat:hover { border-color: var(--accent); color: var(--ink); }
.stat__value { font-size: var(--fs-3xl); font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat__sub { font-size: var(--fs-xs); color: var(--muted); }
.stat--zero .stat__value { color: var(--subtle); font-weight: 500; }

/* Form fields */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.label, .field > label, legend.label { font-size: var(--fs-sm); font-weight: 600; color: var(--ink); padding: 0; }
.hint { font-size: var(--fs-xs); color: var(--muted); }
.input, .select { width: 100%; height: 40px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); color: var(--ink); font: inherit; font-size: var(--fs-base); }
.select { appearance: none; padding-right: 32px; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%234F4F5A' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat right 12px center; }
.input:hover, .select:hover { border-color: var(--muted); }
.input--short { max-width: 120px; }
.field--error .input, .field--error .select { border-color: var(--err-fg); box-shadow: 0 0 0 1px var(--err-fg); }
.field__error { display: flex; gap: 6px; align-items: flex-start; font-size: var(--fs-sm); color: var(--err-fg); font-weight: 600; }
.field__error .icon { width: 14px; height: 14px; font-size: 9px; margin-top: 2px; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }

/* Segmented radio (works without JS) */
.seg { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.seg label { position: relative; display: block; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span { display: flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); font-size: var(--fs-base); font-weight: 500; }
.seg span::before { content: ""; width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid var(--border-strong); flex: none; }
.seg input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-hover); font-weight: 650; box-shadow: inset 0 0 0 1px var(--accent); }
.seg input:checked + span::before { border: 4px solid var(--accent); }
.seg input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Switch */
.switch { display: flex; align-items: center; gap: 10px; font-size: var(--fs-base); cursor: pointer; min-height: 40px; }
.switch input { appearance: none; width: 40px; height: 24px; margin: 0; flex: none; border-radius: var(--r-pill); background: var(--border-strong); position: relative; cursor: pointer; }
.switch input::before { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .15s; }
.switch input:checked { background: var(--accent); }
.switch input:checked::before { transform: translateX(16px); }

/* Filter bar */
.filters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(0, 2fr) auto; gap: var(--s-3); align-items: end; padding: var(--s-4); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); }
.filters__actions { display: flex; gap: var(--s-2); align-items: center; }

/* Data table (stacked cards below 760px — see section 6) */
.table-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; }
.table-card__head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--s-2); padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--border); font-size: var(--fs-sm); color: var(--muted); }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-base); }
.table th { text-align: left; padding: 10px 14px; background: var(--surface-3); border-bottom: 1px solid var(--border); font-size: var(--fs-xs); font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-3); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tfoot td { font-weight: 700; background: var(--surface-3); border-top: 1px solid var(--border); border-bottom: 0; }
.cell-sub { display: block; font-size: var(--fs-xs); color: var(--muted); margin-top: 2px; }
.cell-stack { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.row-link { font-weight: 600; text-decoration: none; }
.row-link:hover { text-decoration: underline; }
.q-row td { background: var(--surface-3); padding-top: 0; }
.table tr.has-q td { border-bottom: 0; }

/* Pagination */
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-3) var(--s-4); border-top: 1px solid var(--border); font-size: var(--fs-sm); color: var(--muted); }
.pager__links { display: flex; flex-wrap: wrap; gap: 4px; }
.pager__links a, .pager__links span { min-width: 36px; height: 36px; padding: 0 10px; display: grid; place-items: center; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--ink); text-decoration: none; font-weight: 500; }
.pager__links a:hover { border-color: var(--accent); }
.pager__links [aria-current="page"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.pager__links .is-disabled { color: var(--subtle); background: var(--surface-3); }

/* Severity chip */
.sev { display: inline-flex; align-items: center; gap: 6px; padding: 0 8px; border-radius: var(--r-sm); font-size: 11.5px; font-weight: 750; letter-spacing: .05em; text-transform: uppercase; line-height: 22px; white-space: nowrap; }
.sev__bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 11px; }
.sev__bars i { width: 3px; border-radius: 1px; background: currentColor; opacity: .25; }
.sev__bars i:nth-child(1) { height: 5px; } .sev__bars i:nth-child(2) { height: 8px; } .sev__bars i:nth-child(3) { height: 11px; }
.sev--high { background: var(--err-bg); color: var(--err-fg); }
.sev--high i { opacity: 1; }
.sev--medium { background: var(--warn-bg); color: var(--warn-fg); }
.sev--medium i:nth-child(-n+2) { opacity: 1; }
.sev--low { background: var(--neu-bg); color: var(--neu-fg); }
.sev--low i:nth-child(1) { opacity: 1; }

/* Flag (expandable) + evidence rows */
.flag + .flag { border-top: 1px solid var(--border); }
.flag > summary { list-style: none; display: grid; grid-template-columns: 92px minmax(0, 1fr) auto auto; gap: var(--s-2) var(--s-5); align-items: start; padding: var(--s-4) var(--s-5); cursor: pointer; }
.flag > summary::-webkit-details-marker { display: none; }
.flag > summary:hover { background: var(--surface-3); }
.flag__kind { font-weight: 650; }
.flag__who { color: var(--muted); font-weight: 500; }
.flag__text { font-size: var(--fs-base); color: var(--ink); margin-top: 2px; }
.flag__count { text-align: right; font-size: var(--fs-xl); font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.flag__count small { display: block; font-size: var(--fs-xs); color: var(--muted); font-weight: 500; }
.flag__toggle { font-size: var(--fs-sm); font-weight: 600; color: var(--accent); white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; padding-top: 2px; }
.flag__toggle::before { content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg) translateY(-2px); transition: transform .15s; }
.flag__toggle::after { content: "Show evidence"; }
.flag[open] .flag__toggle::before { transform: rotate(225deg) translate(-2px, -1px); }
.flag[open] .flag__toggle::after { content: "Hide evidence"; }
.flag__evidence { padding: 0 var(--s-5) var(--s-5); }
.flag__evidence .table-card { border-radius: var(--r-sm); }
.change { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.change__from { padding: 0 6px; border-radius: 5px; background: var(--neu-bg); color: var(--neu-fg); font-size: var(--fs-xs); font-weight: 600; line-height: 20px; }
.change__arrow { color: var(--subtle); }
.change__to { padding: 0 6px; border-radius: 5px; background: var(--accent-soft); color: var(--accent-hover); font-size: var(--fs-xs); font-weight: 600; line-height: 20px; }
.written { font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); padding: 1px 6px; border-radius: 4px; }

/* Key/value list and facts row */
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px var(--s-5); margin: 0; font-size: var(--fs-base); }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--s-4) var(--s-5); margin: 0; }
.facts > div { min-width: 0; }
.facts dt { font-size: var(--fs-xs); color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.facts dd { margin: 0; font-size: var(--fs-md); font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.facts dd .cell-sub { font-weight: 400; }

/* Source text / transcript */
.source { margin: 0; padding: var(--s-3) var(--s-4); background: var(--surface-2); border-radius: 8px; font-family: var(--mono); font-size: 13px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.transcript { margin: 0; padding: var(--s-3) var(--s-4); background: var(--surface-3); border: 1px solid var(--border); border-radius: 8px; font-size: var(--fs-base); line-height: 1.6; }
.meter { display: inline-block; width: 64px; height: 6px; border-radius: var(--r-pill); background: var(--surface-2); vertical-align: middle; overflow: hidden; margin-right: 6px; box-shadow: inset 0 0 0 1px var(--border); }
.meter > span { display: block; height: 100%; background: var(--accent); }

/* Audio player */
.audio { display: flex; flex-direction: column; gap: 8px; padding: var(--s-3); background: var(--surface-2); border-radius: var(--r-md); }
.audio__meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; font-size: var(--fs-sm); }
.audio__name { font-weight: 600; }
.audio audio { width: 100%; height: 40px; display: block; }

/* Image thumbnail */
.thumbs { display: flex; flex-wrap: wrap; gap: var(--s-3); }
.thumb { display: flex; flex-direction: column; gap: 6px; width: 124px; color: var(--ink); text-decoration: none; font-size: var(--fs-xs); }
.thumb:hover { color: var(--accent); }
.thumb__img { aspect-ratio: 3 / 4; border-radius: 8px; border: 1px solid var(--border); overflow: hidden; display: grid; place-items: center; background: repeating-linear-gradient(135deg, #ECECF1 0 8px, #F5F5F8 8px 16px); color: var(--subtle); font-family: var(--mono); font-size: 11px; text-align: center; padding: 6px; }
.thumb__img img { width: 100%; height: 100%; object-fit: cover; }
.thumb__img--doc { background: var(--surface); box-shadow: inset 0 -28px 0 var(--surface-2); font-weight: 700; color: var(--err-fg); font-size: 13px; }
.thumb:hover .thumb__img { border-color: var(--accent); }
.thumb__cap { font-weight: 600; overflow-wrap: anywhere; }
.thumb__cap small { display: block; color: var(--muted); font-weight: 400; }

/* Lettered options shown to the salesperson */
.question { padding: var(--s-3) var(--s-4); border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); }
.question__head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-bottom: 8px; font-size: var(--fs-base); }
.options { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; font-size: var(--fs-base); }
.options li { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 8px; align-items: baseline; padding: 5px 8px; border-radius: 6px; }
.options__letter { font-family: var(--mono); font-weight: 700; color: var(--muted); }
.options__score { font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; }
.options li.is-chosen { background: var(--ok-bg); color: var(--ok-fg); font-weight: 600; }
.options li.is-chosen .options__letter, .options li.is-chosen .options__score { color: var(--ok-fg); }

/* Timeline of corrections */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: var(--s-3); padding: var(--s-3) 0; }
.timeline li + li { border-top: 1px solid var(--border); }
.timeline time { font-size: var(--fs-sm); color: var(--muted); font-variant-numeric: tabular-nums; padding-top: 2px; }
.timeline__msg { font-size: var(--fs-base); }
.timeline__msg q { font-family: var(--mono); font-size: 13px; background: var(--surface-2); padding: 1px 6px; border-radius: 4px; quotes: none; }
.timeline__change { margin-top: 6px; font-size: var(--fs-sm); color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* Chat thread (as the salesperson saw it: their messages right, bot left) */
.thread { display: flex; flex-direction: column; gap: 10px; padding: var(--s-4); background: var(--surface-2); border-radius: var(--r-md); }
.msg { max-width: min(560px, 88%); display: flex; flex-direction: column; gap: 4px; }
.msg--sp { align-self: flex-end; align-items: flex-end; }
.msg--bot { align-self: flex-start; }
.msg__bubble { padding: 8px 12px; border-radius: 12px; font-size: var(--fs-base); line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; border: 1px solid var(--border); background: var(--surface); }
.msg--sp .msg__bubble { background: var(--accent-soft); border-color: #D8D6F6; border-bottom-right-radius: 4px; }
.msg--bot .msg__bubble { border-bottom-left-radius: 4px; }
.msg__meta { font-size: 11.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.msg__who { font-weight: 650; color: var(--ink); }
.msg--failed .msg__bubble { border: 1px dashed var(--err-fg); background: var(--err-bg); }
.msg__fail { color: var(--err-fg); font-weight: 650; display: inline-flex; gap: 4px; align-items: center; }
.msg__fail .icon { width: 12px; height: 12px; font-size: 8px; }
.msg .audio { min-width: 240px; background: var(--surface); }

/* Draft block in chat detail */
.draft__head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3); }
.draft__title { font-weight: 650; font-size: var(--fs-md); }
.draft__meta { font-size: var(--fs-sm); color: var(--muted); }
.draft__open { margin-left: auto; }

/* Status counts list */
.counts { display: flex; flex-wrap: wrap; gap: 4px; list-style: none; margin: 0; padding: 0; }

/* Empty state */
.empty { text-align: center; padding: var(--s-12) var(--s-6); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.empty__mark { width: 44px; height: 44px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; margin-bottom: 6px; }
.empty__mark::before { content: ""; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border-strong); }
.empty__title { font-weight: 650; font-size: var(--fs-md); }
.empty__text { font-size: var(--fs-base); color: var(--muted); max-width: 46ch; }
.empty--sm { padding: var(--s-6) var(--s-4); }

/* Details (raw JSON etc.) */
.disclose > summary { cursor: pointer; font-weight: 600; font-size: var(--fs-base); color: var(--accent); padding: 4px 0; }
.disclose pre { margin: var(--s-2) 0 0; max-height: 320px; overflow: auto; }

/* 5 ─ PAGE BITS ──────────────────────────────────────── */

/* Settings: show only the fields the chosen frequency needs.
   Pure CSS (:has) so it works with JS off. Browsers without :has show every field. */
.freq-fields { display: flex; flex-wrap: wrap; gap: var(--s-4); align-items: flex-end; margin-top: var(--s-4); }
.freq-fields > [data-for] { display: flex; }
@supports selector(:has(*)) {
  .freq-fields > [data-for] { display: none; }
  .sched:has(input[value="hours"]:checked)   .freq-fields > [data-for~="hours"],
  .sched:has(input[value="daily"]:checked)   .freq-fields > [data-for~="daily"],
  .sched:has(input[value="weekly"]:checked)  .freq-fields > [data-for~="weekly"],
  .sched:has(input[value="monthly"]:checked) .freq-fields > [data-for~="monthly"],
  .sched:has(input[value="manual"]:checked)  .freq-fields > [data-for~="manual"] { display: flex; }
  .prices:has(input[name="prices_mode"][value="live"]:checked) .prices__snapshot { display: none; }
}
.master-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-4); margin: 0; padding: var(--s-4) var(--s-5); background: var(--surface-3); border-top: 1px solid var(--border); }
.master-facts dt { font-size: var(--fs-xs); color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.master-facts dd { margin: 4px 0 0; font-size: var(--fs-base); font-weight: 600; font-variant-numeric: tabular-nums; }
.master-facts .is-error dd { color: var(--err-fg); }
.master-facts .span-all { grid-column: 1 / -1; }
.savebar { position: sticky; bottom: 0; z-index: 2; margin-top: var(--s-6); padding: var(--s-3) var(--s-4); background: rgba(255,255,255,.96); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: 0 -4px 16px rgba(20,19,31,.06); display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--s-3); }
.savebar__note { margin-right: auto; font-size: var(--fs-sm); color: var(--muted); }

/* ERPNext calls */
.calls { display: grid; grid-template-columns: minmax(0, 260px) minmax(0, 1fr); gap: var(--s-6); align-items: start; }
.calls__totals { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-4); }
.calls__num { font-size: 40px; font-weight: 700; line-height: 1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.calls__label { font-size: var(--fs-sm); color: var(--muted); margin-top: 6px; }
.bar { height: 8px; border-radius: var(--r-pill); background: var(--surface-2); overflow: hidden; min-width: 60px; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.table .bar-cell { width: 34%; vertical-align: middle; }

/* Components page */
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--s-3); }
.swatch { border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; background: var(--surface); font-size: var(--fs-xs); }
.swatch__chip { height: 52px; }
.swatch__txt { padding: 8px 10px; display: flex; flex-direction: column; }
.swatch__txt b { font-size: var(--fs-sm); }
.spec-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); }

/* page: chats — the still-open-questions summary atop a chat's latest
   draft (chat_detail.html); every other chats-page bit reuses components
   already defined above (table, counts, draft__head, status pill...). */
.plain-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-2); font-size: var(--fs-base); }
.plain-list li { padding: 6px 10px; border-radius: 6px; background: var(--surface-2); }

/* page: settings — bettergrow's MasterSchedule.frequency values are
   every_n_hours/daily/weekly/monthly/manual (see bettergrow.settings),
   not the handoff's plain "hours", and the price-mode radios are named
   "price_mode" (one setting shared by every master), not "prices_mode".
   The rules above already cover daily/weekly/monthly/manual verbatim (the
   value strings match); these two add the two that don't, rather than
   editing the handoff's own rules. */
@supports selector(:has(*)) {
  .sched:has(input[value="every_n_hours"]:checked) .freq-fields > [data-for~="every_n_hours"] { display: flex; }
  .prices:has(input[name="price_mode"][value="live"]:checked) .prices__snapshot { display: none; }
}
/* A disabled fieldset (the Prices card while price mode is "live") still
   renders at full strength by default in most browsers; dim it so it
   reads as inactive, matching every disabled .btn below it. */
fieldset.card:disabled { opacity: .6; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* 6 ─ MOBILE ─────────────────────────────────────────── */
@media (max-width: 960px) {
  .grid-main-side, .calls { grid-template-columns: minmax(0, 1fr); }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters .field--search, .filters__actions { grid-column: 1 / -1; }
  .master-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .container { padding: 0 var(--s-4); }
  .topbar__inner { padding-top: var(--s-2); gap: var(--s-2); }
  .topbar__meta { display: none; }
  .nav { order: 3; flex: 1 1 100%; margin: 0 calc(var(--s-2) * -1); }
  .nav a { flex: 1; min-height: 44px; padding: 0 6px; border-radius: 8px 8px 0 0; }
  .nav a[aria-current="page"] { background: transparent; box-shadow: inset 0 -3px 0 var(--accent); }
  .page-head { margin-top: var(--s-5); }
  .page-head h1 { font-size: 22px; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-2); }
  .stat__value { font-size: 24px; }
  .btn { min-height: 44px; }
  .btn--sm { min-height: 36px; }
  .input, .select { height: 44px; font-size: 16px; }
  .card__head, .card__body { padding-left: var(--s-4); padding-right: var(--s-4); }
  .card__foot { padding-left: var(--s-4); padding-right: var(--s-4); }
  .banner__action { margin-left: 0; }
  .calls__num { font-size: 32px; }

  /* Mobile table pattern: stacked cards, everywhere. */
  .table--stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table--stack, .table--stack tbody, .table--stack tfoot, .table--stack tr, .table--stack td { display: block; }
  .table--stack tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--border); }
  .table--stack tbody tr:last-child { border-bottom: 0; }
  .table--stack td { padding: 0; border: 0; min-width: 0; }
  .table--stack td[data-label]::before { content: attr(data-label); display: block; font-size: 11px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 2px; }
  .table--stack td.cell-primary { grid-column: 1 / -1; order: -1; font-size: var(--fs-md); }
  .table--stack td.cell-primary::before { display: none; }
  .table--stack td.cell-full { grid-column: 1 / -1; }
  .table--stack .num { text-align: left; }
  .table--stack td:empty { display: none; }
  .table--stack tr.has-q { border-bottom: 0; padding-bottom: 0; }
  .table--stack .q-row td { background: transparent; grid-column: 1 / -1; }
  .table--stack tfoot tr { background: var(--surface-3); }
  .table .bar-cell { width: auto; }

  .flag > summary { grid-template-columns: minmax(0, 1fr) auto; padding: var(--s-4); }
  .flag__main { grid-column: 1 / -1; order: 2; }
  .flag__count { order: 3; text-align: left; display: flex; align-items: baseline; gap: 6px; font-size: var(--fs-lg); }
  .flag__count small { display: inline; }
  .flag__toggle { order: 4; justify-self: end; }
  .flag__evidence { padding: 0 var(--s-3) var(--s-4); }
  .master-facts { padding: var(--s-4); }
  .savebar { margin-left: calc(var(--s-4) * -1); margin-right: calc(var(--s-4) * -1); border-radius: 0; border-width: 1px 0 0; }
  .savebar .btn { flex: 1; }
  .msg { max-width: 92%; }
  .thread { padding: var(--s-3); }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .kv dd { margin-bottom: 8px; }
}

/* --- Translations (client decision 2026-10-03) ------------------------- */
/* An English rendering shown alongside a non-English original — "written",
   "source" or "transcript" text, or a line's "as written" quote. Styled as
   a quieter, italic second line so the original stays the primary read. */
.translation { display: inline-block; font-style: italic; color: var(--muted); font-size: var(--fs-sm); }
.label--translation { color: var(--accent); }
.transcript--translation { background: var(--accent-soft); border-color: var(--accent); font-style: italic; }
