/* Finviz-like dark theme */
:root {
  --bg: #0b111a;
  --panel: #0f1724;
  --border: #1e293b;
  --text: #e6eef6;
  --muted: #9aa5b1;
  --accent: #3dd3a6;
  --danger: #ff6b6b;
  --warn: #f7c948;
}

body {
  background: linear-gradient(180deg, #07111f 0%, #0a1320 100%);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  margin: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 19, 32, 0.88);
  backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.topbar-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 60px;
}
.brand { text-decoration: none; }
.brand-logo { height: 28px; width: 28px; margin-right: 10px; display: block; }
.brand-name { color: #f9fbff; font-weight: 700; letter-spacing: 0.3px; }
.topbar-center .nav-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 18px;
  border-radius: 999px;
  margin: 0 6px;
  font-weight: 600;
  text-decoration: none;
  color: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.06);
  transition: all 0.2s ease;
}
.topbar-center .nav-pill:hover {
  color: #ffffff;
  border-color: rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.12);
}
.topbar-center .nav-pill.active {
  color: #04121f;
  background: linear-gradient(90deg, var(--accent), #2fbf9b);
  border-color: transparent;
  box-shadow: 0 2px 12px rgba(61, 211, 166, 0.35);
}
.top-links .top-link { color: rgba(255,255,255,0.96); text-decoration: none; font-weight: 600; }
.top-links .top-link:hover { color: #ffffff; }
.lang-select { color: rgba(255,255,255,0.96); font-weight: 600; }
.lang-select .lang-option { color: rgba(255,255,255,0.96); text-decoration: none; }
.lang-select .lang-option.active { color: #ffffff; }
.lang-select .lang-option:hover { color: #ffffff; }
.lang-select .lang-sep { margin: 0 6px; color: rgba(255,255,255,0.96); }
.topbar-center::-webkit-scrollbar { display: none; }

@media (max-width: 767.98px) {
  .topbar {
    padding: 10px 12px;
  }
  .topbar-grid {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .topbar-left {
    justify-content: flex-start;
    width: 100%;
  }
  .topbar-center {
    order: 2;
    display: flex;
    width: 100%;
    padding-bottom: 2px;
    justify-content: flex-start;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
  }
  .topbar-center .nav-pill {
    flex: 0 0 auto;
    margin: 0 6px;
    white-space: nowrap;
    scroll-snap-align: start;
  }
  .top-links {
    order: 3;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
  }
  .top-links .top-link {
    margin-left: 0 !important;
    font-size: 0.875rem;
  }
  .lang-select {
    margin-left: 0 !important;
  }
}

.main-wrap { padding: 24px 0; }

.card-dark {
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 10px;
}

.site-title {
  font-weight: 800;
  letter-spacing: 0.4px;
}

.site-sub { color: var(--muted); }

.main-input {
  min-width: 260px;
  background: rgba(255,255,255,0.94);
  border: 1px solid rgba(255,255,255,0.95);
  color: #04121f;
  box-shadow: 0 10px 26px rgba(10, 19, 32, 0.45);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.main-input::placeholder { color: rgba(4, 18, 31, 0.58); }
.main-input:focus {
  outline: none;
  border-color: rgba(61, 211, 166, 0.8);
  box-shadow: 0 0 0 3px rgba(61, 211, 166, 0.35);
}

.btn-primary {
  background: linear-gradient(90deg, var(--accent), #2fbf9b);
  border: none;
}
.btn.is-busy { pointer-events: none; opacity: 0.85; }
.btn-primary.btn-loading { opacity: 0.85; cursor: wait; }
.spinner {
  display: inline-block;
  width: 1em;
  height: 1em;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: -0.125em;
  margin-right: 8px;
}
.spinner-lg { width: 2em; height: 2em; border-width: 3px; margin-right: 10px; }

/* Hide any stray paragraphs dropped inside the search box area */
.landing-search p { display: none !important; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Page overlay while navigating */
.page-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(7, 17, 31, 0.6);
  backdrop-filter: blur(2px) saturate(120%);
  z-index: 1050;
  align-items: center;
  justify-content: center;
}
.page-overlay.show { display: flex; }
.page-overlay .page-overlay-inner { display: flex; align-items: center; color: var(--text); font-weight: 600; }
.page-overlay .overlay-text { margin-left: 6px; }

.footer-note { color: var(--muted); }

.analysis-title { margin-bottom: 4px; }
.big-score { font-size: 2.6rem; font-weight: 800; color: var(--accent); }
.score-pill { color: var(--muted); }

.nav-tabs .nav-link { color: var(--muted); }
.nav-tabs .nav-link.active { color: var(--text); }
.nav-tabs {
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.nav-tabs .nav-link {
  background: transparent;
  border: none;
  margin-right: 8px;
  border-radius: 6px 6px 0 0;
}
.nav-tabs .nav-link.active {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-bottom-color: transparent;
}

.quote-box {
  margin-top: 12px;
  padding: 12px;
  border-radius: 8px;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.06);
}

.muted-small { color: var(--muted); }

/* Criteria list */
.criteria-list {
  list-style: none;
  padding-left: 0;
  margin: 8px 0 14px 0;
}
.criteria-item { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.criteria-item .criteria-title { margin-left: 4px; }
.score-wrap { padding: 8px 0 12px; }
.badge-status {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%; font-weight: 700;
  background: rgba(255,255,255,0.06); border: 1px solid var(--border);
}
.badge-status.ok { color: #16a34a; border-color: #16a34a33; }
.badge-status.fail { color: #ef4444; border-color: #ef444433; }
.badge-status.unknown { color: var(--warn); border-color: #f7c94833; }
.criteria-title { font-weight: 600; }
.criteria-value { color: var(--muted); margin-left: auto; }
.criteria-note { color: var(--muted); margin-left: 8px; font-size: 0.9em; }

/* Pill badges */
.badge-success { background: linear-gradient(90deg, var(--accent), #2fbf9b); }

/* Metric grid for compact summary */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  grid-gap: 14px;
}
.score-badge { border: none; color: #fff; }

/* Info tooltip helper */
.info {
  display: inline-block;
  width: 16px;
  height: 16px;
  line-height: 16px;
  text-align: center;
  margin-left: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  color: #fff;
  font-size: 11px;
  cursor: pointer;
}

/* Focus ring for keyboard accessibility */
.info:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Modern badges and criteria */
.badge-status { width: 22px; height: 22px; }
.criteria-item { padding: 8px 10px; border-radius: 8px; }
.criteria-item:hover { background: rgba(255,255,255,0.03); }
.criteria-title { font-weight: 600; }
.criteria-value { font-variant-numeric: tabular-nums; }

/* Headline pill styles */
.score-pill { color: var(--muted); font-weight: 600; }
.score-badge { box-shadow: 0 1px 0 rgba(0,0,0,0.2); }

/* Landing page quote */
.landing-quote {
  margin: 0;
  padding: 12px 14px;
  border-left: 3px solid var(--accent);
  background: rgba(255,255,255,0.025);
  border-radius: 6px;
}
.landing-quote .quote-text { font-style: italic; }
.landing-quote .quote-subtext { color: var(--muted); margin-top: 4px; }

/* Inline search progress under the landing header */
.search-progress {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text);
  margin-top: 16px;
}
.search-progress .spinner-lg { margin-right: 0; }
.search-progress-bar {
  width: 160px;
  height: 6px;
  border-radius: 999px;
  background: rgba(255,255,255,0.18);
  overflow: hidden;
}
.search-progress-bar-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #2fbf9b);
  transition: width 0.35s ease;
}
.d-none { display: none !important; }

.landing-examples {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
}
.landing-examples .examples-label {
  color: rgba(255,255,255,0.72);
  font-weight: 600;
}
.landing-examples .quick-example {
  color: #f8fbff;
  font-weight: 600;
  text-decoration: none;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  transition: background 0.2s ease, color 0.2s ease;
}
.landing-examples .quick-example:hover {
  background: rgba(61,211,166,0.25);
  color: #04121f;
}
.landing-examples .examples-sep {
  color: rgba(255,255,255,0.55);
  font-weight: 600;
  margin: 0 2px;
}

.analysis-header {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.analysis-top-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 16px;
}
.analysis-title-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1 1 260px;
  min-width: 200px;
}
.analysis-title-block .analysis-title {
  margin-bottom: 2px;
}
.analysis-title-block .small-muted {
  margin-bottom: 0;
}
.analysis-summary {
  flex: 1 1 100%;
  margin: 0;
  color: rgba(255,255,255,0.75);
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.5;
  max-width: 940px;
}
.analysis-summary:empty {
  display: none;
}
.analysis-scores {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0;
  margin-left: auto;
  white-space: normal;
}
.analysis-scores .score-pill {
  margin: 0;
  white-space: nowrap;
}
.analysis-tab-header {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.related-searches {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.95rem;
}
.related-label {
  font-weight: 600;
  color: rgba(255,255,255,0.82);
}
.related-link {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}
.related-link:hover {
  color: var(--accent);
}
.related-name {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.related-symbol {
  color: rgba(255,255,255,0.65);
  font-weight: 500;
}
.related-sep {
  color: rgba(255,255,255,0.4);
  font-weight: 600;
  margin: 0 4px;
}

/* Funds & ETFs table */
.funds-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
}
.segment-switch {
  display: inline-flex;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 999px;
  overflow: hidden;
}
.segment-switch a {
  padding: 6px 16px;
  font-weight: 600;
  text-decoration: none;
  color: var(--muted);
  border-right: 1px solid rgba(255,255,255,0.08);
}
.segment-switch a:last-child { border-right: none; }
.segment-switch a.active {
  color: #04121f;
  background: linear-gradient(90deg, var(--accent), #2fbf9b);
}
.funds-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 18px;
  font-variant-numeric: tabular-nums;
}
.funds-table thead tr {
  background: rgba(255,255,255,0.03);
}
.funds-table th, .funds-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  text-align: left;
}
.funds-table tbody tr:hover {
  background: rgba(255,255,255,0.02);
}
.funds-table .score-cell {
  font-weight: 700;
  color: var(--accent);
}
.funds-table .negative { color: #f87171; }
.funds-table .positive { color: #34d399; }
.funds-help {
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 10px;
}
.add-fund-form input[type="text"] {
  min-width: 200px;
  text-transform: uppercase;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  color: var(--text);
}
.add-fund-form .btn {
  min-width: 140px;
}
.add-fund-form > * {
  margin-right: 8px;
}
.add-fund-form > *:last-child {
  margin-right: 0;
}

.score-cell {
  --score-fill: 0%;
  background: linear-gradient(90deg, rgba(61, 211, 166, 0.18) 0%, rgba(61, 211, 166, 0.32) var(--score-fill), rgba(255,255,255,0.02) var(--score-fill));
  font-weight: 600;
  color: var(--text);
  transition: background 0.25s ease;
}
.score-cell:hover {
  background: linear-gradient(90deg, rgba(61, 211, 166, 0.28) 0%, rgba(61, 211, 166, 0.42) var(--score-fill), rgba(255,255,255,0.04) var(--score-fill));
}

@media (min-width: 992px) {
  .analysis-top-row {
    align-items: center;
  }
  .analysis-tab-header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
  }
  .analysis-tab-header .nav-tabs {
    margin-bottom: 0;
  }
  .analysis-tab-header .related-searches {
    margin-top: 0;
    margin-left: auto;
  }
}

@media (max-width: 991.98px) {
  .analysis-top-row {
    gap: 12px;
  }
  .analysis-scores {
    margin-left: 0;
    margin-top: 8px;
    justify-content: flex-start;
    gap: 8px;
  }
  .analysis-summary {
    max-width: 100%;
    width: 100%;
    padding-right: 0;
  }
  .criteria-item {
    align-items: flex-start;
    flex-wrap: wrap;
  }
  .criteria-value,
  .criteria-note {
    margin-left: 0;
  }
}


@media (max-width: 575.98px) {
  .landing-header {
    padding: 0 16px;
  }
  .topbar-center .nav-pill {
    margin-right: 8px;
    padding: 8px 14px;
  }
  .landing-search .form-inline {
    flex-direction: column;
    width: 100%;
    gap: 10px;
  }
  .landing-search .form-control {
    width: 100%;
    max-width: 100%;
  }
  .landing-search .btn {
    width: 100%;
    margin-left: 0 !important;
  }
  .analysis-scores {
    flex-wrap: wrap;
    margin-left: 0;
    justify-content: flex-start;
  }
  .related-searches {
    justify-content: flex-start;
  }
  .related-label {
    width: 100%;
  }
  .landing-examples {
    gap: 4px;
  }
  .landing-examples .quick-example {
    padding: 2px 10px;
  }
}

