:root {
  --bg: #0B1914;
  --surface: #11241D;
  --surface-alt: #162E25;
  --border: #234739;
  --border-soft: #1B392D;
  --ink: #ECFDF5;
  --ink-muted: #9CC5B3;
  --gold: #FBBF24;
  --gold-dim: rgba(251, 191, 36, 0.16);
  --emerald: #34D399;
  --emerald-dim: rgba(52, 211, 153, 0.15);
  --coral: #FB7185;
  --coral-dim: rgba(251, 113, 133, 0.16);
  --sky: #7DD3FC;
  --font-serif: Georgia, "Palatino Linotype", "Times New Roman", serif;
  --font-sans: "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  overflow-x: hidden;
}

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.editorial-shell {
  max-width: 1380px;
  margin: 0 auto;
  padding: 20px 24px 38px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Header */
.portal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.portal-brand {
  display: flex;
  align-items: center;
  gap: 13px;
}

.brand-line {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.brand-line h1 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--ink);
}

.retainer-tag {
  font-family: var(--font-mono);
  font-size: 0.71rem;
  font-weight: 700;
  padding: 2px 8px;
  border: 1px solid rgba(251, 191, 36, 0.45);
  background: var(--gold-dim);
  color: var(--gold);
  border-radius: 3px;
}

.brand-sub {
  margin: 2px 0 0;
  font-size: 0.85rem;
  color: var(--ink-muted);
}

.portal-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.forest-select,
.forest-input {
  min-height: 36px;
  padding: 0 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 0.83rem;
}

.cycle-group {
  display: inline-flex;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 4px;
  overflow: hidden;
}

.cycle-btn {
  min-height: 34px;
  padding: 0 11px;
  border: none;
  border-right: 1px solid var(--border-soft);
  background: transparent;
  color: var(--ink-muted);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
}

.cycle-btn:last-child {
  border-right: none;
}

.cycle-btn.is-active {
  background: var(--gold-dim);
  color: var(--gold);
}

.gold-btn {
  min-height: 36px;
  padding: 0 13px;
  border: none;
  border-radius: 4px;
  background: var(--gold);
  color: #0B1914;
  font-family: var(--font-sans);
  font-size: 0.83rem;
  font-weight: 700;
  cursor: pointer;
}

.gold-btn:hover:not(:disabled) {
  background: #FCD34D;
}

.gold-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.ghost-btn {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-alt);
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.ghost-btn.small {
  min-height: 30px;
  padding: 0 9px;
  font-size: 0.74rem;
}

.coral-btn {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid rgba(251, 113, 133, 0.55);
  border-radius: 4px;
  background: var(--coral-dim);
  color: var(--coral);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.coral-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.full {
  width: 100%;
}

/* Quick Log Hours Composer */
.log-composer {
  background: var(--surface);
  border: 1px solid var(--gold);
  border-radius: 4px;
  padding: 14px 16px;
}

.composer-grid {
  display: grid;
  grid-template-columns: 1.5fr 0.7fr 1.6fr auto;
  gap: 12px;
  align-items: end;
}

.composer-grid label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ink-muted);
  margin-bottom: 4px;
}

.composer-grid .forest-select,
.composer-grid .forest-input {
  width: 100%;
}

.composer-actions {
  display: flex;
  gap: 8px;
}

/* KPI Strip */
.editorial-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.e-kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 15px 17px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.e-kpi-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--ink-muted);
  font-weight: 600;
}

.e-badge {
  font-family: var(--font-mono);
  font-size: 0.69rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--surface-alt);
  color: var(--ink-muted);
  border: 1px solid var(--border);
}

.e-badge.gold {
  background: var(--gold-dim);
  color: var(--gold);
  border-color: rgba(251, 191, 36, 0.45);
}

.e-kpi-num {
  font-family: var(--font-serif);
  font-variant-numeric: tabular-nums;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.e-kpi-sub {
  font-size: 0.78rem;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

/* Charts Grid */
.editorial-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.38fr) minmax(0, 1fr);
  gap: 14px;
}

.forest-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.f-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.f-head h2,
.d-title-wrap h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--ink);
}

.f-sub {
  margin: 2px 0 0;
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.f-legend {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.76rem;
  color: var(--ink-muted);
}

.f-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.swatch-gold {
  width: 11px;
  height: 3px;
  background: var(--gold);
  display: inline-block;
}

.swatch-plan {
  width: 13px;
  border-top: 2px dashed var(--ink-muted);
  display: inline-block;
}

.svg-stage {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  padding: 6px;
}

#burnSvg {
  width: 100%;
  height: auto;
  display: block;
}

.ring-layout {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

#ringSvg {
  display: block;
  margin: 0 auto;
}

.stream-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stream-row {
  width: 100%;
  border: 1px solid var(--border-soft);
  background: var(--bg);
  border-radius: 4px;
  padding: 8px 10px;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  text-align: left;
}

.stream-row:hover {
  border-color: var(--gold);
}

.stream-row.is-selected {
  border-color: var(--gold);
  background: var(--gold-dim);
}

.stream-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.81rem;
  font-weight: 600;
}

.stream-hours {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
  color: var(--ink-muted);
}

/* Deliverables Ledger */
.d-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.d-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mono-tag {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.74rem;
  font-weight: 700;
  padding: 2px 8px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--gold);
}

.d-filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.forest-search {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 35px;
  padding: 0 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--ink-muted);
}

.forest-search input {
  border: none;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 0.83rem;
  width: 195px;
}

.forest-search input:focus {
  outline: none;
}

.status-pills {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.d-pill {
  min-height: 33px;
  padding: 0 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--ink-muted);
  border-radius: 4px;
  font-size: 0.77rem;
  font-weight: 600;
  cursor: pointer;
}

.d-pill.is-active {
  background: var(--gold);
  border-color: var(--gold);
  color: #0B1914;
  font-weight: 700;
}

.deliv-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(280px, 0.95fr);
  gap: 16px;
  align-items: start;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.deliv-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 650px;
}

.deliv-table th {
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
  text-align: left;
  padding: 9px 10px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--ink-muted);
  white-space: nowrap;
}

.deliv-table th.num,
.deliv-table td.num {
  text-align: right;
}

.sort-btn {
  border: none;
  background: transparent;
  padding: 0;
  color: inherit;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.sort-btn.num-btn {
  width: 100%;
  justify-content: flex-end;
}

.sort-btn.is-active {
  color: var(--gold);
}

.deliv-table tbody tr {
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer;
}

.deliv-table tbody tr:hover {
  background: rgba(236, 253, 245, 0.04);
}

.deliv-table tbody tr.is-selected {
  background: rgba(251, 191, 36, 0.1);
}

.deliv-table td {
  padding: 10px;
  font-size: 0.83rem;
  vertical-align: middle;
}

.mono-val {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
}

.sub-stream {
  display: block;
  font-size: 0.73rem;
  color: var(--ink-muted);
}

.d-badge {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.71rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 3px;
  border: 1px solid transparent;
}

.d-Approved {
  background: var(--emerald-dim);
  color: var(--emerald);
  border-color: rgba(52, 211, 153, 0.4);
}

.d-In-Review {
  background: var(--gold-dim);
  color: var(--gold);
  border-color: rgba(251, 191, 36, 0.45);
}

.d-In-Progress {
  background: rgba(125, 211, 252, 0.14);
  color: var(--sky);
  border-color: rgba(125, 211, 252, 0.35);
}

.d-Revision {
  background: var(--coral-dim);
  color: var(--coral);
  border-color: rgba(251, 113, 133, 0.45);
}

/* Sign-off Card */
.signoff-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-top: 2px solid var(--gold);
  border-radius: 4px;
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.signoff-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid var(--border-soft);
  padding-bottom: 9px;
}

.signoff-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--gold);
  display: block;
}

.signoff-head h3 {
  margin: 3px 0 0;
  font-family: var(--font-serif);
  font-size: 1.05rem;
  color: var(--ink);
}

.rev-brief {
  margin: 0;
  font-size: 0.82rem;
  color: var(--ink-muted);
  line-height: 1.5;
}

.rev-meta {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.rev-meta > div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px dashed var(--border-soft);
  padding-bottom: 5px;
}

.rev-meta dt {
  font-size: 0.76rem;
  color: var(--ink-muted);
}

.rev-meta dd {
  margin: 0;
  font-size: 0.79rem;
  font-weight: 600;
  color: var(--ink);
  text-align: right;
}

.rev-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.rev-feedback {
  margin: 0;
  min-height: 18px;
  font-size: 0.76rem;
  color: var(--emerald);
  font-weight: 600;
}

@media (max-width: 1120px) {
  .editorial-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .editorial-grid,
  .deliv-workspace,
  .composer-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .editorial-shell {
    padding: 14px 12px 28px;
  }
  .editorial-kpis,
  .ring-layout,
  .rev-actions {
    grid-template-columns: 1fr;
  }
  .forest-search input {
    width: 165px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
  }
}
