/* HerdMatch app styles. Design rules live in AGENTS.md (Digital Field Almanac): high contrast, 48px targets, flat 1.5px borders, Inter, tabular numbers.
   Three looks (Field, Dark, Demo) differ only in tokens, fonts, weights, lines and surface styling: never in size or layout. */
:root {
  --bg: #F6F4EE; --surface: #FFFFFF; --sunk: #ECE8DC; --ink: #181A17; --muted: #52564E; --line: #D4CFC2;
  --accent: #1E4D36; --accent-ink: #FFFFFF; --accent-soft: #F0F7F3; --accent-mid: rgba(30,77,54,.5); --copper: #B85D19; --brand-red: #C00000;
  --warn: #B45309; --warn-soft: #FEF3C7; --bad: #A62626; --bad-soft: #FDECEC; --good: #216E43; --good-soft: #E6F2EB; --grey-bar: #B9B3A3;
  --f: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --r: 8px; --bw: 1.5px; --tap: 48px; --gap: 12px;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]):not([data-theme="demo"]) { color-scheme: dark; --bg: #141512; --surface: #1D1F1B; --sunk: #272A24; --ink: #F1EFE8; --muted: #BDBAAE; --line: #4A4C44; --accent: #7CC39A; --accent-ink: #0E1A13; --accent-soft: rgba(124,195,154,.14); --accent-mid: rgba(124,195,154,.5); --copper: #E8934F; --brand-red: #E5484D; --warn: #F0B866; --warn-soft: rgba(240,184,102,.16); --bad: #F08A84; --bad-soft: rgba(240,138,132,.16); --good: #79C995; --good-soft: rgba(121,201,149,.16); --grey-bar: #5C5A52 } }
:root[data-theme="dark"] { color-scheme: dark; --bg: #141512; --surface: #1D1F1B; --sunk: #272A24; --ink: #F1EFE8; --muted: #BDBAAE; --line: #4A4C44; --accent: #7CC39A; --accent-ink: #0E1A13; --accent-soft: rgba(124,195,154,.14); --accent-mid: rgba(124,195,154,.5); --copper: #E8934F; --brand-red: #E5484D; --warn: #F0B866; --warn-soft: rgba(240,184,102,.16); --bad: #F08A84; --bad-soft: rgba(240,138,132,.16); --good: #79C995; --good-soft: rgba(121,201,149,.16); --grey-bar: #5C5A52 }
/* Demo look: neutral charcoal, electric blue, cyan data accents. Presentation only. */
:root[data-theme="demo"] { color-scheme: dark; --bg: #121315; --surface: #1C1D20; --sunk: #26272B; --ink: #F4F5F7; --muted: #A4A8B0; --line: #2E3034; --accent: #0A5CFF; --accent-ink: #FFFFFF; --accent-soft: rgba(10,92,255,.16); --accent-mid: rgba(10,92,255,.6); --copper: #00B8F0; --brand-red: #FF5A44; --warn: #F5A524; --warn-soft: rgba(245,165,36,.16); --bad: #FF6F61; --bad-soft: rgba(255,111,97,.16); --good: #3DD26E; --good-soft: rgba(61,210,110,.16); --grey-bar: #3B3E44; --r: 12px; --bw: 1px }

* { box-sizing: border-box }
[x-cloak] { display: none !important }
html { -webkit-text-size-adjust: 100% }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 16px/1.5 var(--f); font-variant-numeric: tabular-nums }
:root:not([data-theme="demo"]) body { font-weight: 500 }
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -.01em; text-wrap: balance }
h1 { font-size: 24px } h2 { font-size: 19px } h3 { font-size: 16px }
p { margin: 0 } small, .small { font-size: 15px } .muted { color: var(--muted) } .num { font-variant-numeric: tabular-nums }
a { color: var(--accent) } :focus-visible { outline: 3px solid var(--copper); outline-offset: 2px }
.sr { position: absolute; left: -9999px } .row { display: flex; gap: var(--gap); align-items: center; flex-wrap: wrap } .grow { flex: 1 1 0; min-width: 0 } .stack { display: grid; gap: var(--gap) }
.right { margin-left: auto } .hide { display: none !important } .mono { font-variant-numeric: tabular-nums }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: var(--bw) solid var(--line); box-shadow: inset 0 3px 0 var(--brand-red) }
:root[data-theme="demo"] .topbar { box-shadow: none }
.topbar .in { max-width: 1280px; margin: 0 auto; padding: 8px 16px 0; display: flex; gap: var(--gap); align-items: center; flex-wrap: wrap }
.brand { display: inline-flex; align-items: center; min-height: var(--tap); font-size: 21px; font-weight: 700; letter-spacing: -.02em; text-decoration: none; color: var(--ink); padding-right: 8px } .brand i { font-style: normal; color: var(--brand-red) }
:root[data-theme="demo"] .brand i { color: var(--ink) }
.nav { display: flex; gap: 2px; flex-wrap: wrap } .nav a { display: flex; align-items: center; min-height: var(--tap); padding: 0 12px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: 15px; border-bottom: 3px solid transparent }
.nav a:hover { color: var(--ink) } .nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent) }
:root[data-theme="demo"] .nav a[aria-current="page"] { background: var(--sunk); border-radius: var(--r); border-bottom-color: transparent }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--grey-bar); display: inline-block } .dot.on { background: var(--good) }
.themes { display: flex } .themes .seg { border-radius: 0; margin-left: -1px } .themes .seg:first-child { border-radius: var(--r) 0 0 var(--r); margin-left: 0 } .themes .seg:last-child { border-radius: 0 var(--r) var(--r) 0 }

/* layout */
.page { max-width: 1280px; margin: 0 auto; padding: 20px 16px 96px; display: grid; gap: 20px }
.pagehead { display: flex; gap: var(--gap); align-items: center; flex-wrap: wrap } .pagehead h1 { margin-right: auto }
.grid { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)) } .grid.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)) }
.card { background: var(--surface); border: var(--bw) solid var(--line); border-radius: var(--r); padding: 16px; display: grid; gap: var(--gap); align-content: start }
.card.sel { border: 2.5px solid var(--accent); background: var(--accent-soft); padding: 14.5px }
:root[data-theme="demo"] .card.sel { border-width: 1.5px; padding: 15px }
.stat { display: grid; gap: 2px } .stat b { font-size: 28px; line-height: 1.1; font-weight: 700 } .stat span { color: var(--muted); font-size: 15px }
.split { display: grid; grid-template-columns: minmax(260px, 35%) 1fr; gap: 20px; align-items: start } @media (max-width: 860px) { .split { grid-template-columns: 1fr } }

/* controls (48px targets, 12px gaps) */
.btn, .seg { min-height: var(--tap); padding: 0 16px; border: var(--bw) solid var(--ink); border-radius: var(--r); background: var(--surface); color: var(--ink); font: 600 15px var(--f); display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; cursor: pointer; white-space: nowrap }
.btn:hover { background: var(--sunk) } .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink) } .btn.primary:hover { filter: brightness(1.12) }
.btn.danger { border-color: var(--bad); color: var(--bad) } .btn.ghost { border-color: transparent; background: transparent } .btn:disabled { opacity: .5; cursor: not-allowed }
.seg { border-radius: 0 } .seg[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink) }
.iconbtn { width: var(--tap); height: var(--tap); padding: 0; border: var(--bw) solid var(--line); border-radius: var(--r); background: var(--surface); color: var(--ink); cursor: pointer; display: inline-grid; place-items: center; font: 700 16px var(--f) }
.iconbtn.sm { width: 48px; height: 48px }
:root[data-theme="demo"] .btn, :root[data-theme="demo"] .seg, :root[data-theme="demo"] .iconbtn { border-color: var(--line) } :root[data-theme="demo"] .btn.primary { border-color: var(--accent) }
label.f { display: grid; gap: 4px; font-size: 15px; font-weight: 600 } label.f .h { color: var(--muted); font-weight: 500 }
input[type=text], input[type=email], input[type=number], input[type=date], input[type=tel], select, textarea { font: 500 16px var(--f); color: var(--ink); background: var(--surface); border: var(--bw) solid var(--line); border-radius: var(--r); padding: 0 12px; min-height: var(--tap); width: 100%; min-width: 0 }
textarea { padding: 10px 12px; min-height: 96px; resize: vertical } :root[data-theme="demo"] input, :root[data-theme="demo"] select, :root[data-theme="demo"] textarea { background: var(--bg) }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--copper); outline-offset: 1px }
.toggle { display: flex; align-items: center; gap: 12px; min-height: var(--tap); padding: 0 12px; border: var(--bw) solid var(--line); border-radius: var(--r); background: var(--surface); font-weight: 600; cursor: pointer }
.toggle input { width: 28px; height: 28px; accent-color: var(--accent) } .toggle:has(input:checked) { border: 2.5px solid var(--accent); background: var(--accent-soft); padding: 0 10.5px }
:root[data-theme="demo"] .toggle:has(input:checked) { border-width: 1.5px; padding: 0 11px }
.stepper { display: flex; align-items: center; gap: 12px } .stepper output { min-width: 72px; text-align: center; font-weight: 700 }
input[type=range] { accent-color: var(--copper); min-height: var(--tap); width: 100% }

/* chips, tables, bars */
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 15px; font-weight: 600; padding: 2px 8px; border-radius: var(--r); background: var(--sunk); color: var(--muted); white-space: nowrap }
.chip.ok { background: var(--good-soft); color: var(--good) } .chip.warn { background: var(--warn-soft); color: var(--warn) } .chip.bad { background: var(--bad-soft); color: var(--bad) } .chip.acc { background: var(--accent-soft); color: var(--accent) }
:root[data-theme="demo"] .chip.ok { background: #DDF7E5; color: #0F7A31 } :root[data-theme="demo"] .chip.warn { background: #FFF0D1; color: #8A5300 } :root[data-theme="demo"] .chip.bad { background: #FFE2DE; color: #A3281B } :root[data-theme="demo"] .chip.acc { background: #DCE8FF; color: #0A3FBF }
.tablewrap { overflow-x: auto } table { border-collapse: collapse; width: 100%; font-size: 15px } th { text-align: left; color: var(--muted); font-weight: 700; padding: 8px 10px; border-bottom: var(--bw) solid var(--line); white-space: nowrap }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle } td.n, th.n { text-align: right; font-variant-numeric: tabular-nums } tr.click { cursor: pointer } tr.click:hover td { background: var(--sunk) }
.bar { height: 14px; background: var(--sunk); border-radius: 7px; overflow: hidden; position: relative } .bar > i { display: block; height: 100%; background: var(--accent); border-radius: 7px }
.delta.up { color: var(--good); font-weight: 700 } .delta.down { color: var(--warn); font-weight: 700 } .delta.flat { color: var(--muted); font-weight: 700 }
.empty { border: var(--bw) dashed var(--line); border-radius: var(--r); padding: 24px; text-align: center; color: var(--muted) }
.tabs { display: flex; gap: 4px; border-bottom: var(--bw) solid var(--line); overflow-x: auto } .tabs a { padding: 0 14px; min-height: var(--tap); display: flex; align-items: center; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; white-space: nowrap } .tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent) }

/* modal and toast */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 40; display: grid; place-items: start center; padding: 5vh 12px; overflow-y: auto }
.modal { background: var(--surface); border: var(--bw) solid var(--line); border-radius: var(--r); width: min(640px, 100%); display: grid; gap: var(--gap); padding: 20px } .modal.wide { width: min(900px, 100%) }
.modal header { display: flex; gap: var(--gap); align-items: center } .modal header h2 { margin-right: auto }
.toasts { pointer-events: none; position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 60; display: grid; gap: 8px; width: min(440px, calc(100% - 24px)) }
.toast a { pointer-events: auto } .toast { pointer-events: none; background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: var(--r); font-weight: 600 } .toast.bad { background: var(--bad); color: #fff }
pre.json { margin: 0; background: var(--sunk); padding: 12px; border-radius: var(--r); overflow: auto; max-height: 320px; font: 500 13.5px/1.45 ui-monospace, Menlo, monospace; white-space: pre-wrap; word-break: break-word }

/* Herdi chat */
.chat { display: grid; grid-template-columns: 260px 1fr; gap: 16px; min-height: 70vh } @media (max-width: 860px) { .chat { grid-template-columns: 1fr } }
.convlist { display: grid; gap: 8px; align-content: start } .conv { display: block; padding: 10px 12px; border: var(--bw) solid var(--line); border-radius: var(--r); text-decoration: none; color: var(--ink); min-height: var(--tap) } .conv[aria-current="page"] { border: 2.5px solid var(--accent); background: var(--accent-soft); padding: 8.5px 10.5px }
.thread { display: grid; grid-template-rows: 1fr auto; gap: 12px; min-height: 60vh } .msgs { display: grid; gap: 12px; align-content: start; padding: 4px }
.bubble { max-width: min(640px, 92%); padding: 12px 14px; border-radius: var(--r); border: var(--bw) solid var(--line); background: var(--surface); white-space: pre-wrap; display: grid; gap: 6px }
.bubble.user { margin-left: auto; background: var(--accent-soft); border-color: var(--accent-mid) } .bubble .meta { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 15px }
.step { display: flex; gap: 10px; align-items: center; padding: 6px 10px; border: var(--bw) dashed var(--line); border-radius: var(--r); color: var(--muted); font-size: 15px; max-width: min(640px, 92%) }
.composer { display: grid; gap: 8px; position: sticky; bottom: 0; background: var(--bg); padding-top: 8px }
.working { color: var(--muted); font-weight: 600 }

/* customer page (mobile first) */
.cust { max-width: 560px; margin: 0 auto; padding: 16px 16px 120px; display: grid; gap: 16px }
.stamp { display: grid; gap: 2px; padding-bottom: 12px; border-bottom: var(--bw) solid var(--line) } .stamp b { font-size: 20px }
.note { border-left: 4px solid var(--accent); padding: 12px 16px; background: var(--surface); border-radius: 0 var(--r) var(--r) 0; font-size: 18px; font-weight: 600; display: grid; gap: 6px } .note footer { font-size: 15px; color: var(--muted); font-weight: 700 }
.dock { position: fixed; left: 0; right: 0; bottom: 0; height: 64px; background: var(--surface); border-top: var(--bw) solid var(--line); display: flex; align-items: center; gap: 12px; padding: 0 16px calc(env(safe-area-inset-bottom, 0px)); z-index: 30; justify-content: center }
.dock .who { min-width: 0; flex: 1 1 auto; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px } .dock .btn { min-width: 84px }
.fit { font-size: 22px; font-weight: 700 } .bull { display: grid; gap: 6px; padding: 12px 0; border-top: 1px solid var(--line) } .bull:first-of-type { border-top: 0 }
details.proof > summary { min-height: var(--tap); display: flex; align-items: center; font-weight: 700; cursor: pointer }
@media (max-width: 640px) { .topbar .in { gap: 8px } .nav a { padding: 0 10px } }
@media (prefers-reduced-motion: no-preference) { .bubble, .toast, .modal { animation: pop .12s ease-out } @keyframes pop { from { opacity: 0; transform: translateY(4px) } } }

.err { color: var(--bad); font-weight: 600; font-size: 15px } .okline { color: var(--good); font-weight: 600 }

pre.text { margin: 0; background: var(--sunk); padding: 12px; border-radius: var(--r); overflow: auto; max-height: 320px; font: 500 15px/1.5 var(--f); white-space: pre-wrap; word-break: break-word }
.formrows { display: grid; grid-template-columns: minmax(110px, 30%) 1fr; gap: 6px 12px; font-size: 15px } .formrows dt { color: var(--muted); font-weight: 600 } .formrows dd { margin: 0; white-space: pre-line }
.proposal { border: 2.5px solid var(--copper); background: var(--surface); border-radius: var(--r); padding: 14px; display: grid; gap: 10px; max-width: min(640px, 100%) } :root[data-theme='demo'] .proposal { border-width: 1.5px }
.proposal .was { color: var(--muted); text-decoration: line-through; margin-right: 6px }
.linkchips { display: flex; gap: 8px; flex-wrap: wrap }
