:root {
  /* Premium fintech palette */
  --bg: #f5f7fb;
  --bg-2: #eef1f8;
  --panel: #ffffff;
  --panel-2: #f7f9fc;
  --border: #e6e9f0;
  --border-strong: #d3d9e6;
  --text: #131a2b;
  --muted: #6b7691;
  --muted-2: #93a0bd;

  /* Brand: deep navy → indigo */
  --navy: #16213e;
  --navy-2: #1e2a4d;
  --indigo: #4f46e5;
  --indigo-2: #6366f1;
  --accent: #4338ca;
  --sky: #0ea5e9;

  --green: #0f9d58;
  --green-bg: #e8f6ee;
  --amber: #b7791f;
  --amber-bg: #fdf4e3;
  --red: #d92d20;
  --red-bg: #fdeceb;

  /* Gradients */
  --grad-header: linear-gradient(120deg, #16213e 0%, #243b6b 55%, #3730a3 100%);
  --grad-brand: linear-gradient(120deg, #1e2a4d 0%, #4338ca 100%);
  --grad-btn: linear-gradient(120deg, #4338ca 0%, #6366f1 100%);
  --grad-tile-1: linear-gradient(135deg, #1e2a4d 0%, #3a4a85 100%);
  --grad-tile-2: linear-gradient(135deg, #4338ca 0%, #6366f1 100%);
  --grad-tile-3: linear-gradient(135deg, #0f766e 0%, #14b8a6 100%);
  --grad-tile-4: linear-gradient(135deg, #b45309 0%, #f59e0b 100%);

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow: 0 2px 6px rgba(20, 30, 60, 0.06), 0 1px 2px rgba(20, 30, 60, 0.05);
  --shadow-md: 0 8px 24px rgba(20, 30, 60, 0.10);
  --shadow-lg: 0 18px 40px rgba(20, 30, 60, 0.16);
  --shadow-tile: 0 10px 24px rgba(40, 50, 110, 0.22);

  --serif: "Iowan Old Style", Georgia, "Times New Roman", serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "SF Mono", "Cascadia Mono", "Roboto Mono", Consolas, "Courier New", monospace;

  --radius: 14px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--sans);
  background:
    radial-gradient(1200px 600px at 100% -10%, rgba(99, 102, 241, 0.07), transparent 60%),
    radial-gradient(900px 500px at -10% 0%, rgba(14, 165, 233, 0.06), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

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

/* ---------- Sidebar ---------- */
.sidebar {
  width: 312px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 0 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  box-shadow: 1px 0 0 rgba(20, 30, 60, 0.02);
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  margin: 0 -22px 6px;
  padding: 28px 22px 26px;
  background: var(--grad-brand);
  color: #fff;
  position: relative;
}
.brand::after {
  content: "";
  position: absolute;
  right: -40px; top: -40px;
  width: 140px; height: 140px;
  background: radial-gradient(circle, rgba(255,255,255,0.16), transparent 70%);
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
}
.brand > * { position: relative; z-index: 1; }
.brand .logo { display: none; }
.brand h1 {
  font-family: var(--sans);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.3;
  margin: 0;
  padding: 2px 0;
}
.muted { color: var(--muted); font-size: 12px; }
.brand .muted { color: rgba(255,255,255,0.72); text-transform: uppercase; letter-spacing: 0.1em; font-size: 10px; font-weight: 600; }

.field-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  margin-bottom: 2px;
}

select, textarea, input[type="range"] {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 10px 11px;
  font-family: inherit;
  font-size: 13px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
textarea { resize: vertical; line-height: 1.5; font-family: var(--mono); font-size: 12px; min-height: 96px; flex-shrink: 0; }
select:focus, textarea:focus { outline: none; background: var(--panel); border-color: var(--indigo); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15); }

input[type="range"] { padding: 0; border: none; accent-color: var(--indigo); cursor: pointer; background: transparent; }

.pill {
  background: var(--grad-btn);
  color: #fff;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--mono);
  box-shadow: 0 1px 3px rgba(67, 56, 202, 0.4);
}

.dcf-box { background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; }
.dcf-box summary { cursor: pointer; font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--navy); margin-bottom: 6px; }
.dcf-box > label { margin-top: 12px; }

.weights { font-size: 11px; color: var(--muted); border-top: 1px solid var(--border); padding-top: 12px; }
.weights .w-row { display: flex; justify-content: space-between; padding: 3px 0; }
.weights .w-row span:last-child { font-family: var(--mono); font-weight: 700; color: var(--indigo); }

.btn-primary {
  background: var(--grad-btn);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 13px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  margin-top: 6px;
  box-shadow: 0 6px 16px rgba(67, 56, 202, 0.32);
  transition: transform 0.12s ease, box-shadow 0.18s ease, filter 0.15s ease;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(67, 56, 202, 0.4); filter: brightness(1.05); }
.btn-primary:active { transform: translateY(0); box-shadow: 0 4px 10px rgba(67, 56, 202, 0.3); }
.btn-primary:disabled { opacity: 0.6; cursor: wait; box-shadow: none; transform: none; }

.disclaimer { font-size: 10.5px; color: var(--muted); margin-top: auto; padding-top: 12px; line-height: 1.6; border-top: 1px solid var(--border); }

/* ---------- Main ---------- */
.main { flex: 1; padding: 0 32px 48px; max-width: 1480px; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  background: rgba(245, 247, 251, 0.85);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  backdrop-filter: saturate(180%) blur(10px);
  padding: 18px 0 0;
  z-index: 5;
  border-bottom: 1px solid var(--border);
  margin-bottom: 26px;
}
.tabs { display: flex; gap: 6px; }
.tab {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--muted);
  padding: 9px 20px;
  margin-bottom: 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: all 0.15s ease;
}
.tab:hover { color: var(--navy); background: var(--bg-2); }
.tab.active { color: #fff; background: var(--grad-btn); border-color: transparent; box-shadow: 0 4px 12px rgba(67, 56, 202, 0.3); }

.hidden { display: none !important; }

/* ---------- Cards ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 22px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.card:hover { box-shadow: var(--shadow-md); }
.card h3 {
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--navy);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.card h3::before {
  content: "";
  width: 4px; height: 16px;
  border-radius: 2px;
  background: var(--grad-btn);
}
.card h3 .muted { font-weight: 500; }
.card h3 .muted::before { display: none; }

/* ---------- Metrics (stat tiles) ---------- */
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 22px; }
.metric {
  position: relative;
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-tile);
  overflow: hidden;
  isolation: isolate;
}
.metric::after {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(120px 80px at 120% -20%, rgba(255,255,255,0.22), transparent 70%);
  z-index: -1;
}
.metric:nth-child(1) { background: var(--grad-tile-1); }
.metric:nth-child(2) { background: var(--grad-tile-2); }
.metric:nth-child(3) { background: var(--grad-tile-3); }
.metric:nth-child(4) { background: var(--grad-tile-4); }
.metric .label { font-size: 11px; color: rgba(255,255,255,0.82); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.metric .value { font-size: 28px; font-weight: 800; margin-top: 6px; color: #fff; letter-spacing: -0.02em; font-family: var(--sans); }
.metric .sub { font-size: 12px; color: rgba(255,255,255,0.8); margin-top: 4px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
th, td { text-align: right; padding: 11px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { font-variant-numeric: tabular-nums; }
th {
  color: var(--muted);
  font-weight: 700;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border-strong);
  position: sticky;
  top: 0;
}
th:hover { color: var(--indigo); }
th:first-child, td:first-child { text-align: left; }
th.name-col, td.name-col { text-align: left; }
tbody tr { transition: background 0.12s ease; }
tbody tr:hover { background: linear-gradient(90deg, rgba(79,70,229,0.06), rgba(79,70,229,0.02)); }
td.ticker { font-weight: 700; color: var(--indigo); font-family: var(--mono); }

.score-cell {
  font-weight: 800;
  border-radius: 999px;
  padding: 4px 10px;
  display: inline-block;
  min-width: 46px;
  text-align: center;
  font-family: var(--mono);
  font-size: 12px;
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.25), 0 1px 3px rgba(0,0,0,0.12);
}

.verdict { font-size: 12px; }

/* ---------- Charts ---------- */
.chart { width: 100%; min-height: 380px; }

/* ---------- Empty / loading ---------- */
.empty-state {
  padding: 8px;
  max-width: 1040px;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.empty-state h2 { font-family: var(--sans); font-size: 34px; font-weight: 800; letter-spacing: -0.02em; color: var(--navy); margin-bottom: 12px; }
.empty-state h2 .grad { background: var(--grad-btn); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.empty-state p { color: var(--muted); line-height: 1.7; margin-bottom: 14px; }
.legend { list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 18px 0; }
.legend li {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  position: relative;
  padding-left: 18px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.legend li::before { content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 4px; border-radius: 0 3px 3px 0; background: var(--grad-btn); }
.legend li:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.legend b { color: var(--navy); }
.hint { font-size: 15px; color: var(--text); }

.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin: 24px 0 22px;
}
.step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 18px;
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-2) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}
.step-num {
  flex-shrink: 0;
  width: 28px; height: 28px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--grad-btn);
  color: #fff;
  font-weight: 800;
  font-size: 13px;
}
.step b { color: var(--navy); display: block; margin-bottom: 3px; font-size: 14px; }
.step p { color: var(--muted); font-size: 12.5px; line-height: 1.55; margin: 0; }

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

.loading { padding: 80px 0; text-align: center; }
.loading p { color: var(--muted); }
.spinner {
  width: 44px; height: 44px; margin: 0 auto 18px;
  border: 3px solid var(--border);
  border-top-color: var(--indigo);
  border-right-color: var(--indigo-2);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Deep dive ---------- */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.detail-grid .card { margin-bottom: 0; }
.check-list { list-style: none; display: flex; flex-direction: column; gap: 9px; }
.check-list li { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.check-mark {
  font-weight: 700; font-family: var(--mono);
  width: 22px; height: 22px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 6px; font-size: 12px;
}
.news-item { padding: 13px 0; border-bottom: 1px solid var(--border); }
.news-item:last-child { border: none; }
.news-item a { color: var(--text); text-decoration: none; font-weight: 500; }
.news-item a:hover { color: var(--indigo); text-decoration: underline; }
.sent-badge {
  font-weight: 700; font-family: var(--mono); margin-right: 9px; font-size: 11px;
  padding: 2px 7px; border-radius: 6px; display: inline-block;
}
.news-meta { font-size: 11px; color: var(--muted); margin-top: 4px; }

@media (max-width: 1000px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .detail-grid { grid-template-columns: 1fr; }
  .legend { grid-template-columns: 1fr; }
  .sidebar { width: 270px; }
}

/* ---------- Mobile / tablet (stacked layout) ---------- */
@media (max-width: 760px) {
  body { font-size: 14px; }

  /* Stack sidebar above the main content instead of side-by-side */
  .app { flex-direction: column; min-height: 100%; }

  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 0 16px 20px;
    box-shadow: none;
  }
  .brand { margin: 0 -16px 6px; padding: 22px 16px 18px; }
  .brand h1 { font-size: 18px; }

  /* Let textarea/disclaimer sit naturally; no flex-pinned bottom */
  .disclaimer { margin-top: 12px; }

  .main { padding: 0 16px 40px; max-width: 100%; }

  /* Sticky tab bar: allow horizontal scroll if the tabs overflow */
  .topbar { padding: 14px 0 0; margin-bottom: 20px; }
  .tabs {
    overflow-x: auto;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { padding: 8px 16px; white-space: nowrap; flex-shrink: 0; }

  .card { padding: 16px; margin-bottom: 16px; }
  .card h3 { font-size: 14px; }

  /* Single-column metric tiles read better than cramped pairs */
  .metrics { grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
  .metric { padding: 14px 16px; }
  .metric .value { font-size: 22px; }

  .chart { min-height: 320px; }

  /* Empty-state hero scales down */
  .empty-state h2 { font-size: 26px; }
  .empty-state { justify-content: flex-start; padding-top: 8px; }
  .steps { grid-template-columns: 1fr; gap: 12px; margin: 18px 0 16px; }

  /* Comfortable touch targets */
  .btn-primary { padding: 15px; font-size: 14px; }
  select, textarea { font-size: 16px; } /* 16px avoids iOS input zoom */
}

@media (max-width: 420px) {
  .metrics { grid-template-columns: 1fr; }
  .empty-state h2 { font-size: 22px; }
  th, td { padding: 9px 10px; }
}
