:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e2e5ea;
  --text: #16191f;
  --muted: #5d6573;
  --faint: #8a92a0;
  --accent: #1f4fd1;
  --accent-soft: #e8eefc;
  --ok: #157f3b;
  --ok-soft: #e4f5ea;
  --warn: #a15c00;
  --warn-soft: #fdf1dc;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --info-soft: #eef0f3;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a21;
    --surface-2: #1e222b;
    --border: #2a2f3a;
    --text: #e8eaee;
    --muted: #a3aab7;
    --faint: #7a8291;
    --accent: #6f95ff;
    --accent-soft: #1d2945;
    --ok: #4cc77a;
    --ok-soft: #15301f;
    --warn: #f0a640;
    --warn-soft: #362812;
    --danger: #ff7b6e;
    --danger-soft: #3a1a17;
    --info-soft: #232833;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Inter, system-ui, -apple-system, Segoe UI, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 20px; font-weight: 650; }
h2 { font-size: 16px; font-weight: 600; }
h3 { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.boot { padding: 48px; color: var(--muted); }

/* ---------- top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 20px;
  padding: 0 24px; height: 56px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 15px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: #1f4fd1; display: grid; place-items: center; }
.nav { display: flex; gap: 4px; }
.nav a { padding: 6px 10px; border-radius: 6px; color: var(--muted); font-weight: 500; }
.nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.nav a.active { color: var(--text); background: var(--surface-2); }
.spacer { flex: 1; }
.who { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 10px; }
.role-tag { font-size: 11px; padding: 2px 7px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* ---------- layout */
main { max-width: 1120px; margin: 0 auto; padding: 24px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.stack > * + * { margin-top: 16px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.prewrap { white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 14px; overflow-x: auto; }
.tab { padding: 9px 14px; border: 0; background: none; color: var(--muted); font: inherit; font-weight: 500; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tab .count { margin-left: 6px; font-size: 11px; padding: 1px 7px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.tab.active .count { background: var(--accent-soft); color: var(--accent); }

/* ---------- buttons & inputs */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-danger { color: var(--danger); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn.selected { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
input[type=text], input[type=password], input[type=datetime-local], select, textarea {
  width: 100%; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px;
}
textarea { resize: vertical; min-height: 72px; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label.field { display: block; }
label.field > span { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.form-grid .full { grid-column: 1 / -1; }
.check { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; cursor: pointer; }

/* ---------- pills */
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--info-soft); color: var(--muted); white-space: nowrap; }
.sev-critical { background: var(--danger-soft); color: var(--danger); }
.sev-high { background: var(--warn-soft); color: var(--warn); }
.sev-medium { background: var(--accent-soft); color: var(--accent); }
.sev-low, .sev-info { background: var(--info-soft); color: var(--muted); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-acknowledged { background: var(--accent-soft); color: var(--accent); }
.st-action_taken { background: var(--ok-soft); color: var(--ok); }
.st-needs_info { background: var(--warn-soft); color: var(--warn); }
.st-not_relevant { background: var(--info-soft); color: var(--muted); }
.v-useful { background: var(--ok-soft); color: var(--ok); }
.v-not_useful { background: var(--danger-soft); color: var(--danger); }

/* ---------- item list */
.bulkbar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); border-radius: var(--radius) var(--radius) 0 0; flex-wrap: wrap; min-height: 50px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; border-top: 1px solid var(--border); }
.list li:first-child { border-top: 0; }
.list li:hover { background: var(--surface-2); }
.list .main { flex: 1; min-width: 0; cursor: pointer; }
.list .title { font-weight: 600; color: var(--text); }
.list .summary { color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.list .meta { margin-top: 6px; display: flex; gap: 6px 12px; flex-wrap: wrap; color: var(--faint); font-size: 12.5px; align-items: center; }
.list input[type=checkbox] { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--accent); }
.unread-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); display: inline-block; }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); }

/* ---------- detail */
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); margin-bottom: 14px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 16px 0 4px; }
.fact .k { font-size: 12px; color: var(--faint); }
.fact .v { font-weight: 500; overflow-wrap: anywhere; }
.section-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 18px 0 6px; }
.callout { background: var(--accent-soft); border-radius: 8px; padding: 12px 14px; }
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.choice-grid .btn { height: auto; padding: 9px 10px; white-space: normal; text-align: center; }

.thread { list-style: none; padding: 0; margin: 0; }
.thread li { padding: 12px 0; border-top: 1px solid var(--border); }
.thread li:first-child { border-top: 0; padding-top: 0; }
.thread .head { display: flex; gap: 8px; align-items: center; font-size: 13px; }
.thread .author { font-weight: 600; }
.thread .body { margin-top: 4px; white-space: pre-wrap; overflow-wrap: anywhere; }
.thread li.internal .body { background: var(--warn-soft); border-radius: 6px; padding: 8px 10px; }

details.raw summary { cursor: pointer; color: var(--muted); font-weight: 500; }
details.raw pre { background: var(--surface-2); border-radius: 8px; padding: 12px; overflow: auto; font-size: 12px; max-height: 360px; }

.timeline { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.timeline li { padding: 7px 0; border-top: 1px solid var(--border); display: flex; gap: 8px; }
.timeline li:first-child { border-top: 0; }

/* ---------- login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 360px; }
.login .brand { margin-bottom: 22px; justify-content: center; font-size: 18px; }
.error { color: var(--danger); font-size: 13px; min-height: 18px; }

/* ---------- people */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--border); }
.table td { padding: 12px 14px; border-top: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:first-child td { border-top: 0; }
.table select { width: auto; padding: 5px 8px; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions .btn + .btn { margin-left: 4px; }
.table tr.inactive td { opacity: .6; }
.who a.name { color: var(--muted); }
.who a.name:hover, .who a.name.active-link { color: var(--text); }
@media (max-width: 860px) {
  .table thead { display: none; }
  .table tr { display: block; border-top: 1px solid var(--border); padding: 8px 0; }
  .table td { display: block; border: 0; padding: 4px 14px; }
  .table .actions { text-align: left; white-space: normal; }
}

/* ---------- learnings */
.learning { padding: 16px 18px; border-top: 1px solid var(--border); }
.learning:first-child { border-top: 0; }
.d-adjusted { background: var(--ok-soft); color: var(--ok); }
.d-no_change { background: var(--info-soft); color: var(--muted); }
.d-needs_human { background: var(--warn-soft); color: var(--warn); }

#toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 8px;
  font-weight: 500; opacity: 0; pointer-events: none; transition: all .18s ease; z-index: 50;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 860px) {
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  main { padding: 16px; }
  .topbar { padding: 0 16px; gap: 10px; }
  .who .name { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .list li { padding: 12px; }
}
