:root {
  color-scheme: light;
  --surface:#fcfcfb; --page:#f9f9f7; --raised:#ffffff;
  --ink:#0b0b0b; --ink-2:#52514e; --muted:#898781;
  --grid:#e1e0d9; --line:#c3c2b7; --border:rgba(11,11,11,.10);
  --accent:#2a78d6; --accent-soft:#eaf2fd; --accent-deep:#184f95;
  --good:#0ca30c; --good-ink:#006300; --warn:#fab219; --warn-ink:#7a5200;
  --serious:#ec835a; --crit:#d03b3b;
  --ai:#4a3aa7; --ai-soft:#efedfb;
  --r:10px;
  --shadow:0 1px 2px rgba(11,11,11,.05), 0 4px 16px rgba(11,11,11,.04);
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface:#1a1a19; --page:#0d0d0d; --raised:#201f1e;
    --ink:#ffffff; --ink-2:#c3c2b7; --muted:#898781;
    --grid:#2c2c2a; --line:#383835; --border:rgba(255,255,255,.10);
    --accent:#3987e5; --accent-soft:#16283f; --accent-deep:#86b6ef;
    --good-ink:#0ca30c; --warn-ink:#fab219;
    --ai:#9085e9; --ai-soft:#221f3a;
    --shadow:0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
  }
}

* { box-sizing:border-box; }
html, body { height:100%; }
body {
  margin:0; background:var(--page); color:var(--ink);
  font:14.5px/1.55 system-ui,-apple-system,"Segoe UI",sans-serif;
  -webkit-font-smoothing:antialiased;
}
h1,h2,h3,h4 { margin:0; font-weight:600; letter-spacing:-.01em; }
a { color:var(--accent); text-decoration:none; }
a:hover { text-decoration:underline; }
button, input, select, textarea { font:inherit; color:inherit; }
button { cursor:pointer; }
hr { border:none; border-top:1px solid var(--grid); margin:20px 0; }

/* ----------------------------------------------------------- app frame */
#app { display:grid; grid-template-rows:auto 1fr; min-height:100%; }

header.top {
  position:sticky; top:0; z-index:40; background:var(--surface);
  border-bottom:1px solid var(--border);
  display:flex; align-items:center; gap:14px; padding:0 20px; height:56px;
}
.brand { display:flex; align-items:center; gap:9px; font-weight:600; font-size:15px; }
.brand .dot { width:9px; height:9px; border-radius:3px; background:var(--accent); }
.grow { flex:1; }
nav.tabs { display:flex; gap:2px; overflow-x:auto; }
nav.tabs a {
  padding:8px 13px; border-radius:7px; color:var(--ink-2); font-weight:500;
  white-space:nowrap; text-decoration:none; display:flex; align-items:center; gap:7px;
}
nav.tabs a:hover { background:var(--page); color:var(--ink); text-decoration:none; }
nav.tabs a.on { background:var(--accent-soft); color:var(--accent-deep); }
.count {
  min-width:19px; height:19px; padding:0 6px; border-radius:10px; background:var(--crit);
  color:#fff; font-size:11px; font-weight:700; display:inline-flex;
  align-items:center; justify-content:center;
}
.count.q { background:var(--warn); color:#3a2a00; }
.count[data-n="0"] { display:none; }
.who { display:flex; align-items:center; gap:8px; font-size:12.5px; color:var(--muted); }
.who img { width:26px; height:26px; border-radius:50%; }

main { padding:22px 20px 60px; max-width:1240px; margin:0 auto; width:100%; }
.page-head { display:flex; align-items:flex-end; gap:14px; margin-bottom:18px; flex-wrap:wrap; }
.page-head h1 { font-size:21px; }
.page-head p { margin:4px 0 0; color:var(--ink-2); font-size:13.5px; }

/* --------------------------------------------------------------- bits */
.btn {
  border:1px solid var(--border); background:var(--surface); color:var(--ink);
  padding:7px 13px; border-radius:8px; font-weight:500; display:inline-flex;
  align-items:center; gap:7px; line-height:1.3;
}
.btn:hover { background:var(--page); }
.btn.primary { background:var(--accent); border-color:var(--accent); color:#fff; }
.btn.primary:hover { filter:brightness(1.07); }
.btn.ghost { border-color:transparent; background:transparent; color:var(--ink-2); }
.btn.ghost:hover { background:var(--page); color:var(--ink); }
.btn.danger { color:var(--crit); border-color:var(--border); }
.btn.danger:hover { background:#fce8e8; border-color:var(--crit); }
.btn.sm { padding:4px 9px; font-size:12.5px; border-radius:6px; }
.btn:disabled { opacity:.5; cursor:not-allowed; }

.card { background:var(--surface); border:1px solid var(--border); border-radius:var(--r); padding:18px 20px; }
.card + .card { margin-top:14px; }
.card > h3 { font-size:12px; text-transform:uppercase; letter-spacing:.06em; color:var(--muted); margin-bottom:14px; }

.pill {
  display:inline-flex; align-items:center; gap:5px; padding:2px 9px; border-radius:999px;
  font-size:11.5px; font-weight:600; border:1px solid transparent; white-space:nowrap;
}
.pill.ai { background:var(--ai-soft); color:var(--ai); border-color:var(--ai); }
.pill.manual { background:var(--accent-soft); color:var(--accent-deep); border-color:var(--accent); }
.pill.ok { color:var(--good-ink); border-color:var(--good); }
.pill.warn { background:#fff3d6; color:var(--warn-ink); border-color:var(--warn); }
.pill.crit { background:var(--crit); color:#fff; border-color:var(--crit); }
.pill.quiet { color:var(--ink-2); border-color:var(--line); }

label.f { display:block; margin-bottom:12px; }
label.f > span { display:block; font-size:12.5px; color:var(--ink-2); margin-bottom:5px; font-weight:500; }
label.f > em { display:block; font-size:12px; color:var(--muted); font-style:normal; margin-top:4px; }
input[type=text],input[type=search],input[type=url],input[type=email],input[type=number],
input[type=date],select,textarea {
  width:100%; padding:8px 10px; border:1px solid var(--border); border-radius:8px;
  background:var(--raised);
}
textarea { resize:vertical; min-height:84px; line-height:1.55; }
input:focus,select:focus,textarea:focus { outline:2px solid var(--accent); outline-offset:-1px; }
.row { display:grid; grid-template-columns:1fr 1fr; gap:0 14px; }
.row.three { grid-template-columns:1fr 1fr 1fr; }
.row .full { grid-column:1/-1; }
.inline { display:flex; gap:9px; align-items:center; flex-wrap:wrap; }
.check { display:flex; align-items:center; gap:8px; font-size:13.5px; }
.check input { width:auto; }

.toolbar { display:flex; gap:9px; flex-wrap:wrap; align-items:center; margin-bottom:14px; }
.toolbar input[type=search] { width:auto; min-width:260px; }
.toolbar select { width:auto; }

/* --------------------------------------------------------------- tiles */
.tiles { display:grid; grid-template-columns:repeat(auto-fit,minmax(158px,1fr)); gap:12px; margin-bottom:16px; }
.tile { background:var(--surface); border:1px solid var(--border); border-radius:var(--r); padding:14px 16px; }
.tile .lab { font-size:11px; text-transform:uppercase; letter-spacing:.06em; color:var(--muted); font-weight:600; }
.tile .val { font-size:27px; font-weight:600; letter-spacing:-.02em; margin-top:3px; }
.tile .sub { font-size:12.5px; color:var(--ink-2); }
.tile .val.crit { color:var(--crit); } .tile .val.good { color:var(--good-ink); }

/* -------------------------------------------------------------- charts */
.bars { display:flex; flex-direction:column; gap:9px; }
.bar-row { display:grid; grid-template-columns:118px 1fr 58px; gap:12px; align-items:center; }
.bar-lab { font-size:12.5px; color:var(--ink-2); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.bar-track { position:relative; height:13px; background:var(--grid); border-radius:4px; }
.bar-fill { position:absolute; inset:0 auto 0 0; background:var(--accent); border-radius:4px; }
.bar-fill.second { background:var(--accent-deep); }
.bar-val { font-size:12.5px; color:var(--ink-2); text-align:right; font-variant-numeric:tabular-nums; }
.key { display:flex; gap:16px; margin-top:13px; font-size:12px; color:var(--ink-2); flex-wrap:wrap; }
.key i { width:10px; height:10px; border-radius:2px; display:inline-block; margin-right:6px; }

/* ------------------------------------------------------------ listings */
.list { display:flex; flex-direction:column; gap:10px; }
.item {
  background:var(--surface); border:1px solid var(--border); border-radius:var(--r);
  padding:14px 17px; display:grid; grid-template-columns:1fr auto; gap:12px; align-items:start;
}
.item:hover { box-shadow:var(--shadow); }
.item h4 { font-size:15px; display:flex; align-items:center; gap:9px; flex-wrap:wrap; }
.item .meta { font-size:12.5px; color:var(--muted); margin-top:4px; display:flex; gap:10px; flex-wrap:wrap; }
.item .excerpt { font-size:13.5px; color:var(--ink-2); margin-top:7px; }
.code { font-family:ui-monospace,SFMono-Regular,Menlo,monospace; font-size:12.5px;
        background:var(--page); border:1px solid var(--border); border-radius:5px; padding:1px 6px; }

.tagline { display:flex; gap:6px; flex-wrap:wrap; margin-top:9px; }
.tag {
  display:inline-flex; align-items:center; gap:5px; font-size:11.5px; padding:2px 8px;
  border-radius:6px; background:var(--page); border:1px solid var(--border); color:var(--ink-2);
}
.tag b { font-weight:600; color:var(--muted); font-size:10px; text-transform:uppercase; letter-spacing:.04em; }
.tag button { border:none; background:none; color:var(--muted); padding:0 0 0 3px; font-size:14px; line-height:1; }
.tag button:hover { color:var(--crit); }

/* ------------------------------------------------------------ timeline */
.timeline { display:flex; flex-direction:column; gap:0; }
.upd {
  position:relative; padding:16px 0 16px 26px; border-left:2px solid var(--grid);
}
.upd:last-child { border-left-color:transparent; }
.upd::before {
  content:''; position:absolute; left:-6px; top:22px; width:10px; height:10px;
  border-radius:50%; background:var(--muted); border:2px solid var(--surface);
}
.upd.is-pending::before { background:var(--warn); }
.upd.is-deleted { opacity:.55; }
.upd-source { display:flex; align-items:center; gap:9px; flex-wrap:wrap; margin-bottom:5px; }
.upd-meta { font-size:12.5px; color:var(--muted); margin-bottom:9px; }
.upd-body { font-size:14.5px; white-space:pre-wrap; }
.upd-body.struck { text-decoration:line-through; color:var(--muted); }
.upd-foot { display:flex; align-items:center; gap:12px; flex-wrap:wrap; margin-top:11px;
            font-size:12.5px; color:var(--muted); }
.upd-foot .by { color:var(--muted); }
.upd-foot .by.ai { color:var(--ai); font-weight:500; }

/* ---- the channel chip: where this update came from ---- */
.chan {
  display:inline-flex; align-items:center; gap:0; border-radius:8px; overflow:hidden;
  border:1px solid var(--border); background:var(--surface); font-size:12.5px;
  max-width:min(620px,100%); text-decoration:none; color:var(--ink-2); padding:0;
}
.chan:hover { text-decoration:none; border-color:currentColor; }
.chan-k {
  display:inline-flex; align-items:center; gap:6px; padding:4px 9px; font-weight:600;
  white-space:nowrap; color:#fff;
}
.chan-i { font-size:11px; line-height:1; opacity:.9; }
.chan-t {
  padding:4px 10px; color:var(--ink); overflow:hidden; text-overflow:ellipsis;
  white-space:nowrap; min-width:0;
}
.chan-go { padding:4px 9px 4px 0; color:var(--muted); }
.chan:hover .chan-go { color:var(--ink); }

/* One categorical hue per channel, held constant everywhere in the app. */
.chan.email   .chan-k { background:#c4521f; }
.chan.meeting .chan-k { background:#2a78d6; }
.chan.chat    .chan-k { background:#15795a; }
.chan.upload  .chan-k { background:#4a3aa7; }
.chan.manual  .chan-k { background:#6f6e6a; }
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .chan.email   .chan-k { background:#d95926; }
  :root:where(:not([data-theme="light"])) .chan.meeting .chan-k { background:#3987e5; }
  :root:where(:not([data-theme="light"])) .chan.chat    .chan-k { background:#199e70; }
  :root:where(:not([data-theme="light"])) .chan.upload  .chan-k { background:#9085e9; }
  :root:where(:not([data-theme="light"])) .chan.manual  .chan-k { background:#898781; }
}

/* The timeline dot matches the channel, so a glance down the rail reads as
   "meeting, mail, mail, chat" rather than "AI, AI, AI". */
.upd.from-email::before   { background:#c4521f; }
.upd.from-meeting::before { background:#2a78d6; }
.upd.from-chat::before    { background:#15795a; }
.upd.from-upload::before  { background:#4a3aa7; }
.upd.from-manual::before  { background:#6f6e6a; }
.upd.is-pending::before   { background:var(--warn); }

.evidence {
  margin-top:11px; padding:9px 12px; border-left:3px solid var(--line); background:var(--page);
  border-radius:0 7px 7px 0; font-size:13px; color:var(--ink-2); white-space:pre-wrap;
}
.evidence b { display:block; font-size:10.5px; text-transform:uppercase; letter-spacing:.05em;
              color:var(--muted); margin-bottom:3px; }
.acts { display:flex; gap:5px; opacity:.5; transition:opacity .12s; }
.upd:hover .acts, .upd:focus-within .acts { opacity:1; }
@media (hover:none) { .acts { opacity:1; } }

/* -------------------------------------------------------------- misc */
.empty { text-align:center; padding:52px 20px; color:var(--muted); }
.empty h3 { color:var(--ink-2); font-size:15px; margin-bottom:7px; }
.banner {
  display:flex; gap:12px; align-items:flex-start; padding:13px 16px; border-radius:var(--r);
  border:1px solid var(--warn); background:#fff8e6; color:var(--warn-ink); margin-bottom:16px;
  font-size:13.5px;
}
.banner.err { border-color:var(--crit); background:#fce8e8; color:#8f1f1f; }
.banner.ok { border-color:var(--good); background:#eef7ee; color:var(--good-ink); }
.banner .grow { flex:1; }

.toast-wrap { position:fixed; bottom:22px; left:50%; transform:translateX(-50%); z-index:90;
              display:flex; flex-direction:column; gap:8px; align-items:center; }
.toast { background:var(--ink); color:var(--surface); padding:11px 18px; border-radius:9px;
         font-size:13.5px; box-shadow:0 8px 28px rgba(0,0,0,.28); max-width:min(620px,92vw); }
.toast.err { background:var(--crit); color:#fff; }

.scrim { position:fixed; inset:0; background:rgba(0,0,0,.4); z-index:60; display:none; }
.scrim.on { display:block; }
.modal {
  position:fixed; z-index:61; top:50%; left:50%; transform:translate(-50%,-50%);
  width:min(760px,94vw); max-height:88vh; overflow:auto; background:var(--surface);
  border:1px solid var(--border); border-radius:14px; box-shadow:0 20px 60px rgba(0,0,0,.3);
  display:none;
}
.modal.on { display:block; }
.modal-head { padding:17px 22px; border-bottom:1px solid var(--border); display:flex;
              align-items:center; gap:12px; position:sticky; top:0; background:var(--surface); }
.modal-body { padding:22px; }
.modal-foot { padding:14px 22px; border-top:1px solid var(--border); display:flex; gap:10px;
              align-items:center; position:sticky; bottom:0; background:var(--surface); }

.spin { display:inline-block; width:14px; height:14px; border:2px solid currentColor;
        border-right-color:transparent; border-radius:50%; animation:sp .7s linear infinite; }
@keyframes sp { to { transform:rotate(360deg); } }

.signin { display:grid; place-items:center; min-height:72vh; text-align:center; }
.signin .card { max-width:430px; padding:38px 34px; }

@media (max-width:760px) {
  .row, .row.three { grid-template-columns:1fr; }
  header.top { flex-wrap:wrap; height:auto; padding:10px 14px; }
  nav.tabs { order:3; width:100%; }
  main { padding:16px 14px 50px; }
  .item { grid-template-columns:1fr; }
}
