:root {
  --bg-base: #090d16;
  --bg-surface: #0f172a;
  --bg-surface-elevated: #1e293b;
  --bg-hover: #334155;
  --border-subtle: #243247;
  --border-strong: #3b4d66;
  --text-main: #ffffff;
  --text-muted: #e2e8f0;
  --text-dim: #94a3b8;
  --text-label: #cbd5e1;
  --accent: #38bdf8;
  --accent-glow: rgba(56, 189, 248, 0.25);
  --green: #22c55e;
  --green-glow: rgba(34, 197, 94, 0.2);
  --red: #f43f5e;
  --red-glow: rgba(244, 63, 94, 0.2);
  --amber: #f59e0b;
  --purple: #a855f7;
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Consolas, 'Courier New', monospace;
}

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

html, body {
  background-color: var(--bg-base);
  color: var(--text-main);
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  min-height: 100vh;
}

.top-nav {
  background: #0f172a;
  border-bottom: 1px solid var(--border-strong);
  padding: 0 16px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
  white-space: nowrap;
}

.brand-wrap { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.brand-logo {
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13px;
  color: #0b1120;
}

.brand-title {
  font-size: 13.5px;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand-tag {
  font-size: 10px;
  font-weight: 800;
  background: rgba(56, 189, 248, 0.2);
  color: var(--accent);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid rgba(56, 189, 248, 0.35);
  letter-spacing: 0.5px;
}

.ticker-combobox-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface);
  padding: 2px 8px 2px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  position: relative;
  flex-shrink: 0;
}

.ticker-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

.ticker-search-box {
  position: relative;
  display: flex;
  align-items: center;
  width: 250px;
}

.ticker-search-input {
  width: 100%;
  background: var(--bg-base);
  color: var(--accent);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 4px 26px 4px 10px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 700;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ticker-search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.ticker-search-chevron {
  position: absolute;
  right: 8px;
  color: var(--accent);
  pointer-events: none;
  font-size: 10px;
}

.ticker-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 340px;
  max-height: 360px;
  overflow-y: auto;
  background: #0f172a;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.65);
  z-index: 300;
  display: none;
}

.ticker-dropdown.open {
  display: block;
}

.ticker-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid rgba(51, 65, 85, 0.35);
  font-size: 12px;
  white-space: normal;
}

.ticker-option:hover,
.ticker-option.active {
  background: rgba(56, 189, 248, 0.15);
}

.ticker-option-code {
  font-family: var(--font-mono);
  font-weight: 800;
  color: var(--accent);
  min-width: 48px;
}

.ticker-option-name {
  color: var(--text-muted);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ticker-option-missing {
  background: rgba(245, 158, 11, 0.12);
  border-left: 3px solid var(--amber);
  color: #fde68a;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
}

.ticker-option-missing:hover,
.ticker-option-missing.active {
  background: rgba(245, 158, 11, 0.24);
}

.pipeline-toast {
  position: fixed;
  top: 58px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  display: none;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  border: 1px solid var(--border-strong);
  max-width: 90vw;
}

.pipeline-toast.loading {
  display: flex;
  background: #172554;
  border-color: var(--accent);
  color: #e0f2fe;
}

.pipeline-toast.success {
  display: flex;
  background: #052e16;
  border-color: var(--green);
  color: #dcfce7;
}

.pipeline-toast.error {
  display: flex;
  background: #4c0519;
  border-color: var(--red);
  color: #ffe4e6;
}

.pipeline-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(56, 189, 248, 0.3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: radial-gradient(circle at 25% 20%, rgba(14, 165, 233, 0.16), transparent 50%),
              radial-gradient(circle at 80% 80%, rgba(168, 85, 247, 0.12), transparent 50%),
              rgba(9, 13, 22, 0.96);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 390px;
  background: #0f172a;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 28px 26px 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7);
}

.login-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.login-logo {
  width: 40px;
  height: 40px;
  border-radius: 9px;
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  color: #090d16;
  font-weight: 900;
  font-size: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-title {
  font-size: 18px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.3px;
}

.login-subtitle {
  font-size: 11.5px;
  color: var(--text-dim);
}

.login-field { margin-bottom: 14px; }
.login-field label {
  display: block;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-label);
  margin-bottom: 5px;
}

.login-input-wrap { position: relative; display: flex; align-items: center; }

.login-input {
  width: 100%;
  background: var(--bg-base);
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  padding: 9px 12px;
  color: #fff;
  font-size: 13px;
  font-family: var(--font-ui);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.login-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.login-eye-btn {
  position: absolute;
  right: 8px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 13px;
  padding: 2px 4px;
}

.login-error {
  display: none;
  background: rgba(244, 63, 94, 0.14);
  border: 1px solid rgba(244, 63, 94, 0.45);
  color: #fecdd3;
  font-size: 12px;
  padding: 8px 10px;
  border-radius: 6px;
  margin-bottom: 12px;
}

.login-submit-btn {
  width: 100%;
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  color: #090d16;
  border: none;
  border-radius: 7px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.login-submit-btn:hover { opacity: 0.94; }
.login-submit-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.ticker-select {
  background: var(--bg-base);
  color: var(--accent);
  border: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  padding: 4px 20px 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  outline: none;
  text-overflow: ellipsis;
  overflow: hidden;
  max-width: 220px;
}

.ticker-select option { background: #0f172a; color: #f8fafc; font-family: var(--font-ui); }

.controls-wrap { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.segmented-btn-group {
  display: inline-flex;
  align-items: center;
  background: var(--bg-base);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
}

.segmented-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
  line-height: 1.2;
}

.segmented-btn:hover { color: #ffffff; background: rgba(255, 255, 255, 0.05); }
.segmented-btn.active {
  background: var(--bg-surface-elevated);
  color: var(--accent);
  border: 1px solid rgba(56, 189, 248, 0.35);
}

.company-banner {
  background: linear-gradient(180deg, rgba(30, 41, 59, 0.4) 0%, rgba(15, 23, 42, 0.7) 100%);
  border-bottom: 1px solid var(--border-subtle);
  padding: 10px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.comp-meta { display: flex; align-items: baseline; flex-wrap: wrap; gap: 10px; }
.comp-name { font-size: 17px; font-weight: 800; letter-spacing: -0.4px; color: #fff; }
.comp-sector {
  font-size: 12px; color: var(--accent); background: rgba(56, 189, 248, 0.1);
  padding: 2px 8px; border-radius: 4px; border: 1px solid rgba(56, 189, 248, 0.2);
}
.comp-target {
  font-size: 11.5px; color: #38bdf8; background: rgba(56, 189, 248, 0.12);
  padding: 2px 8px; border-radius: 4px; border: 1px solid rgba(56, 189, 248, 0.35);
  font-weight: 700; font-family: var(--font-mono);
}
.comp-badge {
  font-size: 11px; color: var(--green); background: var(--green-glow);
  padding: 2px 8px; border-radius: 4px; border: 1px solid rgba(34, 197, 94, 0.3); font-weight: 600;
}
.comp-eod-pill {
  font-size: 11px; color: #fbbf24; background: rgba(245, 158, 11, 0.12);
  padding: 2px 8px; border-radius: 4px; border: 1px solid rgba(245, 158, 11, 0.35);
  font-family: var(--font-mono); font-weight: 600;
}

.search-box {
  display: flex; align-items: center; background: var(--bg-base);
  border: 1px solid var(--border-strong); border-radius: 6px; padding: 4px 10px; gap: 6px; width: 260px;
}
.search-box input {
  background: transparent; border: none; outline: none; color: var(--text-main);
  font-size: 12px; font-family: var(--font-ui); width: 100%;
}
.search-box input::placeholder { color: var(--text-dim); }

.tab-bar {
  display: flex; flex-wrap: nowrap; align-items: center; justify-content: space-between;
  overflow-x: auto; scrollbar-width: none;
  background: var(--bg-surface); border-bottom: 1px solid var(--border-subtle); padding: 0 8px; gap: 0;
}
.tab-bar::-webkit-scrollbar { display: none; }
.tab-btn {
  flex: 1 1 auto; justify-content: center;
  white-space: nowrap; background: transparent; border: none; color: var(--text-muted);
  font-size: 11px; font-weight: 600; padding: 8px 6px; border-bottom: 2px solid transparent;
  cursor: pointer; display: flex; align-items: center; gap: 4px; transition: all 0.15s ease;
}
.tab-btn:hover { color: var(--text-main); }
.tab-btn.active {
  color: var(--accent); border-bottom-color: var(--accent); background: rgba(56, 189, 248, 0.05);
}
.tab-count {
  font-size: 10px; background: var(--bg-base); padding: 1px 6px;
  border-radius: 10px; color: var(--text-dim); font-family: var(--font-mono);
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 0.85fr);
  height: calc(100vh - 148px);
  background: var(--bg-base);
  overflow: hidden;
}
.main-grid.full-width { grid-template-columns: 1fr !important; }
.main-grid.full-width .inspector-panel { display: none !important; }

.table-container {
  overflow-y: auto; overflow-x: auto; border-right: 1px solid var(--border-subtle); background: var(--bg-surface);
}
.financial-table { width: 100%; border-collapse: collapse; font-size: 12px; font-family: var(--font-mono); }
.financial-table th {
  background: #0d1527; color: var(--text-muted); font-weight: 600; padding: 8px 10px;
  text-align: right; border-bottom: 1px solid var(--border-strong); position: sticky; top: 0; z-index: 10; white-space: nowrap;
}
.financial-table th:first-child { text-align: left; min-width: 250px; font-family: var(--font-ui); }
.financial-table td {
  padding: 6px 10px; border-bottom: 1px solid rgba(51, 65, 85, 0.35); text-align: right; white-space: nowrap; color: #cbd5e1;
}
.financial-table td:first-child { text-align: left; font-family: var(--font-ui); color: var(--text-main); }
.financial-table td.sens-td-wrap {
  white-space: normal !important; text-align: left !important; max-width: 100% !important;
  overflow-x: hidden !important; padding: 10px 14px !important;
}
.financial-table td.sens-td-wrap div, .financial-table td.sens-td-wrap p {
  white-space: normal !important; word-wrap: break-word !important; overflow-wrap: break-word !important;
}
.financial-table tr { cursor: pointer; transition: background 0.1s ease; }
.financial-table tr:hover td { background: var(--bg-surface-elevated); }
.financial-table tr.selected td { background: rgba(56, 189, 248, 0.12); color: #fff; }
.financial-table tr.selected td:first-child { border-left: 3px solid var(--accent); font-weight: 700; color: var(--accent); }
.tr-major td {
  background: rgba(30, 41, 59, 0.55); font-weight: 700; color: #fff !important;
  border-top: 1px solid rgba(56, 189, 248, 0.2); border-bottom: 1px solid rgba(56, 189, 248, 0.2);
}
.tr-major td:first-child { color: #38bdf8 !important; }

.inspector-panel {
  overflow-y: auto; padding: 14px 16px; background: var(--bg-base);
  display: flex; flex-direction: column; gap: 14px;
}
.panel-card { background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: 8px; padding: 12px 14px; }
.panel-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--accent); margin-bottom: 8px; display: flex; align-items: center; gap: 6px;
}
.item-header-title { font-size: 16px; font-weight: 800; color: #fff; line-height: 1.3; margin-bottom: 4px; }
.item-code-badge {
  display: inline-block; font-size: 11px; font-family: var(--font-mono);
  background: rgba(56, 189, 248, 0.12); color: var(--accent); padding: 2px 7px;
  border-radius: 4px; border: 1px solid rgba(56, 189, 248, 0.25); margin-bottom: 10px;
}
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
.stat-box { background: var(--bg-base); border: 1px solid var(--border-subtle); border-radius: 6px; padding: 8px 10px; }
.stat-label { font-size: 10px; color: var(--text-dim); margin-bottom: 2px; }
.stat-val { font-size: 14px; font-family: var(--font-mono); font-weight: 700; color: var(--text-main); }
.concept-text { font-size: 12px; color: #cbd5e1; line-height: 1.55; }
.chart-container { position: relative; height: 190px; width: 100%; }
.chart-container-lg { position: relative; height: 300px; width: 100%; }

.doc-link-btn {
  display: inline-flex; align-items: center; gap: 6px; background: var(--bg-surface-elevated);
  color: var(--text-main); border: 1px solid var(--border-strong); padding: 8px 12px;
  border-radius: 6px; font-size: 11.5px; font-weight: 600; cursor: pointer; width: 100%; justify-content: center;
}
.doc-link-btn:hover { border-color: var(--accent); color: var(--accent); }

.breakdown-table { width: 100%; border-collapse: collapse; font-size: 11px; margin-top: 6px; }
.breakdown-table th {
  background: var(--bg-base); color: var(--text-dim); font-weight: 600; padding: 5px 8px;
  border-bottom: 1px solid var(--border-subtle); font-size: 10px; text-transform: uppercase;
}
.breakdown-table td { padding: 6px 8px; border-bottom: 1px solid rgba(51, 65, 85, 0.25); color: var(--text-main); }
.breakdown-pct-bar { height: 4px; background: rgba(56, 189, 248, 0.2); border-radius: 2px; overflow: hidden; margin-top: 3px; }
.breakdown-pct-fill { height: 100%; background: var(--accent); border-radius: 2px; }

.auditor-badge {
  display: flex; align-items: center; gap: 6px; background: rgba(34, 197, 94, 0.08);
  border: 1px solid rgba(34, 197, 94, 0.25); border-radius: 6px; padding: 6px 10px;
  font-size: 10.5px; color: var(--green); font-weight: 600; margin-top: 8px;
}

.form-control {
  background: var(--bg-base); color: var(--text-main); border: 1px solid var(--border-strong);
  border-radius: 5px; padding: 5px 8px; font-size: 12px; font-family: var(--font-ui); outline: none;
}
.form-control:focus { border-color: var(--accent); }

.screener-filter-bar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
  background: #0f172a; border: 1px solid var(--border-subtle); border-radius: 8px; padding: 12px; margin-bottom: 14px;
}
.filter-field { display: flex; flex-direction: column; gap: 4px; font-size: 10.5px; color: var(--text-dim); font-weight: 600; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(2, 6, 23, 0.8); z-index: 500;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-dialog {
  background: #0f172a; border: 1px solid var(--border-strong); border-radius: 10px;
  width: min(1180px, 96vw); height: 86vh; display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 18px; border-bottom: 1px solid var(--border-subtle); background: #0b1120;
}
.modal-close {
  background: var(--bg-surface-elevated); color: #fff; border: 1px solid var(--border-strong);
  border-radius: 6px; padding: 5px 12px; cursor: pointer; font-size: 12px; font-weight: 600;
}
.modal-filters {
  display: flex; gap: 10px; padding: 10px 18px; border-bottom: 1px solid var(--border-subtle); background: #0f172a;
}
.modal-filters input { flex: 1; }
.modal-body-grid {
  display: grid; grid-template-columns: 340px 1fr; flex: 1; min-height: 0;
}
.report-list-pane {
  border-right: 1px solid var(--border-subtle); overflow-y: auto; padding: 8px; background: #090d16;
}
.report-item {
  padding: 9px 10px; border-radius: 6px; cursor: pointer; border-bottom: 1px solid rgba(51, 65, 85, 0.25);
}
.report-item:hover { background: var(--bg-surface-elevated); }
.report-item.active { background: rgba(56, 189, 248, 0.14); border-left: 3px solid var(--accent); }
.report-content-pane {
  overflow-y: auto; padding: 18px 24px; background: #0f172a; color: #e2e8f0; font-size: 13px; line-height: 1.65;
}
.report-content-pane h1, .report-content-pane h2, .report-content-pane h3 { color: var(--accent); margin: 14px 0 6px; }
.report-content-pane table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 12px; }
.report-content-pane th, .report-content-pane td { border: 1px solid var(--border-strong); padding: 6px 8px; text-align: left; }
.report-content-pane th { background: #1e293b; }
.report-content-pane pre { background: #090d16; padding: 10px; border-radius: 6px; overflow-x: auto; margin: 8px 0; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
