:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #334155;
  --text: #f8fafc;
  --text-secondary: #94a3b8;
  --primary: #38bdf8;
  --primary-dark: #0ea5e9;
  --accent: #34d399;
  --danger: #f87171;
  --warning: #fbbf24;
  --border: #334155;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Top navigation */
.topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--bg);
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.tabs {
  display: flex;
  gap: 8px;
  background: var(--surface);
  padding: 4px;
  border-radius: 999px;
}

.tab {
  padding: 8px 20px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-secondary);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: var(--bg);
  box-shadow: var(--shadow);
}

/* Main content */
.main {
  flex: 1;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 24px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.page-header h1 {
  margin: 0;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.ticker {
  margin: 4px 0 0;
  color: var(--primary);
  font-weight: 600;
  font-size: 0.95rem;
}

.last-updated {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* Status */
.status {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  display: none;
  font-weight: 500;
}

.status.error { background: rgba(248, 113, 113, 0.15); color: #fecaca; display: block; border: 1px solid rgba(248, 113, 113, 0.3); }
.status.info { background: rgba(56, 189, 248, 0.15); color: #bae6fd; display: block; border: 1px solid rgba(56, 189, 248, 0.3); }
.status.success { background: rgba(52, 211, 153, 0.15); color: #a7f3d0; display: block; border: 1px solid rgba(52, 211, 153, 0.3); }

/* Cards */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  transition: transform 0.2s;
}

.card:hover { transform: translateY(-2px); }

.card.highlight {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.15), rgba(52, 211, 153, 0.1));
  border-color: rgba(56, 189, 248, 0.3);
}

.card .label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.card .value {
  font-size: 1.75rem;
  font-weight: 800;
}

.card .sub {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Sections */
section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

section h2 {
  margin: 0 0 20px;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Reference metrics */
.reference-metrics .cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
}

.metric-card {
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 16px;
}

.metric-card .label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.metric-card .value {
  font-size: 1.35rem;
  font-weight: 700;
}

.metric-card .sub {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Two column layout */
.two-col {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 24px;
}

@media (max-width: 1024px) {
  .two-col { grid-template-columns: 1fr; }
}

/* Assumptions */
.assumption-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
}

.field label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
}

.field input[type="number"] {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.field input[type="number"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}

.toggle-field {
  flex-direction: row;
  align-items: center;
  gap: 12px;
}

.toggle-field input {
  width: 20px;
  height: 20px;
  accent-color: var(--primary);
}

.actions {
  margin-top: 20px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

button {
  padding: 10px 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.2s;
}

button:hover {
  background: var(--border);
}

button.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: var(--bg);
  border: none;
}

button.primary:hover {
  opacity: 0.9;
}

.hint {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-top: 16px;
  margin-bottom: 0;
}

/* Tables */
.table-wrapper {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th, td {
  padding: 10px 12px;
  border: 1px solid var(--border);
  text-align: right;
  white-space: nowrap;
}

th:first-child, td:first-child {
  text-align: left;
  position: sticky;
  left: 0;
  background: var(--surface);
  z-index: 1;
}

th {
  background: var(--surface-2);
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
}

tbody tr:nth-child(even) { background: rgba(255, 255, 255, 0.03); }
tbody tr:hover { background: rgba(255, 255, 255, 0.06); }

.forecast { background: rgba(56, 189, 248, 0.08) !important; }
.forecast td:first-child { background: rgba(56, 189, 248, 0.08); }

/* Detail table */
.detail-table td:first-child {
  font-weight: 500;
  text-align: left;
  color: var(--text-secondary);
}

.detail-table td:last-child {
  text-align: right;
  font-weight: 600;
}

/* Charts */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
}

.chart-box {
  position: relative;
  height: 300px;
  background: var(--bg);
  border-radius: var(--radius);
  padding: 12px;
}

/* Sensitivity */
.sensitivity .hint {
  margin-top: -12px;
  margin-bottom: 16px;
}

.sensitivity th:first-child,
.sensitivity td:first-child {
  text-align: center;
  background: var(--surface-2);
  font-weight: 600;
}

.positive { color: var(--accent); }
.negative { color: var(--danger); }

/* Footer */
footer {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.85rem;
  padding: 24px;
  border-top: 1px solid var(--border);
}

/* Mobile */
@media (max-width: 768px) {
  .topnav {
    flex-direction: column;
    gap: 12px;
    padding: 12px 16px;
  }
  .main { padding: 16px; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .page-header h1 { font-size: 1.5rem; }
  .summary-cards { grid-template-columns: 1fr 1fr; }
  .card .value { font-size: 1.35rem; }
  .chart-box { height: 240px; }
}
