:root {
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #1d2a24;
  background: #f2f1eb;
  color-scheme: light dark;
  --ink: #1d2a24;
  --muted: #667169;
  --subtle: #879189;
  --panel: rgba(255, 255, 255, .84);
  --panel-solid: #fbfcf9;
  --line: rgba(29, 42, 36, .12);
  --accent: #19654b;
  --accent-soft: rgba(25, 101, 75, .09);
  --warn: #9b441f;
  --warn-soft: rgba(155, 68, 31, .1);
  --shadow: 0 14px 35px rgba(35, 52, 44, .06);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 320px; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top right, #dbe8dd, transparent 38%), #f2f1eb;
}
main {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 18px max(64px, env(safe-area-inset-bottom));
}
button, input, textarea { font: inherit; }
button { min-height: 44px; }
button, summary { -webkit-tap-highlight-color: transparent; }
h1, h2, h3, h4, p { margin-top: 0; }
h1 {
  margin-bottom: 0;
  font-size: clamp(30px, 7vw, 44px);
  line-height: 1.02;
  letter-spacing: -.045em;
}
h2 { margin-bottom: 0; font-size: 21px; letter-spacing: -.02em; }
h3 { margin-bottom: 0; font-size: 17px; line-height: 1.35; }
h4 { margin-bottom: 0; font-size: 14px; }

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}
.header-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; flex-wrap: wrap; }
.eyebrow, .section-kicker {
  margin-bottom: 6px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .17em;
  text-transform: uppercase;
}
.section-kicker { letter-spacing: .1em; }
.supporting-copy {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}
.compact-copy { margin-top: 8px; font-size: 12px; }
.card, .task {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}
.card { padding: 18px; }
.unlock-card { padding: 22px; }
.unlock-card h2 { margin-bottom: 10px; font-size: 24px; }
label { display: block; margin: 16px 0 6px; color: var(--muted); font-size: 13px; font-weight: 700; }
input, textarea {
  width: 100%;
  min-height: 48px;
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: 0;
  background: rgba(255, 255, 255, .74);
  color: var(--ink);
  padding: 12px 13px;
}
textarea { min-height: 102px; resize: vertical; line-height: 1.55; }
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
button {
  border: 0;
  border-radius: 999px;
  padding: 10px 17px;
  background: var(--accent);
  color: white;
  font-weight: 760;
  cursor: pointer;
}
button:hover { filter: brightness(.96); }
button:disabled { opacity: .55; cursor: wait; }
button.secondary { color: var(--accent); background: var(--accent-soft); }
button.compact { min-height: 44px; padding: 8px 14px; }
button.text-button { min-height: 44px; padding: 6px 9px; color: var(--muted); background: transparent; }
button.full-width { width: 100%; margin-top: 18px; }
button:focus-visible, summary:focus-visible, .tab:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 3px;
}
.status, .data-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 6px 10px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 760;
  white-space: nowrap;
}
.status::before { width: 7px; height: 7px; border-radius: 50%; background: currentColor; content: ""; }
.status.offline, .status.failed { color: var(--warn); background: var(--warn-soft); }
.data-badge.muted { color: var(--muted); background: rgba(102, 113, 105, .1); }
.form-message, .refresh-state { margin: 10px 2px 0; min-height: 20px; color: var(--muted); font-size: 12px; line-height: 1.55; overflow-wrap: anywhere; }
.error { color: var(--warn); }

.view-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-bottom: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .48);
  padding: 4px;
}
.tab { min-height: 44px; background: transparent; color: var(--muted); box-shadow: none; }
.tab.active { background: var(--panel-solid); color: var(--ink); box-shadow: 0 5px 14px rgba(35, 52, 44, .08); }
.section-heading, .card-heading-row, .compose-heading, .subsection-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.section-heading { align-items: center; margin: 0 2px 12px; }
.section-heading .section-kicker, .card-heading-row .section-kicker, .compose-heading .section-kicker { margin-bottom: 4px; }
.metric-label { margin-bottom: 7px; color: var(--muted); font-size: 12px; font-weight: 720; }
.metric-value {
  margin-bottom: 0;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
  letter-spacing: -.045em;
  overflow-wrap: anywhere;
}
.metric-value { font-size: clamp(25px, 7vw, 32px); font-weight: 770; }
.meta-line { margin: 8px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
.metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.metric-card { min-height: 138px; display: flex; flex-direction: column; justify-content: space-between; }
.section-card, .conclusion-card, .gaps-card { margin-top: 12px; }
.section-card h3, .conclusion-card h3 { margin-bottom: 0; }
.fallback-block { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 15px; }
.ranked-list, .risk-list, .gap-list { margin: 12px 0 0; padding: 0; list-style: none; }
.ranked-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.ranked-list li:last-child { border-bottom: 0; }
.rank-label { min-width: 0; font-size: 14px; font-weight: 700; overflow-wrap: anywhere; }
.rank-value { font-variant-numeric: tabular-nums; font-size: 14px; font-weight: 760; text-align: right; }
.rank-value.negative { color: var(--warn); }
.rank-share { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; font-weight: 500; }
.inline-note {
  margin: 12px 0 0;
  border-radius: 12px;
  background: rgba(102, 113, 105, .07);
  color: var(--muted);
  padding: 10px 11px;
  font-size: 12px;
  line-height: 1.55;
}
.risk-list { display: grid; gap: 2px; counter-reset: risk; }
.risk-list li { position: relative; padding: 12px 0 12px 30px; border-bottom: 1px solid var(--line); }
.risk-list li:last-child { border-bottom: 0; }
.risk-list li::before {
  position: absolute;
  top: 13px;
  left: 0;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 7px;
  background: var(--warn-soft);
  color: var(--warn);
  content: counter(risk);
  counter-increment: risk;
  font-size: 11px;
  font-weight: 800;
}
.risk-title { display: block; margin-bottom: 4px; font-size: 14px; }
.risk-level {
  display: inline-block;
  margin: 0 0 5px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--muted);
  padding: 2px 7px;
  font-size: 10px;
  font-weight: 800;
}
.risk-level.warning, .risk-level.critical { background: var(--warn-soft); color: var(--warn); }
.risk-summary, .gap-impact { color: var(--muted); font-size: 12px; line-height: 1.55; }
.conclusion-card { border-color: color-mix(in srgb, var(--accent) 26%, var(--line)); background: color-mix(in srgb, var(--panel) 91%, var(--accent-soft)); }
.conclusion-text { margin: 16px 0 0; font-size: 15px; line-height: 1.75; }
.gaps-card { padding: 0; overflow: clip; }
.gaps-card summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
  padding: 10px 18px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 760;
  list-style: none;
}
.gaps-card summary::-webkit-details-marker { display: none; }
.gap-list { margin: 0; border-top: 1px solid var(--line); padding: 4px 18px 14px; }
.gap-list li { padding: 11px 0; border-bottom: 1px solid var(--line); }
.gap-list li:last-child { border-bottom: 0; }
.gap-title { display: block; margin-bottom: 4px; font-size: 13px; }
.quick-section { margin-top: 28px; }
.compact-heading { margin-bottom: 10px; }
.quick-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.quick-grid button, .state-card .quick-prompt {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  color: var(--ink);
  padding: 10px 12px;
  text-align: left;
  line-height: 1.35;
}
.state-card { text-align: left; }
.state-card h3 { margin-bottom: 8px; }
.state-card button { margin-top: 14px; }

.dashboard-loading { display: grid; gap: 12px; }
.skeleton-card { display: grid; gap: 14px; overflow: hidden; }
.skeleton { display: block; border-radius: 8px; background: linear-gradient(90deg, rgba(102,113,105,.08), rgba(102,113,105,.17), rgba(102,113,105,.08)); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
.skeleton.line { width: 100%; height: 12px; }
.skeleton.line.short { width: 38%; }
.skeleton.amount { width: 70%; height: 44px; }
.skeleton.amount.small { width: 55%; height: 30px; }
@keyframes shimmer { to { background-position: -200% 0; } }

.compose { padding: 20px; }
.compose-heading { margin-bottom: 12px; }
.compose h2 { font-size: 20px; }
.actions, .timeline-header, .retry-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.actions { margin-top: 12px; }
.shortcut-hint { color: var(--subtle); font-size: 11px; }
.timeline-header { margin: 28px 2px 12px; }
.timeline-header h2 { margin: 0; }
.timeline { display: grid; gap: 12px; }
.task { overflow: clip; }
.task summary { list-style: none; cursor: pointer; padding: 16px 18px; }
.task summary::-webkit-details-marker { display: none; }
.task-summary-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.task time { color: var(--muted); font-size: 11px; }
.task-question {
  display: -webkit-box;
  margin: 10px 0 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  font-weight: 680;
  line-height: 1.5;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.task[open] .task-question { display: block; }
.task-body { border-top: 1px solid var(--line); padding: 4px 18px 18px; }
.event { padding-top: 12px; }
.event + .event { border-top: 1px solid var(--line); }
.event-label { display: block; margin-bottom: 5px; color: var(--muted); font-size: 11px; }
.message { margin: 8px 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.65; }
.message.user { color: var(--muted); }
.process-details { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.process-details summary { min-height: 44px; padding: 10px 0; color: var(--muted); font-size: 12px; font-weight: 700; }
.approval { margin-top: 10px; border-radius: 14px; background: var(--warn-soft); padding: 12px; }
.approval-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.approval button.decline { color: var(--warn); background: rgba(155, 68, 31, .14); }
.approval fieldset { margin: 12px 0; border: 0; padding: 0; }
.approval legend { margin-bottom: 8px; color: var(--ink); font-size: 13px; font-weight: 700; }
.option-list { display: grid; gap: 6px; }
.option-label { display: flex; align-items: flex-start; gap: 8px; min-height: 44px; margin: 0; border: 1px solid var(--line); border-radius: 12px; padding: 10px; color: var(--ink); font-weight: 600; }
.option-label input { width: auto; min-height: auto; margin: 2px 0 0; padding: 0; }
.retry-actions { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 12px; }
.retry-note { margin: 0; color: var(--muted); font-size: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (max-width: 540px) {
  main { padding-left: 14px; padding-right: 14px; }
  .site-header { align-items: flex-start; }
  .header-actions { max-width: 48%; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .metric-card { min-height: 128px; padding: 15px; }
  .quick-grid { grid-template-columns: 1fr; }
  .quick-grid button { text-align: center; }
  .actions .primary { width: 100%; }
  .shortcut-hint { order: 2; width: 100%; text-align: center; }
  .retry-actions button { width: 100%; }
}

@media (max-width: 360px) {
  main { padding-left: 12px; padding-right: 12px; }
  .site-header { display: block; }
  .header-actions { max-width: none; justify-content: flex-start; margin-top: 14px; }
  .metric-grid { grid-template-columns: 1fr; }
  .metric-card { min-height: 118px; }
  .card-heading-row { align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

@media (prefers-color-scheme: dark) {
  :root {
    color: #ecf3ee;
    background: #101612;
    --ink: #ecf3ee;
    --muted: #adb8b1;
    --subtle: #8d9a91;
    --panel: rgba(24, 34, 29, .91);
    --panel-solid: #1b2720;
    --line: rgba(235, 244, 238, .13);
    --accent: #7ccdaa;
    --accent-soft: rgba(124, 205, 170, .12);
    --warn: #f2a17c;
    --warn-soft: rgba(242, 161, 124, .12);
    --shadow: 0 14px 35px rgba(0, 0, 0, .18);
  }
  body { background: radial-gradient(circle at top right, #173b2c, transparent 38%), #101612; }
  input, textarea { background: rgba(8, 13, 10, .58); }
  .view-tabs { background: rgba(8, 13, 10, .34); }
}
