:root {
  --bg: #f5f7f8;
  --surface: #fff;
  --muted: #65716f;
  --line: #d9e1df;
  --text: #182321;
  --accent: #0f766e;
  --accent-soft: #e8f5f2;
  --danger: #b42318;
  --warn: #a15c07;
  --shadow: 0 18px 42px rgba(23, 35, 33, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.shell { display: grid; grid-template-columns: 340px minmax(0, 1fr); min-height: 100vh; }
.sidebar { display: flex; flex-direction: column; gap: 16px; padding: 22px; border-right: 1px solid var(--line); background: #fbfcfc; }
.brand { display: flex; gap: 12px; align-items: center; }
.mark { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 8px; background: var(--accent); color: white; font-weight: 900; }
.brand h1, .brand p, .topbar h2, .topbar p { margin: 0; }
.brand h1 { font-size: 18px; }
.brand p, .eyebrow { color: var(--muted); font-size: 12px; }
.workspace { min-width: 0; padding: 22px 28px 32px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 18px; min-height: 64px; }
.topbar h2 { font-size: 28px; line-height: 1.2; }
.topbar-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 10px; }
.topbar-field { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; font-weight: 700; }
.topbar-field select { width: 180px; }

.panel { padding: 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.sidebar .panel { box-shadow: none; }
.grow { flex: 1; min-height: 0; overflow: auto; }
.section-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.stack { display: flex; flex-direction: column; gap: 10px; }

.role-card, .topic-card, .task-card, .review-card, .timeline-item {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 12px;
  text-align: left;
}
.role-card header, .task-row, .review-row { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.role-card span, .topic-card p, .task-card span, .review-card p, .timeline-item p { color: var(--muted); font-size: 12px; line-height: 1.45; }
.topic-card.active { border-color: var(--accent); background: var(--accent-soft); }
.topic-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { display: inline-flex; min-height: 24px; align-items: center; padding: 3px 8px; border-radius: 999px; background: #eef2f7; color: #334155; font-size: 12px; font-weight: 800; }
.pill[data-status="needs_human"] { background: #fff7ed; color: var(--warn); }
.pill[data-status="done"] { background: #ecfdf5; color: var(--accent); }
.pill[data-priority="high"] { background: #fef2f2; color: var(--danger); }

.summary-band { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; padding: 18px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.summary-band p { margin: 0; color: #40504d; line-height: 1.6; }
.content-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.timeline { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.timeline-item { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 12px; box-shadow: none; }
.timeline-item time { color: var(--muted); font-size: 12px; }
.event-form { display: grid; grid-template-columns: 180px minmax(0, 1fr) 84px; gap: 10px; align-items: end; margin-top: 14px; }
.event-form label { color: var(--muted); font-size: 12px; font-weight: 700; }

.empty-state { display: grid; place-content: center; min-height: 60vh; border: 1px dashed var(--line); border-radius: 8px; background: white; text-align: center; }
.empty-state h3, .empty-state p { margin: 0; }
.empty-state p { margin-top: 8px; color: var(--muted); }
.hidden { display: none !important; }

input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; background: white; color: var(--text); }
textarea { resize: vertical; }
button, .primary-button, .icon-button, .small-button, .toolbar-button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  background: white;
  color: var(--text);
  font-weight: 800;
}
.primary-button { border-color: var(--accent); background: var(--accent); color: white; }
.icon-button { width: 40px; padding: 0; font-size: 20px; }
.small-button { min-height: 28px; padding: 4px 8px; font-size: 12px; }

.archive-menu { position: relative; }
.toolbar-button { display: inline-flex; align-items: center; gap: 8px; }
.count-badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; border-radius: 999px; background: var(--accent-soft); color: var(--muted); font-size: 12px; }
.archive-popover {
  position: absolute;
  z-index: 20;
  top: calc(100% + 14px);
  right: -34px;
  width: min(440px, calc(100vw - 40px));
  padding: 16px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: 18px;
  background: rgba(255,255,255,0.9);
  box-shadow: 0 24px 70px rgba(15,23,42,0.18);
  backdrop-filter: blur(18px);
}
.popover-arrow { position: absolute; top: -8px; right: 92px; width: 16px; height: 16px; border-top: 1px solid rgba(148,163,184,0.45); border-left: 1px solid rgba(148,163,184,0.45); background: rgba(255,255,255,0.9); transform: rotate(45deg); }
.archive-popover header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; font-size: 13px; }
.archive-list { display: flex; flex-direction: column; gap: 8px; max-height: 360px; overflow: auto; margin-top: 12px; }
.archive-item { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 10px; width: 100%; min-height: 74px; border: 1px solid transparent; border-radius: 8px; padding: 10px; background: rgba(241,245,249,0.72); text-align: left; }
.archive-item:hover, .archive-item.active { border-color: rgba(15,118,110,0.35); background: rgba(236,253,245,0.82); }
.archive-item-icon { display: grid; place-items: center; width: 24px; height: 24px; border: 1px solid var(--line); border-radius: 6px; background: white; color: var(--accent); font-weight: 900; }
.archive-item strong, .archive-item span, .archive-item small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.archive-item span, .archive-item small, .archive-empty { color: var(--muted); font-size: 12px; }

dialog { width: min(560px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(15,23,42,0.28); }
.dialog-body { display: flex; flex-direction: column; gap: 14px; }
.dialog-body h3, .dialog-body p { margin: 0; }
.dialog-body label { display: flex; flex-direction: column; gap: 7px; color: #34433f; font-size: 13px; font-weight: 700; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }

@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .content-grid, .event-form, .timeline-item { grid-template-columns: 1fr; }
}

