:root {
  color-scheme: dark;
  --bg: #08111f;
  --panel: #101c2f;
  --panel2: #14223a;
  --text: #e7eefb;
  --muted: #91a1b8;
  --accent: #6ee7f9;
  --danger: #fb7185;
  --warn: #facc15;
  --ok: #86efac;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: radial-gradient(circle at top left, #1d3760, var(--bg) 44%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.shell { max-width: 1180px; margin: 0 auto; padding: 32px 20px 64px; }
.hero { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; margin-bottom: 24px; }
.eyebrow { color: var(--accent); text-transform: uppercase; letter-spacing: .15em; font-size: 12px; font-weight: 800; }
h1 { margin: 0; font-size: clamp(36px, 7vw, 72px); line-height: .95; }
h2 { margin-top: 32px; }
.subtitle { color: var(--muted); font-size: 18px; }
.controls { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
label { color: var(--muted); font-size: 13px; display: grid; gap: 6px; }
label.wide { min-width: min(360px, 100%); }
input, button { border: 1px solid rgba(255,255,255,.12); border-radius: 12px; padding: 10px 12px; background: var(--panel); color: var(--text); }
button { cursor: pointer; font-weight: 700; }
button:hover, button.active { border-color: var(--accent); color: var(--accent); }
.status { margin: 16px 0; color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.cards article { background: linear-gradient(145deg, var(--panel), var(--panel2)); border: 1px solid rgba(255,255,255,.08); border-radius: 18px; padding: 20px; box-shadow: 0 16px 50px rgba(0,0,0,.22); }
.metric { font-size: 40px; font-weight: 900; }
.cards p { color: var(--muted); margin: 4px 0 0; }
.filters { display: flex; gap: 10px; margin: 26px 0 8px; flex-wrap: wrap; }
.timeline { display: grid; gap: 12px; }
.change { background: rgba(16,28,47,.92); border: 1px solid rgba(255,255,255,.08); border-left: 5px solid var(--accent); border-radius: 16px; padding: 16px; }
.change.high { border-left-color: var(--danger); }
.change.critical { border-left-color: var(--danger); box-shadow: inset 0 0 0 1px rgba(251,113,133,.18); }
.change.medium { border-left-color: var(--warn); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.summary { font-size: 17px; font-weight: 800; margin-bottom: 8px; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 3px 9px; font-size: 12px; font-weight: 800; background: rgba(255,255,255,.08); color: var(--muted); }
.badge.clickable { border: none; cursor: pointer; }
.badge:disabled { opacity: .45; cursor: not-allowed; }
.badge.risk-high, .badge.risk-critical { color: #fecdd3; background: rgba(251,113,133,.18); }
.badge.risk-medium { color: #fef08a; background: rgba(250,204,21,.16); }
.badge.notion { color: #bbf7d0; background: rgba(134,239,172,.12); }
.meta { color: var(--muted); font-size: 13px; margin-top: 8px; }
@media (max-width: 780px) { .hero { display: block; } .grid { grid-template-columns: 1fr; } }
.charts, .digest { margin-top: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.charts article, .digest article { background: rgba(16,28,47,.78); border: 1px solid rgba(255,255,255,.08); border-radius: 18px; padding: 20px; }
.charts h2, .digest h2 { margin: 0 0 16px; font-size: 18px; }
.bar-chart { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 110px 1fr 72px; gap: 10px; align-items: center; }
.bar-label { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 14px; background: rgba(255,255,255,.07); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), #a78bfa); border-radius: inherit; transition: width .25s ease; }
.bar-fill.high, .bar-fill.critical { background: linear-gradient(90deg, var(--danger), #f97316); }
.bar-fill.medium { background: linear-gradient(90deg, var(--warn), #fb923c); }
.bar-value { color: var(--text); text-align: right; font-weight: 800; font-size: 12px; white-space: nowrap; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-top: 32px; }
.section-heading h2 { margin: 0; }
.section-stat { color: var(--muted); font-size: 13px; font-weight: 800; }
.digest-box, .selection-box { display: grid; gap: 12px; }
.digest-meta { display: flex; gap: 8px; flex-wrap: wrap; }
.digest-list { display: grid; gap: 10px; }
.digest-item { text-align: left; display: grid; gap: 4px; }
.digest-item strong { font-size: 14px; }
.digest-item span { color: var(--muted); font-size: 12px; }
.detail-card { padding: 14px; border-radius: 14px; background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.06); }
.detail-card h3 { margin: 0 0 8px; }
.detail-list { display: grid; gap: 8px; font-size: 13px; }
.empty-state { display: grid; gap: 4px; padding: 14px; border: 1px dashed rgba(255,255,255,.14); border-radius: 14px; background: rgba(255,255,255,.035); color: var(--muted); }
.empty-state strong { color: var(--text); }
.empty-state span { font-size: 13px; line-height: 1.45; }
.selection-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
button.ghost { background: rgba(255,255,255,.04); color: var(--muted); }
button.ghost:hover { color: var(--accent); }
button.primary { background: linear-gradient(135deg, var(--accent), #a78bfa); color: #06121f; border-color: transparent; }
button.primary:hover { color: #06121f; filter: brightness(1.08); }

/* Auth box in the header */
.auth-box { display: flex; flex-direction: column; gap: 6px; align-items: stretch; min-width: 260px; }
.auth-box .status { margin: 0; font-size: 12px; }
.auth-box button { padding: 8px 12px; font-size: 13px; }

/* AI status chip */
.ai-status { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; font-size: 13px; font-weight: 700; border: 1px solid rgba(255,255,255,.12); border-radius: 999px; background: var(--panel); color: var(--muted); cursor: pointer; }
.ai-status:hover { border-color: var(--accent); color: var(--accent); }
.ai-status__dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 2px rgba(255,255,255,.04); flex-shrink: 0; }
.ai-status.ok { color: var(--ok); border-color: rgba(134,239,172,.32); }
.ai-status.ok .ai-status__dot { background: var(--ok); box-shadow: 0 0 0 3px rgba(134,239,172,.18); }
.ai-status.error { color: #fecaca; border-color: rgba(251,113,133,.4); }
.ai-status.error .ai-status__dot { background: var(--danger); box-shadow: 0 0 0 3px rgba(251,113,133,.18); }
.ai-status.disabled { color: var(--muted); }
.ai-status.disabled .ai-status__dot { background: var(--muted); }
.ai-status.checking .ai-status__dot { background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 0.4; } 50% { opacity: 1; } }

/* Description, reason, AI summary on timeline entries */
.change .description { color: var(--text); font-size: 14px; line-height: 1.45; margin: 0 0 8px; opacity: .9; }
.change .reason { color: var(--muted); font-size: 13px; line-height: 1.45; margin: 0 0 8px; }
.change .reason strong { color: var(--text); }
.change .ai-summary { color: var(--muted); font-size: 13px; line-height: 1.45; margin: 0 0 8px; font-style: italic; }
.change .ai-summary strong { color: var(--accent); font-style: normal; }

/* Flagged styling */
.change.flagged { border-left-color: var(--warn); box-shadow: inset 0 0 0 1px rgba(250,204,21,.22); }
.badge.flag { color: #fef3c7; background: rgba(250,204,21,.22); }
.badge.importance { color: var(--accent); background: rgba(110,231,249,.12); }
.badge.user { color: #c4b5fd; background: rgba(167,139,250,.18); }

/* New entry dialog */
.entry-dialog { border: 1px solid rgba(255,255,255,.12); border-radius: 18px; background: var(--panel); color: var(--text); padding: 0; max-width: 640px; width: min(640px, 92vw); box-shadow: 0 40px 100px rgba(0,0,0,.55); }
.entry-dialog::backdrop { background: rgba(4,8,16,.6); backdrop-filter: blur(2px); }
.entry-dialog form { display: grid; gap: 14px; padding: 22px 24px; }
.entry-dialog__header { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.entry-dialog__header h2 { margin: 0; font-size: 20px; }
.entry-dialog__header .ghost { font-size: 18px; padding: 4px 10px; }
.entry-dialog__row { display: grid; gap: 14px; }
.entry-dialog__row.two { grid-template-columns: 1fr 1fr; }
.entry-dialog__field { display: grid; gap: 4px; color: var(--muted); font-size: 13px; }
.entry-dialog__field span { font-weight: 700; }
.entry-dialog__field .req { color: var(--danger); }
.entry-dialog__field input, .entry-dialog__field textarea, .entry-dialog__field select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 10px;
  padding: 9px 11px;
  font: inherit;
}
.entry-dialog__field textarea { resize: vertical; min-height: 60px; }
.entry-dialog__field input:focus, .entry-dialog__field textarea:focus, .entry-dialog__field select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.entry-dialog__error { color: #fecaca; background: rgba(251,113,133,.18); border: 1px solid rgba(251,113,133,.4); border-radius: 10px; padding: 8px 12px; margin: 0; font-size: 13px; }
.entry-dialog__footer { display: flex; justify-content: flex-end; gap: 10px; }
@media (max-width: 600px) { .entry-dialog__row.two { grid-template-columns: 1fr; } }

@media (max-width: 780px) { .charts, .digest { grid-template-columns: 1fr; } .bar-row { grid-template-columns: 88px 1fr 64px; } }
