:root {
  --shell: #1c1a17;
  --shell-2: #28231d;
  --panel: #f1e8d8;
  --panel-2: #e7d7bd;
  --ink: #2b251e;
  --muted: #706657;
  --bronze: #a98245;
  --net: #214b35;
  --pos: #23613c;
  --warn: #b47a22;
  --blocked: #8f2929;
  --blocked-bg: #f2d5ce;
  --gap: 12px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--shell);
  color: #f1e8d8;
  font: 13px/1.35 "Segoe UI", "Helvetica Neue", sans-serif;
}

button,
input {
  font: inherit;
}

.skip,
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.shell {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  min-height: 100vh;
  background: var(--shell);
}

.rail {
  background: var(--shell);
  border-right: 1px solid #3a342c;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.brand {
  margin: 0;
  color: var(--bronze);
  letter-spacing: 0.18em;
  font-weight: 800;
  font-size: 1.05rem;
}

.rail-scope {
  margin: 0;
  color: #b8aa94;
  font-size: 0.75rem;
}

.rail nav,
.rail-actions {
  display: grid;
  gap: 5px;
}

.rail button,
.period-tabs button,
.range button,
.panel-head button,
.dialog button,
.drawer button {
  min-height: 32px;
  border: 1px solid #4a4034;
  background: var(--shell-2);
  color: #f1e8d8;
  border-radius: 8px;
  padding: 5px 9px;
  text-align: left;
  cursor: pointer;
}

.rail button[aria-current="page"],
.period-tabs button[aria-pressed="true"] {
  background: var(--panel);
  color: var(--ink);
  border-color: var(--bronze);
}

.rail-note {
  margin: 8px 0 0;
  padding: 10px;
  background: var(--shell-2);
  border: 1px solid #4a4034;
  border-radius: 8px;
  color: #d9cbb4;
  font-size: 0.72rem;
  line-height: 1.45;
}

.rail-note strong {
  display: block;
  color: var(--bronze);
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}

.rail-actions {
  margin-top: auto;
}

.stage {
  background: var(--shell-2);
  padding: 10px;
  min-width: 0;
  min-height: 0;
  height: auto;
}

.board {
  background: var(--panel-2);
  color: var(--ink);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  height: auto;
  min-height: 0;
  justify-content: flex-start;
}

.topbar,
.period-row,
.panel-head,
.range {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  flex-wrap: nowrap;
  gap: 10px;
  min-height: 0;
  height: auto;
}

.topbar-brand,
.topbar-meta,
.period-tabs {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  align-items: center;
  min-width: 0;
}

.topbar-brand strong {
  color: var(--ink);
  letter-spacing: 0.12em;
}

.topbar-meta {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.pill {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 8px;
  background: var(--panel);
  border: 1px solid var(--bronze);
  color: var(--ink);
  font-size: 0.68rem;
  font-weight: 700;
  white-space: nowrap;
}

.pill-paper,
.pill-block {
  background: var(--blocked);
  border-color: #6d1f1f;
  color: #f8e8e4;
}

.muted,
.toast {
  color: var(--muted);
  margin: 0;
  font-size: 0.75rem;
}

.period-row {
  justify-content: space-between;
  background: var(--panel);
  border: 1px solid #d4c4a8;
  border-radius: 8px;
  padding: 6px 8px;
  height: auto;
}

.heroes {
  display: grid;
  grid-template-columns: 1.35fr 1fr 1fr;
  gap: var(--gap);
  align-items: stretch;
  height: auto;
}

.hero-card,
.panel,
.strip div {
  background: var(--panel);
  color: var(--ink);
  border-radius: 10px;
  border: 1px solid #d4c4a8;
}

.hero-card {
  padding: 12px 14px;
  min-height: 0;
  height: auto;
}

.hero-card.net {
  background: var(--net);
  border-color: #173626;
  color: #f3efe4;
}

.hero-card.gross {
  box-shadow: inset 0 0 0 2px var(--bronze);
}

.hero-card.costs.warn {
  border-color: var(--warn);
}

.hero-card h3,
.strip span,
.panel h3 {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.hero-card.net h3,
.hero-card.net .hero-sub,
.hero-card.net .hero-tag {
  color: #d7c7a4;
}

.hero-figure {
  margin: 8px 0 14px;
  font-size: clamp(1.45rem, 2vw, 2.1rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.hero-card.net .hero-figure {
  margin: 10px 0 16px;
  font-size: clamp(1.9rem, 2.6vw, 2.7rem);
  color: #f7f1e4;
}

.hero-figure.pos,
.strip .pos {
  color: var(--pos);
}

.hero-card.net .hero-figure.pos {
  color: #f7f1e4;
}

.hero-figure.neg,
.neg {
  color: var(--blocked);
}

.hero-card.net .hero-figure.neg {
  color: #f2d5ce;
}

.hero-sub,
.hero-tag {
  margin: 0;
  font-size: 0.72rem;
}

.hero-tag {
  margin-top: 6px;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.strip {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  height: auto;
}

.strip div {
  padding: 8px 10px;
  min-width: 0;
  min-height: 0;
  height: auto;
}

.strip strong {
  display: block;
  margin-top: 3px;
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
}

.mid,
.bottom {
  display: grid;
  gap: var(--gap);
  min-height: 0;
  height: auto;
  align-items: stretch;
}

.mid {
  grid-template-columns: 1.1fr 1fr 1fr;
}

.bottom {
  grid-template-columns: 1fr 1fr;
}

.panel {
  padding: 8px 10px;
  min-width: 0;
  min-height: 0;
  height: auto;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.panel.fail {
  background: var(--blocked-bg);
  border-color: #d4a39b;
}

.panel-head {
  justify-content: space-between;
}

.panel-head button {
  min-height: 28px;
  background: var(--panel-2);
  color: var(--ink);
  border-color: var(--bronze);
}

.waterfall,
.cost-compact,
.exceptions {
  display: grid;
  gap: 6px;
}

.waterfall > div {
  display: grid;
  gap: 3px;
}

.bar {
  min-height: 24px;
  height: auto;
  border-radius: 6px;
  color: #f7f1e4;
  font-weight: 700;
  padding: 3px 8px;
  font-size: 0.78rem;
}

.bar-profit {
  background: var(--pos);
}

.bar-cost {
  background: var(--blocked);
}

.bar-net {
  background: var(--bronze);
}

.cost-visual {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 0;
}

.donut {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: conic-gradient(var(--bronze) 18%, var(--panel-2) 0);
  mask: radial-gradient(circle at center, transparent 48%, #000 50%);
}

.cost-compact {
  grid-template-columns: 1fr;
  font-size: 0.8rem;
}

.cost-line {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 3px 0;
  border-bottom: 1px solid #d4c4a8;
}

.exceptions {
  max-height: 168px;
  overflow: auto;
}

.exception {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  text-align: left;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid #d4a39b;
  border-left: 4px solid var(--blocked);
  border-radius: 8px;
  padding: 6px 8px;
}

.status {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}

.status-blocked {
  background: var(--blocked-bg);
  color: var(--blocked);
}

.status-pending {
  background: #f3e2be;
  color: var(--warn);
}

.status-completed {
  background: #d5e6d8;
  color: var(--pos);
}

.table-wrap {
  overflow: auto;
  max-height: 168px;
  min-height: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 5px 7px;
  border-bottom: 1px solid #d4c4a8;
  white-space: nowrap;
  font-size: 0.78rem;
}

.drawer,
.dialog {
  border: 0;
  border-radius: 12px;
  width: min(960px, 94vw);
  background: var(--panel);
  color: var(--ink);
  padding: 0;
}

.drawer {
  width: min(1100px, 96vw);
  height: min(86vh, 900px);
}

.drawer-body,
.dialog-body {
  padding: 16px 18px 20px;
  overflow: auto;
}

.drawer::backdrop,
.dialog::backdrop {
  background: rgba(28, 26, 23, 0.62);
}

.split,
.safety-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}

.banner-inline {
  background: #f3e2be;
  color: var(--warn);
  font-weight: 800;
  padding: 8px 10px;
  border-radius: 8px;
}

input[type="date"] {
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--bronze);
  border-radius: 8px;
  min-height: 32px;
  padding: 3px 8px;
}

@media (min-width: 1280px) {
  .board {
    min-height: calc(100vh - 20px);
  }

  .topbar,
  .period-row,
  .topbar-brand,
  .topbar-meta {
    flex-wrap: nowrap;
  }
}

@media (min-width: 1280px) {
  html[data-layout="desktop"] .board {
    min-height: calc(100vh - 20px);
  }
}

@media (max-width: 1279px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .rail {
    flex-direction: row;
    flex-wrap: wrap;
    border-right: 0;
    border-bottom: 1px solid #3a342c;
  }

  .rail nav,
  .rail-actions {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    flex: 1;
    margin-top: 0;
  }

  .heroes,
  .strip,
  .mid,
  .bottom {
    grid-template-columns: 1fr 1fr;
  }

  .topbar {
    flex-wrap: wrap;
  }
}

@media (max-width: 767px) {
  .shell {
    display: flex;
    flex-direction: column;
  }

  .stage {
    order: 0;
  }

  .rail {
    order: 1;
  }

  .board {
    min-height: 0;
    height: auto;
  }

  .topbar,
  .period-row,
  .topbar-brand,
  .topbar-meta {
    flex-wrap: wrap;
  }

  .topbar {
    order: 0;
  }

  .heroes {
    order: 1;
    grid-template-columns: 1fr;
  }

  .strip {
    order: 2;
  }

  .period-row {
    order: 3;
  }

  .mid {
    order: 4;
  }

  .bottom {
    order: 5;
  }

  .hero-card.net {
    order: -1;
  }

  .strip,
  .mid,
  .bottom,
  .cost-visual {
    grid-template-columns: 1fr;
  }

  .table-wrap {
    overflow-x: auto;
    max-height: none;
  }

  .rail nav,
  .rail-actions {
    grid-template-columns: 1fr 1fr;
  }
}
