:root {
  --bg: #f3f5f8; --card: #fff; --ink: #1c2733; --muted: #6b7887; --line: #e1e6ec;
  --brand: #12508c; --brand-2: #0e406f; --accent: #0d7d5b; --warn: #b5761a; --bad: #b23b3b;
  --side: #111a26; --side-ink: #c8d3e0; --wa: #25d366;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.5 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--brand); text-decoration: none; } a:hover { text-decoration: underline; }
code { background: #eef2f6; padding: 1px 5px; border-radius: 4px; font-size: 12px; }

/* ---- app shell ---- */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 220px; flex: 0 0 220px; background: var(--side); color: var(--side-ink); padding: 18px 14px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; }
.sidebar .brand { color: #fff; font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.sidebar .logo { background: var(--brand); color: #fff; border-radius: 6px; padding: 2px 6px; font-size: 12px; letter-spacing: .06em; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a { color: var(--side-ink); padding: 9px 10px; border-radius: 8px; display: flex; gap: 10px; align-items: center; }
.sidebar nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.sidebar nav a.active { background: var(--brand); color: #fff; }
.sidebar .ico { width: 18px; text-align: center; opacity: .8; }
.mode-switch { border-top: 1px solid rgba(255,255,255,.08); padding-top: 14px; display: flex; flex-direction: column; gap: 4px; }
.mode-switch .label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; opacity: .6; margin-bottom: 4px; }
.mode-switch a { color: var(--side-ink); padding: 7px 10px; border-radius: 8px; font-size: 13px; }
.mode-switch a.on { background: rgba(255,255,255,.1); color: #fff; font-weight: 600; }
.sidebar-foot { margin-top: auto; font-size: 11px; opacity: .5; }
.content { flex: 1; min-width: 0; padding: 26px 32px 60px; }
@media (max-width: 900px) { .shell { flex-direction: column; } .sidebar { width: auto; flex: none; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; } .sidebar nav { flex-direction: row; } .mode-switch { border: 0; padding: 0; flex-direction: row; } .sidebar-foot { display: none; } .content { padding: 16px; } }

/* ---- page head ---- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 22px; }
.page-head .sub { margin: 4px 0 0; color: var(--muted); }
.page-head .muted { color: var(--muted); font-weight: 400; font-size: 15px; }
.crumb { font-size: 12px; color: var(--muted); }
.head-actions { display: flex; gap: 8px; align-items: center; }

/* ---- buttons ---- */
button, .btn { padding: 8px 14px; border: 0; border-radius: 8px; background: var(--brand); color: #fff; font: inherit; cursor: pointer; display: inline-block; }
button:hover, .btn:hover { background: var(--brand-2); text-decoration: none; }
button.secondary, .btn.ghost { background: #fff; color: var(--brand); border: 1px solid var(--line); }
button.secondary:hover, .btn.ghost:hover { background: #eef2f6; }
button:disabled { opacity: .6; cursor: wait; }
.btn-plain { display: inline-block; padding: 8px 12px; color: var(--muted); }
button.wa, .btn.wa-big { background: var(--wa); color: #073d1f; font-weight: 700; }
button.wa { padding: 3px 8px; font-size: 11px; border-radius: 6px; }
button.copy, button.mini { font-size: 11px; padding: 2px 8px; margin-left: 6px; background: #eef2f6; color: var(--brand); }
.inline { display: inline-flex; gap: 8px; margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---- stats ---- */
.stats, .scorecards { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.stat, .scorecard { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; min-width: 110px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.stat span, .scorecard span { display: block; font-size: 22px; color: var(--ink); font-weight: 700; text-transform: none; letter-spacing: 0; }
.scorecard.big span { font-size: 30px; color: var(--accent); }
.scorecard.dim { opacity: .6; }
.stat.ok span { color: var(--accent); } .stat.off span { color: var(--bad); } .stat.muted span { color: var(--muted); }
.stat.prio-hot span { color: var(--bad); } .stat.prio-high span { color: var(--warn); } .stat.prio-medium span { color: var(--brand); }

/* ---- filters / forms ---- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.filters input, .filters select, .stack input, .stack select, .stack textarea, .inline select, .edit-grid input, .edit-grid textarea { padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font: inherit; }
.stack { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; padding-bottom: 16px; border-bottom: 1px dashed var(--line); }
.stack label { font-size: 12px; color: var(--muted); }
.stack button { align-self: flex-start; margin-top: 4px; }
.stack .row2 { display: flex; gap: 8px; } .stack .row2 input { flex: 1; }
.hint, .hint code { font-size: 12px; color: var(--muted); }
.edit-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px 16px; }
.edit-grid label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 3px; }
.edit-grid .wide { grid-column: 1 / -1; }
@media (max-width: 900px) { .edit-grid { grid-template-columns: 1fr; } }

/* ---- table ---- */
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
table.grid { width: 100%; border-collapse: collapse; }
.grid th, .grid td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.grid th { background: #f7f9fb; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); position: sticky; top: 0; }
.grid tr:last-child td { border-bottom: 0; }
.grid tr:hover td { background: #fafbfd; }
.grid td.score { font-weight: 700; font-size: 16px; }
.grid td.empty, .empty { color: var(--muted); text-align: center; padding: 22px; }
.grid td.msg { max-width: 360px; font-size: 12px; color: var(--muted); }
.grid td.offer { max-width: 260px; font-size: 12px; }
.tiny { font-size: 11px; color: var(--muted); }
.ok { color: var(--accent); font-weight: 600; } .muted { color: var(--muted); }
.pager { display: flex; gap: 16px; justify-content: center; padding: 14px; color: var(--muted); }

/* ---- tags ---- */
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; background: #eef2f6; color: var(--muted); margin-right: 4px; white-space: nowrap; }
.tag.ok { background: #dcf0e8; color: var(--accent); }
.tag.warn { background: #fff0d9; color: var(--warn); }
.prio-hot { background: #fde2e0; color: var(--bad); } .prio-high { background: #fff0d9; color: var(--warn); } .prio-medium { background: #e5f0fb; color: var(--brand); }
.fit-high { background: #dcf0e8; color: var(--accent); } .fit-medium { background: #e5f0fb; color: var(--brand); }
.kind-none { background: #fde2e0; color: var(--bad); font-weight: 600; }
.kind-social { background: #fbe7f3; color: #9b2c6e; font-weight: 600; }
.kind-dead { background: #fde2e0; color: var(--bad); }
.kind-weak { background: #fff0d9; color: var(--warn); }
.kind-ok { background: #dcf0e8; color: var(--accent); }
.kind-na { background: #eef2f6; color: var(--muted); }
.status-new { background: #eef2f6; } .status-reviewed, .status-qualified { background: #e5f0fb; color: var(--brand); }
.status-contacted, .status-replied { background: #fff0d9; color: var(--warn); }
.status-meeting, .status-proposal { background: #ede7fb; color: #5b3fb5; }
.status-customer, .status-done { background: #dcf0e8; color: var(--accent); }
.status-lost, .status-ignored, .status-error { background: #fde2e0; color: var(--bad); }
.status-running { background: #fff0d9; color: var(--warn); }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 4px; margin-left: 6px; vertical-align: middle; border: 1px solid var(--line); }

/* ---- cards ---- */
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .cols { grid-template-columns: 1fr; } }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 18px; margin-bottom: 16px; }
.card h2 { margin: 0 0 12px; font-size: 14px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.card h3 { font-size: 14px; margin: 14px 0 6px; }
.card h4 { margin: 12px 0 4px; }
dl { display: grid; grid-template-columns: 150px 1fr; gap: 6px 12px; margin: 0; }
dl dt { color: var(--muted); } dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
dl.config { grid-template-columns: 330px 1fr; }
.flash { background: #e5f0fb; border: 1px solid #b9d3ee; color: var(--brand); padding: 10px 14px; border-radius: 8px; margin: 0 0 14px; }
.flash.warn { background: #fff0d9; border-color: #f2d4a2; color: var(--warn); }
.opening pre { white-space: pre-wrap; background: #f7f9fb; border: 1px solid var(--line); border-radius: 8px; padding: 12px; font: inherit; }
.site-text { margin-top: 12px; font-size: 12px; color: var(--muted); }
.site-text summary { cursor: pointer; }
.site-text p { white-space: pre-wrap; max-height: 260px; overflow: auto; background: #f7f9fb; padding: 10px; border-radius: 8px; }
.timeline { list-style: none; padding: 0; margin: 8px 0 0; } .timeline li { padding: 3px 0; border-bottom: 1px dashed var(--line); }

/* ---- kanban ---- */
.due { background: #fff0d9; border: 1px solid #f2d4a2; border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.chip { display: inline-block; background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; font-size: 12px; color: var(--ink); }
.chip.late { border-color: var(--bad); color: var(--bad); }
.chip.score { font-weight: 700; color: var(--accent); }
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.col { flex: 0 0 240px; background: #e9edf2; border-radius: 12px; padding: 10px; }
.col header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.col .count { font-size: 11px; color: var(--muted); background: #fff; border-radius: 999px; padding: 1px 8px; }
.cards { min-height: 60px; display: flex; flex-direction: column; gap: 8px; border-radius: 8px; transition: background .15s; }
.cards.over { background: #d9e6f5; }
.card-k { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px; cursor: grab; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.card-k.dragging { opacity: .5; }
.card-k .name { font-weight: 600; color: var(--ink); display: block; }
.card-k .meta { font-size: 11px; color: var(--muted); margin: 2px 0 6px; }
.card-k .row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.card-k .row.foot { justify-content: space-between; margin-top: 6px; }
.card-k .next { font-size: 11px; color: var(--warn); } .card-k .next.late { color: var(--bad); font-weight: 600; }

/* --- v0.4: auth, sidebar user, conversations --- */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.auth-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 28px; width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.06); }
.auth-card .brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--ink); margin-bottom: 4px; }
.auth-card h1 { margin: 0 0 6px; font-size: 20px; }
.auth-card label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.auth-card input { padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }
.auth-card button { margin-top: 6px; }
.auth-foot { text-align: center; font-size: 13px; color: var(--muted); margin: 6px 0 0; }

.sidebar-foot { display: flex; flex-direction: column; gap: 8px; }
.who { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: rgba(255,255,255,.06); border-radius: 8px; }
.avatar { width: 24px; height: 24px; border-radius: 50%; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex: 0 0 24px; }
.who-name { flex: 1; font-size: 13px; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-btn { background: none; border: 0; color: var(--side-ink); font-size: 12px; padding: 0; cursor: pointer; }
.link-btn:hover { color: #fff; text-decoration: underline; }
.ver { font-size: 11px; opacity: .5; }

.thread { display: flex; flex-direction: column; gap: 8px; max-height: 420px; overflow-y: auto; padding: 4px; margin-bottom: 12px; }
.msg { display: flex; }
.msg-out { justify-content: flex-end; }
.msg-in { justify-content: flex-start; }
.msg .bubble { max-width: 75%; padding: 8px 12px; border-radius: 12px; background: #eef2f6; }
.msg-out .bubble { background: #dcf0e8; }
.msg-text { white-space: pre-wrap; font-size: 13px; }
.msg-meta { font-size: 10px; color: var(--muted); margin-top: 4px; }
.reply-box { display: flex; gap: 8px; align-items: flex-end; }
.reply-box textarea { flex: 1; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; resize: vertical; }
