/* Wholesale OS design system — navy/graphite with restrained gold. No external assets. */
:root {
  --bg: #0c111b;
  --surface: #121a28;
  --surface-2: #182234;
  --surface-3: #1f2b40;
  --line: #243149;
  --line-strong: #31415e;
  --text: #e8ecf3;
  --text-2: #b7c0cf;
  --muted: #8693a8;
  --gold: #c8a75e;
  --gold-strong: #dcbd73;
  --gold-soft: rgba(200, 167, 94, .12);
  --gold-line: rgba(200, 167, 94, .35);
  --ok: #5db48a;   --ok-soft: rgba(93, 180, 138, .13);
  --warn: #dba64a; --warn-soft: rgba(219, 166, 74, .13);
  --bad: #e2706b;  --bad-soft: rgba(226, 112, 107, .13);
  --info: #74a3dc; --info-soft: rgba(116, 163, 220, .13);
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 8px 24px rgba(0,0,0,.25);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, ui-serif, serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--gold-strong); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-family: var(--serif); font-size: 26px; font-weight: 500; }
h2 { font-size: 15px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
p { margin: 0 0 .6em; }
.num, td.num, .money { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); font-size: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar { background: #0a0f18; border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.brand-mark { width: 30px; height: 30px; border: 1px solid var(--gold-line); border-radius: 7px; display: grid; place-items: center;
  color: var(--gold); font-family: var(--serif); font-size: 17px; background: var(--gold-soft); }
.brand-name { font-family: var(--serif); font-size: 17px; letter-spacing: .01em; }
.brand-sub { display: block; font-size: 10.5px; color: var(--muted); letter-spacing: .14em; text-transform: uppercase; }
.nav-group { margin: 14px 0 4px; padding: 0 10px; font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.nav a { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); font-size: 13.5px; }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--gold-soft); color: var(--gold-strong); box-shadow: inset 2px 0 0 var(--gold); }
.nav a.planned { color: var(--muted); }
.nav .tag { font-size: 10px; padding: 1px 6px; border-radius: 99px; border: 1px solid var(--line-strong); color: var(--muted); }
.nav .count { font-size: 11px; background: var(--bad-soft); color: var(--bad); padding: 0 7px; border-radius: 99px; }
.main { min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 28px; border-bottom: 1px solid var(--line); background: rgba(12,17,27,.85);
  position: sticky; top: 0; z-index: 5; backdrop-filter: blur(6px); }
.topbar form.search { flex: 1; max-width: 460px; }
.topbar .spacer { flex: 1; }
.topbar .menu-btn { display: none; }
.content { padding: 24px 28px 60px; max-width: 1440px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card > .hd { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card > .bd { padding: 16px 18px; }
.card > .bd.flush { padding: 0; }
.card + .card, .stack > * + * { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 26px 0 10px; }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.stat { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; color: var(--text); }
a.stat:hover { border-color: var(--gold-line); text-decoration: none; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 24px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .v.dim { color: var(--muted); font-weight: 500; font-size: 20px; }
.stat .n { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.stat.alert .v { color: var(--bad); }
.stat.warn .v { color: var(--warn); }
.fin { border-color: var(--gold-line); }
.fin .lbl { display: inline-block; font-size: 10px; letter-spacing: .1em; text-transform: uppercase; padding: 1px 6px; border-radius: 4px; margin-bottom: 6px; }
.lbl.est { background: var(--info-soft); color: var(--info); }
.lbl.con { background: var(--warn-soft); color: var(--warn); }
.lbl.real { background: var(--ok-soft); color: var(--ok); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
.t th { text-align: left; font-weight: 600; color: var(--muted); font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase;
  padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); position: sticky; top: 0; white-space: nowrap; }
.t td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.t tr:last-child td { border-bottom: 0; }
.t tbody tr:hover td { background: rgba(255,255,255,.015); }
.t td.num, .t th.num { text-align: right; }
.t .addr { font-weight: 500; color: var(--text); }
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; padding: 2px 8px; border-radius: 99px; white-space: nowrap;
  border: 1px solid var(--line-strong); color: var(--text-2); background: var(--surface-2); }
.badge.gold { border-color: var(--gold-line); color: var(--gold-strong); background: var(--gold-soft); }
.badge.ok { border-color: transparent; color: var(--ok); background: var(--ok-soft); }
.badge.warn { border-color: transparent; color: var(--warn); background: var(--warn-soft); }
.badge.bad { border-color: transparent; color: var(--bad); background: var(--bad-soft); }
.badge.info { border-color: transparent; color: var(--info); background: var(--info-soft); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; display: inline-block; }

/* ---------- buttons & forms ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: 13px; font-weight: 500; padding: 7px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text); cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--gold-line); text-decoration: none; }
.btn.primary { background: var(--gold); border-color: var(--gold); color: #1a1405; }
.btn.primary:hover { background: var(--gold-strong); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.inline { display: inline; }
label { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 4px; font-weight: 500; }
input[type=text], input[type=search], input[type=password], input[type=email], input[type=number], input[type=date], input[type=time],
input[type=url], input[type=tel], input:not([type]), select, textarea {
  width: 100%; font: inherit; color: var(--text); background: #0d1420; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: 8px 10px; min-height: 36px; }
input::placeholder, textarea::placeholder { color: #5f6b80; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
input[type=date], input[type=time] { color-scheme: dark; }
textarea { min-height: 80px; resize: vertical; }
input[type=checkbox], input[type=radio] { accent-color: var(--gold); width: 16px; height: 16px; vertical-align: -3px; }
.field { margin-bottom: 14px; }
.field .help { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.field .err { font-size: 12px; color: var(--bad); margin-top: 4px; }
.field.has-err input, .field.has-err select, .field.has-err textarea { border-color: var(--bad); }
.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 0 14px; }
.c2 { grid-column: span 2; } .c3 { grid-column: span 3; } .c4 { grid-column: span 4; } .c5 { grid-column: span 5; }
.c6 { grid-column: span 6; } .c7 { grid-column: span 7; } .c8 { grid-column: span 8; } .c9 { grid-column: span 9; }
.c10 { grid-column: span 10; } .c12 { grid-column: span 12; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px 4px; margin: 0 0 16px; }
legend { padding: 0 6px; color: var(--gold); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--text-2); margin-bottom: 8px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.filters .field { margin: 0; min-width: 140px; }
.filters input, .filters select { min-height: 34px; padding: 6px 9px; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; }
.seg a { padding: 6px 12px; color: var(--text-2); font-size: 12.5px; border-right: 1px solid var(--line-strong); }
.seg a:last-child { border-right: 0; }
.seg a.on { background: var(--gold-soft); color: var(--gold-strong); }
.seg a:hover { text-decoration: none; background: var(--surface-2); }

/* ---------- feedback ---------- */
.flash { padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 14px; border: 1px solid; font-size: 13.5px; }
.flash.success { background: var(--ok-soft); border-color: rgba(93,180,138,.35); color: #bfe6d1; }
.flash.error { background: var(--bad-soft); border-color: rgba(226,112,107,.4); color: #f3c3c0; }
.flash.info { background: var(--info-soft); border-color: rgba(116,163,220,.35); color: #c9dcf3; }
.note { border-left: 3px solid var(--gold); background: var(--gold-soft); padding: 10px 14px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 13px; color: var(--text-2); }
.note.warn { border-color: var(--warn); background: var(--warn-soft); }
.note.bad { border-color: var(--bad); background: var(--bad-soft); }
.empty { text-align: center; padding: 36px 20px; color: var(--muted); }
.empty h3 { color: var(--text-2); text-transform: none; letter-spacing: 0; font-size: 15px; margin-bottom: 6px; }
.empty .btn { margin-top: 10px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 9px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: flex-start; }
.list li:last-child { border-bottom: 0; }
ul.plain { margin: 0; padding-left: 18px; }
ul.plain li { margin: 3px 0; }

/* ---------- progress ---------- */
.bar { height: 6px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--gold); border-radius: 99px; }
.bar.ok > i { background: var(--ok); }
.bar.warn > i { background: var(--warn); }

/* ---------- action center ---------- */
.action { display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; align-items: start; padding: 11px 18px; border-bottom: 1px solid var(--line); }
.action:last-child { border-bottom: 0; }
.prio { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; font-size: 11px; font-weight: 700; }
.p1 { background: var(--bad-soft); color: var(--bad); }
.p2 { background: var(--warn-soft); color: var(--warn); }
.p3 { background: var(--info-soft); color: var(--info); }
.p4 { background: var(--surface-3); color: var(--muted); }

/* ---------- pipeline ---------- */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 12px; }
.col { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); min-height: 200px; display: flex; flex-direction: column; }
.col > .hd { padding: 10px 12px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center;
  font-size: 12.5px; font-weight: 600; }
.col > .bd { padding: 8px; display: flex; flex-direction: column; gap: 8px; }
.deal { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px; font-size: 12.5px; color: var(--text); }
.deal:hover { border-color: var(--gold-line); text-decoration: none; }
.deal .a { font-weight: 600; font-size: 13px; }
.deal .m { color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.stage-track { display: flex; gap: 3px; margin: 8px 0 4px; }
.stage-track i { flex: 1; height: 4px; border-radius: 2px; background: var(--surface-3); }
.stage-track i.done { background: var(--gold-line); }
.stage-track i.cur { background: var(--gold); }

/* ---------- calendar ---------- */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.cal .dow { background: var(--surface-2); padding: 8px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; text-align: center; }
.cal .day { min-height: 108px; padding: 6px; border-top: 1px solid var(--line); border-right: 1px solid var(--line); background: var(--surface); font-size: 12px; }
.cal .day:nth-child(7n) { border-right: 0; }
.cal .day.other { background: #0f1622; color: var(--muted); }
.cal .day.today { box-shadow: inset 0 0 0 1px var(--gold); }
.cal .dn { font-size: 11.5px; color: var(--muted); margin-bottom: 4px; }
.cal .ev { display: block; padding: 2px 6px; border-radius: 4px; margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 11.5px; }
.cal .ev.task { background: var(--info-soft); color: #cfe0f5; }
.cal .ev.deadline { background: var(--warn-soft); color: #f2d9a6; }
.cal .ev.done { opacity: .5; text-decoration: line-through; }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1200px 600px at 20% -10%, rgba(200,167,94,.08), transparent), var(--bg); }
.auth .card { width: 100%; max-width: 400px; }
.auth .brand { border: 0; justify-content: center; padding-bottom: 6px; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 20; left: 0; top: 0; width: 270px; transform: translateX(-100%); transition: transform .18s ease; }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.5); }
  .topbar .menu-btn { display: inline-flex; }
  .topbar { flex-wrap: wrap; }
  .topbar form.search { order: 5; flex-basis: 100%; max-width: none; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
  .g2, .g3, .g4 { grid-template-columns: minmax(0, 1fr); }
  .card > .hd { flex-wrap: wrap; }
  .page-head { flex-wrap: wrap; }
  .page-head .actions { flex-wrap: wrap; }
  .form-grid > * { grid-column: span 12; }
  .kv { grid-template-columns: 1fr; gap: 0 0; }
  .kv dt { margin-top: 8px; }
  .cal .day { min-height: 70px; }
  .cal .ev { font-size: 10px; }
  h1 { font-size: 22px; }
}
@media print {
  .sidebar, .topbar, .actions, .btn { display: none !important; }
  body { background: #fff; color: #000; }
  .shell { display: block; }
  .card { border-color: #ccc; box-shadow: none; background: #fff; }
}

/* ---------- Phase 2: property tabs, calculations ---------- */
.ptabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: -6px 0 20px; overflow-x: auto; }
.ptabs a { padding: 10px 14px; color: var(--text-2); font-size: 13.5px; border-bottom: 2px solid transparent; white-space: nowrap; }
.ptabs a:hover { color: var(--text); text-decoration: none; }
.ptabs a.on { color: var(--gold-strong); border-bottom-color: var(--gold); }
.calc { width: 100%; border-collapse: collapse; font-size: 13px; }
.calc td { padding: 6px 0; border-bottom: 1px dashed var(--line); vertical-align: top; }
.calc td.amt { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; padding-left: 12px; }
.calc td.sign { width: 16px; color: var(--muted); }
.calc tr.total td { border-bottom: 0; border-top: 1px solid var(--line-strong); font-weight: 600; padding-top: 8px; }
.calc tr.miss td { color: var(--warn); }
.calc .src { display: block; color: var(--muted); font-size: 11.5px; }
.formula { font-family: var(--mono); font-size: 11.5px; color: var(--muted); margin-bottom: 8px; }
.big { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; }
.big.dim { color: var(--muted); font-size: 18px; font-weight: 500; }
.cases { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.case { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; }
.case.base { border-color: var(--gold-line); }
.case h4 { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.scorebar { display: grid; grid-template-columns: 110px 1fr 40px; gap: 10px; align-items: center; font-size: 12.5px; margin-bottom: 8px; }
.field.src-default input { border-style: dashed; }
.field .srcl { font-size: 11px; color: var(--muted); margin-top: 3px; }
.field .srcl.def { color: var(--info); }
.field .srcl.mine { color: var(--ok); }
.field .srcl.blank { color: var(--warn); }
details.calc-d > summary { cursor: pointer; color: var(--gold-strong); font-size: 12.5px; margin-top: 8px; }
.excluded td { opacity: .55; }
@media (max-width: 860px) { .cases { grid-template-columns: 1fr; } }

/* Phase 6 */
.actiongrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.actiongrid .btn { justify-content: flex-start; text-align: left; white-space: normal; height: auto; min-height: 38px; }
.intg td { vertical-align: top; }
.intg dl { display: grid; grid-template-columns: 120px 1fr; gap: 2px 10px; font-size: 12.5px; margin: 6px 0 0; }
.intg dt { color: var(--muted); }
@media print { .sidebar, .topbar, .ptabs, .actions, form { display: none !important; } .main { margin: 0 !important; } }

.grid > *, .split > *, .stack > * { min-width: 0; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Outreach letters */
.letter-page { max-width: 7.5in; }
.letter-body { white-space: pre-wrap; font-family: Georgia, "Times New Roman", serif; font-size: 15px; line-height: 1.55; }
@media print {
  .letter-page { border: 0 !important; box-shadow: none !important; background: #fff !important; max-width: none; }
  .letter-page .bd { padding: 0 !important; }
  .letter-body { color: #000 !important; font-size: 12pt; }
  .note, .muted { display: none !important; }
  body { background: #fff !important; }
}
