/* K&A CRM — ivory paper, emerald and gold (same family as the Review Desk), dense dashboard layout. */
:root {
  color-scheme: light;
  --green: #004225; --green-800: #0a3524; --green-700: #0b5a33; --green-hover: #00361e; --green-ink: #004225; --on-green: #fff;
  --gold: #e0b04a; --gold-600: #b98a2b; --gold-100: #fbf1d6; --gold-ink: #7a5410; --on-gold: #1d1606;
  --paper: #f6f3ec; --card: #fff; --field: #fff; --surface-2: #faf8f2; --surface-3: #e9e6da;
  --ink: #17211c; --ink-2: #34423b; --muted: #5c6a62; --faint: #6f7b74; --line: #e4e1d6; --line-2: #cfcbbd;
  --tint: rgba(0,66,37,.06); --tint-2: rgba(0,66,37,.14);
  --ok: #1d6a44; --ok-100: #e0f0e6; --warn: #7a4c05; --warn-100: #fbecd0; --bad: #a53a2a; --bad-100: #f7e1dc; --info: #1f5d8a; --info-100: #e0edf7;
  --c1: #0b5a33; --c2: #b98a2b; --c3: #1f5d8a; --c4: #a53a2a; --c5: #7a4aa3;
  --focus: #0b5a33;
  --sh-1: 0 1px 2px rgba(10,40,25,.06), 0 6px 18px -8px rgba(10,40,25,.16);
  --sh-2: 0 2px 4px rgba(10,40,25,.08), 0 24px 48px -16px rgba(10,40,25,.35);
  --serif: "Cormorant Garamond", Georgia, serif; --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --rail: 232px; --r: 10px; --r-lg: 16px; --tap: 44px;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --green: #1f7a4d; --green-800: #10241a; --green-700: #1d6b44; --green-hover: #27895a; --green-ink: #8fd9ae;
  --gold-100: #3a2f14; --gold-ink: #f0cf7d; --gold-600: #e0b04a;
  --paper: #0d1612; --card: #16231c; --field: #0f1a14; --surface-2: #1b2b22; --surface-3: #243a2e;
  --ink: #e8efe9; --ink-2: #c9d6cd; --muted: #9db0a4; --faint: #8fa398; --line: #263a2f; --line-2: #3a5443;
  --tint: rgba(255,255,255,.06); --tint-2: rgba(143,217,174,.2);
  --ok: #6fd19c; --ok-100: #15301f; --warn: #f0b95a; --warn-100: #3a2a0e; --bad: #f4a89a; --bad-100: #3b1f1b; --info: #7fbbe6; --info-100: #14283a;
  --c1: #5fcf94; --c2: #e0b04a; --c3: #6aa8ea; --c4: #f08e7e; --c5: #c29be6;
  --focus: #8fd9ae;
  --sh-1: 0 1px 2px rgba(0,0,0,.4), 0 6px 18px -8px rgba(0,0,0,.6);
  --sh-2: 0 2px 4px rgba(0,0,0,.45), 0 24px 48px -16px rgba(0,0,0,.8);
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { font-variant-numeric: lining-nums; margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.5 var(--sans); }
h1, h2, h3 { margin: 0; font-weight: 600; }
h1 { font: 600 30px/1.1 var(--serif); color: var(--green-ink); letter-spacing: .2px; }
h2 { font-size: 15px; } h3 { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
a { color: var(--green-ink); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
main:focus { outline: none; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--green); color: #fff; padding: 10px 14px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ----- shell ----- */
.shell { display: grid; grid-template-columns: var(--rail) 1fr; min-height: 100vh; }
.rail { position: sticky; top: 0; height: 100vh; background: var(--green-800); color: #e9efe9; display: flex; flex-direction: column; padding: 18px 12px; gap: 4px; overflow-y: auto; }
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 18px; text-decoration: none; color: #fff; }
.brand .mark { width: 36px; height: 36px; border-radius: 9px; background: var(--gold); color: var(--on-gold); display: grid; place-items: center; font: 700 17px var(--serif); }
.brand b { display: block; font: 700 19px/1 var(--serif); letter-spacing: .3px; } .brand small { font-size: 11px; opacity: .7; letter-spacing: .08em; text-transform: uppercase; }
.rail a.nav { display: flex; gap: 12px; align-items: center; min-height: 42px; padding: 0 12px; border-radius: 9px; color: #cfdcd3; text-decoration: none; font-weight: 500; transition: background .15s, color .15s; }
.rail a.nav:hover { background: rgba(255,255,255,.08); color: #fff; }
.rail a.nav[aria-current="page"] { background: rgba(224,176,74,.18); color: #fff; box-shadow: inset 3px 0 0 var(--gold); }
.rail .grow { flex: 1; } .rail .sec { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; opacity: .55; padding: 14px 12px 4px; }
.rail .who { padding: 10px 12px; font-size: 13px; opacity: .85; border-top: 1px solid rgba(255,255,255,.12); margin-top: 8px; }
.rail .who button { background: none; border: 0; color: #cfdcd3; padding: 0; text-decoration: underline; cursor: pointer; min-height: 28px; }
.badge-dot { margin-left: auto; background: var(--gold); color: var(--on-gold); font-size: 11px; font-weight: 700; border-radius: 99px; padding: 0 7px; line-height: 18px; }
.main { min-width: 0; padding: 0 28px 48px; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; gap: 12px; align-items: center; padding: 14px 0; background: linear-gradient(var(--paper) 78%, transparent); }
.btn.menu-btn { display: none; }
.search { flex: 1; max-width: 520px; position: relative; }
.search input[type=search] { width: 100%; min-height: var(--tap); padding: 0 14px 0 42px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--field); }
.search .i { position: absolute; left: 13px; top: 13px; color: var(--faint); }
.search-results { position: absolute; top: 50px; left: 0; right: 0; background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--sh-2); max-height: 360px; overflow: auto; z-index: 30; }
.search-results a { display: flex; flex-direction: column; padding: 10px 14px; text-decoration: none; color: var(--ink); border-bottom: 1px solid var(--line); }
.search-results a:hover, .search-results a:focus { background: var(--tint); }
.search-results small { color: var(--muted); }
.top-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin: 6px 0 18px; }
.page-head .sub { color: var(--muted); margin-top: 4px; } .page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.mode-banner { display: flex; gap: 10px; align-items: center; background: var(--warn-100); color: var(--warn); border: 1px solid var(--gold-600); border-radius: var(--r); padding: 10px 14px; margin-bottom: 16px; font-size: 14px; }
.mode-banner a { font-weight: 600; color: inherit; }

/* ----- controls ----- */
.btn { display: inline-flex; gap: 8px; align-items: center; justify-content: center; min-height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--card); color: var(--ink); font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s, transform .1s, border-color .15s; }
.btn:hover { background: var(--tint); border-color: var(--green-ink); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--green); color: var(--on-green); border-color: var(--green); } .btn.primary:hover { background: var(--green-hover); }
.btn.gold { background: var(--gold); color: var(--on-gold); border-color: var(--gold-600); } .btn.gold:hover { background: #ecbd58; }
.btn.danger { color: var(--bad); border-color: var(--bad); } .btn.danger:hover { background: var(--bad-100); }
.btn.ghost { border-color: transparent; background: transparent; } .btn.ghost:hover { background: var(--tint); }
.btn.sm { min-height: 32px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn.icon { width: 40px; padding: 0; } .btn.icon.sm { width: 32px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
label.f { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
.field { margin-bottom: 14px; } .hint { font-size: 12.5px; color: var(--muted); margin-top: 4px; font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=number], input[type=date], input[type=datetime-local], input[type=tel], input[type=url], select, textarea {
  width: 100%; min-height: 40px; padding: 8px 12px; border: 1px solid var(--line-2); border-radius: 9px; background: var(--field); }
textarea { min-height: 96px; resize: vertical; line-height: 1.5; } textarea.code { font: 13px/1.5 ui-monospace, "SF Mono", Menlo, monospace; min-height: 320px; }
input:focus, select:focus, textarea:focus { border-color: var(--focus); outline: 2px solid var(--focus); outline-offset: 0; }
.err-text { color: var(--bad); font-size: 13px; margin-top: 4px; } .field.bad input, .field.bad textarea { border-color: var(--bad); }
.check { display: flex; gap: 10px; align-items: center; min-height: 32px; cursor: pointer; } .check input { width: 18px; height: 18px; accent-color: var(--green); }
.row { display: grid; gap: 12px; } .row.c2 { grid-template-columns: 1fr 1fr; } .row.c3 { grid-template-columns: repeat(3, 1fr); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 0 10px; border-radius: 99px; background: var(--tint); border: 1px solid var(--line-2); font-size: 13px; cursor: pointer; }
.chip[aria-pressed="true"], .chip.on { background: var(--green); color: var(--on-green); border-color: var(--green); }
.chip.static { cursor: default; } .chip button { background: none; border: 0; padding: 0; cursor: pointer; line-height: 1; font-size: 15px; }

/* ----- cards, stats ----- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-1); padding: 18px; min-width: 0; }
.card > .head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; } .card > .head .more { margin-left: auto; font-size: 13px; }
.grid { display: grid; gap: 16px; } .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.kpi { padding: 16px 18px; } .kpi .lbl { font-size: 12.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.kpi .val { font: 700 34px/1.1 var(--serif); color: var(--green-ink); margin: 6px 0 2px; font-variant-numeric: tabular-nums; } .kpi .sub { font-size: 13px; color: var(--muted); }
.kpi .trend { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; font-size: 12.5px; } .up { color: var(--ok); } .down { color: var(--bad); }
.meter { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; margin: 8px 0 4px; } .meter > i { display: block; height: 100%; background: var(--green); border-radius: 99px; transition: width .4s ease; } .meter.warn > i { background: var(--gold-600); } .meter.bad > i { background: var(--bad); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; color: var(--ink-2); margin-top: 8px; } .legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.chart { width: 100%; height: auto; display: block; } .chart text { fill: var(--muted); font-size: 11px; font-family: var(--sans); } .chart .grid-l { stroke: var(--line); } .chart .pt { cursor: pointer; }
.tip { position: fixed; pointer-events: none; background: var(--toast-bg, #17211c); color: #fff; font-size: 12.5px; padding: 6px 10px; border-radius: 8px; z-index: 90; box-shadow: var(--sh-2); white-space: nowrap; }
:root[data-theme="dark"] .tip { background: #e8efe9; color: #0d1612; }

/* ----- tables ----- */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--card); box-shadow: var(--sh-1); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0; }
.tbl td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; } .tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr { transition: background .12s; } .tbl tbody tr:hover { background: var(--tint); } .tbl tr.click { cursor: pointer; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; } .tbl td.nw { white-space: nowrap; }
.who-cell { display: flex; gap: 10px; align-items: center; min-width: 200px; } .who-cell b { display: block; font-weight: 600; } .who-cell small { color: var(--muted); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--tint-2); color: var(--green-ink); display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; } .toolbar .grow { flex: 1; min-width: 180px; } .toolbar select { width: auto; min-width: 130px; }
.bulkbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; background: var(--green); color: #fff; border-radius: var(--r); padding: 8px 12px; margin-bottom: 12px; } .bulkbar .btn { background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.3); }
.pager { display: flex; align-items: center; gap: 10px; justify-content: flex-end; padding: 12px 4px; color: var(--muted); font-size: 13px; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 1px 9px; min-height: 22px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--surface-3); color: var(--ink-2); white-space: nowrap; }
.badge.ok { background: var(--ok-100); color: var(--ok); } .badge.warn { background: var(--warn-100); color: var(--warn); } .badge.bad { background: var(--bad-100); color: var(--bad); } .badge.info { background: var(--info-100); color: var(--info); } .badge.gold { background: var(--gold-100); color: var(--gold-ink); }
.empty { text-align: center; padding: 44px 20px; color: var(--muted); } .empty b { display: block; font: 600 22px var(--serif); color: var(--ink); margin-bottom: 6px; } .empty .btn { margin-top: 14px; }
.skeleton { background: linear-gradient(90deg, var(--surface-3), var(--surface-2), var(--surface-3)); background-size: 200% 100%; animation: sk 1.2s linear infinite; border-radius: 8px; min-height: 18px; } @keyframes sk { to { background-position: -200% 0; } }
.loading { color: var(--muted); padding: 40px 0; }

/* ----- lists ----- */
.list { list-style: none; margin: 0; padding: 0; } .list li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); } .list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; } .list small { color: var(--muted); display: block; } .list a.t { font-weight: 600; text-decoration: none; color: var(--ink); } .list a.t:hover { text-decoration: underline; }
.tl { position: relative; padding-left: 22px; } .tl::before { content: ""; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.tl .ev { position: relative; padding: 0 0 16px; } .tl .ev::before { content: ""; position: absolute; left: -20px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--card); border: 2px solid var(--green); }
.tl .ev.system::before { border-color: var(--faint); } .tl .ev.task::before { border-color: var(--gold-600); } .tl .ev.email::before { border-color: var(--info); }
.tl .ev .meta { font-size: 12.5px; color: var(--muted); } .tl .ev p { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line-2); margin-bottom: 16px; overflow-x: auto; } .tabs button { background: none; border: 0; padding: 0 16px; min-height: 42px; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap; } .tabs button[aria-selected="true"] { color: var(--green-ink); border-bottom-color: var(--gold); }

/* ----- kanban ----- */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(205px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: start; }
.col { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 10px; min-height: 160px; } .col.over { outline: 2px dashed var(--green); background: var(--tint); }
.col .ch { display: flex; align-items: center; gap: 8px; padding: 2px 4px 10px; } .col .ch b { text-transform: capitalize; } .col .ch small { color: var(--muted); margin-left: auto; font-variant-numeric: tabular-nums; }
.deal { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 8px; cursor: grab; box-shadow: var(--sh-1); } .deal:active { cursor: grabbing; } .deal.drag { opacity: .4; }
.deal b { display: block; margin-bottom: 2px; } .deal .val { font: 700 18px var(--serif); color: var(--green-ink); } .deal small { color: var(--muted); display: block; }
.deal .mv { display: flex; gap: 4px; margin-top: 8px; }

/* ----- dialogs ----- */
dialog { border: 0; border-radius: var(--r-lg); padding: 0; background: var(--card); color: var(--ink); box-shadow: var(--sh-2); width: min(620px, calc(100vw - 24px)); max-height: calc(100vh - 32px); }
dialog.wide { width: min(980px, calc(100vw - 24px)); } dialog::backdrop { background: rgba(8,20,14,.55); backdrop-filter: blur(2px); }
.dlg-head { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); gap: 8px; } .dlg-head h2 { font: 600 22px var(--serif); color: var(--green-ink); flex: 1; }
.dlg-body { padding: 20px; overflow: auto; max-height: calc(100vh - 170px); } .dlg-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); flex-wrap: wrap; }
.toasts { position: fixed; bottom: 18px; right: 18px; display: grid; gap: 8px; z-index: 100; max-width: min(400px, calc(100vw - 36px)); }
.toast { background: #17211c; color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: var(--sh-2); display: flex; gap: 10px; align-items: center; animation: tin .2s ease; } .toast.bad { background: var(--bad); } .toast.ok i { color: var(--gold); } :root[data-theme="dark"] .toast { background: #e8efe9; color: #0d1612; } @keyframes tin { from { opacity: 0; transform: translateY(8px); } }
.preview-frame { width: 100%; height: 520px; border: 1px solid var(--line-2); border-radius: 10px; background: #f6f3ec; }
.editor-split { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; } .tagrow { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; } .tagrow button { min-height: 26px; padding: 0 8px; border-radius: 6px; border: 1px dashed var(--line-2); background: none; cursor: pointer; font-size: 12.5px; }
.stepper { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; } .stepper li { list-style: none; padding: 6px 14px; border-radius: 99px; background: var(--surface-3); font-weight: 600; font-size: 13px; color: var(--muted); } .stepper li.on { background: var(--green); color: #fff; } .stepper { padding: 0; margin: 0 0 18px; }
.ver-table td:first-child { color: var(--muted); width: 38%; }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; word-break: break-all; }
.cta-card { background: linear-gradient(135deg, var(--green-800), var(--green)); color: #fff; border: 0; } .cta-card h2 { color: #fff; } .cta-card .btn { background: var(--gold); color: var(--on-gold); border-color: var(--gold-600); }
.check-item { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; } .check-item .dot { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--surface-3); margin-top: 1px; } .check-item.done .dot { background: var(--ok-100); color: var(--ok); } .check-item.done span { color: var(--muted); text-decoration: line-through; }

/* ----- responsive ----- */
@media (max-width: 1180px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g-main { grid-template-columns: 1fr; } .editor-split { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: fixed; inset: 0 auto 0 0; width: 264px; z-index: 60; transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--sh-2); }
  .rail.open { transform: none; } .scrim { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 55; }
  .btn.menu-btn { display: inline-flex; } .main { padding: 0 14px 40px; } h1 { font-size: 26px; }
  .g3, .g2, .row.c2, .row.c3 { grid-template-columns: 1fr; } .top-actions .hide-s { display: none; }
}
@media (max-width: 520px) { .g4 { grid-template-columns: 1fr 1fr; } .kpi .val { font-size: 28px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media print { .rail, .topbar, .actions { display: none !important; } .shell { display: block; } }
