:root {
  color-scheme: light;
  --ink: #17211d;
  --muted: #6f7c76;
  --line: #dce4df;
  --line-strong: #c8d2cc;
  --paper: #f3f5f2;
  --panel: #fbfcfa;
  --white: #fff;
  --night: #0b1210;
  --night-2: #15201c;
  --green: #1d704d;
  --green-2: #2a9168;
  --green-soft: #e4f0e9;
  --lime: #c8ff65;
  --amber: #b66a17;
  --amber-soft: #fff0d7;
  --red: #b3403b;
  --red-soft: #fee8e5;
  --shadow: 0 18px 44px rgba(26, 42, 34, .08);
  --radius: 20px;
  --sidebar: 250px;
  font-family: Inter, "SF Pro Display", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 80% -10%, rgba(151, 203, 170, .22), transparent 30rem),
    var(--paper);
  color: var(--ink);
}
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; }

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 99;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--night);
  color: white;
  transform: translateY(-150%);
}
.skip-link:focus { transform: translateY(0); }

.app-shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 24px 18px 18px;
  overflow-y: auto;
  background:
    radial-gradient(circle at 10% 85%, rgba(74, 145, 104, .22), transparent 16rem),
    var(--night);
  color: rgba(255,255,255,.88);
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; padding: 4px 6px 24px; }
.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 13px;
  background: linear-gradient(145deg, rgba(255,255,255,.14), rgba(255,255,255,.03));
  color: var(--lime);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: -.03em;
}
.brand span:last-child { display: grid; gap: 2px; }
.brand strong { color: white; font-size: 15px; letter-spacing: .02em; }
.brand small { color: rgba(255,255,255,.48); font-size: 11px; }

.system-state {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 0 2px 20px;
  padding: 14px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 14px;
  background: rgba(255,255,255,.045);
}
.system-state div { display: grid; gap: 3px; }
.system-state strong { font-size: 12px; color: rgba(255,255,255,.9); }
.system-state small { font-size: 10px; line-height: 1.4; color: rgba(255,255,255,.45); }
.health-dot { width: 8px; height: 8px; margin-top: 4px; flex: 0 0 auto; border-radius: 50%; background: #7d8984; }
.health-dot.live { background: var(--lime); box-shadow: 0 0 0 4px rgba(200,255,101,.09), 0 0 14px rgba(200,255,101,.35); }

#primary-nav { display: grid; gap: 5px; }
#primary-nav button {
  display: flex;
  width: 100%;
  min-height: 45px;
  align-items: center;
  justify-content: space-between;
  padding: 0 13px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: rgba(255,255,255,.59);
  cursor: pointer;
  text-align: left;
  transition: 160ms ease;
}
#primary-nav button:hover { background: rgba(255,255,255,.055); color: white; }
#primary-nav button.active { border-color: rgba(200,255,101,.18); background: rgba(200,255,101,.1); color: white; }
#primary-nav button span { font-size: 13px; font-weight: 650; }
#primary-nav button small {
  display: grid;
  min-width: 23px;
  height: 23px;
  place-items: center;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(255,255,255,.07);
  color: rgba(255,255,255,.46);
  font-size: 9px;
}
#primary-nav button.active small { background: var(--lime); color: var(--night); font-weight: 800; }

.privacy-card {
  margin-top: auto;
  padding: 14px;
  border-top: 1px solid rgba(255,255,255,.08);
  color: rgba(255,255,255,.47);
}
.privacy-card strong { color: rgba(255,255,255,.75); font-size: 10px; letter-spacing: .1em; }
.privacy-card p { margin: 7px 0 0; font-size: 10px; line-height: 1.55; }
.sidebar-foot { display: flex; justify-content: space-between; padding: 12px 14px 0; color: rgba(255,255,255,.25); font-size: 9px; text-transform: uppercase; }

.main { width: 100%; max-width: 1680px; min-width: 0; margin: 0 auto; padding: 34px clamp(22px, 4vw, 64px) 72px; }
.topbar { display: flex; justify-content: space-between; gap: 28px; align-items: flex-start; margin-bottom: 24px; }
.eyebrow { margin: 0 0 8px; color: var(--green); font-size: 10px; font-weight: 800; letter-spacing: .18em; }
.topbar h1 { margin: 0; font-size: clamp(28px, 3vw, 43px); font-weight: 690; letter-spacing: -.045em; line-height: 1.08; }
.topbar p:last-child { margin: 11px 0 0; color: var(--muted); font-size: 13px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.save-indicator { color: var(--muted); font-size: 10px; white-space: nowrap; }
.save-indicator.saving { color: var(--amber); }

.global-message, .inline-message { min-height: 0; margin: 0 0 16px; color: var(--green); font-size: 12px; }
.global-message:not(:empty), .inline-message:not(:empty) { padding: 11px 14px; border: 1px solid #cfe0d6; border-radius: 12px; background: var(--green-soft); }
.global-message.error, .inline-message.error { border-color: #efcac5; background: var(--red-soft); color: var(--red); }

.page { display: none; animation: enter 240ms ease both; }
.page.active { display: block; }
@keyframes enter { from { opacity: 0; transform: translateY(5px); } }

.welcome-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 15px;
  padding: 13px 18px;
  border: 1px solid rgba(29,112,77,.15);
  border-radius: 15px;
  background: linear-gradient(110deg, #edf6f1, rgba(255,255,255,.7));
}
.welcome-strip div { display: flex; align-items: center; gap: 13px; }
.welcome-strip strong { font-size: 12px; }
.welcome-strip p { margin: 0; color: var(--muted); font-size: 11px; text-align: right; }
.live-label { display: inline-flex; align-items: center; gap: 6px; color: var(--green); font-size: 8px; font-weight: 850; letter-spacing: .14em; }
.live-label i { width: 6px; height: 6px; border-radius: 50%; background: var(--green-2); box-shadow: 0 0 0 4px rgba(42,145,104,.09); }

.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.metric-grid--five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.metric {
  min-height: 126px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255,255,255,.75);
  box-shadow: 0 1px 0 rgba(255,255,255,.9) inset;
}
.metric span { display: block; color: var(--muted); font-size: 10px; font-weight: 650; letter-spacing: .05em; }
.metric strong { display: block; margin: 14px 0 8px; font-size: 29px; line-height: 1; letter-spacing: -.04em; }
.metric small { color: #93a099; font-size: 9px; }
.metric--attention { border-color: #ead9bd; background: linear-gradient(145deg, #fffaf0, #fff); }
.metric--attention strong { color: var(--amber); }

.panel {
  margin-bottom: 14px;
  padding: clamp(20px, 2.4vw, 30px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255,255,255,.82);
  box-shadow: var(--shadow);
}
.panel--tint { background: linear-gradient(140deg, #edf5f0, rgba(255,255,255,.94)); }
.decision-panel { position: relative; overflow: hidden; background: var(--night-2); color: white; }
.decision-panel::after { content: ""; position: absolute; width: 260px; height: 260px; right: -100px; bottom: -150px; border-radius: 50%; background: rgba(200,255,101,.09); }
.decision-panel .step { color: var(--lime); }
.decision-panel .lede { color: rgba(255,255,255,.62); }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
.panel-heading h2 { margin: 3px 0 0; font-size: clamp(17px, 1.6vw, 21px); letter-spacing: -.025em; }
.step { margin: 0; color: var(--green); font-size: 9px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.panel > p, .lede { max-width: 720px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.lede { margin: 0 0 23px; font-size: 13px; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.two-col--wide { grid-template-columns: minmax(0, 1.15fr) minmax(340px, .85fr); }
.three-col { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }

.button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  padding: 0 15px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: var(--white);
  color: var(--ink);
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  text-decoration: none;
  transition: 150ms ease;
}
.button:hover { border-color: #9eaea5; transform: translateY(-1px); box-shadow: 0 8px 18px rgba(29,49,39,.08); }
.button:active { transform: translateY(0); }
.button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, #primary-nav button:focus-visible { outline: 3px solid rgba(42,145,104,.25); outline-offset: 2px; }
.button--primary { border-color: var(--green); background: var(--green); color: white; }
.decision-panel .button--primary { border-color: var(--lime); background: var(--lime); color: var(--night); }
.button--quiet { min-height: 36px; background: transparent; }
.button--danger { margin-top: 16px; border-color: #e4bbb6; background: #fff5f4; color: var(--red); }

.badge { display: inline-flex; min-height: 24px; align-items: center; padding: 0 9px; border-radius: 999px; background: var(--green-soft); color: var(--green); font-size: 8px; font-weight: 800; letter-spacing: .05em; white-space: nowrap; }
.badge--dark { background: var(--night); color: var(--lime); }
.badge--green { background: var(--green-soft); color: var(--green); }
.badge--amber { background: var(--amber-soft); color: var(--amber); }

.pipeline-summary { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 8px; }
.pipeline-summary div { padding: 15px; border: 1px solid var(--line); border-radius: 14px; background: #f8faf8; }
.pipeline-summary span { display: block; color: var(--muted); font-size: 9px; }
.pipeline-summary strong { display: block; margin-top: 8px; font-size: 20px; }

.stack-form, .stack-actions { display: grid; gap: 12px; }
.row { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; }
label { display: grid; gap: 7px; color: var(--muted); font-size: 10px; font-weight: 700; }
input, select, textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: rgba(255,255,255,.9);
  color: var(--ink);
  padding: 10px 12px;
  font-size: 12px;
}
textarea { min-height: 88px; resize: vertical; line-height: 1.55; }
.file-drop { position: relative; display: grid; place-items: center; min-height: 112px; padding: 16px; border: 1px dashed #aebeb5; border-radius: 14px; background: rgba(255,255,255,.55); text-align: center; cursor: pointer; }
.file-drop span { color: var(--ink); font-size: 12px; }
.file-drop small { color: var(--muted); font-size: 9px; font-weight: 500; }
.file-drop input { position: absolute; inset: 0; min-height: 0; opacity: 0; cursor: pointer; }
.file-drop--compact { min-height: 76px; }

.task-form { display: grid; grid-template-columns: 1.5fr .65fr .65fr; gap: 12px; align-items: end; }
.task-form .grow, .task-form .full { min-width: 0; }
.task-form .full { grid-column: 1 / -1; }
.task-form > .button { justify-self: start; }
.kanban { display: grid; grid-template-columns: repeat(5, minmax(210px, 1fr)); gap: 10px; overflow-x: auto; padding-bottom: 8px; }
.lane { min-height: 360px; padding: 12px; border: 1px solid var(--line); border-radius: 17px; background: rgba(233,237,234,.65); }
.lane-heading { display: flex; justify-content: space-between; align-items: center; padding: 4px 4px 13px; }
.lane-heading h3 { margin: 0; font-size: 11px; }
.lane-heading span { color: var(--muted); font-size: 9px; }
.task-card { margin-bottom: 9px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: white; box-shadow: 0 5px 14px rgba(24,40,32,.04); }
.task-card h4 { margin: 0 0 10px; font-size: 12px; line-height: 1.45; }
.task-card p { margin: 11px 0; color: var(--muted); font-size: 10px; line-height: 1.55; overflow-wrap: anywhere; }
.task-meta, .task-actions, .item-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.task-actions .button, .item-actions .button { min-height: 31px; padding-inline: 9px; font-size: 8px; border-radius: 8px; }

.item-list { display: grid; gap: 8px; }
.item { padding: 14px; border: 1px solid var(--line); border-radius: 13px; background: #fafbf9; }
.item-line { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.item strong { font-size: 11px; line-height: 1.45; }
.item p { margin: 8px 0; color: var(--muted); font-size: 10px; line-height: 1.6; overflow-wrap: anywhere; }
.item small { color: #98a49e; font-size: 8px; overflow-wrap: anywhere; }
.signal-list { grid-template-columns: repeat(2, minmax(0,1fr)); }
.signal-source { color: var(--green); font-size: 8px; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; }
.brief-summary { margin: 10px 0; padding: 12px; border-radius: 12px; background: #f0f4f1; color: var(--muted); font-size: 10px; line-height: 1.6; }
.brief-summary ol { margin: 8px 0 0; padding-left: 18px; }

.report-list { display: grid; gap: 8px; }
.report-card { display: grid; grid-template-columns: 110px 1fr auto; align-items: center; gap: 16px; padding: 14px; border: 1px solid var(--line); border-radius: 13px; background: #fafbf9; }
.report-card strong { font-size: 11px; }
.report-card p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.5; }
.empty { padding: 24px; border: 1px dashed var(--line-strong); border-radius: 13px; color: #96a29c; font-size: 10px; text-align: center; }

.architecture-flow { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr auto 1fr; align-items: stretch; gap: 12px; }
.architecture-flow div { display: grid; gap: 7px; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: #f9faf8; }
.architecture-flow strong { font-size: 11px; }
.architecture-flow span { color: var(--muted); font-size: 9px; line-height: 1.5; }
.architecture-flow b { align-self: center; color: #a3afa8; font-size: 18px; }

dialog { width: min(760px, calc(100vw - 30px)); max-height: 86vh; padding: 30px; border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 30px 90px rgba(7,17,12,.3); }
dialog::backdrop { background: rgba(5,12,9,.62); backdrop-filter: blur(5px); }
.dialog-close { position: absolute; top: 15px; right: 15px; width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 50%; background: white; cursor: pointer; }
#report-content h2 { margin-top: 0; font-size: 24px; }
.report-section { padding: 16px 0; border-top: 1px solid var(--line); }
.report-section h3 { margin: 0 0 9px; color: var(--green); font-size: 10px; letter-spacing: .09em; }
.report-section p, .report-section li { color: var(--muted); font-size: 11px; line-height: 1.7; }

.toast { position: fixed; right: 22px; bottom: 22px; z-index: 80; max-width: min(360px, calc(100vw - 44px)); padding: 13px 17px; border-radius: 12px; background: var(--night); color: white; box-shadow: 0 18px 48px rgba(0,0,0,.24); font-size: 11px; opacity: 0; pointer-events: none; transform: translateY(12px); transition: 180ms ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--red); }
.noscript { position: fixed; inset: auto 20px 20px; z-index: 90; padding: 16px; border-radius: 12px; background: var(--red); color: white; }

@media (max-width: 1180px) {
  :root { --sidebar: 220px; }
  .metric-grid--five { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .three-col { grid-template-columns: 1fr; }
  .kanban { grid-template-columns: repeat(5, 230px); }
}

@media (max-width: 820px) {
  .app-shell { display: block; }
  .sidebar { position: sticky; height: auto; min-height: 0; padding: 12px; overflow: visible; }
  .brand { padding: 0; }
  .brand-mark { width: 36px; height: 36px; }
  .brand small, .system-state, .privacy-card, .sidebar-foot { display: none; }
  #primary-nav { display: flex; gap: 6px; margin-top: 11px; overflow-x: auto; scrollbar-width: none; }
  #primary-nav::-webkit-scrollbar { display: none; }
  #primary-nav button { width: auto; min-width: max-content; min-height: 38px; padding-inline: 12px; }
  #primary-nav button small { display: none; }
  .main { padding: 26px 16px 48px; }
  .topbar { align-items: flex-end; }
  .topbar h1 { font-size: 29px; }
  .topbar p:last-child, .save-indicator { display: none; }
  .welcome-strip { align-items: flex-start; }
  .welcome-strip div { display: grid; gap: 7px; }
  .welcome-strip p { max-width: 220px; }
  .two-col, .two-col--wide { grid-template-columns: 1fr; }
  .task-form { grid-template-columns: 1fr 1fr; }
  .task-form .grow, .task-form .full { grid-column: 1 / -1; }
  .signal-list { grid-template-columns: 1fr; }
  .architecture-flow { grid-template-columns: 1fr; }
  .architecture-flow b { text-align: center; transform: rotate(90deg); }
}

@media (max-width: 560px) {
  .brand strong { font-size: 13px; }
  .brand small { display: none; }
  .topbar { gap: 10px; }
  .topbar h1 { font-size: 25px; }
  .eyebrow { font-size: 8px; }
  .welcome-strip { display: grid; }
  .welcome-strip p { max-width: none; text-align: left; line-height: 1.45; }
  .metric-grid, .metric-grid--five { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .metric { min-height: 108px; padding: 15px; }
  .metric strong { font-size: 25px; }
  .panel { padding: 18px; border-radius: 17px; }
  .panel-heading { gap: 10px; }
  .pipeline-summary { grid-template-columns: repeat(5, minmax(105px, 1fr)); overflow-x: auto; padding-bottom: 6px; }
  .task-form { grid-template-columns: 1fr; }
  .task-form > * { grid-column: 1 !important; }
  .report-card { grid-template-columns: 1fr; gap: 8px; }
  .report-card .item-actions { justify-content: flex-start; }
  .row { display: grid; }
  .row > * { width: 100%; }
  dialog { padding: 24px 20px; }
}

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