/* AFX Trading Academy brand palette (matched to afxtrading.eu) */
:root {
  --bg: #030603;
  --bg-elev-1: #070b07;
  --bg-elev-2: #0c120c;
  --bg-elev-3: #141c14;
  --border: #202820;
  --border-soft: #16201a;
  --text: #f4f4f5;
  --text-dim: #a1a1aa;
  --text-faint: #71717a;
  --accent: #8cff24;
  --accent-strong: #a6ff54;
  --accent-dim: #2f4a1a;
  --accent-bg: rgba(140, 255, 36, 0.12);
  --green: #8cff24;
  --red: #ff5c5c;
  --blue: #5ce1ff;
  --purple: #c084fc;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
  --glow: 0 0 0 1px rgba(140, 255, 36, 0.14), 0 0 24px rgba(140, 255, 36, 0.08);
  --font: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

/* Brand is intentionally dark-only (matches afxtrading.eu identity) */
:root[data-theme="light"] {
  --bg: #030603;
  --bg-elev-1: #070b07;
  --bg-elev-2: #0c120c;
  --bg-elev-3: #141c14;
  --border: #202820;
  --border-soft: #16201a;
  --text: #f4f4f5;
  --text-dim: #a1a1aa;
  --text-faint: #71717a;
  --accent: #8cff24;
  --accent-strong: #a6ff54;
  --accent-bg: rgba(140, 255, 36, 0.12);
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  max-width: 100%;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-strong); }
h1, h2, h3, h4 { font-weight: 650; letter-spacing: -0.01em; margin: 0 0 .5em; }
p { margin: 0 0 1em; }
.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
code, pre { font-family: var(--font-mono); }
::selection { background: var(--accent-bg); }

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
input, select, textarea {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--text);
  padding: 9px 16px;
  font-weight: 550;
  cursor: pointer;
  transition: all .12s ease;
}
.btn:hover { background: var(--bg-elev-3); border-color: var(--accent-dim); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #04120a; font-weight: 700; box-shadow: 0 0 20px rgba(140, 255, 36, 0.35); }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); box-shadow: 0 0 26px rgba(140, 255, 36, 0.5); }
.btn-danger { border-color: var(--red); color: var(--red); background: transparent; }
.btn-danger:hover { background: rgba(248, 113, 113, 0.1); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--bg-elev-2); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.card {
  background: var(--bg-elev-1);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 20px;
}

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; font-weight: 650; letter-spacing: .02em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 999px;
  background: var(--bg-elev-3); color: var(--text-dim);
  border: 1px solid var(--border);
}
.badge-accent { background: var(--accent-bg); color: var(--accent-strong); border-color: var(--accent-dim); }
.badge-green { background: rgba(74, 222, 128, .12); color: var(--green); border-color: rgba(74,222,128,.3); }
.badge-red { background: rgba(248, 113, 113, .12); color: var(--red); border-color: rgba(248,113,113,.3); }
.badge-blue { background: rgba(96, 165, 250, .12); color: var(--blue); border-color: rgba(96,165,250,.3); }
.badge-purple { background: rgba(192, 132, 252, .12); color: var(--purple); border-color: rgba(192,132,252,.3); }

/* ---------- Auth pages ---------- */
.auth-body {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 20% 10%, var(--accent-bg), transparent 40%), var(--bg);
  padding: 24px;
}
.auth-card {
  width: 100%; max-width: 400px;
  background: var(--bg-elev-1); border: 1px solid var(--border-soft);
  border-radius: 14px; padding: 36px 32px; box-shadow: var(--shadow);
}
.auth-logo {
  display: flex; align-items: center; gap: 10px; margin-bottom: 24px;
}
.auth-logo .mark {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; filter: drop-shadow(0 0 8px rgba(140, 255, 36, 0.35));
}
.auth-logo .mark img { width: 100%; height: 100%; object-fit: contain; }
.auth-logo .name { font-weight: 700; font-size: 17px; }
.auth-logo .sub { font-size: 11px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .08em; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12.5px; color: var(--text-dim); margin-bottom: 6px; font-weight: 600; }
.field input { width: 100%; }
.form-error {
  background: rgba(248,113,113,.1); border: 1px solid rgba(248,113,113,.3); color: var(--red);
  padding: 10px 12px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 16px; display: none;
}
.form-error.show { display: block; }
.form-hint { font-size: 12px; color: var(--text-faint); margin-top: 6px; }

/* ---------- App shell ---------- */
.app-shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--bg-elev-1); border-right: 1px solid var(--border-soft);
  padding: 18px 12px; display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 8px 10px 20px; }
.sidebar-brand .mark {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; filter: drop-shadow(0 0 6px rgba(140, 255, 36, 0.3));
}
.sidebar-brand .mark img { width: 100%; height: 100%; object-fit: contain; }
.sidebar-brand .name { font-weight: 700; font-size: 15px; }
.nav-section { margin-top: 14px; margin-bottom: 4px; padding: 0 10px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-faint); font-weight: 700; }
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--text-dim); font-size: 13.5px; font-weight: 550; cursor: pointer;
}
.nav-link .ic { width: 18px; text-align: center; opacity: .85; }
.nav-link:hover { background: var(--bg-elev-2); color: var(--text); }
.nav-link.active { background: var(--accent-bg); color: var(--accent-strong); }
.sidebar-footer { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border-soft); }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--radius-sm); }
.user-chip .avatar {
  width: 26px; height: 26px; border-radius: 50%; background: var(--bg-elev-3); color: var(--text);
  display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700;
}
.user-chip .meta { display: flex; flex-direction: column; line-height: 1.2; }
.user-chip .meta .n { font-size: 12.5px; font-weight: 650; }
.user-chip .meta .r { font-size: 10.5px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .04em; }

.main { padding: 24px 32px 60px; max-width: 1180px; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; gap: 16px; flex-wrap: wrap; }
.page-title { font-size: 22px; font-weight: 700; margin: 0; }
.page-subtitle { color: var(--text-dim); font-size: 13.5px; margin-top: 2px; }

/* Mobile top bar + sidebar drawer (see @media 900px below for the drawer itself) */
.mobile-topbar {
  display: none; align-items: center; gap: 12px; padding: 12px 16px;
  background: var(--bg-elev-1); border-bottom: 1px solid var(--border-soft);
  position: sticky; top: 0; z-index: 500;
}
.hamburger-btn {
  background: transparent; border: 1px solid var(--border); color: var(--text);
  width: 38px; height: 38px; border-radius: var(--radius-sm); font-size: 17px; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.hamburger-btn:active { background: var(--bg-elev-2); }
.mobile-brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14.5px; }
.mobile-brand img { width: 26px; height: 26px; border-radius: 50%; object-fit: contain; }
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 1199; }
.sidebar-backdrop.show { display: block; }

.lang-switcher { display: flex; gap: 4px; }
.lang-btn {
  background: transparent; border: 1px solid var(--border); color: var(--text-dim);
  font-size: 11.5px; font-weight: 700; letter-spacing: .03em; padding: 5px 9px; border-radius: 999px;
  cursor: pointer;
}
.lang-btn:hover { color: var(--text); border-color: var(--text-faint); }
.lang-btn.active { background: var(--accent-bg); color: var(--accent-strong); border-color: var(--accent-dim); }
.lang-switcher-mobile { margin-left: auto; }
.lang-switcher-sidebar { padding: 0 10px 14px; }

.search-box { position: relative; flex: 1; max-width: 420px; }
.search-box input { width: 100%; padding-left: 34px; }
.search-box .ic { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-faint); }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; }
  .app-shell { grid-template-columns: 1fr; }
  .mobile-topbar { display: flex; }
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; width: 260px; max-width: 82vw;
    transform: translateX(-100%); transition: transform .22s ease; z-index: 1200; box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
}
@media (max-width: 560px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } .main { padding: 16px; } }

.stat-tile { display: flex; flex-direction: column; gap: 6px; }
.stat-tile .label { font-size: 12px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .05em; font-weight: 650; }
.stat-tile .value { font-size: 28px; font-weight: 750; }
.stat-tile .sub { font-size: 12.5px; color: var(--text-dim); }

.progress-bar { height: 8px; border-radius: 999px; background: var(--bg-elev-3); overflow: hidden; }
.progress-bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-strong)); border-radius: 999px; }

.chapter-list { display: flex; flex-direction: column; gap: 8px; }
.chapter-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-elev-1); border: 1px solid var(--border-soft); border-radius: var(--radius-sm);
  padding: 12px 14px; cursor: pointer; transition: border-color .12s ease, background .12s ease;
}
.chapter-row:hover { border-color: var(--text-faint); background: var(--bg-elev-2); }
.chapter-row .num { width: 34px; text-align: center; font-family: var(--font-mono); font-size: 12px; color: var(--text-faint); flex-shrink: 0; }
.chapter-row .body { flex: 1; min-width: 0; }
.chapter-row .t { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chapter-row .c { font-size: 12px; color: var(--text-faint); margin-top: 2px; }
.chapter-row .check { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--border); flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.chapter-row .check.done { background: var(--green); border-color: var(--green); color: #04220f; }

.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.filter-bar select { padding: 7px 10px; font-size: 13px; }
.chip-btn {
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--bg-elev-2);
  font-size: 12.5px; font-weight: 600; cursor: pointer; color: var(--text-dim);
}
.chip-btn.active { background: var(--accent-bg); color: var(--accent-strong); border-color: var(--accent-dim); }

/* Study page */
.study-layout { display: grid; grid-template-columns: 1fr 260px; gap: 24px; align-items: start; }
@media (max-width: 1000px) { .study-layout { grid-template-columns: 1fr; } }
.study-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.study-title { font-size: 24px; font-weight: 750; margin: 6px 0 4px; }
.study-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.section-block { margin-bottom: 26px; }
.section-block h3 { font-size: 14px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint); margin-bottom: 10px; }
.prose { line-height: 1.7; font-size: 14.5px; }
.prose h2 { font-size: 17px; margin-top: 22px; }
.prose ul, .prose ol { padding-left: 22px; }
.prose li { margin-bottom: 6px; }
.prose strong { color: var(--text); }
.list-plain { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.list-plain li { padding: 10px 12px; background: var(--bg-elev-2); border-radius: var(--radius-sm); font-size: 13.5px; border-left: 3px solid var(--accent-dim); }
.list-plain.mistakes li { border-left-color: var(--red); }
.list-plain.checklist li { display: flex; align-items: flex-start; gap: 8px; border-left-color: var(--green); }
.def-item { padding: 10px 12px; background: var(--bg-elev-2); border-radius: var(--radius-sm); margin-bottom: 8px; }
.def-item .term { font-weight: 700; color: var(--accent-strong); font-size: 13.5px; }
.def-item .def { font-size: 13.5px; color: var(--text-dim); margin-top: 2px; }

.flashcard {
  background: var(--bg-elev-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; min-height: 110px; display: flex; align-items: center; justify-content: center;
  text-align: center; cursor: pointer; font-size: 14.5px; user-select: none;
}
.flashcard .tag { position: absolute; }

.side-panel { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 24px; }
.side-card h4 { font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint); margin-bottom: 10px; }
.notes-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.note-item { background: var(--bg-elev-2); border-radius: var(--radius-sm); padding: 8px 10px; font-size: 13px; position: relative; }
.note-item .del { position: absolute; top: 6px; right: 8px; cursor: pointer; color: var(--text-faint); font-size: 12px; }

.qa-item { background: var(--bg-elev-2); border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 8px; font-size: 13.5px; }
.qa-item .q { font-weight: 600; }
.qa-item .a { color: var(--text-dim); margin-top: 6px; display: none; }
.qa-item.revealed .a { display: block; }
.qa-item .reveal { color: var(--accent); font-size: 12px; cursor: pointer; margin-top: 6px; }

/* Compare mode */
.compare-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0; border: 1px solid var(--border-soft); border-radius: var(--radius); overflow: hidden; }
.compare-col { padding: 18px; }
.compare-col.y2024 { background: var(--bg-elev-1); border-right: 1px solid var(--border-soft); }
.compare-col.y2025 { background: var(--bg-elev-1); }
.compare-col h4 { font-size: 12px; text-transform: uppercase; color: var(--text-faint); margin-bottom: 10px; }
@media (max-width: 800px) { .compare-grid { grid-template-columns: 1fr; } .compare-col.y2024 { border-right: none; border-bottom: 1px solid var(--border-soft); } }

/* Table */
table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data-table th { text-align: left; color: var(--text-faint); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px; border-bottom: 1px solid var(--border); }
table.data-table td { padding: 10px; border-bottom: 1px solid var(--border-soft); }
table.data-table tr:hover td { background: var(--bg-elev-2); }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-faint); }
.toast {
  position: fixed; bottom: 24px; right: 24px; background: var(--bg-elev-3); border: 1px solid var(--border);
  padding: 12px 18px; border-radius: var(--radius-sm); box-shadow: var(--shadow); font-size: 13.5px;
  opacity: 0; transform: translateY(10px); transition: all .2s ease; pointer-events: none; z-index: 999;
}
.toast.show { opacity: 1; transform: translateY(0); }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); display: none; align-items: center; justify-content: center; z-index: 1000; padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal-box { background: var(--bg-elev-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; width: 100%; max-width: 460px; box-shadow: var(--shadow); }
.modal-box h3 { margin-bottom: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border-soft); margin-bottom: 18px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab-btn { padding: 10px 14px; font-size: 13.5px; font-weight: 600; color: var(--text-dim); cursor: pointer; border-bottom: 2px solid transparent; flex-shrink: 0; white-space: nowrap; }
.tab-btn.active { color: var(--accent-strong); border-bottom-color: var(--accent); }

/* Chart image gallery */
.chart-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.chart-thumb {
  position: relative; aspect-ratio: 4/3; border-radius: var(--radius-sm); overflow: hidden;
  border: 1px solid var(--border); background: var(--bg-elev-2); cursor: zoom-in;
}
.chart-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .15s ease; }
.chart-thumb:hover img { transform: scale(1.05); }
.chart-thumb .num { position: absolute; bottom: 4px; right: 6px; font-size: 10.5px; background: rgba(0,0,0,.55); color: #fff; padding: 1px 6px; border-radius: 999px; }
.chart-thumb .tag { position: absolute; top: 4px; left: 4px; font-size: 10.5px; font-weight: 700; background: rgba(140,255,36,.92); color: #04120a; padding: 1px 7px; border-radius: 999px; max-width: calc(100% - 10px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lightbox-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.85); display: none; align-items: center; justify-content: center;
  z-index: 1100; padding: 30px; flex-direction: column; gap: 14px;
}
.lightbox-overlay.show { display: flex; }
.lightbox-overlay img { max-width: 100%; max-height: 78vh; border-radius: var(--radius); box-shadow: var(--shadow); }
.lightbox-nav { display: flex; gap: 10px; align-items: center; color: #fff; }
.lightbox-close { position: absolute; top: 20px; right: 24px; color: #fff; font-size: 24px; cursor: pointer; background: none; border: none; }
