:root{
  /* Royal Teal theme: bright teal page + deep green panels */
  --bg:#24b4a4;
  --panel:#0c2624;
  --panel2:#071c1a;
  --sidebar:#051513;
  --band:#082622;
  --text:#eafaf6;
  --muted:#8fbdb4;
  --gold:#22b8a0;
  --gold2:#5eead4;
  --gold-rgb: 34,184,160;
  --gold2-rgb: 94,234,212;
  --danger:#ef4444;
  --ok:#22c55e;
  --line:rgba(94,234,212,.16);
  --shadow: 0 12px 40px rgba(0,24,21,.45);
  --radius:18px;

  /* Themeable surface tokens (opaque deep-green panels) */
  --surface-1: #0d2926;
  --surface-2: #0a221f;
  --surface-soft: #0f2e2a;
  --surface-hover: #14403a;
  --input-bg: #071c1a;
  --header-bg: rgba(8,38,34,.94);
  --bottomnav-bg: rgba(5,21,19,.96);
  --overlay-bg: rgba(0,14,12,.6);
  --avatar-bg: #0f2e2a;
}

/* Light theme overrides — activated via <html data-theme="light"> */
[data-theme="light"]{
  --bg:#d6f2ed;
  --panel:#ffffff;
  --panel2:#eefaf8;
  --sidebar:#ffffff;
  --band:#ffffff;
  --text:#0b2a26;
  --muted:#4f7a73;
  --gold:#0f9e8a;
  --gold2:#14b8a6;
  --gold-rgb: 15,158,138;
  --gold2-rgb: 20,184,166;
  --danger:#dc2626;
  --ok:#16a34a;
  --line:rgba(8,70,62,.14);
  --shadow: 0 12px 30px rgba(8,70,62,.10);

  --surface-1: #ffffff;
  --surface-2: #f4fbf9;
  --surface-soft: #eaf7f4;
  --surface-hover: #dff3ef;
  --input-bg: #f2fbf9;
  --header-bg: rgba(255,255,255,.92);
  --bottomnav-bg: rgba(255,255,255,.96);
  --overlay-bg: rgba(0,30,26,.35);
  --avatar-bg: #e3f5f1;
}

/* ============================================================
   Site-wide color schemes — chosen by the admin in
   Admin Settings → Appearance (<html data-scheme="...">).
   Independent of the light/dark toggle above: a scheme just
   swaps the brand accent (--gold/--gold2), everything else
   (surfaces, text) still follows light/dark normally.
   ============================================================ */

/* Royal Teal (default) — no override needed, :root already is this */
[data-scheme="teal"]{
  --gold:#22b8a0;
  --gold2:#5eead4;
  --gold-rgb: 34,184,160;
  --gold2-rgb: 94,234,212;
}
[data-scheme="teal"][data-theme="light"]{
  --gold:#0f9e8a;
  --gold2:#14b8a6;
  --gold-rgb: 15,158,138;
  --gold2-rgb: 20,184,166;
}

/* Gold Noir — classic gold accent */
[data-scheme="gold"]{
  --gold:#d8b15a;
  --gold2:#f2d27d;
  --gold-rgb: 216,177,90;
  --gold2-rgb: 242,210,125;
}
[data-scheme="gold"][data-theme="light"]{
  --gold:#b4860f;
  --gold2:#caa338;
  --gold-rgb: 180,134,15;
  --gold2-rgb: 202,163,56;
}

/* Emerald Prestige — deep emerald + soft mint */
[data-scheme="emerald"]{
  --gold:#1fae7a;
  --gold2:#4ade80;
  --gold-rgb: 31,174,122;
  --gold2-rgb: 74,222,128;
}
[data-scheme="emerald"][data-theme="light"]{
  --gold:#0f9e6d;
  --gold2:#2fae74;
  --gold-rgb: 15,158,109;
  --gold2-rgb: 47,174,116;
}

/* Sapphire Royal — deep blue + sky cyan */
[data-scheme="sapphire"]{
  --gold:#3b82f6;
  --gold2:#7dd3fc;
  --gold-rgb: 59,130,246;
  --gold2-rgb: 125,211,252;
}
[data-scheme="sapphire"][data-theme="light"]{
  --gold:#2563eb;
  --gold2:#38bdf8;
  --gold-rgb: 37,99,235;
  --gold2-rgb: 56,189,248;
}

/* Royal Amethyst — violet + lilac */
[data-scheme="violet"]{
  --gold:#8b5cf6;
  --gold2:#c4b5fd;
  --gold-rgb: 139,92,246;
  --gold2-rgb: 196,181,253;
}
[data-scheme="violet"][data-theme="light"]{
  --gold:#7c3aed;
  --gold2:#a78bfa;
  --gold-rgb: 124,58,237;
  --gold2-rgb: 167,139,250;
}

*{box-sizing:border-box}
html,body{height:100%}
html{color-scheme: dark}
html[data-theme="light"]{color-scheme: light}
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
  background: radial-gradient(900px 500px at 8% 0%, rgba(255,255,255,.16), transparent 55%),
              radial-gradient(700px 420px at 100% 0%, rgba(94,234,212,.28), transparent 55%),
              linear-gradient(180deg, rgba(255,255,255,.04), rgba(0,40,35,.10)),
              var(--bg);
  background-attachment: fixed;
  color:var(--text);
  transition: background-color .2s ease, color .2s ease;
}
[data-theme="light"] body{
  background: radial-gradient(900px 500px at 8% 0%, rgba(255,255,255,.7), transparent 55%),
              radial-gradient(700px 420px at 100% 0%, rgba(20,184,166,.18), transparent 55%),
              var(--bg);
  background-attachment: fixed;
}
a{color:inherit;text-decoration:none}
.container{max-width:1100px;margin:0 auto;padding:18px}

.auth-wrap{min-height:100vh;display:flex;align-items:center;justify-content:center;padding:18px}
.card{
  width:100%;
  max-width:430px;
  background: linear-gradient(180deg, var(--surface-1), var(--surface-2));
  border:1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  overflow:hidden;
  transform: translateY(8px);
  animation: pop .55s ease forwards;
}
@keyframes pop{to{transform:translateY(0)}}
.card-hd{padding:18px 18px 10px}
.brand{display:flex;align-items:center;gap:10px}
.brand-badge{
  width:38px;height:38px;border-radius:12px;
  background: radial-gradient(circle at 30% 30%, var(--gold2), var(--gold));
  box-shadow: 0 12px 28px rgba(var(--gold-rgb),.25);
}
.brand-title{font-weight:800;letter-spacing:.2px}
.brand-sub{color:var(--muted);font-size:12px;margin-top:2px}
.card-bd{padding:0 18px 18px}

.field{margin-top:12px}
.label{display:block;font-size:12px;color:var(--muted);margin-bottom:6px}
.input{
  width:100%;
  background: var(--input-bg);
  border:1px solid var(--line);
  color:var(--text);
  padding:12px 12px;
  border-radius:14px;
  outline:none;
  transition: .2s;
}
.input option{color:#0b0b0b; background:#ffffff}
.input optgroup{color:#0b0b0b; background:#ffffff}
.input[type="file"]{color:var(--text)}
.input:focus{border-color: rgba(var(--gold-rgb),.6); box-shadow: 0 0 0 4px rgba(var(--gold-rgb),.12)}
.row{display:flex;gap:12px}
.row .col{flex:1}

.pw-wrap{position:relative}
.pw-toggle{
  position:absolute;
  right:10px;
  top:50%;
  transform: translateY(-50%);
  border:1px solid var(--line);
  background: var(--surface-soft);
  color: var(--muted);
  border-radius: 12px;
  padding:7px 10px;
  cursor:pointer;
  font-size:12px;
}
.pw-toggle:hover{color: var(--gold2); border-color: rgba(var(--gold-rgb),.25)}

.btn{
  width:100%;
  margin-top:14px;
  border:0;
  padding:12px 14px;
  border-radius:14px;
  font-weight:700;
  color:#03201b;
  background: linear-gradient(180deg, var(--gold2), var(--gold));
  cursor:pointer;
  transition: transform .08s ease, filter .2s;
}
.btn:active{transform: translateY(1px)}
.btn:hover{filter: brightness(1.05)}

.mini-links{display:flex;justify-content:space-between;gap:10px;margin-top:12px;color:var(--muted);font-size:13px}
.badge{
  display:inline-flex;align-items:center;gap:8px;
  padding:8px 10px;border-radius:999px;
  border:1px solid var(--line);
  background: var(--surface-soft);
  color: var(--muted);
  font-size:12px;
}
.alert{margin-top:12px;padding:10px 12px;border-radius:14px;border:1px solid var(--line);background: var(--surface-soft)}
.alert.ok{border-color: rgba(34,197,94,.45);background: #0d3326}
.alert.err{border-color: rgba(239,68,68,.45);background: #3a1717}
[data-theme="light"] .alert.ok{background:#e3f8ec}
[data-theme="light"] .alert.err{background:#fde8e8}

/* App shell */
.app{
  display:grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}
.sidebar{
  position:sticky;top:0;align-self:start;height:100vh;
  background: var(--sidebar);
  border-right:1px solid var(--line);
  padding:16px;
}
.header{
  position:sticky;top:0;z-index:50;
  display:flex;align-items:center;justify-content:space-between;gap:12px;
  padding:12px 14px;margin:-18px -18px 16px;
  background: var(--header-bg);
  border-bottom:1px solid var(--line);
  backdrop-filter: blur(14px);
}
.header-left{display:flex;align-items:center;gap:12px;min-width:0}
.hamburger{
  display:none;
  width:42px;height:42px;
  border-radius:14px;
  border:1px solid var(--line);
  background: var(--surface-soft);
  color:var(--text);
  cursor:pointer;
}
.hamburger:active{transform: translateY(1px)}
.hdr-brand{display:flex;align-items:center;gap:10px;min-width:0}
.hdr-brand .brand-badge{width:34px;height:34px;border-radius:12px}
.hdr-brand .brand-title{font-weight:900;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:220px}
.header-right{display:flex;align-items:center;gap:10px;flex-shrink:0}
.hdr-user{display:flex;align-items:center;gap:10px;max-width:260px}
.hdr-avatar{width:38px;height:38px;border-radius:14px;overflow:hidden;display:flex;align-items:center;justify-content:center;border:1px solid var(--line);background:var(--avatar-bg)}
.hdr-name{font-size:12px;font-weight:900;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.icon-btn{
  width:38px;height:38px;border-radius:13px;
  display:flex;align-items:center;justify-content:center;
  border:1px solid var(--line);
  background: var(--surface-soft);
  color: var(--muted);
  transition: .2s;
}
.icon-btn:hover{color:var(--gold2);border-color: rgba(var(--gold-rgb),.25);background: rgba(var(--gold-rgb),.08)}
.icon-btn svg{width:16px;height:16px;display:block}

/* Theme toggle switch (sun/moon) */
.theme-toggle{
  width:38px;height:38px;border-radius:13px;
  display:flex;align-items:center;justify-content:center;
  border:1px solid var(--line);
  background: var(--surface-soft);
  color: var(--gold2);
  cursor:pointer;
  transition:.2s;
  flex-shrink:0;
}
.theme-toggle:hover{border-color: rgba(var(--gold-rgb),.35);background: rgba(var(--gold-rgb),.10)}
.theme-toggle svg{width:18px;height:18px;display:block}
.theme-toggle .ico-moon{display:none}
[data-theme="light"] .theme-toggle .ico-sun{display:none}
[data-theme="light"] .theme-toggle .ico-moon{display:block}

.theme-toggle-fab{
  position:fixed;
  right:16px;
  bottom:16px;
  z-index:80;
  width:46px;height:46px;
  border-radius:16px;
  box-shadow: var(--shadow);
}
@media (max-width: 900px){
  .theme-toggle-fab{ bottom:88px; }
}

.overlay{
  display:none;
  position:fixed;inset:0;
  background: var(--overlay-bg);
  backdrop-filter: blur(2px);
  z-index:60;
  pointer-events:none;
}
.sidebar.drawer{
  position:fixed;left:-290px;top:0;bottom:0;width:260px;height:auto;
  z-index:70;
  transition: left .25s ease;
}
.drawer-open .overlay{display:block;pointer-events:auto}
.drawer-open .sidebar.drawer{left:0}

@media (min-width: 901px){
  .sidebar.drawer{
    position:sticky;
    left:auto;top:0;bottom:auto;
    height:100vh;
    width:260px;
    transform:none;
    transition:none;
    z-index:auto;
  }
  .drawer-open .overlay{display:none}
  .drawer-open .sidebar.drawer{left:auto}
}
.nav-title{color:var(--muted);font-size:12px;margin:18px 10px 8px}
.nav a{
  display:flex;align-items:center;gap:10px;
  padding:12px 12px;border-radius:14px;
  color: var(--text);
  border:1px solid transparent;
  transition:.2s;
}
.nav a:hover{background: var(--surface-hover); border-color: var(--line)}
.nav a.active{background: var(--gold); border-color: transparent; color:#fff; font-weight:700; box-shadow:0 8px 22px rgba(var(--gold-rgb),.35)}

.main{padding:18px}
.main, .main *{pointer-events:auto}
.main::before, .main::after{pointer-events:none}
.widget::before{pointer-events:none}
.ov-card:before{pointer-events:none}
.ov-panel, .ov-panel *{pointer-events:auto}
.ov-panel::before, .ov-panel::after{pointer-events:none}
.topbar{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:16px;
  background: var(--band);border:1px solid var(--line);border-radius:var(--radius);padding:14px 16px;box-shadow:var(--shadow)}
.topbar .h1{font-size:20px}
.topbar-sub{color:var(--muted);font-size:12px;margin-top:4px;font-weight:400}
.h1{font-size:18px;font-weight:800}
.grid{display:grid;grid-template-columns:repeat(12,1fr);gap:12px}
.widget{grid-column: span 3; padding:14px; border-radius: var(--radius); border:1px solid var(--line);
  background: linear-gradient(180deg, var(--surface-1), var(--surface-2));
  box-shadow: var(--shadow);
  position:relative; overflow:hidden;
}
.widget:before{content:"";position:absolute;inset:-1px; background: radial-gradient(320px 120px at 0% 0%, rgba(var(--gold-rgb),.22), transparent 60%);
  opacity:.9;pointer-events:none;
}
.widget .t{color:var(--muted);font-size:12px}
.widget .v{font-size:22px;font-weight:900;margin-top:6px}

.bottom-nav{
  display:none;
  position:fixed;left:0;right:0;bottom:0;
  background: var(--bottomnav-bg);
  border-top:1px solid var(--line);
  backdrop-filter: blur(12px);
  padding:8px 10px;
}
.bottom-nav a{flex:1;text-align:center;color:var(--muted);font-size:10px;display:grid;gap:5px;justify-items:center}
.bottom-nav a .nav-ico{width:38px;height:30px;border-radius:13px;display:flex;align-items:center;justify-content:center;border:1px solid transparent;transition:.2s;position:relative}
.bottom-nav a .nav-ico svg{width:16px;height:16px;display:block}
.bottom-nav a.active{color:var(--gold2)}
.bottom-nav a.active .nav-ico{border-color: rgba(var(--gold-rgb),.25);background: rgba(var(--gold-rgb),.10)}
.bottom-nav a:active .nav-ico{transform: translateY(1px)}
.bottom-nav a:hover .nav-ico{background: var(--surface-hover)}

@media (max-width: 900px){
  .app{grid-template-columns: 1fr}
  .sidebar{display:none}
  .hamburger{display:inline-flex;align-items:center;justify-content:center}
  .sidebar.drawer{display:block}
  .main{padding-bottom:78px}
  .bottom-nav{display:flex;gap:8px}
  .widget{grid-column: span 6}
}

@media (min-width: 901px){
  .hamburger{display:none}
}
@media (max-width: 520px){
  .widget{grid-column: span 12}
}
/* Light-mode readability for chart labels (dashboard bars) */
[data-theme="light"] .ov-bar b,
[data-theme="light"] .ov-bar span{color:var(--text)}
