/* ── F&F - Finanical Insights – Global Styles ── */
:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface2: #f7f7f7;
  --border: #e6e6e6;
  --accent: #111111;
  --accent2: #4b4b4b;
  --text: #111111;
  --muted: #6a6a6a;
  --success: #3d3d3d;
  --warning: #7a7a7a;
  --danger: #555555;
  --radius: 8px;
  --font: 'Bahnschrift', 'Segoe UI', system-ui, sans-serif;
  --mono: 'Consolas', 'Cascadia Code', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background:
    radial-gradient(circle at 12% 0%, #f6f6f6 0%, transparent 34%),
    radial-gradient(circle at 100% 6%, #f2f2f2 0%, transparent 32%),
    var(--bg);
  background-color: #ffffff;
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Header ── */
header {
  background: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  backdrop-filter: none;
}
.brand { font-size: 1.2rem; font-weight: 700; color: var(--text); }
.brand-sub { color: var(--muted); font-size: 0.85rem; }
.top-nav { margin-left: auto; }
.top-nav a {
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.28rem 0.6rem;
  margin-left: 0.4rem;
}
.top-nav a:hover {
  color: var(--text);
  border-color: var(--border);
  background: #f6f6f6;
  text-decoration: none;
}

/* ── Main ── */
main { flex: 1; max-width: 1100px; width: 100%; margin: 2rem auto; padding: 0 1.5rem; }

.page-shell {
  width: 100%;
  max-width: 1280px;
  margin: 1.6rem auto 0;
  padding: 0 1.5rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 1.1rem;
  align-items: start;
}

.page-shell main {
  max-width: none;
  margin: 0;
  padding: 0;
}

.right-rail {
  position: sticky;
  top: 0.8rem;
}

/* ── Ads ── */
.site-ad-wrap {
  width: 100%;
  max-width: 1100px;
  margin: 0.9rem auto 0;
  padding: 0 1.5rem;
}

.site-ad-wrap-bottom {
  margin-top: 0.5rem;
  margin-bottom: 0.75rem;
}

.site-ad-frame {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #ffffff;
  padding: 0.55rem;
  min-height: 96px;
}

.inline-ad {
  margin-top: 0.1rem;
  margin-bottom: 0.8rem;
}

/* Ad preview placeholders (local dev only, PREVIEW_ADS_MODE=1) */
.ad-preview-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 90px;
  background: repeating-linear-gradient(
    45deg,
    #f0f4ff,
    #f0f4ff 10px,
    #e8eeff 10px,
    #e8eeff 20px
  );
  border: 2px dashed #a0aec0;
  border-radius: var(--radius);
  gap: 0.3rem;
}
.ad-preview-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: #718096;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.ad-preview-note {
  font-size: 0.75rem;
  color: #a0aec0;
}

/* ── Footer ── */
footer {
  text-align: center;
  padding: 1rem;
  color: var(--muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
}

/* ── Card ── */
.card {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 1.25rem 0;
  margin-bottom: 0.5rem;
}

/* ── Search Form ── */
.search-card h1 { margin-bottom: 0.4rem; }
.hint { color: var(--muted); margin-bottom: 1.25rem; font-size: 0.9rem; }
.search-form .form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
  align-items: flex-end;
}
.field { display: flex; flex-direction: column; gap: 0.3rem; min-width: 160px; }
.field label { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.field input[type="text"],
.field input[type="date"] {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  padding: 0.5rem 0.75rem;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}
.field input:focus { border-color: var(--accent); }

.suggestions-list {
  display: none;
  margin-top: 0.35rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #ffffff;
  max-height: 220px;
  overflow-y: auto;
}

.suggestion-item {
  display: block;
  width: 100%;
  border: none;
  border-bottom: 1px solid #f0f0f0;
  background: #ffffff;
  color: var(--text);
  text-align: left;
  padding: 0.45rem 0.6rem;
  font-size: 0.85rem;
  cursor: pointer;
}

.suggestion-item:last-child {
  border-bottom: none;
}

.suggestion-item:hover {
  background: #f8f8f8;
}
.checkboxes { align-items: center; gap: 1.25rem; }
.group-label { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.check-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  font-size: 0.95rem;
}
.check-label input { accent-color: var(--accent); width: 15px; height: 15px; }

/* ── Buttons ── */
.btn-primary {
  background: #111111;
  color: #ffffff;
  border: none;
  border-radius: 5px;
  padding: 0.55rem 1.4rem;
  font-size: 0.95rem;
  cursor: pointer;
  font-weight: 600;
  transition: opacity 0.15s;
}
.btn-primary:hover { opacity: 0.85; }
.btn-secondary {
  background: #ffffff;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.45rem 1rem;
  font-size: 0.9rem;
  cursor: pointer;
  display: inline-block;
}
.btn-secondary:hover { border-color: var(--accent); text-decoration: none; }

/* ── Info card ── */
.info-card h2 { margin-bottom: 0.75rem; }
.info-card ol { padding-left: 1.25rem; color: var(--muted); }
.info-card ol li { margin-bottom: 0.4rem; }
.info-card ol li em { color: var(--text); }

/* ── Error ── */
.error-card { border-color: var(--danger); }
.error { color: var(--danger); margin-bottom: 1rem; }

/* ── Company header ── */
.company-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1rem;
}
.company-header h1 { font-size: 1.4rem; margin-bottom: 0.5rem; }
.meta-right { text-align: right; color: var(--muted); font-size: 0.9rem; line-height: 1.8; }

/* ── Badges ── */
.badge {
  display: inline-block;
  background: #f1f1f1;
  color: #141414;
  border-radius: 4px;
  padding: 0.15rem 0.6rem;
  font-size: 0.78rem;
  margin-right: 0.3rem;
  font-weight: 600;
}
.badge.muted { background: var(--surface2); color: var(--muted); border: 1px solid var(--border); }

/* ── Results header ── */
.results-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.results-header h2 { flex: 1; }
.count-badge {
  background: #f8f8f8;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.2rem 0.7rem;
  font-size: 0.83rem;
  color: var(--muted);
}

.group-card {
  padding: 0.9rem 1.2rem;
  background: transparent;
}

.group-card .results-header {
  margin-bottom: 0;
}

.group-card h2 {
  letter-spacing: 0.03em;
  text-transform: uppercase;
  font-size: 0.95rem;
}

.metric-tabs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.metric-tab {
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
  border-radius: 6px;
  padding: 0.45rem 0.85rem;
  font-size: 0.86rem;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
}

.metric-tab.is-active {
  background: #111111;
  border-color: #111111;
  color: #ffffff;
}

.metric-tab:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.metric-tab-link {
  display: inline-block;
}

.tab-panel.is-hidden {
  display: none;
}

.metric-details {
  margin-top: 1rem;
  border-top: 1px solid var(--border);
  padding-top: 0.6rem;
}

.metric-details summary {
  color: var(--accent);
  cursor: pointer;
  font-size: 0.86rem;
}

.metric-details[open] summary {
  color: var(--text);
}

/* ── Table ── */
.table-wrap { overflow-x: auto; }
.companies-scroll {
  max-height: 68vh;
  overflow-y: auto;
}
.filings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.filings-table thead th {
  background: #fafafa;
  padding: 0.65rem 0.9rem;
  text-align: left;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--border);
}
.filings-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.filings-table tbody tr:hover { background: var(--surface2); }
.filings-table tbody tr.row-clickable { cursor: pointer; }
.filings-table tbody tr.row-clickable:focus-visible {
  outline: 2px solid #1e40af;
  outline-offset: -2px;
}
.filings-table td { padding: 0.6rem 0.9rem; vertical-align: middle; }
.filings-table .center { text-align: center; }
.amendment-row td:first-child { border-left: 3px solid var(--warning); }

.filings-table .mono {
  font-variant-numeric: tabular-nums;
}

/* Form type color badges */
.form-badge {
  display: inline-block;
  border-radius: 4px;
  padding: 0.2rem 0.6rem;
  font-size: 0.8rem;
  font-weight: 700;
}
.form-10-Q  { background: #1d1d1d; color: #f3f3f3; }
.form-10-K  { background: #262626; color: #f3f3f3; }
.form-10-Q-A { background: #2f2f2f; color: #f3f3f3; }
.form-10-K-A { background: #373737; color: #f3f3f3; }

/* ── Links ── */
.links-cell { white-space: nowrap; }
.inline-form {
  display: inline;
  margin: 0;
  padding: 0;
}
.link-btn {
  display: inline-block;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
  padding: 0.2rem 0.6rem;
  font-size: 0.8rem;
  margin-right: 0.3rem;
  white-space: nowrap;
  transition: background 0.1s;
}
.link-btn:hover { background: #111111; color: #ffffff; text-decoration: none; }
.link-btn.muted { border-color: var(--border); color: var(--muted); }
.link-btn.muted:hover { background: var(--surface2); color: var(--text); }

/* ── Misc ── */
.mono  { font-family: var(--mono); }
.small { font-size: 0.8rem; }
.empty-state { color: var(--muted); padding: 2rem 0; text-align: center; }
.info-box {
  background: #fafafa;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.7;
  margin-top: 1rem;
}
.info-box strong { color: var(--text); }

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.chart-grid > div {
  background: transparent;
  border: 1px solid #f0f0f0;
  border-radius: var(--radius);
  padding: 0.75rem;
  min-height: 260px;
}

.mini-title {
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

.chart-wrap {
  position: relative;
  height: 220px;
}

.chart-controls-card {
  padding-top: 0.8rem;
  padding-bottom: 0.8rem;
}

.chart-controls-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.chart-controls-row select {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.28rem 0.5rem;
  background: #ffffff;
  color: var(--text);
}

.chart-delta-strip {
  margin-top: 0.5rem;
  min-height: 1.8rem;
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
}

.delta-chip {
  border-radius: 999px;
  padding: 0.15rem 0.45rem;
  font-size: 0.75rem;
  line-height: 1.2;
  border: 1px solid transparent;
  font-weight: 600;
}

.delta-pos {
  color: #166534;
  background: #ecfdf3;
  border-color: #bbf7d0;
}

.delta-neg {
  color: #991b1b;
  background: #fef2f2;
  border-color: #fecaca;
}

.delta-na {
  color: var(--muted);
  background: #f5f5f5;
  border-color: #e7e7e7;
}

.metric-chart {
  width: 100% !important;
  height: 100% !important;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

.stat-box {
  background: #fbfbfb;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem;
}

.stat-value {
  font-size: 1.05rem;
  margin-top: 0.2rem;
}

.muted {
  color: var(--muted);
}

/* ── Refine search toggle ── */
.refine-toggle {
  cursor: pointer;
  color: var(--accent);
  font-size: 0.9rem;
  padding: 0.3rem 0;
  list-style: none;
}
.inline-search { margin-top: 1rem; }

/* ── Percent change badges ── */
.pct-pos { color: #2a7a2a; font-weight: 600; font-size: 0.83rem; }
.pct-neg { color: #b03030; font-weight: 600; font-size: 0.83rem; }
.pct-na  { color: var(--muted); font-size: 0.83rem; }

/* ── Hamburger toggle ── */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 4px;
  margin-left: auto;
  flex-shrink: 0;
}
.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Responsive ── */
@media (max-width: 900px) {
  main { max-width: 100%; }
  .page-shell {
    max-width: 100%;
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }
  .right-rail {
    position: static;
    order: 2;
  }
  .site-ad-wrap { max-width: 100%; }
  .chart-grid { gap: 0.75rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 700px) {
  header {
    padding: 0.65rem 1rem;
    flex-wrap: wrap;
    align-items: center;
    row-gap: 0;
  }
  .brand { font-size: 1.05rem; }
  .brand-sub { display: none; }
  .nav-toggle { display: flex; }
  .top-nav {
    display: none;
    width: 100%;
    flex-direction: column;
    margin-left: 0;
    border-top: 1px solid var(--border);
    padding-top: 0.4rem;
    margin-top: 0.4rem;
  }
  .top-nav.is-open { display: flex; }
  .top-nav a {
    margin: 0;
    padding: 0.55rem 0.25rem;
    border: none;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
  }
  .top-nav a:last-child { border-bottom: none; }
  main { padding: 0 0.75rem; margin: 1.25rem auto; }
  .page-shell { padding: 0 0.75rem; margin-top: 1rem; }
  .page-shell main { margin: 0; }
  .site-ad-wrap { padding: 0 0.75rem; margin-top: 0.65rem; }
  .site-ad-frame { min-height: 74px; }
  .company-header { flex-direction: column; }
  .meta-right { text-align: left; width: 100%; }
  .meta-right > div[style] { flex-wrap: wrap !important; }
  .form-row { flex-direction: column; }
  .results-header { flex-wrap: wrap; gap: 0.5rem; }
  .chart-grid { grid-template-columns: 1fr; gap: 0.6rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .metric-tabs { gap: 0.3rem; }
  .metric-tab { padding: 0.35rem 0.55rem; font-size: 0.82rem; }
  .chart-wrap { height: 200px; }
  .field { min-width: 0; }
  .btn-primary, .btn-secondary { width: 100%; text-align: center; }
  .inline-form .btn-secondary { width: auto; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .company-header h1 { font-size: 1.15rem; }
  .chart-wrap { height: 180px; }
  .filings-table { font-size: 0.82rem; }
  .filings-table th, .filings-table td { padding: 0.45rem 0.55rem; }
}

/* ── Disclaimer Bar ── */
.disclaimer-bar {
  background: var(--surface2);
  border-top: 1px solid var(--border);
  text-align: center;
  padding: 0.45rem 1.5rem;
  font-size: 0.78rem;
  color: var(--muted);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.disclaimer-link {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--accent2);
  font-size: 0.78rem;
  font-family: inherit;
  text-decoration: underline;
  padding: 0;
}
.disclaimer-link:hover { color: var(--accent); }

/* ── Disclaimer Modal ── */
.disclaimer-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.disclaimer-modal.is-open { display: flex; }
.disclaimer-modal-box {
  background: var(--bg);
  border-radius: var(--radius);
  max-width: 680px;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
}
.disclaimer-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
.disclaimer-modal-header h2 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
}
.disclaimer-modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
  padding: 0 0.25rem;
}
.disclaimer-modal-close:hover { color: var(--text); }
.disclaimer-modal-body {
  overflow-y: auto;
  padding: 1rem 1.25rem;
  font-size: 0.84rem;
  line-height: 1.65;
  color: var(--text);
}
.disclaimer-modal-body h3 {
  font-size: 0.9rem;
  font-weight: 600;
  margin: 1rem 0 0.35rem;
}
.disclaimer-modal-body p,
.disclaimer-modal-body ul { margin-bottom: 0.6rem; }
.disclaimer-modal-footer {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border);
  text-align: right;
}
.disclaimer-modal-footer button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 5px;
  padding: 0.45rem 1.1rem;
  font-size: 0.85rem;
  cursor: pointer;
  font-family: inherit;
}
.disclaimer-modal-footer button:hover { opacity: 0.85; }
