:root {
  color-scheme: light;
  --bg: #f8fafc;
  --panel: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #0f766e;
  --accent-soft: #ccfbf1;
  --warning-bg: #fffbeb;
  --warning-text: #92400e;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.5;
}

button,
select,
input {
  font: inherit;
}

button,
select,
input[type="date"] {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  padding: 0 12px;
}

button {
  cursor: pointer;
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  font-weight: 700;
}

button.secondary {
  background: #ffffff;
  color: var(--text);
  border-color: var(--line);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px clamp(16px, 4vw, 48px);
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

.topbar h1,
.section h2,
.notes h2 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--muted);
  text-align: right;
}

.topbar-meta strong {
  display: block;
  color: var(--text);
}

.toolbar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.toolbar label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: left;
}

.page {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 28px clamp(16px, 4vw, 48px) 48px;
}

.section {
  padding: 24px 0 34px;
  border-bottom: 1px solid var(--line);
}

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

.section h2 {
  font-size: 26px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #115e59;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.alert {
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid #fbbf24;
  border-radius: 6px;
  background: var(--warning-bg);
  color: var(--warning-text);
  font-weight: 650;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.funnel-grid {
  grid-template-columns: repeat(4, minmax(170px, 1fr));
}

.trading-grid {
  grid-template-columns: repeat(4, minmax(170px, 1fr));
}

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

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

.row-label {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0;
}

.kpi-card span,
.metric-label {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metric-label {
  display: inline-flex !important;
  align-items: center;
  gap: 6px;
  line-height: 1.25;
}

.info-icon {
  display: inline-grid;
  place-items: center;
  width: 17px;
  min-width: 17px;
  height: 17px;
  min-height: 17px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid #94a3b8;
  background: #ffffff;
  color: #475569;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
}

.info-icon:hover,
.info-icon:focus {
  border-color: var(--accent);
  color: var(--accent);
  outline: none;
}

.kpi-card strong {
  display: block;
  margin-top: 10px;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1;
  letter-spacing: 0;
}

.ratio-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(170px, 1fr));
  gap: 12px;
  margin: 0 0 18px;
}

.ratio-grid article {
  min-height: 98px;
  padding: 14px;
  border: 1px solid #99f6e4;
  border-radius: 8px;
  background: #f0fdfa;
}

.ratio-grid span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.ratio-grid strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.1;
  color: #115e59;
}

.caveat-value {
  color: var(--warning-text);
  font-size: 20px !important;
}

.split {
  display: grid;
  grid-template-columns: minmax(320px, 0.85fr) minmax(360px, 1.15fr);
  gap: 18px;
  margin-bottom: 18px;
}

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

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel h3 {
  margin: 0 0 14px;
  font-size: 16px;
  letter-spacing: 0;
}

.panel-header h3 {
  margin: 0;
}

.stage-toggle {
  display: inline-flex;
  align-items: center;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.toggle-button {
  min-height: 30px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
}

.toggle-button.active {
  background: var(--accent);
  color: #ffffff;
}

.toggle-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.chart-box {
  position: relative;
  height: 340px;
}

.chart-box.compact {
  height: 292px;
}

.pending-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 38px;
  margin-bottom: 10px;
  padding: 8px 10px;
  border: 1px dashed #cbd5e1;
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
}

.pending-row strong {
  color: var(--warning-text);
}

.window-note {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 12px;
}

.table-panel {
  margin-top: 4px;
}

.table-wrap {
  overflow-x: auto;
}

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

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

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.numeric {
  text-align: right;
  white-space: nowrap;
}

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

.notes {
  padding-top: 26px;
  color: var(--muted);
}

.notes h2 {
  color: var(--text);
  font-size: 18px;
}

.notes p {
  max-width: 920px;
  margin: 8px 0;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-shell {
  width: min(100%, 420px);
}

.login-panel {
  padding: 28px;
}

.brand-mark {
  color: var(--accent);
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

.login-panel h1 {
  margin: 4px 0 22px;
  font-size: 34px;
  letter-spacing: 0;
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.login-form input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--text);
}

.login-form button {
  margin-top: 4px;
}

@media (max-width: 980px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-meta {
    width: 100%;
    justify-content: flex-start;
    text-align: left;
  }

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

@media (max-width: 640px) {
  .kpi-grid,
  .trading-grid,
  .funnel-grid,
  .ratio-grid,
  .split {
    grid-template-columns: 1fr;
  }

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

  .toolbar,
  .toolbar button,
  .toolbar select,
  .toolbar input,
  .topbar-meta form {
    width: 100%;
  }

  button,
  select,
  input[type="date"] {
    width: 100%;
  }

  .chart-box,
  .chart-box.compact {
    height: 300px;
  }
}
