:root {
  color-scheme: light;
  --bg: #f6f6f2;
  --ink: #111111;
  --muted: #666661;
  --subtle: #8b8b84;
  --line: #d8d8cf;
  --surface: #ffffff;
  --surface-soft: #efefea;
  --rail: #111111;
  --rail-muted: #9c9c96;
  --good: #247a52;
  --bad: #b3261e;
  --warn: #9a6b1d;
  --shadow: 0 18px 45px rgba(17, 17, 17, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.side-rail {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 24px 18px;
  background: var(--rail);
  color: #ffffff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
  min-height: 42px;
}

.brand-mark,
.login-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  font-size: 16px;
  font-weight: 700;
}

.brand-word {
  font-size: 14px;
  font-weight: 800;
}

.rail-nav {
  display: grid;
  gap: 6px;
  margin-top: 40px;
}

.rail-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--rail-muted);
  text-align: left;
  font-size: 14px;
  font-weight: 650;
}

.rail-item svg,
.icon-button svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  flex: 0 0 auto;
}

.rail-item:hover,
.rail-item.is-active {
  background: #ffffff;
  color: var(--ink);
}

.rail-footer {
  margin-top: auto;
  padding: 16px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.rail-caption,
.status-strip span,
.select-shell span,
.scenario-form span,
th {
  display: block;
  color: var(--subtle);
  font-size: 11px;
  font-weight: 750;
  line-height: 1.2;
  text-transform: uppercase;
}

.rail-footer strong {
  display: block;
  margin-top: 6px;
  font-size: 15px;
}

.workspace {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(30px, 4vw, 54px);
  font-weight: 760;
  line-height: 0.94;
}

h2 {
  font-size: 18px;
  font-weight: 760;
}

p {
  color: var(--muted);
  line-height: 1.5;
}

.topbar > div:first-child p {
  margin-top: 10px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.select-shell {
  display: grid;
  gap: 6px;
}

select,
input {
  min-height: 39px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: var(--ink);
  padding: 0 12px;
  font-size: 14px;
  font-weight: 620;
  outline: none;
}

select:focus,
input:focus,
button:focus-visible {
  outline: 2px solid #111111;
  outline-offset: 2px;
}

.icon-button,
.account-button,
.text-button,
.primary-button {
  min-height: 39px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  font-size: 13px;
  font-weight: 740;
}

.icon-button {
  width: 42px;
  display: grid;
  place-items: center;
  margin-top: 18px;
}

.account-button {
  padding: 0 15px;
  margin-top: 18px;
}

.text-button {
  padding: 0 12px;
}

.primary-button {
  width: 100%;
  border-color: var(--ink);
  background: var(--ink);
  color: #ffffff;
  padding: 0 16px;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.status-strip > div {
  min-width: 0;
  padding: 14px 16px;
  background: var(--surface);
}

.status-strip strong {
  display: block;
  overflow: hidden;
  margin-top: 4px;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(330px, 0.8fr);
  gap: 18px;
  align-items: start;
}

.kpi-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}

.kpi-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.kpi-card {
  min-height: 128px;
  padding: 16px;
}

.kpi-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.kpi-card strong {
  display: block;
  margin-top: 22px;
  font-size: clamp(21px, 2vw, 30px);
  line-height: 1;
  white-space: nowrap;
}

.kpi-card em {
  display: block;
  margin-top: 10px;
  color: var(--subtle);
  font-size: 12px;
  font-style: normal;
  font-weight: 650;
}

.chart-panel,
.entity-panel {
  grid-column: 1;
}

.scenario-panel,
.contribution-panel {
  grid-column: 2;
}

.performance-panel {
  grid-column: 1 / -1;
}

.cash-panel {
  grid-column: 1 / -1;
}

.panel {
  min-width: 0;
  padding: 18px;
}

.panel-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.panel-heading p {
  margin-top: 5px;
  font-size: 13px;
}

.chart-wrap {
  height: 280px;
}

.chart-wrap svg {
  display: block;
  width: 100%;
  height: 100%;
}

.performance-totals {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.cash-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.cash-total {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fafaf7;
  padding: 13px;
}

.cash-total span,
.cash-head span,
.cash-row small {
  display: block;
  color: var(--subtle);
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
}

.cash-total strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(18px, 2vw, 24px);
  line-height: 1;
  white-space: nowrap;
}

.cash-table {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.cash-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) repeat(5, minmax(120px, 1fr));
  min-width: 900px;
  border-bottom: 1px solid var(--line);
}

.cash-row:last-child {
  border-bottom: 0;
}

.cash-row > * {
  min-width: 0;
  padding: 12px;
  border-right: 1px solid var(--line);
}

.cash-row > *:last-child {
  border-right: 0;
}

.cash-head {
  background: #fafaf7;
}

.cash-row strong,
.cash-row span {
  font-size: 13px;
  font-weight: 720;
}

.cash-row span {
  display: grid;
  gap: 3px;
}

.cash-row small {
  margin-top: 4px;
  text-transform: none;
}

.cash-total.is-negative strong,
.cash-row .is-negative {
  color: var(--bad);
}

.equity-totals {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.performance-total,
.equity-total {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fafaf7;
  padding: 13px;
}

.performance-total span,
.performance-total em,
.equity-total span,
.equity-total em,
.equity-cell span,
.metric-bar span,
.pl-summary span {
  display: block;
  color: var(--subtle);
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
}

.performance-total strong,
.equity-total strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(18px, 2vw, 26px);
  line-height: 1;
}

.performance-total em,
.equity-total em {
  margin-top: 8px;
  font-style: normal;
  line-height: 1.35;
  text-transform: none;
}

.performance-total.is-negative strong,
.equity-total.is-negative strong,
.equity-cell.is-negative strong,
.pl-summary .is-negative strong,
.metric-bar.is-negative strong {
  color: var(--bad);
}

.performance-chart {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.performance-row {
  display: grid;
  grid-template-columns: minmax(180px, 0.72fr) repeat(3, minmax(190px, 1fr));
  min-width: 820px;
  border-bottom: 1px solid var(--line);
}

.performance-row:last-child {
  border-bottom: 0;
}

.performance-row > * {
  min-width: 0;
  border-right: 1px solid var(--line);
}

.performance-row > *:last-child {
  border-right: 0;
}

.performance-head {
  background: #fafaf7;
}

.performance-head span {
  padding: 11px 12px;
  color: var(--subtle);
  font-size: 11px;
  font-weight: 780;
  text-transform: uppercase;
}

.performance-entity,
.performance-cell {
  padding: 12px;
}

.performance-entity {
  display: grid;
  align-content: center;
  gap: 5px;
}

.performance-entity strong {
  overflow-wrap: anywhere;
  font-size: 13px;
}

.performance-entity span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.performance-cell {
  display: grid;
  gap: 8px;
}

.metric-bar {
  display: grid;
  grid-template-columns: 58px minmax(70px, 1fr) minmax(92px, auto);
  align-items: center;
  gap: 9px;
}

.metric-bar strong {
  font-size: 12px;
  text-align: right;
  white-space: nowrap;
}

.metric-track {
  height: 8px;
  overflow: hidden;
  border-radius: 99px;
  background: var(--surface-soft);
}

.metric-track i {
  display: block;
  min-width: 2px;
  height: 100%;
  border-radius: inherit;
  background: var(--ink);
}

.metric-bar.revenue .metric-track i {
  background: var(--good);
}

.metric-bar.costs .metric-track i {
  background: var(--warn);
}

.metric-bar.result .metric-track i {
  background: var(--ink);
}

.metric-bar.result.is-negative .metric-track i {
  background: var(--bad);
}

.equity-page {
  display: grid;
  gap: 18px;
}

.equity-page[hidden] {
  display: none;
}

.equity-panel {
  min-width: 0;
}

.equity-chart {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.equity-row {
  display: grid;
  grid-template-columns: minmax(180px, 0.72fr) repeat(3, minmax(190px, 1fr));
  min-width: 820px;
  border-bottom: 1px solid var(--line);
}

.equity-row:last-child {
  border-bottom: 0;
}

.equity-row > * {
  min-width: 0;
  border-right: 1px solid var(--line);
}

.equity-row > *:last-child {
  border-right: 0;
}

.equity-head {
  background: #fafaf7;
}

.equity-head span {
  padding: 11px 12px;
  color: var(--subtle);
  font-size: 11px;
  font-weight: 780;
  text-transform: uppercase;
}

.equity-entity,
.equity-cell {
  padding: 12px;
}

.equity-entity {
  display: grid;
  align-content: center;
  gap: 5px;
}

.equity-entity strong {
  overflow-wrap: anywhere;
  font-size: 13px;
}

.equity-entity span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.equity-cell strong {
  display: block;
  margin-top: 5px;
  font-size: 17px;
  line-height: 1.1;
  white-space: nowrap;
}

.equity-track {
  height: 8px;
  overflow: hidden;
  margin-top: 10px;
  border-radius: 99px;
  background: var(--surface-soft);
}

.equity-track i {
  display: block;
  min-width: 2px;
  height: 100%;
  border-radius: inherit;
  background: var(--good);
}

.equity-cell.is-negative .equity-track i {
  background: var(--bad);
}

.equity-cell dl {
  display: grid;
  gap: 5px;
  margin: 10px 0 0;
}

.equity-cell dl div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.equity-cell dt,
.equity-cell dd {
  margin: 0;
  font-size: 12px;
  font-weight: 650;
}

.equity-cell dt {
  color: var(--muted);
}

.equity-cell dd {
  text-align: right;
  white-space: nowrap;
}

.chart-grid-line {
  stroke: #e6e6de;
  stroke-width: 1;
}

.chart-axis {
  fill: var(--subtle);
  font-size: 11px;
  font-weight: 700;
}

.chart-line {
  fill: none;
  stroke: var(--ink);
  stroke-linecap: round;
  stroke-width: 3;
}

.chart-area {
  fill: rgba(17, 17, 17, 0.05);
}

.chart-point {
  fill: var(--surface);
  stroke: var(--ink);
  stroke-width: 2;
}

.bar-list {
  display: grid;
  gap: 14px;
}

.bar-row {
  display: grid;
  gap: 7px;
}

.bar-row header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  font-weight: 720;
}

.bar-track {
  height: 9px;
  overflow: hidden;
  border-radius: 99px;
  background: var(--surface-soft);
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--ink);
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 13px 10px;
  text-align: left;
  vertical-align: middle;
}

td {
  font-size: 13px;
  font-weight: 620;
}

tbody tr:hover {
  background: #fafaf7;
}

.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.status-dot::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 99px;
  background: var(--warn);
}

.status-dot.good::before {
  background: var(--good);
}

.scenario-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.scenario-form label {
  display: grid;
  gap: 6px;
}

.scenario-form label:first-child,
.scenario-form label:nth-child(2),
.scenario-form label:nth-child(6),
.scenario-form button {
  grid-column: 1 / -1;
}

.scenario-list {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.scenario-item {
  display: grid;
  gap: 4px;
  padding: 11px 0;
  border-top: 1px solid var(--line);
}

.scenario-item strong {
  font-size: 13px;
}

.scenario-item span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.secondary-section {
  margin-top: 18px;
}

.annual-page {
  display: grid;
  gap: 18px;
}

.annual-page[hidden] {
  display: none;
}

.annual-heading {
  margin-bottom: 12px;
}

.annual-notice {
  display: flex;
  align-items: center;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.annual-notice strong {
  font-size: 13px;
}

.annual-notice span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.annual-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

.annual-card {
  display: grid;
  gap: 18px;
}

.pl-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.pl-summary div {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fafaf7;
  padding: 12px;
}

.pl-summary strong {
  display: block;
  margin-top: 8px;
  overflow-wrap: anywhere;
  font-size: 18px;
  line-height: 1.1;
}

.annual-card-header {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.annual-card-header div {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 12px;
}

.annual-card-header span,
.detail-tile span {
  color: var(--subtle);
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
}

.annual-card-header strong {
  display: block;
  margin-top: 8px;
  font-size: 15px;
}

.statement-section {
  display: grid;
  gap: 8px;
}

.statement-section h3 {
  margin: 0;
  font-size: 14px;
}

.statement-table {
  min-width: 480px;
}

.statement-table td:last-child,
.statement-table th:last-child,
.statement-table tfoot td:last-child {
  text-align: right;
}

.statement-table tfoot td {
  border-bottom: 0;
  font-size: 13px;
  font-weight: 800;
}

.annual-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  font-size: 13px;
}

.annual-card-footer span {
  color: var(--muted);
  font-weight: 650;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.detail-tile {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.detail-tile span {
  color: var(--subtle);
  font-size: 12px;
  font-weight: 740;
  text-transform: uppercase;
}

.detail-tile strong {
  display: block;
  margin-top: 10px;
  font-size: 20px;
}

.detail-action {
  width: auto;
  margin-top: 18px;
}

.sync-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.login-page {
  display: grid;
  place-items: center;
  padding: 24px;
  background: #111111;
  color: #ffffff;
}

.login-shell {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(320px, 420px);
  gap: 24px;
  width: min(960px, 100%);
  align-items: stretch;
}

.login-brand,
.login-panel {
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
}

.login-brand {
  min-height: 520px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 36px;
  background:
    linear-gradient(140deg, rgba(255, 255, 255, 0.16), transparent 38%),
    radial-gradient(circle at 70% 20%, rgba(255, 255, 255, 0.18), transparent 26%),
    #181818;
}

.login-mark {
  width: 48px;
  height: 48px;
  margin-bottom: 26px;
}

.login-brand h1 {
  font-size: clamp(44px, 8vw, 88px);
}

.login-brand p {
  margin-top: 18px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 18px;
}

.login-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
  padding: 32px;
  background: #ffffff;
  color: var(--ink);
}

.login-panel h2 {
  font-size: 28px;
}

.login-panel p {
  margin-top: 7px;
}

.login-panel label {
  display: grid;
  gap: 7px;
}

.login-error {
  color: var(--bad);
  font-size: 13px;
  font-weight: 700;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 82px minmax(0, 1fr);
  }

  .brand-word,
  .rail-item span,
  .rail-footer {
    display: none;
  }

  .side-rail {
    padding: 20px 14px;
    align-items: center;
  }

  .rail-item {
    justify-content: center;
    padding: 12px;
  }

  .kpi-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

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

  .chart-panel,
  .entity-panel,
  .scenario-panel,
  .contribution-panel,
  .performance-panel,
  .equity-panel {
    grid-column: 1;
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .side-rail {
    position: static;
    width: 100%;
    height: auto;
    flex-direction: row;
    justify-content: space-between;
    overflow-x: auto;
  }

  .rail-nav {
    display: flex;
    margin-top: 0;
  }

  .brand {
    flex: 0 0 auto;
  }

  .workspace {
    padding: 18px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    overflow: visible;
    padding-bottom: 0;
  }

  .select-shell,
  .select-shell select,
  .topbar-actions form,
  .account-button,
  .icon-button {
    width: 100%;
    min-width: 0;
  }

  .icon-button,
  .account-button {
    margin-top: 0;
  }

  .status-strip,
  .kpi-row,
  .annual-card-header,
  .performance-totals,
  .equity-totals,
  .cash-summary,
  .pl-summary,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .scenario-form {
    grid-template-columns: 1fr;
  }

  .login-shell {
    grid-template-columns: 1fr;
  }

  .login-brand {
    min-height: 260px;
  }
}
