/* ═══════════════════════════════════════════════════════════════
   Corporate Finance Fundamentals — styles.css
   RequestNotes Design System — Dark Default + Light Mode
═══════════════════════════════════════════════════════════════ */

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body { font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; line-height: 1.6; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }

/* ── Theme Tokens — Dark Default ── */
:root {
  --bg:            #09090b;
  --surface:       #111113;
  --card:          #18181b;
  --border:        #27272a;
  --border-light:  #3f3f46;
  --text:          #fafafa;
  --muted:         #a1a1aa;
  --dim:           #52525b;
  --accent:        #6366f1;
  --accent2:       #818cf8;
  --accent3:       #a5b4fc;
  --green:         #22c55e;
  --amber:         #f59e0b;
  --coral:         #f97316;
  --pink:          #ec4899;
  --teal:          #14b8a6;
  --shadow:        0 1px 3px rgba(0,0,0,0.4);
  --shadow-md:     0 4px 12px rgba(0,0,0,0.5);
  --radius:        6px;
  --radius-md:     8px;
  --radius-lg:     12px;
  --topbar-height: 40px;
}

/* ── Light Mode ── */
.light {
  --bg:           #fafaf9;
  --surface:      #f4f4f5;
  --card:         #ffffff;
  --border:       #e4e4e7;
  --border-light: #d4d4d8;
  --text:         #09090b;
  --muted:        #52525b;
  --dim:          #a1a1aa;
  --shadow:       0 1px 3px rgba(0,0,0,0.06);
  --shadow-md:    0 4px 12px rgba(0,0,0,0.08);
}

body { background: var(--bg); color: var(--text); transition: background-color 0.2s ease, color 0.2s ease; }

/* ── Topbar ── */
.site-topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--topbar-height);
  background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
}
.topbar-inner { width: 100%; padding: 0 16px; display: flex; align-items: center; gap: 12px; }
.topbar-brand { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; flex-shrink: 0; }
.topbar-logo-mark { width: 22px; height: 22px; background: var(--accent); color: #fff; border-radius: 5px; display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700; }
.topbar-logo-text { color: var(--text); }
.topbar-breadcrumb { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); flex: 1; overflow: hidden; }
.topbar-bc-link { color: var(--muted); transition: color .15s ease; }
.topbar-bc-link:hover { color: var(--text); }
.topbar-bc-sep { color: var(--dim); }
.topbar-bc-current { color: var(--text); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-theme-toggle { margin-left: auto; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; color: var(--muted); border-radius: var(--radius); transition: all .15s ease; flex-shrink: 0; }
.topbar-theme-toggle:hover { color: var(--text); background: rgba(255,255,255,.05); }
.light .topbar-theme-toggle:hover { background: rgba(0,0,0,.05); }
.topbar-theme-toggle .icon-light { display: none; }
.topbar-theme-toggle .icon-dark  { display: inline; }
.light .topbar-theme-toggle .icon-dark  { display: none; }
.light .topbar-theme-toggle .icon-light { display: inline; }
.topbar-request { font-size: 11px; font-weight: 500; padding: 4px 10px; background: var(--accent); color: #fff; border-radius: var(--radius); white-space: nowrap; flex-shrink: 0; transition: opacity .15s ease; }
.topbar-request:hover { opacity: .85; }

/* ── App Layout ── */
.app-layout { display: flex; height: calc(100vh - var(--topbar-height)); margin-top: var(--topbar-height); overflow: hidden; }

/* ── Sidebar ── */
.sidebar { width: 240px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; height: calc(100vh - var(--topbar-height)); }
.sidebar-label { padding: 12px 14px 8px; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--dim); flex-shrink: 0; }
#toc-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding-bottom: 8px; }
#toc-nav::-webkit-scrollbar { width: 3px; }
#toc-nav::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 2px; }
#toc-nav::-webkit-scrollbar-track { background: transparent; }

a.toc-header { display: flex; align-items: center; gap: 8px; padding: 7px 14px; font-size: 13px; color: var(--muted); text-decoration: none; transition: all .15s ease; cursor: pointer; }
a.toc-header:hover { color: var(--text); background: rgba(255,255,255,.04); }
.light a.toc-header:hover { background: rgba(0,0,0,.04); }
a.toc-header.active { color: var(--accent); background: rgba(99,102,241,.07); border-left: 2px solid var(--accent); }
.toc-icon { font-size: 13px; flex-shrink: 0; }
.toc-label { flex: 1; }
.toc-chevron { font-size: 9px; color: var(--dim); transition: transform .2s ease; flex-shrink: 0; }
.toc-item.open .toc-chevron { transform: rotate(90deg); }
.toc-subs { display: none; }
.toc-item.open .toc-subs { display: block; }
a.toc-sub { display: block; padding: 5px 14px 5px 35px; font-size: 12px; color: var(--dim); text-decoration: none; transition: all .15s ease; }
a.toc-sub:hover { color: var(--muted); background: rgba(255,255,255,.02); }
.light a.toc-sub:hover { background: rgba(0,0,0,.02); }
a.toc-sub.active { color: var(--accent2); }

/* Progress */
.sidebar-footer { padding: 10px 14px; border-top: 1px solid var(--border); flex-shrink: 0; }
.progress-meta { display: flex; justify-content: space-between; font-size: 11px; color: var(--dim); margin-bottom: 5px; }
.progress-bar { height: 2px; background: var(--border); border-radius: 2px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 2px; width: 0%; transition: width .4s ease; }

/* ── Main Content ── */
.main-content { flex: 1; overflow-y: auto; height: calc(100vh - var(--topbar-height)); }
.main-content::-webkit-scrollbar { width: 6px; }
.main-content::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
.main-content::-webkit-scrollbar-track { background: transparent; }
.main-header { padding: 16px 48px 0; max-width: 960px; margin: 0 auto; }
.breadcrumb { font-size: 12px; color: var(--dim); padding-bottom: 12px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.breadcrumb .bc-active { color: var(--muted); }
#content-area { max-width: 960px; margin: 0 auto; padding: 0 48px 80px; }

/* ── Content ── */
.content-container { }
.content-container h2 { font-size: 26px; font-weight: 700; color: var(--text); margin: 28px 0 6px; line-height: 1.25; }
.content-container h3 { font-size: 18px; font-weight: 600; color: var(--text); margin: 28px 0 10px; }
.content-container h4 { font-size: 12px; font-weight: 600; color: var(--muted); margin: 20px 0 8px; text-transform: uppercase; letter-spacing: .04em; }
.content-container p { color: var(--muted); font-size: 14.5px; line-height: 1.75; margin-bottom: 14px; }
.content-container ul, .content-container ol { color: var(--muted); font-size: 14.5px; line-height: 1.75; padding-left: 20px; margin-bottom: 14px; }
.content-container li { margin-bottom: 4px; }
.content-container strong { color: var(--text); font-weight: 600; }
.content-container em { color: var(--accent3); font-style: normal; font-weight: 500; }
.body-text { color: var(--muted); font-size: 14.5px; line-height: 1.75; margin-bottom: 14px; }

/* ── Difficulty Badge ── */
.difficulty-badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; margin-bottom: 20px; border: 1px solid transparent; }
.difficulty-badge.beginner     { background: rgba(34,197,94,.1);  border-color: rgba(34,197,94,.25);  color: #22c55e; }
.difficulty-badge.intermediate { background: rgba(245,158,11,.1); border-color: rgba(245,158,11,.25); color: #f59e0b; }
.difficulty-badge.advanced     { background: rgba(249,115,22,.1); border-color: rgba(249,115,22,.25); color: #f97316; }
.difficulty-badge.expert       { background: rgba(239,68,68,.1);  border-color: rgba(239,68,68,.25);  color: #ef4444; }

/* ── Callout Boxes ── */
.callout { padding: 14px 18px; border-radius: var(--radius-md); border-left: 3px solid; margin: 20px 0; font-size: 14px; }
.callout p { margin-bottom: 0; font-size: 14px; }
.callout-info    { background: rgba(99,102,241,.07);  border-color: var(--accent); color: var(--muted); }
.callout-warning { background: rgba(245,158,11,.07);  border-color: var(--amber);  color: var(--muted); }
.callout-success { background: rgba(34,197,94,.07);   border-color: var(--green);  color: var(--muted); }
.callout-danger  { background: rgba(249,115,22,.07);  border-color: var(--coral);  color: var(--muted); }
.callout-teal    { background: rgba(20,184,166,.07);  border-color: var(--teal);   color: var(--muted); }
.callout strong  { color: var(--text); }
.callout ul { padding-left: 18px; margin-top: 6px; }
.callout li { margin-bottom: 4px; font-size: 14px; }

/* ── Formula Block ── */
.formula-block { background: var(--card); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: var(--radius-md); padding: 16px 20px; margin: 20px 0; }
.formula-label { font-size: 10px; text-transform: uppercase; letter-spacing: .07em; color: var(--dim); margin-bottom: 8px; font-weight: 600; }
.formula-body { font-size: 16px; color: var(--text); font-style: italic; line-height: 1.6; }
.formula-vars { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.formula-vars p { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.formula-vars code { color: var(--accent3); background: rgba(99,102,241,.1); padding: 1px 5px; border-radius: 3px; font-size: 12px; }

/* ── Stat Cards ── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin: 24px 0 32px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-top: 3px solid var(--accent); border-radius: var(--radius-md); padding: 16px 18px; }
.stat-value { font-size: clamp(14px, 1.5vw, 20px); font-weight: 700; color: var(--sv-color, var(--accent2)); line-height: 1.3; margin-bottom: 4px; }
.stat-label { font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; margin-bottom: 6px; }
.stat-desc  { font-size: 12px; color: var(--muted); line-height: 1.5; }

/* ── Data Tables ── */
.table-wrapper { overflow-x: auto; margin: 20px 0; border-radius: var(--radius-md); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead { background: var(--card); }
th { padding: 10px 14px; text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--border); }
td { padding: 10px 14px; color: var(--muted); border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,.02); }
.light tr:hover td { background: rgba(0,0,0,.02); }
td strong { color: var(--text); }
.td-green  { color: var(--green) !important; }
.td-coral  { color: var(--coral) !important; }
.td-amber  { color: var(--amber) !important; }
.td-teal   { color: var(--teal) !important; }
.td-accent { color: var(--accent2) !important; }

/* ── Code Blocks ── */
.code-block { background: #18181b; border: 1px solid #27272a; border-radius: var(--radius-md); margin: 20px 0; overflow: hidden; }
.light .code-block { background: #18181b; border-color: #27272a; }
.code-header { background: #111113; padding: 8px 14px; border-bottom: 1px solid #27272a; font-size: 11px; color: #71717a; font-weight: 600; }
.code-block code { display: block; padding: 14px 16px; font-family: 'Cascadia Code','Fira Code',Consolas,monospace; font-size: 13px; line-height: 1.7; color: #fafafa; white-space: pre; overflow-x: auto; }

/* ── Content Tabs ── */
.tabs-wrapper { margin: 20px 0; border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
.tabs-header { display: flex; background: var(--card); border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab-btn { padding: 9px 18px; font-size: 13px; font-weight: 500; color: var(--muted); white-space: nowrap; border-bottom: 2px solid transparent; transition: all .15s ease; }
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); background: rgba(99,102,241,.05); }
.tab-panels { }
.tab-panel { display: none; padding: 20px; }
.tab-panel.active { display: block; }
.tab-panel p { color: var(--muted); font-size: 14px; line-height: 1.7; margin-bottom: 10px; }
.tab-panel p:last-child { margin-bottom: 0; }
.tab-panel ul { color: var(--muted); font-size: 14px; padding-left: 18px; line-height: 1.7; }

/* ── Country Tabs ── */
.country-tabs { margin: 20px 0; border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
.country-tab-btns { display: flex; flex-wrap: wrap; background: var(--surface); border-bottom: 1px solid var(--border); }
.country-tab-btn { padding: 7px 14px; font-size: 12px; font-weight: 500; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; transition: all .15s ease; }
.country-tab-btn:hover { color: var(--text); }
.country-tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); background: rgba(99,102,241,.04); }
.country-tab-panel { display: none; padding: 18px 20px; }
.country-tab-panel.active { display: block; }
.country-tab-panel p { color: var(--muted); font-size: 13.5px; line-height: 1.7; margin-bottom: 8px; }
.country-tab-panel ul { color: var(--muted); font-size: 13.5px; padding-left: 18px; line-height: 1.7; margin-bottom: 8px; }
.country-tab-panel strong { color: var(--text); }

/* ── Expand/Collapse ── */
.expand-trigger { display: flex; align-items: center; gap: 8px; padding: 12px 16px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-md); font-size: 14px; color: var(--text); width: 100%; cursor: pointer; margin: 12px 0; transition: background .15s ease; }
.expand-trigger:hover { background: rgba(99,102,241,.06); }
.expand-trigger::before { content: '▶'; font-size: 9px; color: var(--dim); transition: transform .2s ease; }
.expand-trigger.open::before { transform: rotate(90deg); }
.expand-content { display: none; padding: 14px 16px; border: 1px solid var(--border); border-top: none; border-radius: 0 0 var(--radius-md) var(--radius-md); background: var(--bg); margin-top: -12px; margin-bottom: 12px; font-size: 14px; color: var(--muted); line-height: 1.75; }
.expand-content.open { display: block; }
.expand-content p { margin-bottom: 10px; font-size: 14px; }
.expand-content ul { padding-left: 18px; margin-bottom: 10px; }

/* ── Subtopic Nav Strip ── */
.subtopic-nav { margin-top: 36px; padding: 14px 0 10px; border-top: 1px solid var(--border); }
.subtopic-nav-label { display: block; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--dim); margin-bottom: 8px; }
.subtopic-nav-links { display: flex; flex-wrap: wrap; gap: 6px; }
.subtopic-nav-link { display: inline-block; padding: 4px 10px; border-radius: 4px; font-size: 12px; color: var(--muted); background: var(--surface); border: 1px solid var(--border); text-decoration: none; transition: color .15s, border-color .15s; cursor: pointer; }
.subtopic-nav-link:hover { color: var(--text); border-color: var(--accent); }
.subtopic-nav-link.active { color: var(--accent); border-color: var(--accent); background: rgba(99,102,241,.07); font-weight: 500; pointer-events: none; }

/* ── Prev / Next Footer ── */
.topic-nav-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); flex-wrap: wrap; gap: 8px; }
.topic-nav-prev, .topic-nav-next { font-size: 13px; color: var(--accent2); text-decoration: none; transition: color .15s; }
.topic-nav-prev:hover, .topic-nav-next:hover { color: var(--accent); }
.topic-nav-next { margin-left: auto; }

/* ── Quiz ── */
.quiz-question { margin-bottom: 24px; }
.quiz-q { font-size: 14.5px; color: var(--text); font-weight: 500; margin-bottom: 10px; line-height: 1.6; }
.quiz-options { display: flex; flex-direction: column; gap: 6px; }
.quiz-opt { text-align: left; padding: 9px 14px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-md); font-size: 13.5px; color: var(--muted); transition: all .15s ease; }
.quiz-opt:hover { border-color: var(--accent2); color: var(--text); }
.quiz-question.answered .quiz-opt { pointer-events: none; }
.quiz-opt.correct { background: rgba(34,197,94,.1); border-color: var(--green); color: var(--green); }
.quiz-opt.wrong   { background: rgba(249,115,22,.1); border-color: var(--coral); color: var(--coral); }
.quiz-explain { display: none; margin-top: 10px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); font-size: 13.5px; color: var(--muted); line-height: 1.65; }
.quiz-question.answered .quiz-explain { display: block; }

/* ── Mini Quiz Section ── */
.mini-quiz-section { margin-top: 40px; padding-top: 32px; border-top: 1px solid var(--border); }
.mini-quiz-section h3 { margin-bottom: 4px; }
.mini-quiz-block { margin-bottom: 32px; }
.mini-quiz-block h4, .knowledge-check-block h4 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 16px; }

/* ── Topic Quick Check ── */
.topic-quick-check { margin-top: 40px; padding-top: 32px; border-top: 1px solid var(--border); }
.topic-quick-check h3 { margin-bottom: 4px; }

/* ── Knowledge Check Items ── */
.kc-item { border: 1px solid var(--border); border-radius: var(--radius-md); margin-bottom: 10px; overflow: hidden; }
.kc-question { width: 100%; display: flex; justify-content: space-between; align-items: flex-start; padding: 12px 16px; background: var(--surface); border: none; cursor: pointer; text-align: left; gap: 12px; }
.kc-question:hover { background: rgba(99,102,241,.05); }
.light .kc-question:hover { background: rgba(99,102,241,.04); }
.kc-q-text { font-size: 14px; color: var(--text); font-weight: 500; line-height: 1.5; }
.kc-toggle { font-size: 11px; color: var(--muted); flex-shrink: 0; margin-top: 3px; transition: transform .2s ease; }
.kc-item.open .kc-toggle { transform: rotate(180deg); }
.kc-answer { display: none; padding: 14px 16px; border-top: 1px solid var(--border); background: var(--bg); font-size: 14px; line-height: 1.65; color: var(--text); }
.kc-item.open .kc-answer { display: block; }
.kc-answer p { color: var(--muted); font-size: 14px; margin-bottom: 8px; }
.kc-answer strong { color: var(--text); }
.kc-answer ul { color: var(--muted); font-size: 14px; padding-left: 18px; margin-bottom: 8px; }

/* ── Cheatsheet ── */
.cheatsheet-section { margin-bottom: 36px; }
.cheatsheet-section:last-child { margin-bottom: 0; }
.cheatsheet-section > h3 { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); border-left: 3px solid var(--accent); padding-left: 10px; margin-bottom: 16px; }
.cs-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
.cs-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
@media (max-width: 700px) { .cs-grid-2, .cs-grid-3 { grid-template-columns: 1fr; } }
.cs-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 14px 16px; }
.cs-card-title { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--accent2); padding-bottom: 8px; margin-bottom: 10px; border-bottom: 1px solid var(--border); }
.cs-items { display: flex; flex-direction: column; gap: 5px; }
.cs-items span { font-size: 12.5px; color: var(--muted); line-height: 1.5; padding-bottom: 5px; border-bottom: 1px solid var(--border); }
.cs-items span:last-child { border-bottom: none; padding-bottom: 0; }
.cs-formula-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-bottom: 16px; }
.cs-formula-card { background: var(--card); border: 1px solid var(--border); border-top: 3px solid var(--accent); border-radius: var(--radius-md); padding: 14px 16px; }
.cs-f-name { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--accent2); margin-bottom: 8px; }
.cs-f-formula { font-family: 'Cascadia Code','Fira Code',Consolas,monospace; font-size: 13px; color: var(--text); background: var(--surface); padding: 6px 10px; border-radius: var(--radius); margin-bottom: 8px; }
.cs-f-note { font-size: 12px; color: var(--dim); line-height: 1.5; }
.cs-formula-compact { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; margin-bottom: 16px; }
.cs-fc-row { display: grid; grid-template-columns: 220px 28px 1fr; align-items: center; padding: 8px 14px; border-bottom: 1px solid var(--border); font-size: 12.5px; }
.cs-fc-row:last-child { border-bottom: none; }
.cs-fc-row:nth-child(odd) { background: var(--surface); }
.cs-fc-name { color: var(--muted); font-weight: 600; }
.cs-fc-eq { color: var(--dim); text-align: center; }
.cs-fc-formula { font-family: 'Cascadia Code','Fira Code',Consolas,monospace; color: var(--accent2); }

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-header { padding: 12px 16px 0; }
  #content-area { padding: 0 16px 60px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
