/* ============================================================
   DAY / NIGHT THEME
   Light is the default (tokens live in style.css :root).
   Dark mode is opt-in via <html data-theme="dark"> and simply
   remaps the design tokens — the rest of the UI is token-driven
   so it follows automatically. A few targeted overrides handle
   surfaces that hardcode white or reuse --green-deep as a
   background (sidebar, green stat card, popups, form fields).
   Persistence: a long-lived "ebb_theme" cookie (survives the
   localStorage.clear() that logout performs). Applied pre-paint
   by a tiny inline script in each page <head> to avoid a flash.
   ============================================================ */

/* ---- Toggle in sidebar menu (Account section) ---- */
.menu-theme-toggle{
  display:flex;align-items:center;gap:12px;padding:11px 14px;border-radius:9px;
  color:rgba(255,255,255,.82);font-weight:500;font-size:14px;transition:.25s;
  cursor:pointer;
}
.menu-theme-toggle:hover{background:rgba(255,255,255,.08);color:#fff}
.menu-theme-toggle .ico{width:22px;display:grid;place-items:center;color:var(--green-mint);font-size:13px}
.sidebar .menu-theme-toggle:hover .ico{color:#fff}

/* ============================================================
   DARK THEME TOKENS
   ============================================================ */
html[data-theme="dark"]{
  --bg:#0F140F;
  --bg-2:#131A13;
  --bg-3:#182018;
  --paper:#141C15;

  --ink:#E9ECE0;
  --ink-2:#C6CCB8;
  --muted:#93997F;

  --line:rgba(160,168,140,0.14);
  --line-strong:rgba(160,168,140,0.28);

  --green:#7FA989;
  --green-2:#96BC9E;
  --green-soft:#1B2620;
  --green-mint:#24332A;
  --green-pale:#192420;
  /* --green-deep is used across the UI as the PRIMARY heading/value
     text colour, so in dark mode it must read as light. Background
     uses of it are overridden explicitly below. */
  --green-deep:#DFE6D6;
}

/* Page base */
html[data-theme="dark"] body{background:var(--bg);color:var(--ink)}

/* Keep the brand sidebar dark-green (it uses --green-deep as a
   gradient start, which we just remapped to light) */
html[data-theme="dark"] .sidebar{
  background:linear-gradient(180deg,#0B120D 0%,#1B2A20 100%);
}

/* Green stat card should stay green, not pick up the lightened token */
html[data-theme="dark"] .stat-card.green{
  background:linear-gradient(135deg,#2E4A38 0%,#152219 100%);
  border-color:#152219;
}

/* Form fields: give them a dark surface so light text is readable */
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea{
  background:var(--bg-2);
  color:var(--ink);
  border-color:var(--line-strong);
}
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder{color:var(--muted)}

/* Popups / modal cards that hardcode a white background */
html[data-theme="dark"] .cong-card,
html[data-theme="dark"] .retopup-card,
html[data-theme="dark"] .modal-card,
html[data-theme="dark"] .popup-card{
  background:var(--paper);
  color:var(--ink);
  border-color:var(--line);
}

/* Tables inside dark cards */
html[data-theme="dark"] table th{color:var(--ink-2)}
html[data-theme="dark"] table td{color:var(--ink-2)}

/* Smooth the switch */
html, body, .app, .main, .topbar, .sidebar, .stat-card, .card{
  transition:background-color .25s ease, color .25s ease, border-color .25s ease;
}
