:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --ink: #141414;
  --muted: #6b6a66;
  --line: #e4e2dc;
  --accent: #FCB040;
  --accent-ink: #111111;
  --good: #1f8a4c;
  --warn: #b7791f;
  --bad: #c53030;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111110; --surface: #1b1b1a; --ink: #f1f0ec; --muted: #9a9892;
    --line: #2c2c2a; --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 15px/1.5 Inter, system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }

.boot { display: grid; place-items: center; height: 100vh; font-size: 32px; font-weight: 700; letter-spacing: -.02em; }
.dot { color: var(--accent); }

/* ---------- Layout ---------- */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.shell > div { min-width: 0; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; font-size: 20px; letter-spacing: -.02em; padding: 4px 10px 18px; }
.brand small { display: block; font-size: 11px; font-weight: 500; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; text-decoration: none; color: var(--muted); font-weight: 500; }
.nav a:hover { background: var(--bg); color: var(--ink); }
.nav a.active { background: var(--ink); color: var(--surface); }
.nav a.soon { opacity: .45; pointer-events: none; }
.nav a .tag { margin-left: auto; font-size: 10px; text-transform: uppercase; letter-spacing: .06em; }
.nav .sep { height: 1px; background: var(--line); margin: 10px 6px; }
.me { margin-top: auto; padding: 10px; font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); }
.me b { color: var(--ink); display: block; font-weight: 600; }
.main { padding: 28px 32px 60px; max-width: 1200px; width: 100%; }
.topbar { display: none; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 30; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
  .topbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
  .main { padding: 20px 16px 60px; }
}

/* ---------- Elements ---------- */
h1 { font-size: 26px; letter-spacing: -.02em; margin: 0; }
h2 { font-size: 17px; margin: 0 0 12px; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 16px; }
.grid.kpi { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.grid.two { grid-template-columns: 1.4fr 1fr; }
@media (max-width: 860px) { .grid.two { grid-template-columns: 1fr; } }
.kpi .num { font-size: 28px; font-weight: 700; letter-spacing: -.02em; }
.kpi .lbl { color: var(--muted); font-size: 13px; }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); padding: 8px 14px; border-radius: 8px; cursor: pointer; font-weight: 500; text-decoration: none; }
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(.95); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.icon-btn { border: 0; background: transparent; font-size: 22px; cursor: pointer; padding: 4px 8px; }

.search { padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); min-width: 220px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar select { padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--bg); }
.table-wrap { overflow-x: auto; }
@media (max-width: 640px) { .hide-sm { display: none; } }

.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--bg); border: 1px solid var(--line); white-space: nowrap; }
.pill.active, .pill.won { color: var(--good); border-color: currentColor; }
.pill.paused, .pill.proposal { color: var(--warn); border-color: currentColor; }
.pill.past, .pill.lost { color: var(--muted); }
.muted { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 36px 12px; }
dl.info { display: grid; grid-template-columns: 110px 1fr; gap: 8px 12px; margin: 0; }
dl.info dt { color: var(--muted); font-size: 13px; }
dl.info dd { margin: 0; word-break: break-word; }

.list-row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.note { padding: 10px 0; border-bottom: 1px solid var(--line); }
.note .meta { font-size: 12px; color: var(--muted); }
.note-form { display: flex; gap: 8px; margin-top: 10px; }
.note-form textarea { flex: 1; min-height: 42px; }

/* ---------- Pipeline ---------- */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.col { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; min-height: 160px; }
.col h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; margin: 2px 4px 10px; display: flex; justify-content: space-between; color: var(--muted); }
.col.drop { outline: 2px dashed var(--accent); }
.lead { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; cursor: grab; }
.lead b { display: block; }
.lead .row { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-top: 4px; }

/* ---------- Forms & modal ---------- */
.form { display: grid; gap: 12px; }
.form .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .form .row2 { grid-template-columns: 1fr; } }
label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 500; }
input, select, textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
textarea { resize: vertical; min-height: 80px; }
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: var(--surface); border-radius: 14px; width: min(560px, 100%); max-height: 90vh; overflow: auto; padding: 22px; }
.modal-actions { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; }
.modal-actions .right { display: flex; gap: 8px; margin-left: auto; }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth .card { width: min(400px, 100%); padding: 28px; }
.auth .logo { font-size: 30px; font-weight: 700; letter-spacing: -.02em; margin-bottom: 4px; }
.auth .switch { text-align: center; font-size: 14px; margin-top: 14px; }
.auth .switch a { color: var(--accent); cursor: pointer; }
.err { color: var(--bad); font-size: 14px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: 8px; font-size: 14px; z-index: 60; }

/* ---------- Offer editor ---------- */
.pill.draft { color: var(--muted); }
.pill.sent { color: var(--warn); border-color: currentColor; }
.pill.accepted { color: var(--good); border-color: currentColor; }
.pill.rejected { color: var(--bad); border-color: currentColor; }
.line { border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 8px; display: grid; gap: 8px; background: var(--bg); }
.line-main { display: grid; gap: 6px; }
.line-main textarea { min-height: 38px; font-size: 14px; }
.line-name { font-weight: 600; }
.line-nums { display: grid; grid-template-columns: 80px 90px 110px 1fr auto; gap: 8px; align-items: end; }
.line-nums label { font-size: 11px; }
.line-total { text-align: right; font-weight: 600; padding-bottom: 9px; white-space: nowrap; }
.line-tools { display: flex; padding-bottom: 4px; }
.icon-btn.sm { font-size: 15px; padding: 4px 6px; color: var(--muted); }
.icon-btn.sm:hover { color: var(--ink); }
@media (max-width: 560px) { .line-nums { grid-template-columns: 1fr 1fr 1fr; } .line-total { grid-column: 1 / 3; text-align: left; } }
dl.totals dd { text-align: right; }

/* ---------- Offer document (screen + print) ---------- */
.print-bar { position: sticky; top: 0; display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--line); z-index: 5; flex-wrap: wrap; }
.doc { --doc-accent: #FCB040; background: #fff; color: #161616; width: min(210mm, 100% - 32px); margin: 24px auto; padding: 18mm 16mm; box-shadow: 0 4px 30px rgba(0,0,0,.08); font-size: 10.5pt; line-height: 1.5; }
.doc-head { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; padding-bottom: 14px; border-bottom: 3px solid var(--doc-accent); }
.doc-logo { max-height: 40px; max-width: 220px; }
.doc-word { font-size: 26pt; font-weight: 700; letter-spacing: -.02em; }
.doc-co { text-align: right; font-size: 8.5pt; color: #555; }
.doc-co b { color: #161616; }
.doc-title { margin: 26px 0 18px; }
.doc-kicker { text-transform: uppercase; letter-spacing: .14em; font-size: 8pt; font-weight: 700; color: color-mix(in srgb, var(--doc-accent) 60%, #000); }
.doc-title h1 { font-size: 22pt; margin: 4px 0 18px; letter-spacing: -.01em; line-height: 1.15; }
.doc-meta { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 16px; font-size: 9pt; color: #555; background: #f6f5f2; padding: 12px 14px; border-radius: 6px; }
.doc-meta span { display: block; text-transform: uppercase; letter-spacing: .08em; font-size: 7.5pt; color: #888; }
.doc-meta b { color: #161616; font-size: 10pt; }
.doc-intro { white-space: pre-wrap; margin: 0 0 18px; }
.doc-table { width: 100%; border-collapse: collapse; margin-top: 6px; }
.doc-table th { font-size: 7.5pt; text-transform: uppercase; letter-spacing: .08em; color: #888; border-bottom: 1px solid #ddd; padding: 8px 6px; }
.doc-table td { padding: 10px 6px; border-bottom: 1px solid #eee; vertical-align: top; cursor: default; }
.doc-table tbody tr:hover { background: none; }
.doc-table .r { text-align: right; white-space: nowrap; }
.doc-desc { color: #666; font-size: 9pt; white-space: pre-wrap; margin-top: 2px; }
.doc-totals { margin: 14px 0 0 auto; width: 260px; font-size: 10pt; }
.doc-totals div { display: flex; justify-content: space-between; padding: 4px 6px; }
.doc-totals .grand { margin-top: 6px; border-top: 2px solid #161616; padding-top: 8px; font-size: 13pt; font-weight: 700; }
.doc-totals .grand span:last-child { background: var(--doc-accent); padding: 0 8px; border-radius: 4px; }
.doc-terms { margin-top: 28px; page-break-inside: avoid; }
.doc-terms h3 { font-size: 9pt; text-transform: uppercase; letter-spacing: .1em; margin: 0 0 6px; }
.doc-terms p { white-space: pre-wrap; font-size: 9pt; color: #444; margin: 0; }
.doc-sign { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 48px; font-size: 8.5pt; color: #666; page-break-inside: avoid; }
.doc-sign .line { display: block; border: 0; border-bottom: 1px solid #999; border-radius: 0; height: 40px; background: none; padding: 0; margin-bottom: 6px; }
@media (max-width: 640px) {
  .doc { padding: 20px 16px; width: calc(100% - 16px); margin: 8px auto; }
  .doc-head { flex-direction: column; } .doc-co { text-align: left; }
  .doc-meta { grid-template-columns: 1fr 1fr; }
}
@page { size: A4; margin: 0; }
@media print {
  html, body { background: #fff !important; }
  .no-print, #toast, #modal-root { display: none !important; }
  .doc { box-shadow: none; margin: 0; width: 210mm; min-height: 297mm; padding: 16mm 15mm; }
  .doc-meta { grid-template-columns: 2fr 1fr 1fr 1fr; }
  .doc-head { flex-direction: row; } .doc-co { text-align: right; }
}

/* ---------- Phase 3: campaigns, tasks, calendar ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.camp { text-decoration: none; display: grid; gap: 6px; transition: border-color .15s; }
.camp:hover { border-color: var(--ink); }
.camp h3 { margin: 2px 0 0; font-size: 17px; letter-spacing: -.01em; }
.camp-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0; }
.chip { font-size: 11.5px; padding: 2px 8px; border-radius: 99px; background: var(--bg); border: 1px solid var(--line); white-space: nowrap; }
.progress { height: 6px; border-radius: 99px; background: var(--bg); border: 1px solid var(--line); overflow: hidden; margin-top: 6px; }
.progress span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.progress.over span { background: var(--bad); }
.pill.planning { color: #3b82f6; border-color: currentColor; }
.pill.done { color: var(--muted); }
.pill.high { color: var(--bad); border-color: currentColor; }
.late { color: var(--bad) !important; font-weight: 600; }
.lbl-sm { font-size: 13px; color: var(--muted); font-weight: 500; margin-bottom: 6px; }
.chip-picks { display: flex; flex-wrap: wrap; gap: 6px; }
.pick { display: inline-flex; cursor: pointer; }
.pick input { position: absolute; opacity: 0; width: 0; height: 0; }
.pick span { padding: 5px 11px; border-radius: 99px; border: 1px solid var(--line); font-size: 13px; color: var(--ink); background: var(--surface); }
.pick input:checked + span { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.pick input:focus-visible + span { outline: 2px solid var(--accent); }
label.inline { display: flex; flex-direction: row; gap: 8px; align-items: center; color: var(--ink); font-size: 14px; }
label.inline input { width: auto; }
.form .row3 { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .form .row3 { grid-template-columns: 1fr 1fr; } .form .row3 label:first-child { grid-column: 1 / -1; } }

.task-row { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.task-row:last-child { border-bottom: 0; }
.task-row input[type=checkbox] { width: 18px; height: 18px; margin-top: 2px; flex: none; accent-color: var(--accent); cursor: pointer; }
.task-row.is-done b { text-decoration: line-through; color: var(--muted); }
.task-main { flex: 1; min-width: 0; }
.task-meta { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.task-side { display: grid; justify-items: end; gap: 3px; white-space: nowrap; }
.tasks-board { grid-auto-columns: minmax(240px, 1fr); }
.tcard .row i { font-style: italic; }

.ev-row { display: flex; gap: 12px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.ev-row:last-child { border-bottom: 0; }
.ev-date { width: 42px; text-align: center; line-height: 1.1; flex: none; border: 1px solid var(--line); border-radius: 8px; padding: 4px 0; background: var(--bg); }
.ev-date b { display: block; font-size: 16px; }
.ev-date small { font-size: 10.5px; color: var(--muted); text-transform: uppercase; }
.dot-ev { display: inline-block; width: 8px; height: 8px; border-radius: 50%; vertical-align: 1px; margin-right: 2px; }
.legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: 12.5px; color: var(--muted); align-items: center; margin-left: auto; }

.cal { padding: 0; overflow: hidden; }
.cal-head { display: grid; grid-template-columns: repeat(7, 1fr); border-bottom: 1px solid var(--line); }
.cal-head div { padding: 8px 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); grid-auto-rows: minmax(112px, auto); }
.cal-cell { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 6px; min-width: 0; cursor: pointer; display: grid; align-content: start; gap: 3px; }
.cal-cell:nth-child(7n) { border-right: 0; }
.cal-cell:hover { background: var(--bg); }
.cal-cell.out { background: color-mix(in srgb, var(--bg) 60%, transparent); }
.cal-cell.out .cal-num { opacity: .4; }
.cal-num { font-size: 13px; font-weight: 600; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; }
.cal-cell.today .cal-num { background: var(--accent); color: #111; }
.cal-item { --c: #999; font-size: 12px; line-height: 1.3; padding: 3px 6px; border-radius: 5px; background: color-mix(in srgb, var(--c) 14%, var(--surface)); border-left: 3px solid var(--c); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; text-decoration: none; display: block; }
.cal-item small { color: var(--muted); }
.cal-item.task { --c: var(--ink); background: transparent; border: 1px dashed var(--line); border-left-width: 1px; }
.cal-item.task.late { border-color: var(--bad); }
.cal-item.camp { --c: var(--muted); background: transparent; color: var(--muted); border-left: 0; padding-left: 2px; font-weight: 600; }
.cal-more { font-size: 11.5px; color: var(--muted); padding-left: 4px; }
.agenda { display: none; }
.agenda-day { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 10px; display: grid; gap: 5px; }
.agenda-date { font-size: 13px; font-weight: 600; text-transform: capitalize; margin-bottom: 2px; }
.agenda-date.today { color: color-mix(in srgb, var(--accent) 65%, #000); }
.agenda .cal-item { white-space: normal; font-size: 13.5px; padding: 6px 8px; }
@media (max-width: 760px) {
  .cal { display: none; }
  .agenda { display: block; }
  .legend { margin-left: 0; }
}

/* ---------- Phase 4: deck editor ---------- */
.sec { padding: 14px 16px; }
.sec.off { opacity: .5; }
.sec.off .sec-body { display: none; }
.sec-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.sec-body { margin-top: 12px; }
.sec-body small { font-weight: 400; color: var(--muted); }
.sec-body textarea { font-size: 14px; }
.deck-grid { grid-template-columns: 1.6fr 1fr; }
@media (max-width: 860px) { .deck-grid { grid-template-columns: 1fr; } }
