:root {
  --bg: #e9eef6;
  --panel: #ffffff;
  --text: #0f172a;
  --muted: #475569;
  --line: #cbd5e1;
  --blue: #1d4ed8;
  --blue-dark: #1e3a8a;
  --green: #047857;
  --amber: #92400e;
  --danger: #b91c1c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(29, 78, 216, 0.12), transparent 34rem),
    linear-gradient(180deg, #f8fafc 0, var(--bg) 18rem);
  color: var(--text);
  font-family: Inter, Segoe UI, Arial, sans-serif;
}

.app-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  padding: 26px 32px;
  background:
    linear-gradient(135deg, rgba(15, 23, 42, 0.98), rgba(30, 58, 138, 0.96)),
    #0f172a;
  color: #ffffff;
  border-bottom: 4px solid var(--blue);
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.18);
}

.app-header h1 {
  margin: 4px 0;
  font-size: clamp(26px, 3vw, 38px);
  letter-spacing: 0;
}

.eyebrow,
.subhead {
  margin: 0;
  color: #dbeafe;
}

.eyebrow {
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

main {
  width: min(1480px, calc(100% - 32px));
  margin: 18px auto 48px;
}

.status-pill {
  padding: 8px 12px;
  border-radius: 999px;
  background: #dbeafe;
  color: #172554;
  font-weight: 800;
  white-space: nowrap;
}

.caveat {
  background: #fefce8;
  color: #422006;
  border: 1px solid #eab308;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 16px;
  font-weight: 650;
  box-shadow: 0 8px 22px rgba(146, 64, 14, 0.08);
}

.tabs {
  display: flex;
  gap: 4px;
  align-items: flex-end;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
  overflow-x: auto;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid #d8e0ec;
  border-radius: 12px;
  padding: 6px 6px 0;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.07);
}

.tab {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  padding: 10px 14px;
  border-radius: 8px 8px 0 0;
  font-weight: 800;
  cursor: pointer;
}

.tab.active {
  background: #ffffff;
  color: var(--blue-dark);
  border-color: var(--blue);
  box-shadow: inset 0 -3px 0 var(--blue);
}

.grid {
  display: grid;
  gap: 16px;
}

.grid.two {
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.75fr);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.07);
}

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

.section-title h2 {
  margin: 0;
  font-size: 18px;
}

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

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

label {
  display: grid;
  gap: 6px;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid #94a3b8;
  border-radius: 8px;
  padding: 8px 10px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(37, 99, 235, 0.18);
  border-color: #2563eb;
}

select,
option {
  background: #ffffff;
  color: var(--text);
}

.span-all {
  grid-column: 1 / -1;
}

.full {
  margin-bottom: 12px;
}

button {
  min-height: 38px;
  border-radius: 8px;
  border: 0;
  padding: 9px 12px;
  font-weight: 850;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
}

.primary {
  background: var(--green);
  color: #ffffff;
}

.secondary {
  background: var(--blue);
  color: #ffffff;
  width: 100%;
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border-radius: 7px;
  padding: 9px 12px;
  text-decoration: none;
  font-weight: 850;
}

.ghost {
  background: #e2e8f0;
  color: var(--text);
}

button:disabled {
  background: #94a3b8;
  cursor: not-allowed;
}

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

.metric {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: linear-gradient(180deg, #ffffff, #f8fafc);
}

.metric span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.metric strong {
  display: block;
  margin-top: 4px;
  color: var(--text);
  font-size: 20px;
}

.table-wrap {
  overflow: auto;
  max-height: 520px;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: inset 0 1px 0 #ffffff;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
  background: #ffffff;
}

th {
  position: sticky;
  top: 0;
  background: #1e3a8a;
  color: #ffffff;
  text-align: left;
  padding: 9px 10px;
  font-size: 12px;
  z-index: 1;
}

td {
  color: var(--text);
  padding: 8px 10px;
  border-bottom: 1px solid #e2e8f0;
  font-size: 13px;
  vertical-align: top;
}

tr:nth-child(even) td {
  background: #f8fafc;
}

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

.chart-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
}

.chart-card h3 {
  margin: 0 0 10px;
  font-size: 15px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(120px, 2fr) 86px;
  gap: 8px;
  align-items: center;
  margin: 8px 0;
  color: var(--text);
  font-size: 12px;
}

.bar-track {
  height: 13px;
  background: #dbeafe;
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #1d4ed8);
}

.line-chart {
  width: 100%;
  min-height: 220px;
}

.empty,
.error,
.warning,
.toast {
  border-radius: 8px;
  padding: 12px;
  margin: 10px 0;
}

.empty {
  background: #f8fafc;
  border: 1px solid var(--line);
  color: var(--muted);
}

.error {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: var(--danger);
  font-weight: 800;
}

.warning {
  background: #fffbeb;
  border: 1px solid #f59e0b;
  color: #78350f;
  font-weight: 750;
}

.span-charts {
  grid-column: 1 / -1;
}

.toast {
  background: #dbeafe;
  border: 1px solid #93c5fd;
  color: #172554;
  font-weight: 800;
}

.hidden {
  display: none;
}

pre {
  white-space: pre-wrap;
  color: var(--text);
  font-family: Inter, Segoe UI, Arial, sans-serif;
  line-height: 1.5;
}

.ai-note {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #172554;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 14px;
  font-weight: 700;
}

.ai-panel {
  margin-top: 16px;
}

.ai-brief {
  display: grid;
  gap: 14px;
  color: var(--text);
}

.ai-brief h2,
.ai-brief h3,
.ai-brief h4 {
  margin: 8px 0 0;
  color: #172554;
  letter-spacing: 0;
}

.ai-brief h4,
.ai-brief h3 {
  border-left: 4px solid var(--blue);
  padding: 8px 10px;
  background: #eff6ff;
  border-radius: 0 8px 8px 0;
}

.ai-brief p {
  margin: 0;
  line-height: 1.58;
  color: #1e293b;
}

.ai-brief ul {
  margin: 0;
  padding-left: 1.2rem;
  display: grid;
  gap: 8px;
}

.ai-brief li {
  line-height: 1.55;
  color: #1e293b;
}

.ai-brief strong {
  color: #0f172a;
}

@media (max-width: 980px) {
  .app-header,
  .section-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .grid.two,
  .form-grid,
  .chart-grid {
    grid-template-columns: 1fr;
  }
}
