:root {
  --paper: #e8eef1;
  --surface: #f8fafb;
  --ink: #10283a;
  --ink-2: #4c6372;
  --rule: #c5d2d9;
  --rule-2: #dbe4e9;
  --sea: #17688a;
  --sea-dark: #0d4a66;
  --sea-tint: #d5e7ef;
  --done: #2b7a55;
  --done-tint: #d7ebe0;
  --warn: #b97a06;
  --warn-tint: #f5e6c4;
  --alert: #bf3a2b;
  --alert-tint: #f4d9d4;
  --late: #c2651a;
  --late-tint: #f7dfcc;
  --idle: #8aa0ad;
  --serif: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --sans: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --rail: 216px;
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--sans); line-height: 1.45; font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
a { color: var(--sea-dark); text-underline-offset: 2px; }
h1, h2, h3 { margin: 0; font-weight: 500; }
h1.page { font-family: var(--serif); font-weight: 400; font-size: 2.6rem; line-height: 1.08; letter-spacing: -0.01em; max-width: 22ch; }
h2 { font-size: 1.05rem; font-weight: 600; margin-bottom: .6rem; }
.muted { color: var(--ink-2); }
.small { font-size: .86rem; }
:focus-visible { outline: 2px solid var(--sea); outline-offset: 2px; border-radius: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; align-content: center; padding: 1.5rem; }
.login-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--rule); padding: 2rem; display: grid; gap: .45rem; }
.login-card h1 { font-family: var(--serif); font-weight: 400; font-size: 2rem; }
.login-card p { margin: 0 0 .7rem; }
label { font-size: .86rem; font-weight: 500; margin-top: .4rem; display: block; }
input, select, textarea { width: 100%; background: #fff; border: 1px solid var(--rule); padding: .5rem .6rem; border-radius: 4px; }
textarea { min-height: 6rem; resize: vertical; }
.error { color: var(--alert); min-height: 1.3em; margin: .2rem 0 !important; font-size: .9rem; }

/* ---------- buttons ---------- */
.btn { border: 1px solid var(--rule); background: var(--surface); padding: .45rem .9rem; border-radius: 4px; cursor: pointer; font-weight: 500; }
.btn:hover { border-color: var(--sea); }
.btn.primary { background: var(--sea-dark); border-color: var(--sea-dark); color: #fff; }
.btn.primary:hover { background: var(--sea); }
.btn.danger { color: var(--alert); }
.btn.small { padding: .25rem .6rem; font-size: .86rem; }
button.link { background: none; border: 0; padding: 0; color: var(--sea-dark); text-decoration: underline; cursor: pointer; font-size: .86rem; text-underline-offset: 2px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); min-height: 100vh; }
.rail { background: var(--sea-dark); color: #dcebf2; padding: 1.4rem 1rem; display: flex; flex-direction: column; gap: 1.4rem; position: sticky; top: 0; height: 100vh; }
.brand { text-decoration: none; color: #fff; display: grid; }
.brand-name { font-family: var(--serif); font-size: 1.7rem; line-height: 1; }
.brand-sub { font-size: .8rem; color: #a9c8d7; margin-top: .25rem; }
.nav { display: grid; gap: 1px; align-content: start; flex: 1; overflow-y: auto; }
.nav a { color: #dcebf2; text-decoration: none; padding: .42rem .6rem; border-radius: 4px; display: flex; justify-content: space-between; gap: .5rem; }
.nav a:hover { background: rgba(255,255,255,.08); }
.nav a[aria-current="page"] { background: #fff; color: var(--sea-dark); font-weight: 600; }
.nav .group { font-size: .8rem; color: #8fb4c6; margin: .9rem .6rem .25rem; }
.nav .count { color: #a9c8d7; font-size: .86rem; }
.nav a[aria-current="page"] .count { color: var(--ink-2); }
.me { border-top: 1px solid rgba(255,255,255,.18); padding-top: .9rem; }
.me-name { font-weight: 600; color: #fff; }
.me .muted { color: #a9c8d7; }
.me-actions { display: flex; gap: .9rem; margin-top: .5rem; }
.me button.link { color: #dcebf2; }
.main { padding: 2rem 2.4rem 4rem; min-width: 0; max-width: 1240px; }
.main:focus { outline: none; }
.lede { color: var(--ink-2); margin: .7rem 0 0; font-size: 1.05rem; max-width: 60ch; }
.section { margin-top: 2.4rem; }
.readiness { margin: 1rem 0 0; padding: .6rem .9rem; background: var(--surface); border-left: 4px solid var(--idle); max-width: 72ch; }
.readiness.ready, .readiness.on_track { border-left-color: var(--done); }
.readiness.unknown, .readiness.miss_soft { border-left-color: var(--warn); }
.readiness.miss_hard { border-left-color: var(--alert); }

/* ---------- passage timeline ---------- */
.passage { margin-top: 1.8rem; background: var(--surface); border: 1px solid var(--rule); padding: .6rem .4rem .2rem; overflow-x: auto; }
.passage svg { width: 100%; min-width: 760px; height: auto; display: block; }
.passage text { font-family: var(--sans); fill: var(--ink); }
.passage .sub { fill: var(--ink-2); }

/* ---------- ledger ---------- */
.ledger { width: 100%; min-width: 760px; border-collapse: collapse; background: var(--surface); }
.ledger th { text-align: left; font-weight: 500; font-size: .86rem; color: var(--ink-2); padding: .6rem .9rem; border-bottom: 1px solid var(--rule); }
.ledger td { padding: .9rem; border-bottom: 1px solid var(--rule-2); vertical-align: top; }
.ledger tr:last-child td { border-bottom: 0; }
.ledger .svc { font-weight: 600; font-size: 1.05rem; text-decoration: none; }
.ledger .svc:hover { text-decoration: underline; }
.when { white-space: nowrap; }
.bar { display: flex; height: 12px; background: var(--rule-2); border-radius: 2px; overflow: hidden; min-width: 200px; }
.bar > i { display: block; height: 100%; }
.bar .b-done { background: var(--done); }
.bar .b-prog { background: var(--sea); }
.bar .b-block { background: var(--warn); }
.legend { display: flex; flex-wrap: wrap; gap: .2rem .9rem; margin-top: .4rem; font-size: .86rem; color: var(--ink-2); }
.legend b { color: var(--ink); font-weight: 600; }
.sw { display: inline-block; width: .6rem; height: .6rem; border-radius: 1px; margin-right: .3rem; background: var(--idle); }
.sw.done { background: var(--done); } .sw.prog { background: var(--sea); } .sw.block { background: var(--warn); }
.pill { display: inline-block; padding: .12rem .55rem; border-radius: 999px; font-weight: 600; font-size: .84rem; white-space: nowrap; }
.pill.on_track, .pill.complete { background: var(--done-tint); color: var(--done); }
.pill.behind, .pill.stalled { background: var(--warn-tint); color: #7d5304; }
.pill.late { background: var(--late-tint); color: #8a4308; }
.pill.critical, .pill.overdue { background: var(--alert-tint); color: var(--alert); }
.outlook small { display: block; color: var(--ink-2); margin-top: .3rem; font-size: .84rem; max-width: 24ch; }

.attention { background: var(--surface); border: 1px solid var(--rule); }
.attention a { display: grid; grid-template-columns: 9rem 1fr auto; gap: 1rem; padding: .7rem .9rem; border-bottom: 1px solid var(--rule-2); text-decoration: none; color: inherit; align-items: baseline; }
.attention a:last-child { border-bottom: 0; }
.attention a:hover { background: var(--sea-tint); }
.attention .n { font-family: var(--serif); font-size: 1.5rem; line-height: 1; }
.attention .svcname { font-weight: 600; }

/* ---------- service page ---------- */
.head { display: flex; flex-wrap: wrap; gap: 1rem 2rem; justify-content: space-between; align-items: flex-end; }
.head-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1px; background: var(--rule); border: 1px solid var(--rule); margin-top: 1.4rem; }
.fact { background: var(--surface); padding: .8rem 1rem; }
.fact .v { font-family: var(--serif); font-size: 1.9rem; line-height: 1.1; }
.fact .l { color: var(--ink-2); font-size: .86rem; }
.burn { background: var(--surface); border: 1px solid var(--rule); margin-top: 1rem; padding: .6rem; overflow-x: auto; }
.burn svg { width: 100%; min-width: 560px; height: auto; display: block; }
.burn text { font-family: var(--sans); fill: var(--ink-2); font-size: 12.5px; }
.toolbar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin: 1.6rem 0 .8rem; }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip { border: 1px solid var(--rule); background: var(--surface); border-radius: 999px; padding: .25rem .75rem; cursor: pointer; font-size: .9rem; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip .c { color: var(--ink-2); margin-left: .3rem; }
.chip[aria-pressed="true"] .c { color: #b9cbd6; }
.toolbar .grow { flex: 1 1 280px; min-width: 220px; max-width: 380px; width: auto; }
.toolbar select { width: auto; max-width: 260px; }
.tablewrap { background: var(--surface); border: 1px solid var(--rule); overflow-x: auto; }
table.items { width: 100%; border-collapse: collapse; min-width: 980px; }
table.items th { position: sticky; top: 0; background: var(--surface); text-align: left; font-weight: 500; font-size: .84rem; color: var(--ink-2); padding: .55rem .7rem; border-bottom: 1px solid var(--rule); white-space: nowrap; }
table.items td { padding: .45rem .7rem; border-bottom: 1px solid var(--rule-2); vertical-align: middle; }
table.items tr:hover td { background: #f0f5f7; }
table.items .vname { font-weight: 600; background: none; border: 0; padding: 0; cursor: pointer; text-align: left; color: var(--ink); }
table.items .vname:hover { text-decoration: underline; color: var(--sea-dark); }
table.items .sub { color: var(--ink-2); font-size: .82rem; }
table.items .note { max-width: 24ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
table.items td.late { color: var(--alert); font-weight: 600; }
table.items select { padding: .25rem .4rem; width: auto; font-size: .9rem; }
.empty { padding: 2rem; text-align: center; color: var(--ink-2); }
.st { display: inline-flex; align-items: center; gap: .4rem; font-weight: 500; }
.st::before { content: ""; width: .6rem; height: .6rem; border-radius: 50%; background: var(--idle); }
.st.in_progress::before { background: var(--sea); }
.st.blocked::before { background: var(--warn); }
.st.completed::before, .st.terminated::before { background: var(--done); }
.st.lost::before, .st.excluded::before { background: repeating-linear-gradient(45deg, var(--idle) 0 2px, #fff 2px 4px); border: 1px solid var(--idle); }
select.s-in_progress { border-color: var(--sea); } select.s-blocked { border-color: var(--warn); background: var(--warn-tint); }
select.s-completed, select.s-terminated { border-color: var(--done); background: var(--done-tint); }
select.s-lost, select.s-excluded { color: var(--ink-2); }

/* ---------- drawer & dialogs ---------- */
.drawer { position: fixed; inset: 0; z-index: 20; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(16,40,58,.4); }
.drawer-panel { position: absolute; top: 0; right: 0; bottom: 0; width: min(520px, 100%); background: var(--surface); overflow-y: auto; padding: 1.6rem; box-shadow: -8px 0 24px rgba(16,40,58,.18); animation: slide .18s ease-out; }
@keyframes slide { from { transform: translateX(24px); opacity: .4; } to { transform: none; opacity: 1; } }
.drawer h2.title { font-family: var(--serif); font-weight: 400; font-size: 1.9rem; margin: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .2rem .9rem; }
.grid2 .full { grid-column: 1 / -1; }
dl.refs { display: grid; grid-template-columns: auto 1fr; gap: .25rem 1rem; margin: .4rem 0 0; font-size: .9rem; }
dl.refs dt { color: var(--ink-2); } dl.refs dd { margin: 0; overflow-wrap: anywhere; }
.steps { display: grid; gap: 1px; background: var(--rule-2); border: 1px solid var(--rule-2); margin-top: .5rem; }
.step { background: #fff; padding: .5rem .6rem; display: grid; grid-template-columns: 1fr auto; gap: .6rem; align-items: center; font-size: .9rem; }
.step .cat { color: var(--ink-2); font-size: .8rem; }
.step select { width: auto; font-size: .86rem; padding: .2rem .3rem; }
.history { margin: .5rem 0 0; padding: 0; list-style: none; font-size: .86rem; display: grid; gap: .35rem; }
.history li { color: var(--ink-2); }
.history b { color: var(--ink); font-weight: 500; }
.actions { display: flex; gap: .6rem; margin-top: 1.2rem; flex-wrap: wrap; }
dialog { border: 1px solid var(--rule); padding: 1.5rem; width: min(440px, 94vw); background: var(--surface); color: var(--ink); }
dialog::backdrop { background: rgba(16,40,58,.4); }
.toast { position: fixed; bottom: 1.2rem; left: 50%; transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: .55rem 1rem; border-radius: 4px; opacity: 0; pointer-events: none; transition: .2s; z-index: 40; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--alert); }

/* ---------- misc pages ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .8rem; margin-top: 1rem; }
.card { background: var(--surface); border: 1px solid var(--rule); padding: 1rem; display: grid; gap: .3rem; }
.card button.vname { text-align: left; }
.vchips { display: flex; flex-wrap: wrap; gap: .3rem; }
.vchip { font-size: .82rem; padding: .08rem .5rem; border-radius: 3px; background: var(--rule-2); text-decoration: none; color: var(--ink); }
.vchip.done { background: var(--done-tint); color: var(--done); } .vchip.open { background: var(--sea-tint); color: var(--sea-dark); }
.vchip.blocked { background: var(--warn-tint); color: #7d5304; }
.formrow { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .8rem; max-width: 900px; }
table.plain { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--rule); }
table.plain th { text-align: left; font-weight: 500; color: var(--ink-2); font-size: .86rem; padding: .5rem .8rem; border-bottom: 1px solid var(--rule); }
table.plain td { padding: .5rem .8rem; border-bottom: 1px solid var(--rule-2); vertical-align: top; }
table.plain select { width: auto; padding: .2rem .4rem; }

.foot { margin-top: 3.5rem; padding-top: 1rem; border-top: 1px solid var(--rule); color: var(--ink-2); font-size: .86rem; }
.login-foot { text-align: center; max-width: 380px; margin: 1.2rem auto 0; }
details.explain summary { cursor: pointer; font-weight: 600; }
details.explain ul { margin: .7rem 0; padding-left: 1.2rem; display: grid; gap: .3rem; max-width: 70ch; }
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: .8rem 1rem; gap: .6rem 1rem; }
  .nav { display: flex; overflow-x: auto; flex: 1 1 100%; order: 3; }
  .nav .group { display: none; }
  .nav a { white-space: nowrap; }
  .me { border: 0; padding: 0; margin-left: auto; }
  .me-actions { margin-top: .2rem; }
  .main { padding: 1.4rem 1rem 3rem; }
  h1.page { font-size: 2.1rem; }
  .attention a { grid-template-columns: 1fr auto; } .attention .svcname { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
