:root {
  --bg: #0b0d12; --panel: #12151c; --panel2: #181c25; --line: #252a36; --ink: #e8eaf0; --dim: #8b92a5;
  --accent: #f4c542; --ok: #3ecf8e; --warn: #f4a742; --bad: #f2617a; --info: #6aa7ff; --it: #b58cff;
  --side: 232px; --r: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 Outfit, system-ui, sans-serif; }
button, input, textarea { font: inherit; color: inherit; }
a { color: var(--info); }
code, .mono { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: .86em; }
.logo { font-weight: 700; letter-spacing: .06em; font-size: 20px; }
.logo span { color: var(--accent); }

/* gate */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.gate-box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 28px; width: min(360px, 100%); }
.gate input { width: 100%; margin: 12px 0; padding: 10px 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
.gate button { width: 100%; padding: 10px; background: var(--accent); color: #111; border: 0; border-radius: 8px; font-weight: 700; cursor: pointer; }
.err { color: var(--bad); min-height: 1.2em; }

/* shell */
.shell { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--panel); border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 14px; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side .grp { color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: .1em; margin: 12px 8px 4px; }
.nav-a { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; cursor: pointer; }
.nav-a:hover { background: var(--panel2); }
.nav-a.on { background: var(--panel2); box-shadow: inset 3px 0 0 var(--accent); }
.nav-a .n { color: var(--dim); font-size: 12px; }
.nav-a .n.need { color: #111; background: var(--warn); border-radius: 99px; padding: 0 7px; font-weight: 700; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.linkbtn { background: none; border: 0; color: var(--dim); cursor: pointer; padding: 0; text-align: left; }
.main { min-width: 0; }
.bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; padding: 12px 20px; background: rgba(11,13,18,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.bar h1 { font-size: 18px; margin: 0; white-space: nowrap; }
.bar input { flex: 1; min-width: 0; max-width: 520px; margin-left: auto; padding: 8px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.synced { color: var(--dim); font-size: 12px; white-space: nowrap; }
.menu { display: none; background: none; border: 0; font-size: 20px; cursor: pointer; }
.view { padding: 20px; max-width: 1400px; }

/* blocks */
.h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .1em; color: var(--dim); margin: 22px 0 10px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; cursor: pointer; }
.stat b { display: block; font-size: 28px; }
.stat span { color: var(--dim); font-size: 13px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; cursor: pointer; display: flex; flex-direction: column; }
.tile:hover { border-color: #3a4152; }
.tile .img { aspect-ratio: 16/10; background: #0e1118; display: grid; place-items: center; overflow: hidden; }
.tile .img img { width: 100%; height: 100%; object-fit: contain; }
.tile .img.empty { border-bottom: 1px dashed var(--line); color: var(--dim); font-size: 12px; }
.tile .tb { padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.tile .t { font-weight: 600; }
.row-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; color: var(--dim); }
.pill { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 99px; background: var(--panel2); border: 1px solid var(--line); color: var(--ink); white-space: nowrap; }
.pill.locked, .pill.approved, .pill.validated, .pill.agreed, .pill.done, .pill.canonical { border-color: var(--ok); color: var(--ok); }
.pill.open, .pill.todo, .pill.awaiting, .pill.blocked { border-color: var(--warn); color: var(--warn); }
.pill.iterate, .pill.draft, .pill.claimed, .pill.proposed { border-color: var(--it); color: var(--it); }
.pill.rejected, .pill.retired { border-color: var(--bad); color: var(--bad); }
.pill.info, .pill.skip, .pill.parked { color: var(--dim); }
.chips { display: flex; gap: 3px; }
.chip-c { width: 14px; height: 14px; border-radius: 3px; border: 1px solid rgba(255,255,255,.15); }

/* table list */
.tbl { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.tbl th, .tbl td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: top; }
.tbl th { position: sticky; top: 58px; background: var(--panel2); color: var(--dim); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.tbl tr:nth-child(even) td { background: rgba(255,255,255,.015); }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: var(--panel2); }
.bar-p { display: flex; height: 8px; border-radius: 99px; overflow: hidden; background: var(--panel2); min-width: 120px; }
.bar-p i { display: block; height: 100%; }
.progress-row { display: grid; grid-template-columns: 70px 1fr 64px; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.progress-row .pct { text-align: right; font-weight: 700; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--dim); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.gap { display: flex; gap: 10px; align-items: baseline; padding: 8px 12px; background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--warn); border-radius: 8px; margin-bottom: 6px; cursor: pointer; }
.empty-v { color: var(--dim); padding: 30px 0; }

/* detail drawer */
.detail { position: fixed; top: 0; right: 0; width: min(520px, 100%); height: 100vh; overflow-y: auto; background: var(--panel); border-left: 1px solid var(--line); padding: 18px 20px 40px; z-index: 20; box-shadow: -20px 0 40px rgba(0,0,0,.4); }
.detail h2 { margin: 6px 0 10px; font-size: 20px; }
.detail .close { float: right; background: none; border: 0; font-size: 22px; cursor: pointer; color: var(--dim); }
.detail img.big { width: 100%; border-radius: 8px; background: #0e1118; margin: 8px 0; }
.detail .body p { margin: 0 0 10px; }
.detail .strip { display: flex; gap: 8px; overflow-x: auto; padding: 6px 0; }
.detail .strip figure { margin: 0; flex: 0 0 120px; cursor: pointer; }
.detail .strip img { width: 120px; height: 80px; object-fit: contain; background: #0e1118; border-radius: 6px; border: 1px solid var(--line); }
.detail .strip figcaption { font-size: 11px; color: var(--dim); }
.detail textarea { width: 100%; min-height: 80px; margin-top: 10px; padding: 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
.acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.act { padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel2); cursor: pointer; }
.act.yes { border-color: var(--ok); } .act.it { border-color: var(--it); } .act.no { border-color: var(--bad); }
.hist { margin-top: 14px; font-size: 12px; color: var(--dim); display: flex; flex-direction: column; gap: 4px; }
.src { margin-top: 12px; font-size: 12px; color: var(--dim); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #111; padding: 8px 14px; border-radius: 8px; z-index: 30; }
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 9; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; z-index: 10; width: 260px; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; }
  .menu { display: block; }
  .bar { padding: 10px 16px; gap: 8px; flex-wrap: wrap; }
  .bar input { order: 5; flex-basis: 100%; max-width: none; }
  .synced { display: none; }
  .view { padding: 16px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .tbl th { top: 104px; }
  .hide-sm { display: none; }
}
