:root {
  color-scheme: light;
  --nav-height: 60px;
  --ink: #17201b;
  --muted: #69746e;
  --dim: #8b948e;
  --line: #dde4dc;
  --paper: #f3f5ef;
  --panel: #ffffff;
  --deep: #111813;
  --green: #1f6b45;
  --green-soft: #e8f3ea;
  --gold: #d3a53b;
  --gold-soft: #fff5db;
  --red: #c92f3e;
  --red-soft: #fdebee;
  --blue: #315f8c;
  --blue-soft: #e9f1f8;
  --shadow: 0 10px 30px rgba(23, 32, 27, 0.07);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  background: var(--paper);
}

body {
  margin: 0;
  overflow-x: hidden;
  background:
    linear-gradient(150deg, rgba(31, 107, 69, 0.11), transparent 34%),
    linear-gradient(330deg, rgba(211, 165, 59, 0.16), transparent 36%),
    var(--paper);
  color: var(--ink);
  font-size: 14px;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(100%, 1180px);
  min-height: 100vh;
  margin: 0 auto;
}

.command-bar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: grid;
  grid-template-columns: minmax(190px, 1fr) auto minmax(210px, 1fr);
  gap: 14px;
  align-items: center;
  min-height: var(--nav-height);
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  border-bottom: 1px solid rgba(221, 228, 220, 0.82);
  background: rgba(243, 245, 239, 0.93);
  backdrop-filter: blur(16px);
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 8px;
  background: var(--gold);
  color: var(--deep);
  font-weight: 950;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 0.98rem;
  line-height: 1.1;
}

.brand small {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 750;
}

.view-tabs {
  display: inline-flex;
  gap: 4px;
  justify-self: center;
  max-width: 100%;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 6px 18px rgba(23, 32, 27, 0.05);
}

.view-tabs a {
  min-width: max-content;
  border-radius: 6px;
  color: #405047;
  font-size: 0.78rem;
  font-weight: 850;
  line-height: 34px;
  padding: 0 12px;
  text-align: center;
  text-decoration: none;
}

.view-tabs a.active,
.view-tabs a:hover {
  background: var(--deep);
  color: #ffffff;
}

.source-chip {
  display: inline-flex;
  align-items: center;
  justify-self: end;
  gap: 8px;
  min-height: 38px;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 8px 11px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  box-shadow: 0 6px 18px rgba(23, 32, 27, 0.05);
}

.source-chip[data-status="ok"] {
  border-color: rgba(31, 107, 69, 0.24);
  background: var(--green-soft);
  color: var(--green);
}

.source-chip[data-status="error"] {
  border-color: rgba(201, 47, 62, 0.32);
  background: var(--red-soft);
  color: var(--red);
}

.source-chip svg,
.icon-button svg,
.readout-list svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

main {
  display: grid;
  gap: 14px;
  padding: 14px 12px calc(34px + env(safe-area-inset-bottom));
}

[data-view-panel] {
  display: none;
}

[data-view-panel].is-active {
  display: grid;
}

main > [data-view-panel].is-active:first-child {
  animation: tabFade 160ms ease-out;
}

@keyframes tabFade {
  from {
    opacity: 0.78;
    transform: translateY(3px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hero,
.mission-strip,
.metric-card,
.panel,
.filters {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 0.82fr) minmax(360px, 1.18fr);
  gap: 14px;
  align-items: stretch;
  overflow: hidden;
  padding: 14px;
}

.hero-copy {
  min-height: 188px;
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(17, 24, 19, 0.92), rgba(25, 71, 45, 0.88)),
    var(--deep);
  color: #ffffff;
  padding: 20px;
}

.hero-copy::after {
  display: block;
  width: 112px;
  height: 64px;
  margin-top: 18px;
  border-radius: 6px;
  background: url("./powerhouse-flag.png") center / cover no-repeat;
  opacity: 0.84;
  content: "";
}

.hero-copy h1,
.hero-copy p,
.eyebrow,
.panel h2,
.panel h3,
.panel p,
.section-heading h2,
.section-heading p {
  margin: 0;
}

.eyebrow {
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hero-copy .eyebrow {
  color: #f1d586;
}

.hero-copy h1 {
  margin-top: 4px;
  font-size: clamp(2rem, 4vw, 3.25rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.hero-copy p:last-child {
  max-width: 520px;
  margin-top: 10px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.95rem;
  line-height: 1.45;
}

.filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-self: stretch;
  padding: 14px;
  box-shadow: none;
}

.filters label,
.search-field {
  display: grid;
  gap: 6px;
  align-content: start;
}

.search-field {
  grid-column: 1 / -1;
}

.field-label {
  color: #3c4942;
  font-size: 0.78rem;
  font-weight: 850;
}

input,
select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  color: var(--ink);
  padding: 0 12px;
  font-size: 1rem;
}

input:focus,
select:focus {
  border-color: var(--green);
  outline: 3px solid rgba(31, 107, 69, 0.14);
}

.combo-wrap {
  position: relative;
}

.icon-button {
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  background: var(--deep);
  color: #ffffff;
  font-weight: 900;
}

.custom-date-fields {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.mission-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  overflow: hidden;
}

.mission-strip article {
  display: grid;
  gap: 5px;
  min-height: 102px;
  padding: 16px;
  border-left: 1px solid var(--line);
}

.mission-strip article:first-child {
  border-left: 0;
}

.mission-strip span,
.metric-label {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

.mission-strip strong,
.metric-card strong {
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1;
}

.mission-strip small,
.metric-card small {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

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

.metric-card {
  display: grid;
  gap: 11px;
  min-height: 132px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.metric-card.primary {
  border-color: rgba(201, 47, 62, 0.26);
  background: linear-gradient(145deg, #ffffff, #fff7f8);
}

.metric-card::after {
  display: block;
  width: 44px;
  height: 4px;
  margin-top: auto;
  border-radius: 999px;
  background: var(--green);
  content: "";
}

.metric-card.primary::after {
  background: var(--red);
}

.metric-card:nth-child(3)::after {
  background: var(--gold);
}

.metric-card:nth-child(4)::after {
  background: var(--blue);
}

.delta {
  font-weight: 900;
}

.delta.up {
  color: var(--green);
}

.delta.down {
  color: var(--red);
}

.delta.neutral {
  color: var(--muted);
}

.insight-grid,
.two-column,
.profile-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.95fr);
  gap: 12px;
}

.panel {
  min-width: 0;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 10px;
}

.panel h2,
.section-heading h2 {
  margin-top: 2px;
  font-size: 1.32rem;
  line-height: 1.12;
}

.panel h3 {
  font-size: 0.98rem;
  line-height: 1.22;
}

.panel p,
.section-heading p {
  color: var(--muted);
  font-size: 0.83rem;
  line-height: 1.4;
}

.badge,
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 8px;
  background: var(--gold-soft);
  color: #7b5a0d;
  padding: 5px 9px;
  font-size: 0.75rem;
  font-weight: 900;
}

.chart-box {
  position: relative;
  min-height: 280px;
  padding: 8px 12px 16px;
}

.chart-box.tall {
  min-height: 330px;
}

canvas {
  display: block;
  max-width: 100%;
}

.section-band {
  display: grid;
  gap: 12px;
  padding-top: 10px;
  scroll-margin-top: calc(var(--nav-height) + 18px);
}

[data-view-panel]:not(.is-active) {
  display: none !important;
}

.section-heading {
  padding: 2px 2px 0;
}

.readout-list,
.quality-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0 16px 16px;
  list-style: none;
}

.readout-list li,
.quality-list li {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.readout-list li:first-child,
.quality-list li:first-child {
  border-top: 0;
}

.quality-list li {
  grid-template-columns: 1fr;
}

.readout-list svg {
  margin-top: 2px;
  color: var(--green);
}

.readout-list span,
.quality-list strong {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
}

.readout-list strong {
  display: block;
  margin-top: 2px;
  font-size: 1rem;
}

.readout-list p,
.quality-list span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

.watchlist {
  display: grid;
  gap: 8px;
  padding: 0 16px 16px;
}

.watch-item {
  display: grid;
  gap: 4px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  color: inherit;
  padding: 12px;
  text-align: left;
}

.watch-item span {
  font-weight: 900;
}

.watch-item strong {
  color: var(--red);
  font-size: 0.86rem;
}

.watch-item small,
.empty-copy {
  color: var(--muted);
  font-size: 0.78rem;
}

.empty-copy {
  margin: 0;
  padding: 0 16px 16px;
}

.table-wrap {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
  background: #ffffff;
}

th,
td {
  min-width: 82px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  position: sticky;
  z-index: 1;
  top: 0;
  border-bottom: 1px solid var(--line);
  background: #f7f9f5;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
}

tbody tr:hover td {
  background: #fbfcfa;
}

.compact-table {
  max-height: 220px;
  border-top: 1px solid var(--line);
}

.compact-table table {
  font-size: 0.8rem;
}

.compact-table th,
.compact-table td {
  padding: 8px 12px;
}

.numeric,
td.numeric,
th.numeric {
  text-align: right;
}

.row-button {
  border: 0;
  background: transparent;
  color: var(--green);
  padding: 0;
  font-weight: 900;
  text-align: left;
}

.empty-cell {
  color: var(--muted);
  text-align: center;
}

.momentum {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 8px;
  padding: 3px 8px;
  font-size: 0.72rem;
  font-weight: 900;
}

.momentum.positive {
  background: var(--green-soft);
  color: var(--green);
}

.momentum.negative {
  background: var(--red-soft);
  color: var(--red);
}

.momentum.neutral {
  background: #eef1ed;
  color: var(--muted);
}

.person-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 0 16px 14px;
}

.person-stats article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  padding: 10px;
}

.person-stats span {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 900;
  text-transform: uppercase;
}

.person-stats strong {
  display: block;
  margin-top: 4px;
  font-size: 1.2rem;
}

.mini-chart {
  display: flex;
  align-items: end;
  gap: 6px;
  min-height: 130px;
  padding: 0 16px 16px;
}

.timeline-bar {
  display: grid;
  align-items: end;
  justify-items: center;
  gap: 5px;
  flex: 1;
  height: 112px;
}

.timeline-bar span {
  width: 100%;
  min-height: 6px;
  border-radius: 6px 6px 0 0;
  background: linear-gradient(180deg, var(--red), #e67848);
}

.timeline-bar small {
  color: var(--muted);
  font-size: 0.66rem;
}

.pax-suggestions {
  position: absolute;
  z-index: 30;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 18px 42px rgba(23, 32, 27, 0.15);
}

.suggestion-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  border: 0;
  border-top: 1px solid var(--line);
  background: #ffffff;
  color: inherit;
  padding: 10px 12px;
  text-align: left;
}

.suggestion-item:first-child {
  border-top: 0;
}

.suggestion-item:hover {
  background: var(--green-soft);
}

.suggestion-item strong,
.suggestion-item small {
  display: block;
}

.suggestion-item small,
.suggestion-item em,
.suggestion-empty {
  color: var(--muted);
  font-size: 0.76rem;
  font-style: normal;
}

.suggestion-empty {
  padding: 12px;
}

.info-tip {
  display: inline-grid;
  place-items: center;
  width: 15px;
  height: 15px;
  margin-left: 3px;
  border-radius: 50%;
  background: var(--gold-soft);
  color: #76550c;
  font-size: 10px;
  font-weight: 950;
  vertical-align: middle;
}

.definition-tooltip {
  position: fixed;
  z-index: 100;
  display: none;
  max-width: min(280px, calc(100vw - 28px));
  border: 1px solid rgba(17, 24, 19, 0.16);
  border-radius: 8px;
  background: var(--deep);
  color: #ffffff;
  padding: 9px 10px;
  font-size: 0.78rem;
  line-height: 1.35;
  box-shadow: 0 18px 42px rgba(23, 32, 27, 0.26);
  pointer-events: none;
}

.definition-tooltip.visible {
  display: block;
}

@media (max-width: 980px) {
  .command-bar {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .view-tabs {
    order: 3;
    grid-column: 1 / -1;
    justify-self: stretch;
    overflow-x: auto;
    scrollbar-width: thin;
  }

  .view-tabs a {
    flex: 0 0 auto;
  }

  .hero,
  .insight-grid,
  .two-column,
  .profile-grid {
    grid-template-columns: 1fr;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: 100%;
  }

  .command-bar {
    min-height: auto;
    padding: calc(7px + env(safe-area-inset-top)) 8px 7px;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
  }

  .brand small {
    display: none;
  }

  .source-chip {
    justify-self: stretch;
    min-width: 0;
    font-size: 0.68rem;
  }

  main {
    gap: 10px;
    padding: 10px 8px calc(18px + env(safe-area-inset-bottom));
  }

  .hero,
  .filters,
  .panel-header,
  .metric-card,
  .mission-strip article {
    padding: 12px;
  }

  .hero-copy {
    min-height: 152px;
    padding: 16px;
  }

  .hero-copy h1 {
    font-size: 2.25rem;
  }

  .filters,
  .custom-date-fields,
  .metric-grid,
  .mission-strip,
  .person-stats {
    grid-template-columns: 1fr;
  }

  .mission-strip article {
    min-height: 88px;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .mission-strip article:first-child {
    border-top: 0;
  }

  .metric-card {
    min-height: 112px;
  }

  .chart-box,
  .chart-box.tall {
    min-height: 250px;
  }

  .panel h2,
  .section-heading h2 {
    font-size: 1.2rem;
  }

  th,
  td {
    padding: 9px 10px;
  }
}
