:root {
  --bg: #12100e;
  --bg-2: #1a1714;
  --bg-3: #221e1a;
  --line: #322c26;
  --line-2: #443c34;
  --text: #f0ebe4;
  --text-2: #b8ada0;
  --text-3: #7d7266;
  --gold: #d9a441;
  --gold-dim: #8a6b2c;
  --blue: #6fa8c7;
  --green: #7bab6e;
  --red: #cf6b5c;
  --purple: #a186c4;
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 ui-sans-serif, -apple-system, "Segoe UI", Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.spacer { flex: 1; }

/* ------------------------------- login ---------------------------------- */
.login { min-height: 100vh; display: grid; place-items: center; }
.login-card {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 14px;
  padding: 36px; width: 340px; display: flex; flex-direction: column; gap: 14px;
}
.login-card h1 { font-size: 24px; letter-spacing: -.02em; }
.login-card p { color: var(--text-2); font-size: 14px; }
.login-err { color: var(--red); font-size: 13px; min-height: 18px; }

/* ------------------------------- shell ---------------------------------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--bg-2); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; gap: 11px; align-items: center; padding: 20px 18px; border-bottom: 1px solid var(--line); }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(140deg, var(--gold), var(--gold-dim)); color: #241c0c;
  font-size: 19px; font-weight: 700;
}
.brand-name { font-weight: 650; letter-spacing: -.01em; }
.brand-sub { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .09em; }

nav { flex: 1; overflow-y: auto; padding: 12px 10px; }
nav .nav-group { font-size: 10px; text-transform: uppercase; letter-spacing: .1em; color: var(--text-3); padding: 14px 10px 6px; }
nav button {
  display: flex; width: 100%; align-items: center; gap: 10px; background: none; border: 0;
  color: var(--text-2); font: inherit; font-size: 14px; padding: 7px 10px; border-radius: 7px;
  cursor: pointer; text-align: left;
}
nav button:hover { background: var(--bg-3); color: var(--text); }
nav button.active { background: var(--bg-3); color: var(--gold); font-weight: 550; }
nav .nav-count { margin-left: auto; font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }

.sidebar-foot { padding: 12px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 7px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 20px;
  padding: 24px 30px 18px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: rgba(18,16,14,.93); backdrop-filter: blur(8px); z-index: 5;
}
.topbar h1 { font-size: 21px; letter-spacing: -.02em; font-weight: 620; }
.sub { color: var(--text-3); font-size: 13px; margin-top: 2px; max-width: 68ch; }
.topbar-right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

.view { padding: 24px 30px 70px; }

/* ------------------------------ buttons --------------------------------- */
button, input, select, textarea { font-family: inherit; }
.primary-btn {
  background: var(--gold); color: #241c0c; border: 0; border-radius: 8px;
  padding: 8px 15px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.primary-btn:hover { filter: brightness(1.08); }
.ghost-btn {
  background: var(--bg-3); color: var(--text-2); border: 1px solid var(--line-2);
  border-radius: 8px; padding: 7px 13px; font-size: 13px; cursor: pointer;
  text-decoration: none; display: inline-block; text-align: center;
}
.ghost-btn:hover { color: var(--text); border-color: var(--text-3); }
.ghost-btn.danger:hover { color: var(--red); border-color: var(--red); }
.icon-btn { background: none; border: 0; color: var(--text-3); font-size: 24px; cursor: pointer; line-height: 1; }
.icon-btn:hover { color: var(--text); }

input, select, textarea {
  background: var(--bg); border: 1px solid var(--line-2); color: var(--text);
  border-radius: 8px; padding: 8px 11px; font-size: 14px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 1px solid var(--gold-dim); border-color: var(--gold-dim); }
textarea { resize: vertical; min-height: 80px; line-height: 1.6; }
label { display: block; font-size: 12px; color: var(--text-3); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .06em; }

/* ------------------------------- cards ---------------------------------- */
.card { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card + .card { margin-top: 14px; }
.card h3 { font-size: 15px; font-weight: 600; margin-bottom: 4px; letter-spacing: -.01em; }
.card-grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

.section-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: .11em; color: var(--text-3);
  margin: 28px 0 11px; font-weight: 600;
}
.section-title:first-child { margin-top: 0; }

/* -------------------------------- bits ---------------------------------- */
.pill {
  display: inline-block; font-size: 11px; padding: 2px 9px; border-radius: 20px;
  border: 1px solid var(--line-2); color: var(--text-2); white-space: nowrap;
  text-transform: uppercase; letter-spacing: .05em; font-weight: 550;
}
.pill.gold  { color: var(--gold);   border-color: var(--gold-dim);  background: rgba(217,164,65,.09); }
.pill.green { color: var(--green);  border-color: #3f5a38;          background: rgba(123,171,110,.09); }
.pill.red   { color: var(--red);    border-color: #6b3730;          background: rgba(207,107,92,.09); }
.pill.blue  { color: var(--blue);   border-color: #3a5666;          background: rgba(111,168,199,.09); }
.pill.purple{ color: var(--purple); border-color: #4d4064;          background: rgba(161,134,196,.09); }
.pill.mute  { color: var(--text-3); }

.stat { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 15px 17px; }
.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); }
.stat-value { font-size: 27px; font-weight: 650; letter-spacing: -.03em; margin-top: 5px; font-variant-numeric: tabular-nums; }
.stat-note { font-size: 12px; color: var(--text-3); margin-top: 3px; }

.bar { height: 5px; background: var(--bg-3); border-radius: 3px; overflow: hidden; margin-top: 9px; }
.bar > i { display: block; height: 100%; background: var(--gold); border-radius: 3px; }

.muted { color: var(--text-3); }
.dim { color: var(--text-2); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.pre-wrap { white-space: pre-wrap; }
.mono { font-family: var(--mono); font-size: 12px; }
a { color: var(--blue); }

.row { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }
.between { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }

/* -------------------------------- list ---------------------------------- */
.list-item {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 9px; cursor: pointer;
}
.list-item:hover { border-color: var(--line-2); }
.list-item h4 { font-size: 14.5px; font-weight: 570; letter-spacing: -.005em; }
.list-item .meta { display: flex; gap: 7px; align-items: center; flex-wrap: wrap; margin-top: 7px; }

/* -------------------------------- board --------------------------------- */
.board { display: grid; grid-template-columns: repeat(4, minmax(215px, 1fr)); gap: 13px; align-items: start; }
.col { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 11px; }
.col-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; padding: 0 3px; }
.col-head strong { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.tcard {
  background: var(--bg-3); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 11px; margin-bottom: 8px; cursor: grab; font-size: 13.5px; line-height: 1.45;
}
.tcard:hover { border-color: var(--line-2); }
.tcard.dragging { opacity: .4; }
.tcard .meta { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 8px; }
.tcard .pill { font-size: 10px; padding: 1px 7px; }
.col.over { border-color: var(--gold-dim); background: var(--bg-3); }
.bl { border-left: 3px solid var(--line-2); padding-left: 9px; }
.bl.critical { border-left-color: var(--red); }
.bl.high { border-left-color: var(--gold); }
.bl.medium { border-left-color: var(--blue); }
.bl.low { border-left-color: var(--line-2); }

/* ------------------------------- table ---------------------------------- */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-3); padding: 8px 11px; border-bottom: 1px solid var(--line); font-weight: 600;
}
td { padding: 10px 11px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--bg-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ------------------------------ timeline -------------------------------- */
.phase-block { border-left: 2px solid var(--line-2); padding-left: 20px; margin-bottom: 26px; position: relative; }
.phase-block::before {
  content: ''; position: absolute; left: -7px; top: 5px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--bg); border: 2px solid var(--line-2);
}
.phase-block.active { border-left-color: var(--gold); }
.phase-block.active::before { border-color: var(--gold); background: var(--gold); }
.ms-row {
  display: grid; grid-template-columns: 92px 1fr auto; gap: 12px; align-items: start;
  padding: 9px 11px; border-radius: 8px; cursor: pointer; font-size: 13.5px;
}
.ms-row:hover { background: var(--bg-2); }
.ms-row .date { font-family: var(--mono); font-size: 11.5px; color: var(--text-3); padding-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ms-row .ttl { font-weight: 520; }
.ms-row.gate { background: rgba(217,164,65,.06); border: 1px solid var(--gold-dim); margin: 6px 0; }
.ms-row.done .ttl { text-decoration: line-through; color: var(--text-3); }

/* ------------------------------- docs ----------------------------------- */
.doc-layout { display: grid; grid-template-columns: 210px 1fr; gap: 24px; align-items: start; }
.doc-nav button {
  display: block; width: 100%; text-align: left; background: none; border: 0; color: var(--text-2);
  font: inherit; font-size: 13.5px; padding: 7px 10px; border-radius: 7px; cursor: pointer;
}
.doc-nav button:hover { background: var(--bg-2); color: var(--text); }
.doc-nav button.active { background: var(--bg-3); color: var(--gold); }
.prose { max-width: 74ch; }
.prose h1 { font-size: 25px; margin: 4px 0 16px; letter-spacing: -.025em; font-weight: 650; }
.prose h2 { font-size: 17.5px; margin: 30px 0 9px; letter-spacing: -.015em; font-weight: 620; color: var(--gold); }
.prose h3 { font-size: 15px; margin: 20px 0 6px; font-weight: 600; }
.prose p { margin: 11px 0; color: #ded6cc; }
.prose ul, .prose ol { margin: 11px 0 11px 22px; color: #ded6cc; }
.prose li { margin: 5px 0; }
.prose strong { color: var(--text); font-weight: 620; }
.prose em { color: var(--text-2); }
.prose code { font-family: var(--mono); background: var(--bg-3); padding: 1.5px 6px; border-radius: 4px; font-size: .88em; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 26px 0; }
.prose blockquote { border-left: 3px solid var(--gold-dim); padding-left: 15px; color: var(--text-2); margin: 14px 0; }

/* ------------------------------- modal ---------------------------------- */
.modal { position: fixed; inset: 0; background: rgba(8,7,6,.75); display: grid; place-items: center; z-index: 100; padding: 20px; }
.modal-card {
  background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 13px;
  width: min(700px, 100%); max-height: 88vh; display: flex; flex-direction: column;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 17px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 16px; font-weight: 600; }
.modal-body { padding: 20px; overflow-y: auto; display: grid; gap: 14px; }
.modal-body .pair { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.modal-foot { display: flex; gap: 9px; align-items: center; padding: 14px 20px; border-top: 1px solid var(--line); }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: var(--bg-3); border: 1px solid var(--line-2); color: var(--text);
  padding: 10px 18px; border-radius: 9px; font-size: 13.5px; transition: transform .22s ease; z-index: 200;
}
.toast.show { transform: translateX(-50%) translateY(0); }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.filters select, .filters input { width: auto; min-width: 130px; font-size: 13px; padding: 6px 10px; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  nav { display: flex; flex-wrap: wrap; }
  nav button { width: auto; }
  nav .nav-group { width: 100%; }
  .board { grid-template-columns: 1fr; }
  .doc-layout { grid-template-columns: 1fr; }
  .view, .topbar { padding-left: 16px; padding-right: 16px; }
}
