:root {
  --bg: #0d1117;
  --bg-panel: #161b22;
  --bg-elev: #1c2230;
  --border: #2a3140;
  --border-soft: #222936;
  --text: #e6edf3;
  --text-dim: #8b949e;
  --text-faint: #6e7681;
  --accent: #58a6ff;
  --accent-2: #7c9cff;
  --good: #3fb950;
  --amber: #d29922;
  --amber-bg: rgba(210, 153, 34, 0.12);
  --red: #f85149;
  --red-bg: rgba(248, 81, 73, 0.12);
  --teal: #2dd4bf;
  --violet: #a371f7;
  --shadow: 0 1px 3px rgba(0,0,0,0.4), 0 8px 24px rgba(0,0,0,0.25);
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* landing page */
.landing {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}
.landing[hidden] { display: none; }
.landing-inner {
  max-width: 480px;
  width: 100%;
}
.landing-title {
  font-size: 26px; margin: 0 0 20px; font-weight: 700;
  font-family: var(--mono); letter-spacing: -0.03em;
}
.landing-tld { color: var(--text-faint); font-weight: 400; }
.landing-tagline {
  color: var(--text-dim); font-size: 15px; line-height: 1.7;
  margin: 0 0 40px;
}
.drop-zone {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 32px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  background: var(--bg-panel);
}
.drop-zone:hover, .drop-zone-active {
  border-color: var(--accent);
  background: rgba(88,166,255,0.04);
}
.drop-zone-content { pointer-events: none; }
.drop-primary { font-size: 15px; font-weight: 600; margin: 0 0 6px; }
.drop-secondary { font-size: 13px; color: var(--text-dim); margin: 0; }
.drop-secondary .file-label {
  color: var(--accent); cursor: pointer; pointer-events: auto;
  text-decoration: underline; text-underline-offset: 2px;
}
.drop-secondary .file-label:hover { color: var(--accent-2); }
.landing-links {
  display: flex; align-items: center; gap: 10px;
  margin-top: 16px; font-size: 13px;
}
.landing-link {
  color: var(--text-dim); background: none; border: none; padding: 0;
  font: inherit; font-size: 13px; cursor: pointer;
  text-decoration: underline; text-underline-offset: 2px;
  text-decoration-color: var(--border);
}
.landing-link:hover { color: var(--text); text-decoration-color: var(--text-dim); }
.landing-sep { color: var(--text-faint); }
.landing-privacy {
  margin-top: 28px; font-size: 12px; color: var(--text-faint);
}

/* header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 22px 32px 18px;
  max-width: 1480px;
  margin: 0 auto;
  flex-wrap: wrap;
  gap: 12px;
}
.brand { display: flex; align-items: center; }
.app-header h1 {
  font-size: 18px; margin: 0; font-weight: 700;
  font-family: var(--mono); letter-spacing: -0.03em;
}
.app-header .tld { color: var(--text-faint); font-weight: 400; }
.subtitle { margin: 2px 0 0; color: var(--text-dim); font-size: 12.5px; }
.as-of {
  color: var(--text-dim); font-size: 13px;
  background: var(--bg-panel); border: 1px solid var(--border);
  padding: 8px 14px; border-radius: 999px;
}
.as-of strong { color: var(--text); }
.header-actions { display: flex; align-items: center; gap: 12px; }
.btn-change-file {
  background: var(--bg-elev); border: 1px solid var(--border); color: var(--text-dim);
  padding: 8px 14px; border-radius: 999px; font-size: 12px; font-weight: 600;
  cursor: pointer; transition: border-color .12s, color .12s;
}
.btn-change-file:hover { border-color: var(--accent); color: var(--text); }

main { max-width: 1480px; margin: 0 auto; padding: 0 32px 48px; }

/* commitment bar */
.commitment-bar {
  display: flex; align-items: flex-end; gap: 20px; flex-wrap: wrap;
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 20px; margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.commit-field { display: flex; flex-direction: column; gap: 6px; }
.commit-field label {
  font-size: 11px; color: var(--text-dim); text-transform: uppercase;
  letter-spacing: 0.06em; font-weight: 600;
}
.commit-field label .opt { color: var(--text-faint); font-weight: 400; text-transform: none; letter-spacing: 0; }
.commit-input { display: flex; align-items: baseline; gap: 6px; }
.commitment-bar input {
  background: var(--bg-elev); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 9px 11px; font-size: 16px; font-family: var(--mono);
}
.commitment-bar input[type=number] { width: 84px; }
.commit-unit { color: var(--text-dim); font-size: 13px; }
.commit-arrow { color: var(--text-faint); font-size: 12px; padding-bottom: 10px; letter-spacing: 0.04em; }
.commit-verdict {
  margin-left: auto; padding: 10px 18px; border-radius: 10px; font-weight: 700;
  font-size: 15px; letter-spacing: 0.02em; align-self: center; border: 1px solid var(--border);
}
.commit-verdict .verdict-sub { display: block; font-weight: 500; font-size: 11.5px; opacity: 0.85; margin-top: 2px; letter-spacing: 0; }
.verdict-green { background: rgba(63,185,80,0.14); border-color: var(--good); color: var(--good); }
.verdict-amber { background: var(--amber-bg); border-color: var(--amber); color: var(--amber); }
.verdict-red   { background: var(--red-bg); border-color: var(--red); color: var(--red); }
.verdict-neutral { background: var(--bg-elev); color: var(--text-dim); }

/* status-update summary sentence */
.summary-line {
  font-size: 15.5px; line-height: 1.55; color: var(--text); padding: 14px 18px;
  background: linear-gradient(135deg, rgba(88,166,255,0.06), rgba(163,113,247,0.05));
  border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: 10px; margin-bottom: 20px;
}
.summary-line strong { color: #fff; font-weight: 680; }
.summary-line .s-green { color: var(--good); font-weight: 700; }
.summary-line .s-amber { color: var(--amber); font-weight: 700; }
.summary-line .s-red { color: var(--red); font-weight: 700; }

/* tiles — primary, big, scannable */
.tiles {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 22px;
}
.tile {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px 22px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow);
  min-height: 148px;
  display: flex; flex-direction: column;
}
.tile::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--accent);
}
.tile.tile-amber::before { background: var(--amber); }
.tile.tile-green::before { background: var(--good); }
.tile.tile-red::before { background: var(--red); }
.tile.tile-neutral::before { background: var(--text-faint); }
.tile.clickable { cursor: pointer; transition: border-color .12s, transform .12s; }
.tile.clickable:hover { border-color: var(--accent); transform: translateY(-1px); }
.tile-q {
  font-size: 13px; color: var(--text); font-weight: 620; margin-bottom: 12px;
  line-height: 1.3;
}
.tile-value { font-size: 34px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.0; margin-top: auto; }
.tile-value .unit { font-size: 15px; color: var(--text-dim); font-weight: 500; margin-left: 5px; }
.tile-amber .tile-value { color: var(--amber); }
.tile-green .tile-value { color: var(--good); }
.tile-red .tile-value { color: var(--red); }
.tile-pill {
  display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; padding: 3px 9px; border-radius: 999px; margin-bottom: 8px; align-self: flex-start;
}
.tile-amber .tile-pill { background: var(--amber-bg); color: var(--amber); }
.tile-green .tile-pill { background: rgba(63,185,80,0.14); color: var(--good); }
.tile-red .tile-pill { background: var(--red-bg); color: var(--red); }
.tile-neutral .tile-pill { background: var(--bg-elev); color: var(--text-dim); }
.tile-sub { font-size: 12px; color: var(--text-faint); margin-top: 8px; }
.tile-sub strong { color: var(--text-dim); }

/* layout grid */
.grid { display: grid; gap: 16px; margin-bottom: 16px; }
.grid-2 { grid-template-columns: 1fr 1fr; }

/* panels */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px 16px;
  box-shadow: var(--shadow);
}
.panel-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 12px; margin-bottom: 14px; flex-wrap: wrap;
}
.panel-head h2 { font-size: 15px; margin: 0; font-weight: 620; }
.panel-sub { display: block; font-size: 11.5px; color: var(--text-faint); font-weight: 400; margin-top: 2px; }
.panel-foot { font-size: 11.5px; color: var(--text-faint); margin: 10px 0 0; }
.chart-wrap { position: relative; height: 260px; }

/* forecast controls */
.forecast-controls { display: flex; align-items: center; gap: 8px; }
.forecast-controls label { font-size: 12px; color: var(--text-dim); }
.forecast-controls input {
  width: 64px; background: var(--bg-elev); border: 1px solid var(--border);
  color: var(--text); border-radius: 7px; padding: 6px 8px; font-size: 13px; font-family: var(--mono);
}
.forecast-controls button {
  background: var(--accent); color: #06121f; border: none; font-weight: 600;
  padding: 6px 12px; border-radius: 7px; cursor: pointer; font-size: 12.5px;
}
.forecast-controls button:hover { background: var(--accent-2); }
.forecast-summary { display: flex; gap: 22px; margin-bottom: 12px; flex-wrap: wrap; }
.fc-stat { font-size: 12px; color: var(--text-dim); }
.fc-stat b { display: block; font-size: 20px; color: var(--text); font-weight: 660; }
.fc-stat.p85 b { color: var(--amber); }
.fc-stat.p95 b { color: var(--red); }
.fc-stat.p50 b { color: var(--good); }
.fc-stat.target b { color: #e6edf3; }
.fc-headline {
  background: var(--bg-elev); border: 1px solid var(--border); border-left: 3px solid var(--text-faint);
  border-radius: 8px; padding: 12px 16px; margin-bottom: 14px; font-size: 14px; color: var(--text-dim);
}
.fc-headline strong { color: var(--text); }
.fc-headline.fc-green { border-left-color: var(--good); background: rgba(63,185,80,0.07); }
.fc-headline.fc-amber { border-left-color: var(--amber); background: var(--amber-bg); }
.fc-headline.fc-red { border-left-color: var(--red); background: var(--red-bg); }
.fc-headline .s-green { color: var(--good); font-weight: 700; }
.fc-headline .s-amber { color: var(--amber); font-weight: 700; }
.fc-headline .s-red { color: var(--red); font-weight: 700; }

/* table */
.table-wrap { overflow-x: auto; max-height: 460px; overflow-y: auto; border-radius: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  position: sticky; top: 0; background: var(--bg-elev); z-index: 1;
  text-align: left; padding: 10px 12px; color: var(--text-dim);
  font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
}
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody td { padding: 9px 12px; border-bottom: 1px solid var(--border-soft); }
tbody tr:hover { background: rgba(255,255,255,0.02); }
td .mono { font-family: var(--mono); font-size: 12px; }
td a { color: var(--accent); text-decoration: none; }
td a:hover { text-decoration: underline; }
.row-amber { background: var(--amber-bg); }
.row-red { background: var(--red-bg); }
.row-amber:hover { background: rgba(210,153,34,0.18); }
.row-red:hover { background: rgba(248,81,73,0.18); }
.assignee-unassigned { color: var(--red); font-style: italic; font-weight: 600; }
.age-flag-amber { color: var(--amber); font-weight: 600; }
.age-flag-red { color: var(--red); font-weight: 700; }
.status-pill {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px;
  background: var(--bg-elev); border: 1px solid var(--border); color: var(--text-dim);
}
.title-cell { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-dim); }

/* risk ratio annotation in ageing table */
.ratio { font-variant-numeric: tabular-nums; }
.ratio-amber { color: var(--amber); font-weight: 600; }
.ratio-red { color: var(--red); font-weight: 700; }
.ratio-ok { color: var(--text-faint); }

/* flow detail (collapsible secondary section) */
.flow-detail { margin-top: 26px; }
.flow-toggle {
  width: 100%; text-align: left; background: var(--bg-panel); border: 1px solid var(--border);
  color: var(--text); border-radius: var(--radius); padding: 14px 18px; cursor: pointer;
  font-size: 14px; font-weight: 620; display: flex; align-items: center; gap: 10px;
  box-shadow: var(--shadow);
}
.flow-toggle:hover { border-color: var(--accent); }
.flow-toggle .chev { display: inline-block; transition: transform .15s; color: var(--text-dim); }
.flow-toggle[aria-expanded="true"] .chev { transform: rotate(90deg); }
.flow-toggle-sub { color: var(--text-faint); font-weight: 400; font-size: 12px; margin-left: 6px; }
.flow-body { margin-top: 16px; }

/* legend chips */
.legend { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  font-size: 11px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--border);
  color: var(--text-dim);
}
.chip-amber { background: var(--amber-bg); border-color: var(--amber); color: var(--amber); }
.chip-red { background: var(--red-bg); border-color: var(--red); color: var(--red); }
.chip-unassigned { font-style: italic; }

/* loading / error / footer */
.loading { text-align: center; padding: 80px 20px; color: var(--text-dim); }
.error {
  max-width: 700px; margin: 60px auto; padding: 20px 24px; background: var(--red-bg);
  border: 1px solid var(--red); border-radius: var(--radius); color: #ffb4ae;
}
.error code { font-family: var(--mono); }
.app-footer {
  max-width: 1480px; margin: 0 auto; padding: 20px 32px 40px;
  color: var(--text-faint); font-size: 11.5px; border-top: 1px solid var(--border-soft);
}
.app-footer code { font-family: var(--mono); color: var(--text-dim); }

@media (max-width: 1000px) {
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .tiles { grid-template-columns: 1fr; }
  main, .app-header, .app-footer { padding-left: 16px; padding-right: 16px; }
}
