:root {
  --bg: #f5f5f2; --surface: #ffffff; --surface2: #efeee9; --ink: #16181d; --ink2: #4a4e57; --mute: #7b7f87;
  --line: #e2e1db; --accent: #1f4fd8; --accent-bg: #e7edfc;
  --crit: #c4320a; --crit-bg: #fdebe4; --high: #b25e00; --high-bg: #fdf1df; --norm: #2f6fdb; --norm-bg: #e6eefc; --low: #6b7280; --low-bg: #eeeff1;
  --ok: #137a47; --ok-bg: #e2f4ea; --warn: #9a5b00; --warn-bg: #fdf0d8; --bad: #b42318; --bad-bg: #fde8e6;
  --radius: 12px; --shadow: 0 1px 2px rgba(20, 20, 30, .05), 0 6px 24px rgba(20, 20, 30, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1013; --surface: #17181c; --surface2: #1e2025; --ink: #ecedef; --ink2: #b9bcc3; --mute: #8b8f97;
    --line: #2a2c32; --accent: #86a8ff; --accent-bg: #1c2540;
    --crit: #ff8a6b; --crit-bg: #3a1d15; --high: #f3ad57; --high-bg: #35260f; --norm: #86a8ff; --norm-bg: #1b2440; --low: #a0a5ad; --low-bg: #24262b;
    --ok: #55c98d; --ok-bg: #12301f; --warn: #f0b04a; --warn-bg: #33270f; --bad: #ff7d72; --bad-bg: #3a1916;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 28px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 24px; } h2 { font-size: 15px; font-weight: 650; } h3 { font-size: 14px; }
.mute { color: var(--mute); } .small { font-size: 13px; } .err { color: var(--bad); min-height: 1.2em; margin: 8px 0 0; }

/* layout */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 24px; padding: 12px 24px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.01em; }
.logo { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; background: var(--ink); color: var(--bg); font-size: 15px; }
#nav { display: flex; gap: 4px; }
#nav a { text-decoration: none; color: var(--ink2); padding: 6px 12px; border-radius: 8px; font-weight: 550; }
#nav a.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.me { margin-left: auto; color: var(--mute); font-size: 13px; }
main { max-width: 1120px; margin: 0 auto; padding: 24px 24px 120px; }
.tabbar { display: none; }
@media (max-width: 760px) {
  .top { padding: 10px 16px; } #nav, .me { display: none; }
  main { padding: 16px 16px 110px; }
  .tabbar { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; background: var(--surface); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .tabbar a { flex: 1; text-align: center; text-decoration: none; color: var(--mute); font-size: 11px; font-weight: 600; display: flex; flex-direction: column; align-items: center; gap: 1px; }
  .tabbar a span { font-size: 18px; line-height: 1.2; }
  .tabbar a.on { color: var(--ink); }
}

/* cards & sections */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.section { margin-top: 22px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* buttons & inputs */
.btn { appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 9px; padding: 8px 14px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--mute); }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink2); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; width: 100%; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
label { display: block; font-size: 12px; font-weight: 600; color: var(--mute); text-transform: uppercase; letter-spacing: .03em; }
label > input, label > select, label > textarea { margin-top: 4px; text-transform: none; letter-spacing: 0; font-weight: 400; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; display: grid; gap: 14px; background: var(--surface); padding: 28px; border-radius: 16px; border: 1px solid var(--line); box-shadow: var(--shadow); }
.login-card .brand { font-size: 18px; margin-bottom: 6px; }

/* capture */
.capture { padding: 16px; }
.cap-row { display: flex; gap: 12px; align-items: stretch; }
.mic { flex: none; width: 64px; border-radius: 14px; border: 0; background: var(--ink); color: var(--bg); font-size: 26px; cursor: pointer; display: grid; place-items: center; }
.mic.live { background: var(--bad); animation: pulse 1.2s infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--bad) 45%, transparent); } 50% { box-shadow: 0 0 0 10px transparent; } }
.cap-row textarea { min-height: 64px; border-radius: 14px; font-size: 16px; }
.cap-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.reply { margin-top: 14px; padding: 12px 14px; border-radius: 10px; background: var(--accent-bg); color: var(--ink); }
.question { margin-top: 8px; padding: 10px 14px; border-radius: 10px; background: var(--warn-bg); color: var(--warn); font-weight: 550; }
.proposal { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-top: 10px; background: var(--bg); }
.proposal-head { display: flex; gap: 10px; align-items: center; }
.proposal-head input[type=checkbox] { width: 18px; height: 18px; flex: none; }
.proposal .fields { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
@media (max-width: 760px) { .proposal .fields { grid-template-columns: 1fr 1fr; } }
.why { font-size: 12.5px; color: var(--mute); margin-top: 6px; }
.kind { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 2px 7px; border-radius: 6px; background: var(--surface2); color: var(--ink2); flex: none; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 22px; }
.kpi { padding: 14px 16px; text-decoration: none; color: inherit; }
.kpi .n { font-size: 28px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi .l { font-size: 13px; color: var(--mute); font-weight: 550; }
.kpi.bad .n { color: var(--bad); } .kpi.warn .n { color: var(--warn); }
@media (max-width: 760px) { .kpis { grid-template-columns: repeat(2, 1fr); gap: 10px; } }

/* rows */
.list { overflow: hidden; }
.row { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto auto; align-items: center; gap: 12px; width: 100%; padding: 11px 14px; background: none; border: 0; border-top: 1px solid var(--line); text-align: left; font: inherit; color: inherit; cursor: pointer; }
.row:first-child { border-top: 0; }
.row:hover { background: var(--surface2); }
.row .title { font-weight: 600; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sub { display: block; font-size: 13px; color: var(--mute); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 10px; height: 10px; border-radius: 50%; }
.dot.critical { background: var(--crit); } .dot.high { background: var(--high); } .dot.normal { background: var(--norm); } .dot.low { background: var(--low); }
.due { font-size: 13px; font-weight: 600; color: var(--ink2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.due.over { color: var(--bad); } .due.soon { color: var(--warn); }
.chip { font-size: 12px; font-weight: 650; padding: 2px 8px; border-radius: 99px; background: var(--surface2); color: var(--ink2); white-space: nowrap; }
.chip.blocked { background: var(--bad-bg); color: var(--bad); } .chip.in_progress { background: var(--accent-bg); color: var(--accent); }
.chip.done { background: var(--ok-bg); color: var(--ok); } .chip.cancelled { text-decoration: line-through; }
.chip.critical { background: var(--crit-bg); color: var(--crit); } .chip.high { background: var(--high-bg); color: var(--high); } .chip.normal { background: var(--norm-bg); color: var(--norm); } .chip.low { background: var(--low-bg); color: var(--low); }
.chip.sent { background: var(--ok-bg); color: var(--ok); } .chip.simulated { background: var(--accent-bg); color: var(--accent); } .chip.failed { background: var(--bad-bg); color: var(--bad); } .chip.queued { background: var(--warn-bg); color: var(--warn); } .chip.expired { text-decoration: line-through; }
.chip.skipped { background: var(--warn-bg); color: var(--warn); }
@media (max-width: 760px) { .row { grid-template-columns: 10px minmax(0, 1fr) auto; } .row .chip.st { display: none; } }
.empty { padding: 22px 16px; color: var(--mute); text-align: center; }
.attn { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-top: 1px solid var(--line); }
.attn:first-child { border-top: 0; }
.attn .body { flex: 1; min-width: 0; }
.attn .actions { display: flex; gap: 6px; flex: none; }
.tag { font-size: 11px; font-weight: 750; letter-spacing: .05em; text-transform: uppercase; }
.tag.bad { color: var(--bad); } .tag.warn { color: var(--warn); } .tag.acc { color: var(--accent); }

/* filters */
.filters { display: grid; grid-template-columns: 2fr repeat(5, 1fr); gap: 8px; margin: 16px 0; }
@media (max-width: 900px) { .filters { grid-template-columns: 1fr 1fr; } .filters .search { grid-column: 1 / -1; } }
.group-h { padding: 10px 14px; background: var(--surface2); font-size: 12.5px; font-weight: 700; color: var(--ink2); display: flex; justify-content: space-between; border-top: 1px solid var(--line); }
.group-h:first-child { border-top: 0; }

/* drawer & modal */
.drawer, .modal { position: fixed; inset: 0; z-index: 50; }
.drawer-bg { position: absolute; inset: 0; background: rgba(10, 10, 15, .4); }
.drawer-panel { position: absolute; right: 0; top: 0; bottom: 0; width: min(560px, 100%); background: var(--bg); overflow-y: auto; padding: 20px 22px 60px; box-shadow: -10px 0 40px rgba(0, 0, 0, .2); }
.modal-card { position: relative; margin: 8vh auto 0; width: min(520px, calc(100% - 32px)); max-height: 84vh; overflow-y: auto; background: var(--bg); border-radius: 16px; padding: 22px; box-shadow: var(--shadow); }
.dr-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.title-input { font-size: 20px; font-weight: 700; border: 1px solid transparent; background: transparent; padding: 4px 6px; margin-left: -6px; }
.title-input:hover { border-color: var(--line); }
.meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.seg button { flex: 1; min-width: 90px; }
.seg button.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.fu { margin-top: 18px; padding: 14px; }
.meter { display: flex; gap: 3px; margin: 8px 0; }
.meter i { flex: 1; height: 6px; border-radius: 3px; background: var(--surface2); }
.meter i.on { background: var(--warn); } .meter i.on.hot { background: var(--bad); }
.timeline { margin-top: 10px; border-left: 2px solid var(--line); padding-left: 14px; }
.tl { position: relative; padding: 6px 0; font-size: 13.5px; }
.tl::before { content: ""; position: absolute; left: -19px; top: 12px; width: 8px; height: 8px; border-radius: 50%; background: var(--mute); }
.tl.done::before, .tl.progress::before { background: var(--ok); } .tl.blocked::before, .tl.escalation::before { background: var(--bad); } .tl.nudge::before { background: var(--accent); } .tl.extension::before { background: var(--warn); }
.tl .when { color: var(--mute); font-size: 12px; }
.decision { margin-top: 14px; padding: 14px; background: var(--warn-bg); border-radius: 10px; }
.blocker { margin-top: 14px; padding: 12px 14px; background: var(--bad-bg); color: var(--bad); border-radius: 10px; }

/* people */
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin-top: 16px; }
.person { padding: 14px 16px; cursor: pointer; text-align: left; font: inherit; color: inherit; }
.person .nm { font-weight: 700; }
.stats { display: flex; gap: 14px; margin-top: 10px; font-size: 13px; }
.stats b { font-size: 17px; display: block; font-variant-numeric: tabular-nums; }
.contacts { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.contacts span { font-size: 11.5px; font-weight: 650; padding: 2px 7px; border-radius: 6px; background: var(--surface2); color: var(--mute); }
.contacts span.on { background: var(--ok-bg); color: var(--ok); }

/* outbox, settings */
.msg { padding: 12px 14px; border-top: 1px solid var(--line); }
.msg:first-child { border-top: 0; }
.msg-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; }
.msg-text { white-space: pre-wrap; margin-top: 6px; font-size: 14px; color: var(--ink2); }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 8px 16px; padding: 16px; }
.kv dt { color: var(--mute); font-weight: 600; font-size: 13px; } .kv dd { margin: 0; }
.rules { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.rules th, .rules td { text-align: left; padding: 8px 12px; border-top: 1px solid var(--line); }
.rules th { color: var(--mute); font-weight: 650; border-top: 0; }
.brief { white-space: pre-wrap; font-size: 14px; padding: 16px; margin: 0; font-family: inherit; }
.banner { max-width: 1120px; margin: 12px auto 0; padding: 0 24px; }
.banner div { padding: 10px 14px; border-radius: 10px; background: var(--accent-bg); font-size: 13.5px; }
@media (max-width: 760px) { .banner { padding: 0 16px; } .kv { grid-template-columns: 1fr; gap: 2px; } .kv dd { margin-bottom: 10px; } }
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600; z-index: 99; box-shadow: var(--shadow); max-width: calc(100% - 32px); }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: sp .8s linear infinite; vertical-align: -2px; }
@keyframes sp { to { transform: rotate(360deg); } }

/* AI summary + conversation */
.summary { margin-top: 14px; padding: 14px 16px; border-radius: 12px; background: var(--accent-bg); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent); line-height: 1.55; }
.summary.empty-sum { background: var(--surface); border-style: dashed; border-color: var(--line); }
.sum-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.convo { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.msgc { padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); max-width: 92%; }
.msgc.in { align-self: flex-start; border-left: 3px solid var(--ok); }
.msgc.out { align-self: flex-end; background: var(--surface2); }
.msgc-head { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; font-size: 12.5px; margin-bottom: 4px; }
.msgc-text { white-space: pre-wrap; font-size: 14px; overflow-wrap: anywhere; }
.chan { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 1px 6px; border-radius: 5px; background: var(--surface2); color: var(--ink2); }
.chan.slack { background: #f3e8fd; color: #6b2fa6; } .chan.email { background: var(--norm-bg); color: var(--norm); } .chan.imessage { background: var(--ok-bg); color: var(--ok); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chan.slack { background: #2d1b40; color: #d4a8ff; } }
details.section > summary { cursor: pointer; list-style: none; }
details.section > summary::-webkit-details-marker { display: none; }
details.section > summary::before { content: '▸ '; color: var(--mute); }
details.section[open] > summary::before { content: '▾ '; }
