/* ═══════════════════════════════════════════════════════════════
   THE BOOK: Treble Clef Cricket's CRM
   The website's maroon and cream, set as a calm working tool:
   sentence-case UI type, one accent colour, colour only where it
   carries meaning (status, payment).
   ═══════════════════════════════════════════════════════════════ */
:root {
  --bg: #F4EFE5; --surface: #FFFDF8; --surface-2: #FAF6EE;
  --line: #E6DDCB; --line-2: #F0E9DC;
  --ink: #1F1714; --ink-2: #66564B; --ink-3: #9B8C80;
  --maroon: #79241D; --maroon-deep: #5C1A14; --maroon-50: #F7EAE7;
  --side: #2B0E0B; --side-ink: #EFE7D4;
  --ok: #2F6B3F; --wa: #1F7A47;
  --r: 12px; --r-sm: 8px;
  --sh: 0 1px 2px rgba(43, 14, 11, .05), 0 1px 0 rgba(43, 14, 11, .03);
  --sh-lg: 0 18px 50px rgba(43, 14, 11, .18);
  --f-ui: 'Barlow', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --f-display: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --f-mono: 'DM Mono', ui-monospace, monospace;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 400 15px/1.5 var(--f-ui); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.15; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.mono { font-family: var(--f-mono); font-size: 12px; }
code { font-family: var(--f-mono); font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--line); padding: 1px 5px; border-radius: 4px; }
[hidden] { display: none !important; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg.ic { width: 14px; height: 14px; }
.hint { margin: 0 0 14px; color: var(--ink-2); font-size: 14px; }

/* ── buttons ─────────────────────────────────────────────────── */
.b {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 38px; padding: 0 14px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: var(--r-sm); cursor: pointer;
  font-weight: 600; font-size: 14px; text-decoration: none; white-space: nowrap; box-shadow: var(--sh);
  transition: background .15s, border-color .15s, color .15s;
}
.b:hover { border-color: var(--ink-3); background: var(--surface-2); }
.b--solid { background: var(--maroon); border-color: var(--maroon); color: #fff; }
.b--solid:hover { background: var(--maroon-deep); border-color: var(--maroon-deep); }
.b--lg { min-height: 46px; font-size: 15px; }
.b--sm { min-height: 32px; padding: 0 10px; font-size: 13px; }
.b--wa { background: var(--wa); border-color: var(--wa); color: #fff; }
.b--wa:hover { background: #17603A; border-color: #17603A; }
.b--link { border: 0; background: none; box-shadow: none; min-height: auto; padding: 0; color: var(--maroon); font-weight: 600; }
.b--link:hover { background: none; text-decoration: underline; }
.x { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: var(--ink-2); font-size: 20px; cursor: pointer; flex: none; line-height: 1; }
.x:hover { color: var(--ink); border-color: var(--ink-3); }

/* ── fields ──────────────────────────────────────────────────── */
.stack { display: grid; gap: 14px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fld { display: grid; gap: 5px; }
.fld > span { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.fld input, .fld select, .fld textarea, .select {
  width: 100%; border: 1px solid var(--line); background: var(--surface); padding: 9px 11px; border-radius: var(--r-sm); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.fld input:focus, .fld select:focus, .fld textarea:focus, .select:focus { border-color: var(--maroon); box-shadow: 0 0 0 3px var(--maroon-50); }
.select { width: auto; min-height: 38px; padding: 0 30px 0 11px; font-weight: 500; font-size: 14px; cursor: pointer; appearance: none; -webkit-appearance: none;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%2366564B' stroke-width='1.5'/%3E%3C/svg%3E") right 11px center no-repeat; }
.msg { margin: 0; padding: 10px 12px; border-radius: var(--r-sm); background: var(--maroon-50); color: var(--maroon-deep); font-size: 14px; }

/* ── sign-in ─────────────────────────────────────────────────── */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(1200px 600px at 50% -10%, #EADFCB, var(--bg)); }
.gate__card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 32px; display: grid; gap: 20px; box-shadow: var(--sh-lg); }
.gate__logo { width: 96px; }
.gate h1 { font-family: var(--f-display); font-weight: 800; font-size: 40px; text-transform: uppercase; color: var(--maroon); line-height: 1; margin-bottom: 6px; }
.gate .muted { margin: 0; }
.gate__demo { border-top: 1px solid var(--line); padding-top: 18px; display: grid; gap: 12px; font-size: 14px; }
.gate__demo p { margin: 0; }

/* ── app frame ───────────────────────────────────────────────── */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; background: var(--side); color: var(--side-ink);
  display: flex; flex-direction: column; padding: 18px 12px; gap: 18px; overflow-y: auto;
}
.side__brand { display: flex; align-items: center; gap: 11px; color: var(--side-ink); text-decoration: none; padding: 4px 8px 6px; }
.side__brand img { height: 40px; width: auto; }
.side__brand b { display: block; font-family: var(--f-display); font-weight: 800; font-size: 23px; text-transform: uppercase; letter-spacing: .02em; line-height: 1; }
.side__brand small { display: block; font-size: 12px; opacity: .6; margin-top: 3px; }
.side__nav { display: grid; gap: 2px; }
.side__label { font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; opacity: .45; padding: 14px 10px 6px; }
.side__nav button {
  display: flex; align-items: center; gap: 11px; width: 100%; padding: 9px 10px; border: 0; border-radius: var(--r-sm);
  background: transparent; color: rgba(239, 231, 212, .78); cursor: pointer; font-weight: 500; font-size: 14.5px; text-align: left;
}
.side__nav button:hover { background: rgba(239, 231, 212, .07); color: var(--side-ink); }
.side__nav button[aria-selected="true"] { background: var(--side-ink); color: var(--side); font-weight: 600; }
.side__nav button span { flex: 1; }
.n { font-style: normal; font-size: 11.5px; font-weight: 700; min-width: 22px; height: 20px; padding: 0 6px; border-radius: 10px; display: inline-grid; place-items: center; background: #E0453A; color: #fff; }
.n:empty { display: none; }
.n--soft { background: rgba(239, 231, 212, .14); color: inherit; font-weight: 600; }
.side__nav button[aria-selected="true"] .n--soft { background: rgba(43, 14, 11, .1); }
.side__foot { margin-top: auto; display: grid; gap: 2px; border-top: 1px solid rgba(239, 231, 212, .12); padding-top: 12px; }
.side__foot a, .side__foot button {
  display: flex; align-items: center; gap: 11px; padding: 8px 10px; border: 0; border-radius: var(--r-sm); background: none;
  color: rgba(239, 231, 212, .7); text-decoration: none; font-size: 14px; cursor: pointer; text-align: left;
}
.side__foot a:hover, .side__foot button:hover { background: rgba(239, 231, 212, .07); color: var(--side-ink); }
.side__user { font-size: 12px; opacity: .5; padding: 6px 10px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side__scrim { display: none; }

.main { min-width: 0; display: flex; flex-direction: column; }
.demo-bar { background: #FFE58A; color: #4A3A00; text-align: center; font-size: 13px; padding: 7px 16px; }
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 18px 32px; background: rgba(244, 239, 229, .92); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.top__menu { display: none; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); cursor: pointer; place-items: center; }
.top__title { min-width: 0; }
.top__kicker { margin: 0 0 2px; font-size: 13px; color: var(--ink-3); }
.top h1 { font-size: 26px; font-weight: 700; letter-spacing: -.01em; }
.top__acts { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.search { display: flex; align-items: center; gap: 8px; width: 300px; height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: var(--ink-3); box-shadow: var(--sh); }
.search:focus-within { border-color: var(--maroon); box-shadow: 0 0 0 3px var(--maroon-50); }
.search input { border: 0; outline: none; background: none; width: 100%; color: var(--ink); font-size: 14px; }
.views { padding: 24px 32px 80px; max-width: 1480px; width: 100%; }

/* ── overview ────────────────────────────────────────────────── */
.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; box-shadow: var(--sh);
  text-align: left; cursor: pointer; display: grid; gap: 4px; transition: border-color .15s, transform .15s;
}
.stat:hover { border-color: var(--ink-3); transform: translateY(-1px); }
.stat span { font-size: 13px; color: var(--ink-2); font-weight: 500; }
.stat b { font-family: var(--f-display); font-weight: 700; font-size: 34px; line-height: 1; color: var(--ink); }
.stat small { font-size: 12.5px; color: var(--ink-3); }
.stat--alert { border-color: #F0C4BE; background: #FFF6F4; }
.stat--alert b { color: #B3261E; }
.ov { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; box-shadow: var(--sh); min-width: 0; }
.box--wide { grid-column: 1 / -1; }
.box__head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; }
.box h2 { font-size: 16px; font-weight: 700; }
.feed { display: grid; }
.feed__row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 11px 8px; margin: 0 -8px;
  border-radius: var(--r-sm); cursor: pointer; border-top: 1px solid var(--line-2);
}
.feed__row:first-child { border-top: 0; }
.feed__row:hover { background: var(--surface-2); }
.feed__row b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed__row .sub { grid-column: 1; font-size: 13px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed__row .end { grid-row: 1 / span 2; grid-column: 2; display: grid; justify-items: end; align-content: center; gap: 4px; font-size: 13px; color: var(--ink-3); }
.feed__row .amt { font-weight: 700; color: var(--ink); font-size: 14.5px; }
.feed--grid { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 32px; }
.feed--grid .feed__row:nth-child(2) { border-top: 0; }
.feed__empty { padding: 18px 0 6px; color: var(--ink-3); font-size: 14px; }

/* ── toolbar, chips, segmented ───────────────────────────────── */
.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .hint { margin: 0; }
.toolbar__r { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button {
  display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 13px; border-radius: 17px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); font-size: 13.5px; font-weight: 500; color: var(--ink-2);
}
.chips button:hover { border-color: var(--ink-3); color: var(--ink); }
.chips button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.chips button i { font-style: normal; font-size: 12px; font-weight: 700; opacity: .6; }
.seg { display: inline-flex; padding: 3px; background: var(--line-2); border: 1px solid var(--line); border-radius: 10px; gap: 2px; }
.seg button, .seg label span { display: block; background: transparent; border: 0; padding: 6px 12px; cursor: pointer; border-radius: 7px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.seg button[aria-pressed="true"], .seg input:checked + span { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.seg label { position: relative; flex: 1; text-align: center; }
.seg input { position: absolute; opacity: 0; }
.seg--full { display: flex; }

/* ── status + type pills ─────────────────────────────────────── */
.tag {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 11px;
  font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--line-2); color: var(--ink-2);
}
.tag::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.tag--order { background: #F7EAE7; color: #8E2A21; }
.tag--fitting { background: #E4F0E8; color: #23603A; }
.tag--club { background: #E5EAF4; color: #27406E; }
.tag--enquiry { background: #FBF0D9; color: #8A5A0B; }
.tag--paid { background: #E4F0E8; color: #23603A; }
.tag--unpaid { background: var(--line-2); color: var(--ink-2); }
.tag--deposit { background: #FBF0D9; color: #8A5A0B; }
.tag--refunded { background: #FBE4E1; color: #A3261B; }
.tag--s-new { background: #FBE4E1; color: #A3261B; }
.tag--s-contacted { background: #E5EDF8; color: #2552A0; }
.tag--s-confirmed { background: #E4F0E8; color: #23603A; }
.tag--s-awaiting_payment { background: #FBF0D9; color: #8A5A0B; }
.tag--s-ready { background: #DDF1EE; color: #146B5E; }
.tag--s-done { background: #ECE7DF; color: #5E544C; }
.tag--s-lost { background: #EFEBE7; color: #8A7F77; }
.tag--s-checkout { background: #FBF0D9; color: #8A5A0B; }

/* ── tables ──────────────────────────────────────────────────── */
.tblwrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--sh); overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; font-weight: 600; color: var(--ink-3); padding: 11px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: var(--surface-2); }
.tbl .num { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl td .mono, .tbl td.mono { color: var(--ink-3); }
.tbl td b { font-weight: 600; }
.tbl .sub { display: block; font-size: 13px; color: var(--ink-2); }
.tbl select, .tbl input { border: 1px solid var(--line); background: var(--surface); padding: 5px 8px; border-radius: 6px; font-size: 13px; }
.tbl td a { color: var(--maroon); }
.tbl .row-new td:first-child { box-shadow: inset 3px 0 0 #E0453A; }
.day { font-size: 15px; font-weight: 700; margin: 26px 0 10px; display: flex; align-items: center; gap: 10px; }
.day::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.day:first-child { margin-top: 0; }
.empty { padding: 44px 20px; border: 1px dashed var(--line); border-radius: var(--r); text-align: center; color: var(--ink-2); background: var(--surface); }
.swatch { display: inline-block; width: 30px; height: 12px; border-radius: 3px; vertical-align: middle; margin-right: 8px; }

/* ── kanban ──────────────────────────────────────────────────── */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: 272px; gap: 12px; overflow-x: auto; padding-bottom: 14px; align-items: start; scroll-snap-type: x proximity; }
.col { background: var(--line-2); border: 1px solid var(--line); border-radius: var(--r); min-height: 220px; display: flex; flex-direction: column; scroll-snap-align: start; }
.col.is-over { background: #E9E0CF; border-color: var(--ink-3); }
.col__head { display: flex; align-items: center; gap: 8px; padding: 12px 12px 8px; }
.col__head h3 { font-size: 14px; font-weight: 700; }
.col__head .mono { margin-left: auto; color: var(--ink-3); }
.col__body { padding: 0 8px 10px; display: grid; gap: 8px; }
.col--lost { opacity: .8; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; cursor: grab; display: grid; gap: 5px; box-shadow: var(--sh); }
.card:hover { border-color: var(--ink-3); }
.card.is-drag { opacity: .4; }
.card__top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card__top .mono { color: var(--ink-3); }
.card b { font-weight: 600; font-size: 15px; line-height: 1.25; }
.card .it { font-size: 13px; color: var(--ink-2); }
.card .small { color: var(--ink-2); }
.card__foot { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; color: var(--ink-3); padding-top: 6px; border-top: 1px solid var(--line-2); margin-top: 2px; }
.card__foot b { font-size: 13px; color: var(--ink); }
.card--new { box-shadow: inset 3px 0 0 #E0453A, var(--sh); }

/* ── KPI strip (payments, emails) ────────────────────────────── */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; box-shadow: var(--sh); }
.kpi b { display: block; font-family: var(--f-display); font-weight: 700; font-size: 28px; line-height: 1.05; }
.kpi span { font-size: 13px; color: var(--ink-2); }

.rackform { display: grid; grid-template-columns: 1fr 1.4fr 1.1fr 1fr .7fr 1fr .9fr auto; gap: 10px; align-items: end; margin-bottom: 16px; }

/* ── side panel ──────────────────────────────────────────────── */
.panel { position: fixed; inset: 0; z-index: 70; visibility: hidden; }
.panel.is-open { visibility: visible; }
.panel__scrim { position: absolute; inset: 0; background: rgba(31, 23, 20, .35); opacity: 0; transition: opacity .25s; }
.panel.is-open .panel__scrim { opacity: 1; }
.panel__in {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(600px, 100%); background: var(--bg); box-shadow: var(--sh-lg);
  display: flex; flex-direction: column; transform: translateX(100%); transition: transform .3s cubic-bezier(.2, .7, .1, 1);
}
.panel.is-open .panel__in { transform: none; }
.panel__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 20px 24px; background: var(--surface); border-bottom: 1px solid var(--line); }
.panel__ref { font-size: 13px; color: var(--ink-3); }
.panel__head h2 { font-size: 24px; font-weight: 700; margin: 3px 0 8px; }
.panel__tags { display: flex; gap: 6px; flex-wrap: wrap; }
.panel__body { overflow: auto; padding: 18px 24px 48px; display: grid; gap: 14px; align-content: start; }
.blk { display: grid; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.blk > .mono { font-family: var(--f-ui); font-size: 13px; font-weight: 700; color: var(--ink); }
.blk--card { border-color: #BFD9C6; background: #F6FBF7; }
.blk--card > .mono { color: var(--ok); }
.blk--card .b { justify-self: start; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 7px 12px; font-size: 14px; margin: 0; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.lines .ln { display: grid; grid-template-columns: 1fr auto; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.lines .ln:last-child { border-bottom: 0; }
.lines .ln b { font-weight: 600; }
.lines .ln span { font-size: 13px; color: var(--ink-2); }
.lines .ln .p { font-weight: 600; text-align: right; }
.total { display: flex; justify-content: space-between; font-weight: 700; font-size: 15px; padding-top: 10px; border-top: 1px solid var(--line); }
.contact { display: flex; flex-wrap: wrap; gap: 8px; }
.tpl { display: grid; gap: 6px; }
.tpl button { text-align: left; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 9px 11px; cursor: pointer; font-size: 13.5px; color: var(--ink-2); }
.tpl button b { color: var(--ink); }
.tpl button:hover { border-color: var(--wa); background: #F2F9F4; }
.notebox { width: 100%; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); padding: 10px 12px; outline: none; resize: vertical; }
.notebox:focus { border-color: var(--maroon); box-shadow: 0 0 0 3px var(--maroon-50); }
.note { padding: 10px 12px; background: var(--surface-2); border-radius: var(--r-sm); font-size: 14px; white-space: pre-wrap; }
.note .mono { display: block; margin-bottom: 3px; color: var(--ink-3); font-size: 11.5px; }

.snack { position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 160%); background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 10px; font-weight: 500; font-size: 14px; box-shadow: var(--sh-lg); transition: transform .3s; z-index: 80; visibility: hidden; }
.snack.is-on { transform: translate(-50%, 0); visibility: visible; }

/* ── responsive ──────────────────────────────────────────────── */
@media (max-width: 1280px) {
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ov { grid-template-columns: 1fr 1fr; }
  .feed--grid { grid-template-columns: 1fr; }
  .feed--grid .feed__row:nth-child(2) { border-top: 1px solid var(--line-2); }
  .rackform { grid-template-columns: repeat(4, 1fr); }
  .search { width: 220px; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 60; left: 0; top: 0; bottom: 0; width: 264px; transform: translateX(-100%); transition: transform .3s cubic-bezier(.2, .7, .1, 1); }
  .app.menu-open .side { transform: none; box-shadow: var(--sh-lg); }
  .app.menu-open .side__scrim { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(31, 23, 20, .35); }
  .top__menu { display: inline-grid; }
  .top { padding: 12px 16px; gap: 12px; }
  .top h1 { font-size: 21px; }
  .top__acts { width: 100%; margin-left: 0; }
  .search { flex: 1; width: auto; }
  .views { padding: 16px 16px 80px; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat b { font-size: 28px; }
  .ov { grid-template-columns: 1fr; }
  .two { grid-template-columns: 1fr; }
  .rackform { grid-template-columns: 1fr 1fr; }
  .toolbar__r { margin-left: 0; }
  .chips { flex-wrap: nowrap; overflow-x: auto; width: 100%; padding-bottom: 2px; }
  .chips button { flex: none; }
  .tbl { white-space: nowrap; }
  .board { grid-auto-columns: 84vw; }
  .kv { grid-template-columns: 96px 1fr; }
}
@media (max-width: 480px) {
  .stat:last-child { grid-column: 1 / -1; }
}

/* refinements */
.app { background: linear-gradient(to right, var(--side) 248px, var(--bg) 248px); }
.fld select, .tbl select {
  appearance: none; -webkit-appearance: none; cursor: pointer; padding-right: 30px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%2366564B' stroke-width='1.5'/%3E%3C/svg%3E") right 11px center no-repeat;
}
.tbl select { padding: 6px 28px 6px 10px; border-radius: var(--r-sm); font-weight: 500; min-width: 150px; }
.tbl select:hover { border-color: var(--ink-3); }
.tpls summary { cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--ink-2); list-style: none; display: flex; align-items: center; gap: 6px; }
.tpls summary::-webkit-details-marker { display: none; }
.tpls summary::before { content: '▸'; font-size: 11px; transition: transform .15s; }
.tpls[open] summary::before { transform: rotate(90deg); }
.tpls[open] summary { margin-bottom: 10px; }
.cards { display: grid; gap: 10px; }
.cards .card { cursor: pointer; }
.card__top > span:last-child { display: inline-flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 900px) { .app { background: var(--bg); } }

/* card orders: pack and send */
.ov { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tag--s-packed { background: #E5EDF8; color: #2552A0; }
.tag--s-shipped { background: #DDF1EE; color: #146B5E; }
.tag--s-refunded { background: #FBE4E1; color: #A3261B; }
.tag--plain { background: var(--line-2); color: var(--ink-2); }
.tag--plain::before { display: none; }
.blk--next { border-color: #D9CBB2; }
.blk--next .b--lg { width: 100%; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; counter-reset: s; }
.steps li { counter-increment: s; position: relative; padding-top: 30px; font-size: 12.5px; font-weight: 600; color: var(--ink-3); text-align: center; }
.steps li::before {
  content: counter(s); position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center; font-size: 12px; background: var(--line-2); border: 1px solid var(--line); color: var(--ink-3); z-index: 1;
}
.steps li + li::after { content: ''; position: absolute; top: 12px; right: 50%; width: calc(100% + 6px); height: 2px; background: var(--line); }
.steps li.is-done, .steps li.is-now { color: var(--ink); }
.steps li.is-done::before { content: '✓'; background: var(--ok); border-color: var(--ok); color: #fff; }
.steps li.is-now::before { background: var(--maroon); border-color: var(--maroon); color: #fff; box-shadow: 0 0 0 4px var(--maroon-50); }
.steps li.is-done + li::after, .steps li.is-done + li.is-now::after { background: var(--ok); }
.card__foot .b { margin: -2px 0; }
@media (max-width: 900px) { .ov { grid-template-columns: 1fr; } }

/* ── simple version: one list, one button per row ─────────────── */
.side__nav { padding-top: 14px; gap: 4px; }
.side__nav button { padding: 11px 12px; font-size: 15px; }
.stats--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.seg button i { font-style: normal; font-size: 12px; font-weight: 700; margin-left: 4px; padding: 1px 7px; border-radius: 9px; background: rgba(0, 0, 0, .07); }
.seg button[aria-pressed="true"] i { background: #E0453A; color: #fff; }
.seg button { padding: 8px 16px; font-size: 14px; }
.list { display: grid; gap: 8px; }
.row {
  display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(0, 1.2fr) 110px 190px; align-items: center; gap: 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 18px; box-shadow: var(--sh); cursor: pointer;
  transition: border-color .15s;
}
.row:hover { border-color: var(--ink-3); }
.row--plain { cursor: default; }
.row__main { min-width: 0; display: grid; gap: 2px; }
.row__main b { font-size: 15.5px; font-weight: 600; }
.row__main span, .row__meta span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__main span { color: var(--ink-2); font-size: 14px; }
.row__meta { display: grid; gap: 2px; font-size: 13.5px; color: var(--ink-2); min-width: 0; }
.row__meta span:last-child { color: var(--ink-3); font-size: 13px; }
.row__amt { font-weight: 700; font-size: 16px; text-align: right; font-variant-numeric: tabular-nums; }
.row__act { display: flex; justify-content: flex-end; }
.row__act .b { min-width: 150px; }
.row__act .b--link { min-width: 0; }
.tag--tosend, .tag--new { background: #FBE4E1; color: #A3261B; }
.tag--sent { background: #E4F0E8; color: #23603A; }
.tag--replied { background: #E5EDF8; color: #2552A0; }
.tag--closed { background: #ECE7DF; color: #5E544C; }
.quote { margin: 0; padding: 10px 12px; background: var(--surface-2); border-radius: var(--r-sm); font-size: 14px; color: var(--ink-2); font-style: italic; }
.addr { margin: 0; white-space: pre-line; font-size: 16px; line-height: 1.45; }
.blk--done { border-color: #BFD9C6; background: #F6FBF7; }
.blk--done > .mono { color: var(--ok); }
.blk .seg--full button { flex: 1; text-align: center; }
.tpl button { line-height: 1.45; }
@media (max-width: 1100px) { .stats--4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 760px) {
  .row { grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; padding: 14px; }
  .row__main { grid-column: 1; }
  .row__amt { grid-column: 2; grid-row: 1; align-self: start; }
  .row__meta { grid-column: 1 / -1; grid-template-columns: auto auto; justify-content: start; gap: 12px; }
  .row__act { grid-column: 1 / -1; justify-content: stretch; }
  .row__act .b { width: 100%; }
  .row__act .b--link, .row__act .tag { width: auto; }
  .kpis { grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
  .kpi { padding: 10px 12px; } .kpi b { font-size: 22px; }
  .toolbar .seg { width: 100%; } .toolbar .seg button { flex: 1; }
  .stats--4 .stat:last-child { grid-column: auto; }
}

/* ── products ────────────────────────────────────────────────── */
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.pcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; box-shadow: var(--sh); cursor: pointer; display: flex; flex-direction: column; transition: border-color .15s, transform .15s; }
.pcard:hover { border-color: var(--ink-3); transform: translateY(-2px); }
.pcard.is-off .pcard__img img { opacity: .45; filter: grayscale(.6); }
.pcard__img { position: relative; aspect-ratio: 4 / 3; background: var(--line-2); display: grid; place-items: center; color: var(--ink-3); font-size: 13px; }
.pcard__img img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.pcard__flag { position: absolute; left: 10px; top: 10px; font-style: normal; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 10px; background: var(--ink); color: #fff; }
.pcard__flag--save { left: auto; right: 10px; background: var(--ok); }
.pcard__body { padding: 12px 14px 4px; display: grid; gap: 2px; flex: 1; }
.pcard__body span { font-size: 12px; color: var(--ink-3); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.pcard__body b { font-weight: 600; font-size: 15px; line-height: 1.3; }
.pcard__body strong { font-size: 15px; margin-top: 4px; }
.pcard__body strong small { font-weight: 500; color: var(--ink-2); }
.pcard .switch { padding: 10px 14px 14px; }

.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; font-size: 14px; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch__ui { position: relative; flex: none; width: 42px; height: 24px; border-radius: 12px; background: #D6CCBA; transition: background .2s; }
.switch__ui::after { 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 .2s; }
.switch input:checked + .switch__ui { background: var(--ok); }
.switch input:checked + .switch__ui::after { transform: translateX(18px); }
.switch input:focus-visible + .switch__ui { box-shadow: 0 0 0 3px var(--maroon-50); }
.switch--sm { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.switch--sm .switch__ui { width: 36px; height: 20px; }
.switch--sm .switch__ui::after { width: 14px; height: 14px; }
.switch--sm input:checked + .switch__ui::after { transform: translateX(16px); }

#prodform { gap: 14px; }
.fld-note { margin: 0; font-size: 13px; color: var(--ink-2); }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.photo { position: relative; aspect-ratio: 1; border-radius: var(--r-sm); overflow: hidden; border: 2px solid transparent; cursor: pointer; background: var(--line-2); }
.photo img { width: 100%; height: 100%; object-fit: cover; }
.photo.is-main { border-color: var(--maroon); }
.photo em { position: absolute; left: 0; right: 0; bottom: 0; font-style: normal; font-size: 11px; font-weight: 700; text-align: center; padding: 3px; background: var(--maroon); color: #fff; }
.photo__x { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: rgba(31,23,20,.75); color: #fff; font-size: 16px; line-height: 1; cursor: pointer; }
.upl { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 14px; border: 1.5px dashed var(--ink-3); border-radius: var(--r-sm); cursor: pointer; font-weight: 600; font-size: 14px; color: var(--ink-2); background: var(--surface-2); }
.upl:hover { border-color: var(--maroon); color: var(--maroon); }
.upl input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.optrow { display: grid; grid-template-columns: 150px 1fr 36px; gap: 8px; }
.optrow input { border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); padding: 8px 10px; outline: none; }
.optrow input:focus { border-color: var(--maroon); }
.presets { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chipbtn { border: 1px solid var(--line); background: var(--surface); border-radius: 14px; padding: 4px 11px; font-size: 13px; font-weight: 500; cursor: pointer; }
.chipbtn:hover { border-color: var(--maroon); color: var(--maroon); }
.search-in { width: 100%; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); padding: 8px 10px; outline: none; }
.pick { display: grid; gap: 4px; max-height: 280px; overflow: auto; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 4px; background: var(--surface-2); }
.pickrow { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.pickrow:hover { background: var(--surface); }
.pickrow.is-on { background: #F2F9F4; }
.pickrow input { accent-color: var(--ok); width: 16px; height: 16px; }
.pickrow img, .pickrow > i { width: 40px; height: 40px; border-radius: 6px; object-fit: cover; background: var(--line-2); flex: none; }
.pickrow > span { flex: 1; display: grid; font-size: 14px; }
.pickrow small { color: var(--ink-2); }
.pickrow__q { display: inline-flex !important; grid: none; align-items: center; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); flex: none !important; }
.pickrow__q button { border: 0; background: none; width: 26px; height: 26px; cursor: pointer; font-size: 15px; }
.pickrow__q output { min-width: 18px; text-align: center; font-weight: 600; }
.dealsum { display: grid; gap: 6px; }
.dealsum div { display: flex; justify-content: space-between; font-size: 14px; }
.dealsum__save { padding: 8px 10px; border-radius: var(--r-sm); background: #E4F0E8; color: #23603A; }
.dealsum__save.is-bad { background: #FBF0D9; color: #8A5A0B; }
.pe-actions { display: grid; gap: 12px; justify-items: center; }
.pe-actions .b--lg { width: 100%; }
#pe-del { color: #A3261B; }

/* ── invoice ─────────────────────────────────────────────────── */
.inv__head { display: flex; justify-content: space-between; align-items: center; }
.inv { display: grid; gap: 14px; font-size: 14px; }
.inv dl { margin: 0; }
.inv__meta { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; padding: 12px; background: var(--surface-2); border-radius: var(--r-sm); }
.inv__meta dt, .inv__who dt { font-size: 12px; color: var(--ink-3); }
.inv__meta dd, .inv__who dd { margin: 0; font-weight: 600; }
.inv__tbl { width: 100%; border-collapse: collapse; }
.inv__tbl th { text-align: left; font-size: 12px; font-weight: 600; color: var(--ink-3); padding: 0 0 8px; border-bottom: 1px solid var(--line); }
.inv__tbl td { padding: 10px 0; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.inv__tbl td b { font-weight: 600; display: block; }
.inv__tbl td small { color: var(--ink-2); }
.inv__tbl .num { text-align: right; white-space: nowrap; padding-left: 12px; font-variant-numeric: tabular-nums; }
.inv__sum { display: grid; gap: 6px; margin-left: auto; width: min(280px, 100%); }
.inv__sum div { display: flex; justify-content: space-between; }
.inv__sum dt { color: var(--ink-2); } .inv__sum dd { margin: 0; font-variant-numeric: tabular-nums; }
.inv__total { padding-top: 8px; border-top: 1.5px solid var(--ink); font-weight: 700; font-size: 16px; }
.inv__total dt { color: var(--ink) !important; }
.inv__who { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding-top: 12px; border-top: 1px solid var(--line); line-height: 1.5; }
body.print { background: #fff; padding: 40px; max-width: 760px; margin: 0 auto; }
body.print h1 { font-size: 28px; margin: 24px 0 16px; }
.print__head { display: flex; justify-content: space-between; align-items: flex-start; font-size: 13px; text-align: right; color: var(--ink-2); }
.print__head img { width: 120px; }
.print__foot { margin-top: 32px; color: var(--ink-2); }
@media print { body.print { padding: 0; } }
@media (max-width: 760px) { .optrow { grid-template-columns: 1fr 1fr 36px; } .inv__who { grid-template-columns: 1fr; } }
.inv__head .mono { font-family: var(--f-ui); font-size: 13px; font-weight: 700; color: var(--ink); }
.inv__sum { justify-self: end; }
