/* Showbound — shared theme (v0.4). Rules: docs/BRAND.md. Module styles live in /css/<module>.css.
   Use the tokens below; never hard-code colors in modules. */
:root {
  /* palette */
  --concrete: #ECEFF2; --paper: #FFFFFF; --graphite: #26303A; --steel: #6B7785; --rule: #D9DEE4; --rule-soft: #E8ECF0;
  --teal: #0E7C7B; --teal-dark: #0A6463; --teal-wash: #E3F1F1;
  --gaffer: #F5C518; --gaffer-wash: #FDF6D8;
  --ok: #1F8A4C; --warn: #B7791F; --bad: #C2382F; --info: #2B6CB0;
  --ok-wash: #E4F3EA; --warn-wash: #FBF0DC; --bad-wash: #FBE7E5; --info-wash: #E5EEF8;
  /* type */
  --font-display: "DIN Alternate", "DIN 2014", "D-DIN", Bahnschrift, "Barlow Semi Condensed", "Arial Narrow", system-ui, sans-serif;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  /* shape */
  --r-ctl: 6px; --r-panel: 10px; --float: 0 12px 32px rgba(38, 48, 58, .16), 0 2px 6px rgba(38, 48, 58, .08);

  /* legacy aliases so older module CSS keeps working */
  --bg: var(--concrete); --panel: var(--paper); --ink: var(--graphite); --muted: var(--steel); --line: var(--rule);
  --accent: var(--teal); --accent-ink: #fff; --blue: var(--teal); --green: var(--ok); --amber: var(--warn); --red: var(--bad);
  --radius: var(--r-panel); --shadow: none;
  --side: var(--paper); --side-ink: var(--graphite);

  font-family: var(--font-ui); font-size: 14px; line-height: 1.45; color: var(--graphite);
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--concrete); display: flex; min-height: 100vh; }
a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--gaffer); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 700; color: var(--graphite); margin: 0; line-height: 1.15; }
h1 { font-size: 26px; letter-spacing: -.005em; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
.num, .money, .stat-value, .tbl td.r { font-variant-numeric: tabular-nums; }
.display { font-family: var(--font-display); }
.muted { color: var(--steel); }
.r { text-align: right; }
.mono { font-family: var(--font-mono); font-size: .92em; }
.pad { padding: 10px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-main-side { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1000px) { .grid-2, .grid-3, .grid-main-side { grid-template-columns: 1fr; } }

/* ───────── Navigation rail ───────── */
.sidebar { width: 232px; background: var(--paper); border-right: 1px solid var(--rule); position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; flex-shrink: 0; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 16px; color: var(--graphite); font-family: var(--font-display); font-weight: 700; font-size: 19px; text-decoration: none !important; }
.logo { width: 28px; height: 28px; border-radius: 6px; background: var(--graphite); color: var(--gaffer); display: grid; place-items: center; font-size: 12px; position: relative; overflow: hidden; }
.logo::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: var(--gaffer); }
.nav { flex: 1; overflow-y: auto; padding: 2px 10px 12px; }
.nav-group { margin-bottom: 12px; }
.nav-title { font-size: 12px; font-weight: 600; color: var(--steel); padding: 8px 10px 4px; }
.nav a { display: flex; gap: 10px; align-items: center; padding: 7px 10px; border-radius: var(--r-ctl); color: var(--graphite); text-decoration: none; position: relative; }
.nav a:hover { background: var(--concrete); }
.nav a.active { background: var(--teal-wash); color: var(--teal-dark); font-weight: 600; }
.nav a.active::before { content: ""; position: absolute; left: -10px; top: 6px; bottom: 6px; width: 3px; border-radius: 0 3px 3px 0; background: var(--teal); }
.nav .ico { width: 18px; text-align: center; opacity: .75; filter: grayscale(1); }
.nav a.active .ico { opacity: 1; }
.sidebar-foot { padding: 10px 12px; border-top: 1px solid var(--rule); font-size: 12px; color: var(--steel); }
.linkish { background: none; border: 0; color: var(--teal); cursor: pointer; padding: 0; font: inherit; text-decoration: underline dotted; }

/* ───────── Shell & command bar ───────── */
.shell { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; gap: 12px; align-items: center; padding: 10px 24px; background: var(--concrete); border-bottom: 1px solid var(--rule); position: sticky; top: 0; z-index: 20; }
.gsearch { position: relative; flex: 1; max-width: 640px; }
.gsearch input { width: 100%; height: 40px; padding-left: 38px; padding-right: 64px; background: var(--paper) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='18' height='18'%3E%3Cpath d='M3 5v14M6 5v14M9 5v14M13 5v14M16 5v14M20 5v14' stroke='%236B7785' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat 12px center; }
.gsearch .kbd { position: absolute; right: 10px; top: 10px; font-size: 11px; color: var(--steel); border: 1px solid var(--rule); border-radius: 4px; padding: 1px 6px; background: var(--concrete); pointer-events: none; }
.gsearch-results { position: absolute; top: 46px; left: 0; right: 0; background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r-panel); box-shadow: var(--float); max-height: 440px; overflow: auto; padding: 6px; }
.gsearch-results a { display: flex; gap: 10px; align-items: center; padding: 8px 10px; color: var(--graphite); border-radius: var(--r-ctl); }
.gsearch-results a:hover, .gsearch-results a.hl { background: var(--teal-wash); text-decoration: none; }
.gsearch-hint { padding: 8px 10px; font-size: 12px; color: var(--steel); border-top: 1px solid var(--rule-soft); margin-top: 4px; }
.gbarcode { display: none !important; } /* merged into the command bar */
.top-actions { margin-left: auto; display: flex; gap: 8px; }
main { padding: 24px 28px 64px; max-width: 1440px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 6px 0 0; color: var(--steel); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ───────── Forms ───────── */
input, select, textarea { font: inherit; border: 1px solid var(--rule); border-radius: var(--r-ctl); padding: 7px 10px; background: var(--paper); color: var(--graphite); min-width: 0; }
input:hover, select:hover, textarea:hover { border-color: #C3CAD2; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gaffer); outline-offset: 0; border-color: var(--graphite); }
textarea { resize: vertical; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--graphite); font-weight: 600; }
.field.full { grid-column: 1 / -1; }
.field input, .field select, .field textarea { font-weight: 400; font-size: 14px; }
.field small { font-weight: 400; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 400; font-size: 14px; padding: 6px 0; }
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input[type=search] { min-width: 260px; }

/* ───────── Buttons ───────── */
.btn { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: var(--r-ctl); border: 1px solid var(--rule); background: var(--paper); color: var(--graphite); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none !important; white-space: nowrap; }
.btn:hover { border-color: var(--steel); }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.primary:hover { background: var(--teal-dark); }
.btn.dark { background: var(--graphite); color: #fff; border-color: var(--graphite); }
.btn.danger { color: var(--bad); border-color: #EBC2BE; }
.btn.danger:hover { background: var(--bad-wash); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { background: none; border: 0; cursor: pointer; font-size: 16px; color: var(--steel); padding: 4px 8px; border-radius: var(--r-ctl); }
.icon-btn:hover { background: var(--concrete); color: var(--graphite); }

/* ───────── Panels / stats ───────── */
.card { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r-panel); margin-bottom: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px 10px; gap: 8px; }
.card-head h3 { font-size: 16px; }
.card-body { padding: 4px 16px 16px; }
.card-body > .table-wrap { margin: 0 -16px -16px; border: 0; border-top: 1px solid var(--rule); border-radius: 0 0 var(--r-panel) var(--r-panel); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0; margin-bottom: 20px; background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r-panel); overflow: hidden; }
.stat { padding: 14px 18px; border-right: 1px solid var(--rule-soft); position: relative; }
.stat:last-child { border-right: 0; }
.stat[data-href] { cursor: pointer; } .stat[data-href]:hover { background: #FAFBFC; }
.stat::before { content: ""; position: absolute; left: 0; top: 16px; bottom: 16px; width: 3px; border-radius: 0 3px 3px 0; background: transparent; }
.stat.tone-green::before { background: var(--ok); } .stat.tone-amber::before { background: var(--warn); }
.stat.tone-red::before { background: var(--bad); } .stat.tone-blue::before { background: var(--info); }
.stat-label { font-size: 13px; color: var(--steel); font-weight: 600; }
.stat-value { font-family: var(--font-display); font-size: 28px; font-weight: 700; margin-top: 2px; line-height: 1.15; }
.stat-sub { font-size: 12px; color: var(--steel); margin-top: 2px; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 7px 18px; margin: 0; }
.dl dt { color: var(--steel); } .dl dd { margin: 0; }

/* ───────── Tables ───────── */
.table-wrap { overflow-x: auto; background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r-panel); }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; font-weight: 600; color: var(--steel); background: var(--paper); padding: 10px 12px; border-bottom: 1px solid var(--rule); white-space: nowrap; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--rule-soft); vertical-align: middle; height: 44px; }
.tbl td.r { font-family: var(--font-display); font-size: 15px; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.clickable { cursor: pointer; } .tbl tr.clickable:hover td { background: #F6F8F9; }
.tbl tr.section-row td { background: var(--concrete); font-weight: 600; }
.tbl tfoot td { font-weight: 600; background: #FAFBFC; }
.tbl input, .tbl select { padding: 4px 6px; }

/* ───────── Tags (status) ───────── */
.badge { display: inline-block; padding: 2px 9px 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; line-height: 18px; }
.badge::first-letter { text-transform: uppercase; }
.badge-green { background: var(--ok-wash); color: #17673A; } .badge-blue { background: var(--info-wash); color: #22548A; }
.badge-amber { background: var(--warn-wash); color: #87590F; } .badge-red { background: var(--bad-wash); color: #962A23; }
.badge-gray { background: var(--concrete); color: var(--graphite); }

/* ───────── Show tape (the signature) ───────── */
.tape { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; color: var(--graphite); }
.tape-swatch { width: 14px; height: 10px; border-radius: 2px; background: var(--tape, var(--steel)); box-shadow: inset 0 -2px 0 rgba(0,0,0,.12); flex-shrink: 0; transform: rotate(-4deg); }
.tape-num { font-family: var(--font-display); font-variant-numeric: tabular-nums; }
.tape-strip { box-shadow: inset 4px 0 0 var(--tape, transparent); }
.tape-band { height: 6px; background: var(--tape, var(--steel)); border-radius: var(--r-panel) var(--r-panel) 0 0; }
tr.tape-strip > td:first-child { box-shadow: inset 4px 0 0 var(--tape, transparent); }

/* ───────── Tabs ───────── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--rule); margin-bottom: 18px; overflow-x: auto; }
.tab { background: none; border: 0; padding: 10px 12px; font: inherit; font-weight: 600; color: var(--steel); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; border-radius: var(--r-ctl) var(--r-ctl) 0 0; }
.tab:hover { color: var(--graphite); }
.tab.active { color: var(--graphite); border-bottom-color: var(--teal); }
.tab-count { background: var(--concrete); border-radius: 999px; padding: 0 7px; font-size: 12px; margin-left: 4px; color: var(--steel); }

/* ───────── Empty / loading ───────── */
.empty { padding: 28px; text-align: center; color: var(--steel); background: var(--paper); border: 1px dashed #C9D0D8; border-radius: var(--r-panel); }
.empty.big { padding: 64px; font-size: 16px; } .empty.err { color: var(--bad); }
.loading { padding: 40px; color: var(--steel); }

/* ───────── Modal ───────── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(38, 48, 58, .42); display: grid; place-items: center; z-index: 100; padding: 20px; }
.modal { background: var(--paper); border-radius: 12px; width: 560px; max-width: 100%; max-height: 90vh; display: flex; flex-direction: column; box-shadow: var(--float); }
.modal.wide { width: 920px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px 8px; }
.modal-body { padding: 8px 20px 16px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--rule); }

/* ───────── Toasts ───────── */
.toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: var(--graphite); color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: var(--float); transition: opacity .25s, transform .25s; max-width: 400px; border-left: 4px solid var(--ok); }
.toast-err { border-left-color: var(--bad); } .toast-warn { border-left-color: var(--gaffer); }
.toast.out { opacity: 0; transform: translateY(6px); }

/* ───────── Progress ───────── */
.progress { height: 6px; background: var(--rule-soft); border-radius: 999px; overflow: hidden; min-width: 80px; }
.progress > span { display: block; height: 100%; background: var(--teal); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* ───────── Print ───────── */
.print-only { display: none; }
@media print {
  .sidebar, .topbar, .page-actions, .no-print, .toasts, .tabs { display: none !important; }
  body { background: #fff; display: block; } main { padding: 0; max-width: none; }
  .card, .table-wrap, .stat { box-shadow: none; } .print-only { display: block; }
  .tape-swatch, .tape-band { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ───────── Compact rail on tablets (icons only; labels as tooltips) ───────── */
@media (max-width: 1000px) {
  .sidebar { width: 64px; }
  .brand { padding: 16px 0; justify-content: center; font-size: 0; gap: 0; }
  .nav { padding: 2px 8px 12px; }
  .nav-title { font-size: 0; height: 1px; padding: 0; margin: 8px 6px; background: var(--rule); }
  .nav a { font-size: 0; justify-content: center; padding: 10px 0; }
  .nav a .ico { font-size: 16px; width: auto; }
  .nav a.active::before { left: -8px; }
  .sidebar-foot { padding: 8px; }
  .sidebar-foot .sf-user-txt, .sidebar-foot .sf-user-caret { display: none; }
  main { padding: 18px 16px 48px; }
  .topbar { padding: 10px 16px; }
}
