@import url('https://fonts.googleapis.com/css2?family=Heebo:wght@400;500;700;800&display=swap');

/* Calm slate neutrals with one soft indigo accent. Green = done, amber = needs attention, red = stuck. */
:root {
  --bg: #f4f5f8;
  --panel: #ffffff;
  --ink: #1b1f2a;
  --muted: #667085;
  --line: #e3e6ec;
  --soft: #eef0f4;
  --accent: #4c63e6;
  --accent-ink: #ffffff;
  --ok: #128a6c;
  --warn: #a8701a;
  --bad: #d23f3f;
  --bad-soft: #fcebeb;
  --ok-soft: #e2f4ee;
  --warn-soft: #fbf1df;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 14px rgba(16, 24, 40, .05);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1218; --panel: #171b23; --ink: #e7e9ef; --muted: #8a92a6; --line: #262b36; --soft: #1e232d;
    --accent: #8197ff; --accent-ink: #0d1020; --ok: #3cc59c; --warn: #e0a849; --bad: #f06a6a;
    --bad-soft: #3a1f24; --ok-soft: #14302a; --warn-soft: #362c18; --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1218; --panel: #171b23; --ink: #e7e9ef; --muted: #8a92a6; --line: #262b36; --soft: #1e232d;
  --accent: #8197ff; --accent-ink: #0d1020; --ok: #3cc59c; --warn: #e0a849; --bad: #f06a6a;
  --bad-soft: #3a1f24; --ok-soft: #14302a; --warn-soft: #362c18; --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.5 Heebo, system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 26px; font-weight: 800; }
h2 { font-size: 19px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* top bar */
.top {
  position: sticky; top: 0; z-index: 10; background: var(--panel); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 16px; padding: 10px 20px; flex-wrap: wrap;
}
.logo { font-weight: 800; font-size: 22px; letter-spacing: -.5px; display: flex; align-items: center; gap: 8px; text-decoration: none; }
.logo::before { content: ''; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 20%, transparent); }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { text-decoration: none; padding: 6px 12px; border-radius: 8px; color: var(--muted); font-weight: 500; }
.nav a.on, .nav a:hover { background: var(--soft); color: var(--ink); }
.me { margin-inline-start: auto; display: flex; gap: 8px; align-items: center; }

main.wrap { max-width: 1180px; margin: 0 auto; padding: 24px 20px 80px; }
.section { margin-top: 28px; }
.section-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.section-head .grow { flex: 1; }

/* buttons, inputs */
.btn {
  border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 7px 14px; cursor: pointer;
  font-weight: 500; white-space: nowrap;
}
.btn:hover { background: var(--soft); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(.95); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 3px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
input[type=text], input[type=number], input[type=date], input[type=url], input[type=email], select, textarea {
  border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 7px 10px; min-width: 0;
}
textarea { width: 100%; min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 1px; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
label.f > input, label.f > select, label.f > textarea { color: var(--ink); font-size: 15px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }

/* panels & cards */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 10px; text-decoration: none; transition: border-color .15s;
}
a.card:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.card .title { display: flex; align-items: center; gap: 8px; }
.card .title h3 { flex: 1; font-size: 16px; }
.card.red { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }
.sub { display: flex; flex-wrap: wrap; gap: 6px; }
.children { display: flex; flex-wrap: wrap; gap: 6px; border-top: 1px dashed var(--line); padding-top: 8px; }

/* chips */
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--soft); color: var(--muted); white-space: nowrap; }
.chip.accent { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
a.chip { text-decoration: none; }
.prio { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.prio.p1 { background: var(--bad); } .prio.p2 { background: var(--warn); } .prio.p3 { background: var(--muted); } .prio.p4 { background: var(--line); }

/* progress */
.bar { height: 8px; background: var(--soft); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s; }
.bar.live > i { background: var(--ok); }
.prog { display: flex; align-items: center; gap: 10px; }
.prog .bar { flex: 1; }
.prog b { font-size: 13px; min-width: 38px; text-align: left; }

/* gate rail */
.gates { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.gate { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--panel); }
.gate .g { font-weight: 800; font-size: 18px; }
.gate.passed { background: var(--ok-soft); border-color: transparent; }
.gate.now { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
@media (max-width: 640px) { .gates { grid-template-columns: repeat(2, 1fr); } }

/* queue */
.queue { display: grid; gap: 10px; }
.q { display: flex; gap: 12px; align-items: center; padding: 12px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; flex-wrap: wrap; }
.q .what { flex: 1; min-width: 200px; }
.q .kind { font-size: 12px; color: var(--muted); }
.q.bad { border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.empty { padding: 18px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 10px; }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 20px 0 16px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 8px 14px; cursor: pointer; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); }

/* checklist */
.gate-block { margin-bottom: 22px; }
.gate-block > h3 { margin-bottom: 8px; display: flex; gap: 8px; align-items: center; }
.items { display: grid; gap: 4px; }
.item { display: grid; grid-template-columns: 22px 1fr auto; gap: 10px; align-items: center; padding: 8px 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.item.done .t { color: var(--muted); text-decoration: line-through; }
.item.late { border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.item input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.item .meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.item .meta select, .item .meta input { padding: 2px 6px; font-size: 13px; }
.item .tr { font-size: 11px; }
@media (max-width: 640px) { .item { grid-template-columns: 22px 1fr; } .item .meta { grid-column: 2; } }

/* tables */
table { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: var(--radius); overflow: hidden; }
th, td { padding: 8px 10px; text-align: start; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 500; background: var(--soft); }
td input, td select { width: 100%; padding: 4px 6px; font-size: 14px; }
td.num { font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.pos { color: var(--ok); } .neg { color: var(--bad); }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 50; overflow-y: auto; }
.modal { background: var(--panel); border-radius: 14px; padding: 22px; width: 100%; max-width: 560px; display: grid; gap: 14px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.modal .actions { display: flex; gap: 8px; justify-content: flex-start; }
.copy { display: flex; gap: 8px; }
.copy input { flex: 1; direction: ltr; font-family: ui-monospace, monospace; font-size: 13px; }

.toast { position: fixed; bottom: 20px; inset-inline-start: 20px; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; z-index: 60; box-shadow: var(--shadow); }
.toast.err { background: var(--bad); color: #fff; }

.banner { padding: 12px 16px; border-radius: 10px; background: var(--warn-soft); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 16px; }
.banner.info { background: var(--soft); }
.spark { width: 120px; height: 32px; }
.spark path { fill: none; stroke: var(--accent); stroke-width: 2; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.kpi b { font-size: 22px; display: block; }
.log { display: grid; gap: 2px; }
.log div { padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
code, .mono { font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; direction: ltr; unicode-bidi: embed; }
pre { background: var(--soft); padding: 12px; border-radius: 8px; overflow-x: auto; direction: ltr; text-align: left; font-size: 12.5px; }

/* login & share */
body.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 32px; max-width: 380px; width: 100%; text-align: center; display: grid; gap: 14px; box-shadow: var(--shadow); }
.login-card .logo { justify-content: center; font-size: 28px; }
.err { color: var(--bad); min-height: 1.5em; }

@media (max-width: 640px) {
  .top { padding: 10px 16px; gap: 8px; }
  main.wrap { padding: 16px 16px 60px; }
  .cards { grid-template-columns: 1fr; }
  h1 { font-size: 22px; }
}

/* wide edit tables scroll sideways inside their box instead of squeezing */
.table-wrap table.wide { min-width: 1100px; }
td select { min-width: 110px; }
td input[type=date] { min-width: 130px; }
td input[type=number] { min-width: 80px; }

/* ---------- stage axis ---------- */
.axis { padding: 6px 16px; }
.axis-row { display: grid; grid-template-columns: 230px 1fr 190px; gap: 18px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); text-decoration: none; }
.axis-row:last-child { border-bottom: 0; }
a.axis-row:hover { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.axis-row.child .who { padding-inline-start: 22px; }
.axis-row.child .who b { font-weight: 500; }
.axis-head { padding: 6px 0 2px; border-bottom: 0; }
.axis-row .who { display: flex; gap: 10px; align-items: center; min-width: 0; }
.axis-row .who b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.axis-row .where { font-size: 13px; display: grid; gap: 4px; }
.warn-text { color: var(--warn); font-weight: 500; }

.track { display: flex; align-items: center; direction: rtl; }
.track .stop { flex: none; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); background: var(--panel); position: relative; }
.track .stop.passed { background: var(--accent); border-color: var(--accent); }
.track .stop.now { border-color: var(--accent); background: var(--panel); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); }
.track .stop.now::after { content: ''; position: absolute; inset: 2px; border-radius: 50%; background: var(--accent); }
.track .stop.unknown { border-style: dashed; }
.track .seg { flex: 1; height: 4px; background: var(--soft); margin: 0 2px; border-radius: 2px; overflow: hidden; }
.track .seg > i { display: block; height: 100%; background: var(--accent); }
.track.red .stop.now { border-color: var(--bad); box-shadow: 0 0 0 4px color-mix(in srgb, var(--bad) 22%, transparent); }
.track.red .stop.now::after { background: var(--bad); }
.track.stopped { opacity: .45; }
.track.labels .lbl { flex: none; width: 14px; display: flex; justify-content: center; white-space: nowrap; font-size: 12px; color: var(--muted); }
.track.labels .seg.blank { background: transparent; }

.track.big { padding: 4px 30px 26px; }
.track.big .stop { width: 22px; height: 22px; }
.track.big .stop em { position: absolute; top: 28px; left: 50%; transform: translateX(-50%); font-style: normal; font-size: 13px; font-weight: 500; white-space: nowrap; color: var(--muted); }
.track.big .stop.now em { color: var(--ink); font-weight: 700; }
.track.big .seg { height: 6px; }
.axis-counts { display: flex; justify-content: space-between; direction: rtl; padding: 0 0 2px; font-size: 12px; color: var(--muted); }
.axis-counts span { flex: 1; text-align: center; }
.axis-counts span:first-child { text-align: right; } .axis-counts span:last-child { text-align: left; }

@media (max-width: 760px) {
  .axis-row { grid-template-columns: 1fr; gap: 8px; }
  .axis-head { display: none; }
  .track.big { padding: 4px 18px 26px; }
  .track.big .stop em { font-size: 11px; }
}

/* ---------- checklist detail ---------- */
.item-wrap.open .item { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.item-title { background: none; border: 0; padding: 0; text-align: start; cursor: pointer; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.item-title:hover .t { text-decoration: underline; text-decoration-color: var(--line); }
.item-detail { border: 1px solid var(--line); border-top: 0; border-radius: 0 0 8px 8px; padding: 12px 14px 14px; background: var(--soft); display: grid; gap: 8px; margin-bottom: 4px; }
.hint { margin: 0; font-size: 14px; }
.steps { display: grid; gap: 2px; }
.step { display: flex; gap: 8px; align-items: center; font-size: 14px; }
.step input { accent-color: var(--accent); }
.req { margin: -2px 0 8px; }

/* ---------- project file ---------- */
.chapters { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 14px; }
.chapter { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; text-align: start; cursor: pointer; display: grid; gap: 6px; }
.chapter.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.chapter .bar { height: 5px; }
.file-body { display: grid; gap: 16px; }
.doc-field .ink { color: var(--ink); font-size: 15px; }
.doc-field .row { gap: 6px; }
.list-block { margin-top: 6px; }
@media (max-width: 760px) { .chapters { grid-template-columns: 1fr 1fr; } }

/* ---------- finance ---------- */
.fin-settings { gap: 14px; margin-bottom: 10px; }
.subtabs { display: flex; gap: 4px; flex-wrap: wrap; margin: 6px 0 14px; }
.subtabs button { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 4px 12px; cursor: pointer; font-size: 13px; }
.subtabs button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chart-wrap { overflow-x: auto; }
.fin-chart { width: 100%; min-width: 640px; height: 220px; direction: ltr; transform: scaleX(-1); }
.fin-chart .ax { font-size: 9px; fill: var(--muted); text-anchor: middle; transform-box: fill-box; transform-origin: center; transform: scaleX(-1); }
.fin-chart .b-rev { fill: var(--accent); }
.fin-chart .b-cost { fill: color-mix(in srgb, var(--bad) 55%, var(--panel)); }
.fin-chart .d-rev { fill: var(--ok); stroke: var(--panel); stroke-width: 1; }
.fin-chart .d-cost { fill: var(--warn); stroke: var(--panel); stroke-width: 1; }
.fin-chart .base { stroke: var(--line); }
.fin-chart .launch-line { stroke: var(--muted); stroke-dasharray: 3 3; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); margin-top: 6px; }
.legend i.lg { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-inline-end: 4px; vertical-align: middle; }
.legend i.rev { background: var(--accent); } .legend i.cost { background: color-mix(in srgb, var(--bad) 55%, var(--panel)); }
.legend i.dot { background: var(--ok); border-radius: 50%; }
.plan-wrap { max-width: 100%; }
table.plan { min-width: 1400px; font-size: 13px; }
table.plan th.m { text-align: center; font-variant-numeric: tabular-nums; min-width: 64px; }
table.plan th.qh { text-align: center; border-inline-start: 1px solid var(--line); }
table.plan td { padding: 4px; }
table.plan td input { min-width: 0; width: 100%; padding: 3px 4px; font-size: 12.5px; text-align: center; }
table.plan .sticky { position: sticky; inset-inline-start: 0; background: var(--panel); z-index: 1; min-width: 190px; }
table.plan thead .sticky { background: var(--soft); }
table.plan tr.grp td { background: var(--soft); }
table.plan tr.grp .sticky { background: var(--soft); }
table.plan tr.auto td { color: var(--muted); font-style: italic; }
table.plan tr.total td, table.plan tr.hl td { border-top: 2px solid var(--line); }
.ledger-form { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; align-items: end; }
@media (max-width: 760px) { .ledger-form { grid-template-columns: 1fr 1fr; } }

/* ---------- dates view ---------- */
.dates { --who: 220px; padding: 8px 16px 14px; }
.dates-body { position: relative; }
.dates-row { display: grid; grid-template-columns: var(--who) 1fr; align-items: center; min-height: 40px; border-bottom: 1px solid var(--line); text-decoration: none; }
.dates-row.head { border-bottom: 0; min-height: 28px; }
.dates-row .who { display: flex; gap: 8px; align-items: center; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.lane { position: relative; height: 26px; }
.lane.months { display: grid; grid-template-columns: repeat(13, 1fr); height: auto; font-size: 11px; color: var(--muted); }
.lane.months span { border-inline-start: 1px solid var(--line); padding-inline-start: 4px; }
.mk { position: absolute; top: 50%; width: 12px; height: 12px; transform: translate(50%, -50%); border-radius: 50%; display: inline-block; }
.legend .mk { position: static; transform: none; vertical-align: middle; margin-inline-end: 4px; }
.mk.ms { background: var(--panel); border: 2px solid var(--accent); }
.mk.ms.done { background: var(--accent); }
.mk.target { background: var(--warn); border-radius: 2px; transform: translate(50%, -50%) rotate(45deg); width: 10px; height: 10px; }
.legend .mk.target { transform: rotate(45deg); }
.mk.launch { background: var(--ok); width: 4px; height: 22px; border-radius: 2px; }
.today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--bad); opacity: .6; z-index: 2; pointer-events: none; }
.empty-lane { position: absolute; top: 4px; inset-inline-start: 8px; }
@media (max-width: 760px) { .dates { --who: 110px; } .lane.months span:nth-child(even) { visibility: hidden; } }
