:root {
  --navy: #002147;
  --navy-soft: #0a2e58;
  --gold: #b8963e;
  --paper: #f7f6f3;
  --ink: #1b2a41;
  --hairline: #e2e0dc;
  --muted: #6b7280;
  --green: #2e6f4e;
  --amber: #b8863b;
  --red: #a03a2e;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, sans-serif;
  background: var(--paper);
  color: var(--ink);
}
.shell { display: grid; grid-template-columns: 208px minmax(0, 1fr) 232px; min-height: 100vh; }
.rail { background: var(--navy); padding: 20px 0; color: #c3d0e0; }
.brand { font-family: Georgia, serif; font-size: 20px; color: #f4f1ea; padding: 0 18px; }
.tagline { font-size: 10px; letter-spacing: 0.09em; color: #8fa6c4; padding: 4px 18px 18px; }
.rail a, .rail button {
  display: block; width: 100%; text-align: left; background: none; border: 0;
  border-left: 3px solid transparent; padding: 9px 18px; font-size: 13px;
  color: #c3d0e0; text-decoration: none; cursor: pointer; font-family: inherit;
}
.rail a.on { border-left-color: var(--gold); background: var(--navy-soft); color: #fff; }
.rail a.off { color: #6f88a8; cursor: default; }
.rail .divider { border-top: 0.5px solid #1d4272; margin: 14px 18px; }
.rail button:hover, .rail a:not(.off):hover { background: var(--navy-soft); color: #fff; }
.main { padding: 26px 30px; }
.title { font-family: Georgia, serif; font-size: 23px; border-bottom: 2px solid var(--gold); display: inline-block; padding-bottom: 6px; }
.sub { font-size: 12px; color: var(--muted); margin: 10px 0 20px; }
.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.card { background: #fff; border: 0.5px solid var(--hairline); border-radius: 8px; padding: 14px 16px; }
.card .k { font-size: 10px; letter-spacing: 0.05em; color: var(--muted); }
.card .v { font-size: 27px; font-variant-numeric: tabular-nums; margin-top: 4px; }
h2 { font-family: Georgia, serif; font-size: 15px; font-weight: normal; margin: 26px 0 10px; }
table { width: 100%; border-collapse: collapse; background: #fff; border: 0.5px solid var(--hairline); border-radius: 8px; }
th { font-size: 10px; letter-spacing: 0.05em; color: var(--muted); text-align: left; font-weight: normal; padding: 9px 14px; border-bottom: 0.5px solid var(--hairline); }
td { font-size: 13px; padding: 9px 14px; border-bottom: 0.5px solid #edebe6; }
tr:last-child td { border-bottom: 0; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
.bar { height: 5px; background: #eceae5; border-radius: 3px; overflow: hidden; min-width: 90px; }
.bar span { display: block; height: 100%; background: var(--navy); }
.bar.gold span { background: var(--gold); }
.pill { font-size: 11px; padding: 2px 8px; border-radius: 3px; font-variant-numeric: tabular-nums; }
.pill.danger { color: var(--red); background: #f7ecea; }
.pill.warning { color: var(--amber); background: #f9f2e4; }
.note { margin-top: 22px; font-size: 11px; color: var(--muted); border-left: 2px solid var(--gold); padding-left: 10px; }
.aside { background: #fff; border-left: 0.5px solid var(--hairline); padding: 20px 16px; }
.aside h3 { font-family: Georgia, serif; font-size: 13px; font-weight: normal; margin: 0 0 12px; }
.aside p { font-size: 11px; color: var(--muted); line-height: 1.6; }
.shell { grid-template-columns: 208px minmax(0, 1fr) 330px; }
.shell.chat-only { grid-template-columns: 208px minmax(0, 1fr); }
.shell.chat-only .main { display: none; }
.chat { background: #fff; border-left: 0.5px solid var(--hairline); padding: 18px 16px; display: flex; flex-direction: column; }
.chat .c-head { font-family: Georgia, serif; font-size: 14px; color: var(--ink); border-bottom: 2px solid var(--gold); display: inline-block; padding-bottom: 5px; margin-bottom: 14px; align-self: flex-start; }
.chat .c-body { overflow: visible; }
.chat .c-hint { font-size: 11.5px; color: var(--muted); line-height: 1.6; }
.rail a:focus, .rail button:focus { outline: 2px solid var(--gold); outline-offset: -2px; }
.ask input:focus, .ask button:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
@media (max-width: 1100px) {
  .shell { grid-template-columns: 180px minmax(0, 1fr); }
  .chat { display: none; }
  .shell.chat-only { grid-template-columns: 180px minmax(0, 1fr); }
  .shell.chat-only .chat { display: flex; }
}
.rail .group { font-size: 9px; letter-spacing: 0.12em; color: #6f88a8; padding: 14px 18px 4px; }
.gantt { background: #fff; border: 0.5px solid var(--hairline); border-radius: 8px; padding: 14px 16px 10px; }
.g-axis { position: relative; height: 16px; margin-left: 178px; margin-right: 52px; font-size: 10px; color: var(--muted); }
.g-axis span { position: absolute; transform: translateX(-50%); }
.g-axis i { position: absolute; top: 13px; width: 1px; height: 5px; background: var(--hairline); }
.g-row { display: flex; align-items: center; height: 26px; }
.g-lbl { width: 178px; flex: none; font-size: 12px; padding-right: 12px; text-align: right; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-track { position: relative; flex: 1; height: 14px; background: #f4f3ef; border-radius: 3px; }
.g-track > i { position: absolute; top: 0; bottom: 0; width: 1px; background: #e7e5e0; }
.g-bar { position: absolute; top: 0; height: 14px; border-radius: 3px; overflow: hidden; }
.g-bar span { display: block; height: 100%; background: var(--gold); opacity: 0.85; }
.g-bar.active { background: #9fb2c9; } .g-bar.active span { background: var(--navy); }
.g-bar.done { background: #b9d2c3; } .g-bar.done span { background: var(--green); }
.g-bar.planned { background: #dcdad5; } .g-bar.planned span { background: #9aa3ae; }
.g-point { position: absolute; top: 1px; width: 12px; height: 12px; transform: rotate(45deg) translateX(-6px); }
.g-point.done { background: var(--green); } .g-point.active { background: var(--navy); } .g-point.planned { background: #9aa3ae; }
.g-today { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--red); }
.g-pct { width: 52px; flex: none; text-align: right; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.legend { margin-top: 12px; display: flex; gap: 18px; font-size: 11px; color: var(--muted); }
.legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.legend .sw.done { background: var(--green); } .legend .sw.active { background: var(--navy); }
.legend .sw.planned { background: #9aa3ae; } .legend .sw.today { background: var(--red); width: 2px; height: 12px; border-radius: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(258px, 1fr)); gap: 14px; }
.pcard { background: #fff; border: 0.5px solid var(--hairline); border-top: 3px solid #9aa3ae; border-radius: 8px; padding: 14px 16px; }
.pcard.active { border-top-color: var(--navy); }
.pcard.done { border-top-color: var(--green); }
.pc-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.pc-name { font-family: Georgia, serif; font-size: 15px; }
.pc-pct { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pcard .bar { margin: 10px 0 12px; }
.pc-row { font-size: 12px; color: var(--ink); padding: 3px 0; }
.pc-row b { font-size: 10px; letter-spacing: 0.05em; color: var(--muted); display: block; }
.pc-row a { color: var(--navy); text-decoration: none; border-bottom: 1px solid var(--gold); }
.pc-row i { color: var(--amber); font-style: normal; }
.card .v.hi { color: var(--red); }
.card .v.md { color: var(--amber); }
.alert { background: #fff; border: 0.5px solid var(--hairline); border-left: 3px solid #9aa3ae; border-radius: 0 8px 8px 0; padding: 11px 15px; margin-bottom: 9px; }
.alert.high { border-left-color: var(--red); }
.alert.medium { border-left-color: var(--amber); }
.alert.clear { border-left-color: var(--green); }
.a-head { font-size: 13px; color: var(--ink); }
.a-det { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.ask { display: flex; gap: 10px; margin-bottom: 20px; }
.ask input { flex: 1; padding: 10px 13px; font-size: 13px; font-family: inherit; border: 0.5px solid var(--hairline); border-radius: 8px; background: #fff; color: var(--ink); }
.ask input:focus { outline: none; border-color: var(--gold); }
.ask button { padding: 10px 20px; font-size: 13px; font-family: inherit; background: var(--navy); color: #fff; border: 0; border-radius: 8px; cursor: pointer; }
.ask button:hover { background: var(--navy-soft); }
.turn { margin-bottom: 20px; }
.turn .q { font-size: 13px; color: var(--muted); border-left: 2px solid var(--hairline); padding: 2px 0 2px 11px; margin-bottom: 10px; }
.turn .a { background: #fff; border: 0.5px solid var(--hairline); border-left: 3px solid var(--gold); border-radius: 0 8px 8px 0; padding: 14px 18px; font-size: 13.5px; }
.turn .a h1, .turn .a h2, .turn .a h3 { font-family: Georgia, serif; font-size: 14px; font-weight: normal; color: var(--navy); margin: 14px 0 6px; }
.turn .a h1:first-child, .turn .a h2:first-child { margin-top: 0; }
.turn .a ul, .turn .a ol { margin: 6px 0 6px 20px; }
.turn .a li { margin: 3px 0; }
.turn .a p { margin: 6px 0; }
.turn .a code { font-family: Menlo, monospace; font-size: 12px; background: #f4f3ef; padding: 1px 5px; border-radius: 3px; }
.a-foot { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--muted); margin-top: 5px; }
.a-foot a { color: var(--navy); text-decoration: none; border-bottom: 1px solid var(--gold); }

/* --- Analyst column: history scrolls, composer anchored at the foot --- */
.chat { position: sticky; top: 0; height: 100vh; padding: 18px 16px 16px; }
.chat .c-body { flex: 1; overflow-y: auto; padding-right: 5px; margin-bottom: 4px; }
.chat .c-body::-webkit-scrollbar { width: 6px; }
.chat .c-body::-webkit-scrollbar-thumb { background: #dcdad5; border-radius: 3px; }
.chat .ask { margin: 12px 0 0; padding-top: 12px; border-top: 0.5px solid var(--hairline); gap: 8px; }
.chat .ask input[type="text"] { flex: 1; min-width: 0; padding: 9px 12px; }
.chat .ask button { padding: 9px 16px; white-space: nowrap; }
.chat .turn { margin-bottom: 16px; }
.chat .turn:last-child { margin-bottom: 0; }
.shell.chat-only .chat { max-width: 860px; }

/* --- Streaming state: progress bar, spinner and stop --- */
.c-status { margin-top: 10px; }
.c-bar { height: 3px; background: #eceae5; border-radius: 2px; overflow: hidden; }
.c-bar i { display: block; height: 100%; width: 4%; background: var(--gold); transition: width 0.25s ease; }
.c-run { display: flex; align-items: center; gap: 8px; margin-top: 7px; font-size: 10.5px; color: var(--muted); }
.c-run button { margin-left: auto; padding: 3px 10px; font-size: 10.5px; font-family: inherit; background: none; color: var(--red); border: 0.5px solid var(--red); border-radius: var(--radius, 8px); cursor: pointer; }
.c-run button:hover { background: #f7ecea; }
.spin { width: 11px; height: 11px; flex: none; border: 2px solid #dcdad5; border-top-color: var(--navy); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.chat .turn .a:empty { min-height: 18px; }
.rail-msg { margin: 8px 14px; padding: 8px 10px; font-size: 10.5px; line-height: 1.45; color: #f4f1ea; background: #0a2e58; border-left: 2px solid var(--gold); border-radius: 0 4px 4px 0; }

/* --- Login --- */
.login-page { background: var(--navy); display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login { background: #fff; border-radius: 12px; padding: 32px 30px; width: 320px; display: flex; flex-direction: column; gap: 11px; }
.l-brand { font-family: Georgia, serif; font-size: 25px; color: var(--navy); border-bottom: 2px solid var(--gold); padding-bottom: 6px; align-self: flex-start; }
.l-tag { font-size: 10px; letter-spacing: 0.09em; color: var(--muted); margin-bottom: 8px; }
.login input { padding: 10px 13px; font-size: 13px; font-family: inherit; border: 0.5px solid var(--hairline); border-radius: 8px; }
.login input:focus { outline: 2px solid var(--gold); outline-offset: 1px; border-color: var(--gold); }
.login button { padding: 11px; font-size: 13px; font-family: inherit; background: var(--navy); color: #fff; border: 0; border-radius: 8px; cursor: pointer; margin-top: 4px; }
.login button:hover { background: var(--navy-soft); }
.l-err { font-size: 11.5px; color: var(--red); text-align: center; }
.rail .out { font-size: 10px; color: #6f88a8; padding: 10px 18px 0; }

/* --- Rail: macro-titles carry the weight; every item is a real door --- */
.rail .group { font-weight: bold; font-size: 13.5px; color: #ffffff; }
.rail a { font-weight: normal; }
.rail a.on { font-weight: bold; }
.chat .turn .a.failed { border-left-color: var(--red); color: var(--red); font-size: 12px; }

/* --- Rail section labels: separated, not shouted --- */
.rail .group {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, sans-serif;
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.16em;
  line-height: 1.6;
  text-transform: uppercase;
  color: #a9bcd4;
  padding: 26px 18px 7px;
  margin: 0;
  border-bottom: 0;
  position: relative;
}
.rail .group::after {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 2px;
  height: 1px;
  background: rgba(184, 150, 62, 0.35);
}
.rail a { font-size: 13px; padding: 9px 18px; color: #d5dee9; }
.rail a.on { font-weight: 500; color: #ffffff; }

/* --- Rail hierarchy, book style: chapter over paragraph --- */
.rail .group {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 15px;
  font-weight: normal;
  letter-spacing: 0.01em;
  line-height: 1.3;
  text-transform: none;
  color: #f7f4ed;
  padding: 28px 18px 8px;
}
.rail .group::after {
  left: 18px;
  right: 18px;
  bottom: 3px;
  height: 1px;
  background: rgba(184, 150, 62, 0.55);
}
.rail a {
  font-size: 12.5px;
  font-weight: normal;
  color: #b9c7d8;
  padding: 8px 18px 8px 20px;
}
.rail a.on { color: #ffffff; font-weight: normal; background: var(--navy-soft); }
.rail a:not(.off):hover { color: #ffffff; }
.filters { display: flex; gap: 8px; margin: 26px 0 6px; }
.filters a { font-size: 11px; padding: 4px 12px; border: 0.5px solid var(--hairline); border-radius: 20px; color: var(--muted); text-decoration: none; background: #fff; }
.filters a.on { color: var(--navy); border-color: var(--gold); }
.filters a:hover { border-color: var(--navy); }
