:root {
  color-scheme: light;
  --bg: #f5f6f3;
  --surface: #ffffff;
  --surface-2: #eef2ee;
  --text: #18211d;
  --muted: #647067;
  --line: #d7ded8;
  --accent: #166853;
  --accent-2: #d99a2b;
  --bad: #a33a33;
  --good: #1f7a4e;
  --warn: #9a6a11;
  --shadow: 0 14px 42px rgba(28, 45, 37, 0.12);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1714;
  --surface: #16231f;
  --surface-2: #1d2d28;
  --text: #edf3ee;
  --muted: #a7b7ad;
  --line: #30443c;
  --accent: #68d1b2;
  --accent-2: #f0ba61;
  --bad: #ff9a90;
  --good: #85d7a6;
  --warn: #e7bd61;
  --shadow: 0 16px 44px rgba(0, 0, 0, 0.26);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  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 {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 18px;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.brand {
  display: block;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.brand-logo {
  display: block;
  width: min(100%, 190px);
  height: auto;
  margin: 0 auto;
}

.nav-list {
  display: grid;
  gap: 6px;
  margin-top: 18px;
}

.utility-nav {
  display: flex;
  gap: 8px;
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.nav-button,
.utility-button,
.tab-button,
.icon-button,
.ghost-button,
.sort-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
}

.utility-button {
  width: 42px;
  height: 42px;
  font-weight: 900;
  text-align: center;
}

.nav-button {
  min-height: 42px;
  padding: 0 12px;
  text-align: left;
  font-weight: 750;
}

.nav-button.is-active,
.utility-button.is-active,
.header-action.is-active,
.tab-button.is-active {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
}

.ghost-button {
  min-height: 40px;
  padding: 0 12px;
  font-weight: 850;
  background: var(--surface);
}

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

.page-header,
.section-title {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  flex-wrap: wrap;
}

.page-header {
  margin-bottom: 24px;
}

.page-header h1,
.section-title h2,
h3 {
  margin: 0;
  line-height: 1.12;
}

.page-header h1 {
  max-width: 980px;
  font-size: clamp(1.9rem, 4vw, 3.4rem);
}

.section-title {
  margin: 20px 0 12px;
}

.section-title p {
  margin: 7px 0 0;
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.86rem;
  white-space: nowrap;
}

.icon-button {
  width: 40px;
  height: 40px;
  font-weight: 900;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

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

.kpi span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.kpi strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(1.15rem, 2.3vw, 1.8rem);
}

.split-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.table-wrap.compact {
  max-height: 420px;
}

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

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 0.9rem;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.73rem;
  text-transform: uppercase;
  white-space: nowrap;
}

.sort-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 8px;
  border-color: transparent;
  background: transparent;
  color: inherit;
  font-size: inherit;
  font-weight: 900;
  text-transform: inherit;
}

.sort-button.is-active {
  border-color: var(--line);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
}

.plan-toggle {
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-weight: 900;
  text-align: left;
}

.nested-row td {
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
}

.nested-panel {
  display: grid;
  gap: 10px;
}

.nested-title {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
  text-transform: uppercase;
}

.nested-table {
  min-width: 560px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.nested-table th {
  position: static;
}

td.number,
td.percent {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

tr:last-child td {
  border-bottom: 0;
}

.good {
  color: var(--good);
  font-weight: 800;
}

.bad {
  color: var(--bad);
  font-weight: 800;
}

.warn {
  color: var(--warn);
  font-weight: 800;
}

.note-band {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--accent-2) 38%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent-2) 12%, var(--surface));
  color: var(--text);
}

.pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
}

.insight-list {
  display: grid;
  gap: 10px;
}

.insight {
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: var(--surface);
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.tab-button {
  min-height: 38px;
  padding: 0 12px;
  font-weight: 800;
}

.detail-block {
  display: none;
  margin-top: 18px;
}

.detail-block.is-visible {
  display: block;
}

.search-box,
.select-box {
  display: grid;
  gap: 4px;
  min-width: min(100%, 330px);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.search-box input,
.select-box select {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

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

  .sidebar {
    position: sticky;
    z-index: 10;
    height: auto;
    display: block;
    padding: 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand {
    padding-bottom: 10px;
  }

  .nav-list {
    display: flex;
    overflow-x: auto;
    margin-top: 10px;
    padding-bottom: 2px;
  }

  .utility-nav {
    margin-top: 10px;
    padding-top: 10px;
  }

  .nav-button {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .content {
    padding: 20px 14px 28px;
  }

  .page-header,
  .section-title,
  .note-band {
    display: block;
  }

  .header-meta {
    margin-top: 12px;
  }

  .kpi-grid,
  .split-grid {
    grid-template-columns: 1fr;
  }
}

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

  table {
    min-width: 860px;
  }
}
