:root {
  --ink: #14211c;
  --ink-soft: #24352d;
  --paper: #f4f0e7;
  --card: #fffdf8;
  --line: #e4dccf;
  --muted: #6f675d;
  --teal: #0f6e56;
  --teal-deep: #0b5341;
  --copper: #b8612e;
  --danger: #9f2d2d;
  --warn: #8a5a12;
  --shadow: 0 18px 50px rgba(20, 33, 28, 0.08);
  --sans: "Outfit", "Avenir Next", "Segoe UI", sans-serif;
  --serif: "Fraunces", "Iowan Old Style", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(15, 110, 86, 0.08), transparent 55%),
    var(--paper);
}
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.45; }

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
}
.login-card {
  width: min(440px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 2.2rem 2rem 1.8rem;
}
.mark {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: #f4f0e7;
  font-family: var(--serif);
  font-weight: 680;
}
.kicker {
  margin: 1.1rem 0 0;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--teal);
  font-weight: 620;
}
h1, h2, h3 { font-family: var(--serif); font-weight: 560; letter-spacing: -0.03em; }
.login-card h1 { margin: 0.35rem 0 0.4rem; font-size: 2.4rem; }
.lede { margin: 0 0 1.4rem; color: var(--muted); line-height: 1.5; }
label { display: grid; gap: 0.4rem; font-size: 0.92rem; font-weight: 500; }
label + label { margin-top: 0.85rem; }
input, select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 0.78rem 0.85rem;
  color: var(--ink);
}
input:focus, select:focus { outline: 2px solid rgba(15, 110, 86, 0.25); border-color: var(--teal); }
.primary, .ghost, .danger {
  border: 0;
  border-radius: 999px;
  padding: 0.72rem 1.05rem;
  font-weight: 620;
}
.primary { background: var(--ink); color: #f7f3ea; }
.primary:hover:not(:disabled) { background: var(--teal-deep); }
.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.danger { background: #f8e8e4; color: var(--danger); }
.login-card .primary { width: 100%; margin-top: 1.15rem; padding: 0.9rem 1rem; }
.alert {
  margin: 0 0 0.9rem;
  padding: 0.75rem 0.85rem;
  border-radius: 12px;
  background: #f8e8e4;
  color: var(--danger);
}

.shell { min-height: 100vh; display: grid; grid-template-columns: 280px 1fr; }
.side {
  background: var(--ink);
  color: #efe8da;
  padding: 1.3rem 0.9rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; gap: 0.75rem; align-items: center; padding: 0.2rem 0.45rem; }
.brand strong { display: block; font-family: var(--serif); font-size: 1.25rem; font-weight: 560; }
.brand span { color: #b7c4bb; font-size: 0.82rem; }
.nav { overflow: auto; display: grid; gap: 1rem; padding-right: 0.2rem; }
.group-label {
  margin: 0 0.55rem 0.35rem;
  color: #8ea197;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.nav button {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: inherit;
  border-radius: 12px;
  padding: 0.62rem 0.7rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
}
.nav button.is-on { background: rgba(255, 250, 240, 0.1); }
.nav button small {
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #d7c4a4;
}
.side-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; padding: 0.2rem 0.4rem; color: #c9d4cd; }
.side-foot button { background: transparent; color: inherit; border: 1px solid rgba(255,255,255,0.16); border-radius: 999px; padding: 0.4rem 0.75rem; }

.main { padding: 1.5rem 1.6rem 2.4rem; min-width: 0; }
.top { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-end; margin-bottom: 1.1rem; }
.top h1 { margin: 0.15rem 0 0; font-size: 2.5rem; }
.pill {
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  background: #efe7da;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 620;
}
.pill.is-on { background: #e5f4ee; color: var(--teal-deep); }

.cards, .stages, .split { display: grid; gap: 0.8rem; }
.cards { grid-template-columns: repeat(6, minmax(0, 1fr)); margin-bottom: 0.9rem; }
.stages { grid-template-columns: repeat(5, minmax(0, 1fr)); margin: 0.9rem 0; }
.split { grid-template-columns: 1fr 1fr; }
.card, .panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 0.95rem 1rem;
}
.card span, .meter, .note, dt { color: var(--muted); }
.card strong { display: block; margin-top: 0.35rem; font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.panel h3 { margin: 0; font-size: 1.25rem; }
.panel-head, .actions, .filters, .metrics { display: flex; gap: 0.55rem; align-items: center; flex-wrap: wrap; }
.panel-head { justify-content: space-between; margin-bottom: 0.7rem; }
.panel + .panel, .stack > * + * { margin-top: 0.9rem; }
.bar { height: 8px; border-radius: 99px; background: #efe8dc; overflow: hidden; }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--teal), #1f8a6d); border-radius: inherit; }
.meter, .note { margin: 0.45rem 0; font-size: 0.92rem; }
.metrics span { background: #f6f1e8; border-radius: 999px; padding: 0.28rem 0.6rem; font-size: 0.82rem; }
.actions { margin-top: 0.8rem; }
.filters button, .linkish {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
}
.filters button.is-on { background: var(--ink); color: #f7f3ea; border-color: var(--ink); }
dl { display: grid; grid-template-columns: 1fr 1fr; gap: 0.45rem 0.8rem; margin: 0.7rem 0 0; }
dt { font-size: 0.75rem; }
dd { margin: 0.1rem 0 0; font-variant-numeric: tabular-nums; }
.index-list { list-style: none; padding: 0; margin: 0.4rem 0 0; max-height: 220px; overflow: auto; font-size: 0.82rem; }
.index-list li { padding: 0.22rem 0; border-bottom: 1px solid #f0e9de; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { text-align: left; padding: 0.55rem 0.4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 0.75rem; letter-spacing: 0.04em; text-transform: uppercase; }
.linkish { color: var(--teal-deep); padding: 0; border: 0; background: transparent; text-align: left; }
.empty {
  min-height: 420px;
  display: grid;
  align-content: center;
  gap: 0.6rem;
  padding: 2rem;
}
.empty h2 { margin: 0; font-size: 2.2rem; }
.field { display: grid; gap: 0.35rem; max-width: 180px; margin: 0.4rem 0; }

.backdrop {
  position: fixed; inset: 0; background: rgba(20, 33, 28, 0.38);
  display: grid; justify-items: end; z-index: 5;
}
.drawer, .modal {
  background: var(--card);
  height: 100%;
  width: min(460px, 100%);
  padding: 1.2rem 1.2rem 2rem;
  overflow: auto;
  box-shadow: var(--shadow);
}
.modal-wrap { place-items: center; justify-items: center; }
.modal { height: auto; width: min(440px, calc(100% - 2rem)); border-radius: 22px; }
.drawer header, .modal header { display: flex; justify-content: space-between; align-items: center; }
.id { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.82rem; word-break: break-all; }

@media (max-width: 1180px) {
  .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stages { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: relative; height: auto; }
  .split, .cards, .stages { grid-template-columns: 1fr; }
  .top h1 { font-size: 2rem; }
}
