/* ==========================================================================
   Dividend Research Desk — site styles.
   Clean, neutral, research-oriented. Readable tables, sticky header,
   muted palette, strong number alignment. No flourishes.
   ========================================================================== */

:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --border: #dde1e6;
  --border-strong: #c4cad2;
  --ink: #1c2430;
  --ink-soft: #4a5562;
  --ink-mute: #76808d;
  --accent: #1f5c8a;
  --accent-dark: #16456a;
  --up: #1a7f4b;
  --down: #b22a2a;
  --row-alt: #f3f5f8;
  --row-hover: #eaf1f7;
  --thead-bg: #eef1f5;
  --sort-hover: #e4e9ef;
  --shadow: 0 1px 2px rgba(20, 30, 45, 0.06);
  --radius: 4px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "SF Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --maxw: 1180px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

/* ---- Header / nav ---- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 12px;
  padding-bottom: 12px;
}
.brand { display: flex; flex-direction: column; line-height: 1.2; }
.brand:hover { text-decoration: none; }
.brand-name {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.brand-tag { font-size: 12px; color: var(--ink-mute); }

.topnav { display: flex; flex-wrap: wrap; gap: 2px; }
.topnav a {
  display: inline-block;
  padding: 7px 12px;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius);
}
.topnav a:hover { background: var(--row-hover); text-decoration: none; }
.topnav a.current { color: var(--accent-dark); background: var(--row-hover); }

/* ---- Layout: content + sidebar ---- */
.layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 28px;
  align-items: start;
  padding-top: 24px;
  padding-bottom: 40px;
}
.content { min-width: 0; }
.sidebar { display: flex; flex-direction: column; gap: 18px; }

@media (max-width: 880px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { order: 2; }
}

/* ---- Headings ---- */
h1, h2, h3 { color: var(--ink); line-height: 1.25; }
h1 { font-size: 26px; margin: 0 0 6px; }
h2 { font-size: 20px; margin: 28px 0 10px; }
.page-lede { color: var(--ink-soft); margin: 0 0 20px; font-size: 15px; }
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  border-bottom: 2px solid var(--border-strong);
  padding-bottom: 6px; margin: 26px 0 12px;
}
.section-head h2 { margin: 0; }
.section-head .more { font-size: 13px; }

/* ---- Data tables ---- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 14px;
}
.data-table thead th {
  background: var(--thead-bg);
  text-align: left;
  font-weight: 600;
  font-size: 12.5px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--border-strong);
  padding: 0;
  white-space: nowrap;
}
.data-table thead th .sort,
.data-table thead th { vertical-align: middle; }
.data-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr:nth-child(even) { background: var(--row-alt); }
.data-table tbody tr:hover { background: var(--row-hover); }
.data-table tbody tr:last-child td { border-bottom: 0; }

.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); }
th.num { text-align: right; }

td.empty, .empty { color: var(--ink-mute); text-align: center; font-style: italic; padding: 18px; }

/* sortable header links */
.sort {
  display: block;
  padding: 9px 12px;
  color: var(--ink-soft);
  text-transform: inherit;
  font: inherit;
  font-weight: 600;
}
.sort:hover { background: var(--sort-hover); text-decoration: none; }
.sort.active { color: var(--accent-dark); }
th.num .sort { text-align: right; }
.sort-arrow { margin-left: 4px; font-size: 10px; color: var(--accent); }

/* ticker + company name */
.ticker { font-weight: 600; font-family: var(--mono); }
.co-name { color: var(--ink-soft); margin-left: 8px; font-size: 13px; }

/* dividend + frequency */
.div-amt { font-family: var(--mono); }
.freq {
  display: inline-block;
  min-width: 16px;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-mute);
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  padding: 0 3px;
  margin-left: 4px;
}

/* up/down ---- */
.up { color: var(--up); }
.down { color: var(--down); }
.chg { font-family: var(--mono); white-space: nowrap; }

/* ---- Cards / article feed ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.card h3 { font-size: 16px; margin: 0 0 4px; }
.card .meta { color: var(--ink-mute); font-size: 12.5px; margin: 0 0 6px; }
.card p { margin: 0; color: var(--ink-soft); }

.feed-list { list-style: none; margin: 0; padding: 0; }
.feed-list li { padding: 9px 0; border-bottom: 1px solid var(--border); }
.feed-list li:last-child { border-bottom: 0; }
.feed-list .meta { color: var(--ink-mute); font-size: 12.5px; }

/* ---- Sidebar widgets ---- */
.widget {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}
.widget-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--ink-soft);
  margin: 0 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.widget .note { font-size: 11.5px; color: var(--ink-mute); margin: 8px 0 0; }

.quotes-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.quotes-table th {
  text-align: left; font-size: 11px; text-transform: uppercase;
  color: var(--ink-mute); padding: 2px 4px; border-bottom: 1px solid var(--border);
}
.quotes-table td { padding: 4px; border-bottom: 1px solid var(--row-alt); }
.quotes-table .num { font-family: var(--mono); }

/* email alert forms */
.alert-form { margin-bottom: 12px; }
.alert-form:last-child { margin-bottom: 0; }
.alert-form label {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--ink-soft); margin-bottom: 4px;
}
.alert-form input[type="email"] {
  width: 100%; padding: 7px 8px; font-size: 13px;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  margin-bottom: 6px;
}
.alert-form button, .btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: var(--radius);
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.alert-form button { width: 100%; }
.alert-form button:hover, .btn:hover { background: var(--accent-dark); text-decoration: none; }

.widget-report .report-cta { font-weight: 700; font-size: 15px; margin: 0 0 4px; }
.widget-report .report-sub { font-size: 13px; color: var(--ink-soft); margin: 0 0 10px; }
.widget-covers .covers-body { font-size: 13.5px; color: var(--ink-soft); }
.widget-covers .covers-body p { margin: 0 0 8px; }

/* flash / thank-you */
.flash {
  background: #e8f3ec; border: 1px solid #b9dcc6; color: var(--up);
  padding: 12px 14px; border-radius: var(--radius); margin-bottom: 16px;
}

/* ---- Footer ---- */
.site-footer {
  background: #1c2430;
  color: #aeb6c0;
  margin-top: 40px;
  padding: 28px 0 32px;
  font-size: 13px;
}
.site-footer h4 {
  color: #fff; font-size: 13px; text-transform: uppercase;
  letter-spacing: 0.03em; margin: 0 0 10px;
}
.site-footer a { color: #cdd6e0; }
.site-footer a:hover { color: #fff; }
.footer-cols {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 28px; padding-bottom: 22px; border-bottom: 1px solid #33404f;
}
.footer-links { list-style: none; margin: 0; padding: 0; }
.footer-links li { padding: 3px 0; }
.disclaimer { margin: 18px 0 8px; color: #8a949f; line-height: 1.5; }
.attributions { margin: 0 0 8px; color: #8a949f; }
.copyright { margin: 0; color: #707b87; }

@media (max-width: 720px) {
  .footer-cols { grid-template-columns: 1fr; gap: 18px; }
}

/* ---- Guide + Learning Center (educational content) ---- */
.guide-lead { margin: 8px 0 26px; }
.guide-lead h2 { margin-top: 0; }
.guide-lead .byline {
  color: var(--ink-mute); font-size: 12.5px; margin: 0 0 14px;
  text-transform: uppercase; letter-spacing: 0.03em;
}
.guide-lead p { margin: 0 0 14px; color: var(--ink-soft); line-height: 1.6; }
.guide-lead p strong { color: var(--ink); }

.takeaways {
  background: var(--row-hover); border: 1px solid var(--border);
  border-left: 3px solid var(--accent); border-radius: var(--radius);
  padding: 16px 20px; margin: 0 0 28px;
}
.takeaways h3 {
  margin: 0 0 10px; font-size: 14px; text-transform: uppercase;
  letter-spacing: 0.03em; color: var(--accent-dark);
}
.takeaways ul { margin: 0; padding-left: 20px; }
.takeaways li { margin: 0 0 7px; color: var(--ink-soft); line-height: 1.5; }
.takeaways li:last-child { margin-bottom: 0; }

.numbered-sections { list-style: none; counter-reset: gsec; margin: 0; padding: 0; }
.numbered-section {
  counter-increment: gsec; position: relative;
  padding: 0 0 16px 44px; margin: 0 0 18px;
  border-bottom: 1px solid var(--border);
}
.numbered-section:last-child { border-bottom: 0; margin-bottom: 0; padding-bottom: 0; }
.numbered-section::before {
  content: counter(gsec); position: absolute; left: 0; top: 0;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent); color: #fff;
  font-family: var(--mono); font-size: 14px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.numbered-section h3 { margin: 0 0 6px; font-size: 16px; }
.numbered-section p { margin: 0; color: var(--ink-soft); line-height: 1.6; }

.recommended-reading { margin-top: 26px; }

.crumbs { font-size: 12.5px; color: var(--ink-mute); margin: 0 0 8px; }
.learn-article { margin-bottom: 8px; }
.learn-section { margin: 0 0 18px; }
.learn-section h2 { margin: 22px 0 8px; }
.learn-section p { margin: 0 0 12px; color: var(--ink-soft); line-height: 1.6; }
.learn-section p:last-child { margin-bottom: 0; }

/* ---- DRIP Returns Calculator ---- */
.calc-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 22px;
}
.calc-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.calc-row:last-child { margin-bottom: 0; }
.calc-row > label {
  flex: 0 0 180px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
}
.calc-form input[type="text"] {
  padding: 7px 9px;
  font-size: 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  min-width: 220px;
  text-transform: uppercase;
}
.calc-form select {
  padding: 7px 8px;
  font-size: 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: #fff;
}
.date-group { display: flex; gap: 8px; }
.calc-actions { margin-top: 4px; }
.calc-actions .btn { font-size: 14px; padding: 9px 18px; }

.calc-error {
  background: #fbecec;
  border: 1px solid #e3b9b9;
  color: var(--down);
  padding: 12px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.calc-chart-wrap {
  position: relative;
  height: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 18px;
}
.calc-summary { margin-bottom: 14px; }
.calc-notes {
  font-size: 13.5px;
  color: var(--ink-soft);
  line-height: 1.55;
  margin: 0 0 12px;
}

@media (max-width: 720px) {
  .calc-row { flex-direction: column; align-items: flex-start; gap: 6px; }
  .calc-row > label { flex-basis: auto; }
  .calc-form input[type="text"] { min-width: 0; width: 100%; }
  .date-group { flex-wrap: wrap; }
}

/* ==========================================================================
   Color themes — cycled via the bottom theme bar (persisted in localStorage).
   Light is the :root default; each block overrides the palette variables.
   ========================================================================== */
[data-theme="dark"] {
  --bg: #0f141a; --surface: #1a212a; --border: #2a333e; --border-strong: #3b4654;
  --ink: #e7ecf2; --ink-soft: #b6c0cc; --ink-mute: #8793a0;
  --accent: #4ea3df; --accent-dark: #7cc0ef;
  --up: #3ecf8e; --down: #ec6a6a;
  --row-alt: #1f2730; --row-hover: #243039;
  --thead-bg: #222b35; --sort-hover: #2a3540;
  --shadow: 0 1px 2px rgba(0,0,0,0.40);
}
[data-theme="sepia"] {
  --bg: #f3ead6; --surface: #fbf5e7; --border: #e2d6ba; --border-strong: #ccbd99;
  --ink: #3f3322; --ink-soft: #6a5a40; --ink-mute: #8d7c5d;
  --accent: #9a6321; --accent-dark: #7c4f17;
  --up: #4c7a36; --down: #a83b2a;
  --row-alt: #efe4cb; --row-hover: #ebdec0;
  --thead-bg: #ece0c2; --sort-hover: #e5d6b3;
  --shadow: 0 1px 2px rgba(90,70,30,0.10);
}
[data-theme="slate"] {
  --bg: #161b22; --surface: #1e2530; --border: #2e3742; --border-strong: #41505f;
  --ink: #dfe7ef; --ink-soft: #aab6c4; --ink-mute: #7e8b9a;
  --accent: #6ea8fe; --accent-dark: #93c0ff;
  --up: #57c98a; --down: #e8727f;
  --row-alt: #232c38; --row-hover: #283340;
  --thead-bg: #232c38; --sort-hover: #2b3744;
  --shadow: 0 1px 2px rgba(0,0,0,0.35);
}
[data-theme="contrast"] {
  --bg: #ffffff; --surface: #ffffff; --border: #b0b6bd; --border-strong: #6b727a;
  --ink: #000000; --ink-soft: #1c1c1c; --ink-mute: #44494f;
  --accent: #0b4ea2; --accent-dark: #073a7c;
  --up: #0a6b34; --down: #9e1414;
  --row-alt: #f0f2f4; --row-hover: #e2e8f0;
  --thead-bg: #e6e9ed; --sort-hover: #d8dee6;
  --shadow: 0 1px 2px rgba(0,0,0,0.12);
}

/* ---- Theme switcher bar (docked bottom-center) ---- */
.theme-bar {
  position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%);
  z-index: 200; display: flex; align-items: center; gap: 7px;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 999px; padding: 6px 12px; box-shadow: 0 2px 12px rgba(0,0,0,0.20);
}
.theme-bar .tb-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--ink-mute); margin-right: 2px;
}
.theme-bar button {
  width: 22px; height: 22px; border-radius: 50%; cursor: pointer; padding: 0;
  border: 2px solid transparent; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.18);
  transition: transform 0.1s ease;
}
.theme-bar button:hover { transform: scale(1.14); }
.theme-bar button.active { border-color: var(--accent); }
.theme-bar .sw-light    { background: #f7f8fa; }
.theme-bar .sw-dark     { background: #0f141a; }
.theme-bar .sw-sepia    { background: #f3ead6; }
.theme-bar .sw-slate    { background: #161b22; box-shadow: inset 0 0 0 1px #3a4a5a; }
.theme-bar .sw-contrast { background: #ffffff; box-shadow: inset 0 0 0 1px #000; }
@media (max-width: 600px) { .theme-bar .tb-label { display: none; } }
