/* ═══════════════════════════════════════════════════════════════
   GTTC PORTAL — THEME CSS
   Drop into: app/static/css/portal-theme.css
   Import in every template: <link rel="stylesheet" href="/static/css/portal-theme.css">
═══════════════════════════════════════════════════════════════ */

/* ── Google Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=Figtree:wght@300;400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

/* ════════════════════════════════════════════
   1. CSS CUSTOM PROPERTIES
════════════════════════════════════════════ */

/* LIGHT MODE — Indigo Official */
:root, html[data-theme="light"] {
  /* Backgrounds */
  --bg:        #EEF2FC;
  --surface:   #FFFFFF;
  --surface2:  #F5F7FE;
  --surface3:  #EDF1FB;

  /* Borders */
  --border:    #E0E8F4;
  --border2:   #D0DCEE;

  /* Text */
  --text:      #0F1E3D;
  --text2:     #375080;
  --text3:     #7A90B2;
  --text4:     #B0C0D8;

  /* Sidebar */
  --sidebar-bg:       linear-gradient(180deg,#1e3a8a 0%,#1e2d6b 55%,#151f52 100%);
  --sidebar-text:     rgba(255,255,255,.65);
  --sidebar-text-act: #ffffff;
  --sidebar-item-act: rgba(255,255,255,.18);
  --sidebar-border:   rgba(255,255,255,.1);
  --sidebar-gold:     #D97706;

  /* Topbar */
  --topbar-bg:     #ffffff;
  --topbar-border: #E0E8F4;
  --topbar-shadow: 0 1px 0 #E0E8F4;

  /* Shadows */
  --shadow-sm:  0 1px 3px rgba(37,99,235,.04), 0 2px 8px rgba(37,99,235,.05);
  --shadow:     0 1px 4px rgba(37,99,235,.05), 0 4px 20px rgba(37,99,235,.07);
  --shadow-md:  0 4px 14px rgba(37,99,235,.1),  0 8px 36px rgba(37,99,235,.09);
  --shadow-lg:  0 8px 24px rgba(37,99,235,.12), 0 24px 64px rgba(37,99,235,.12);

  /* Radius */
  --r: 12px;
  --r-sm: 8px;
  --r-lg: 16px;

  /* Mode flag */
  --is-dark: 0;
}

/* DARK MODE — Glassmorphic */
html[data-theme="dark"] {
  --bg:        #06091A;
  --surface:   rgba(255,255,255,.08);
  --surface2:  rgba(255,255,255,.05);
  --surface3:  rgba(255,255,255,.03);

  --border:    rgba(255,255,255,.13);
  --border2:   rgba(255,255,255,.08);

  --text:      #FFFFFF;
  --text2:     rgba(255,255,255,.7);
  --text3:     rgba(255,255,255,.4);
  --text4:     rgba(255,255,255,.2);

  --sidebar-bg:       rgba(255,255,255,.06);
  --sidebar-text:     rgba(255,255,255,.55);
  --sidebar-text-act: #ffffff;
  --sidebar-item-act: rgba(255,255,255,.15);
  --sidebar-border:   rgba(255,255,255,.08);
  --sidebar-gold:     #FCD34D;

  --topbar-bg:     rgba(255,255,255,.06);
  --topbar-border: rgba(255,255,255,.08);
  --topbar-shadow: 0 1px 0 rgba(255,255,255,.06);

  --shadow-sm:  0 2px 8px rgba(0,0,0,.3);
  --shadow:     0 4px 20px rgba(0,0,0,.35);
  --shadow-md:  0 8px 32px rgba(0,0,0,.4);
  --shadow-lg:  0 12px 48px rgba(0,0,0,.5);

  --is-dark: 1;
}

/* Role accent colors — light */
html[data-theme="light"][data-role="state_admin"],
html[data-theme="light"][data-role="division_master"]   { --accent:#2563EB; --accent-lt:rgba(37,99,235,.1); --accent-glow:rgba(37,99,235,.3); --sidebar-bg:linear-gradient(180deg,#1e3a8a 0%,#1e2d6b 55%,#151f52 100%); }
html[data-theme="light"][data-role="master_trainer"]     { --accent:#7C3AED; --accent-lt:rgba(124,58,237,.1); --accent-glow:rgba(124,58,237,.3); --sidebar-bg:linear-gradient(180deg,#4c1d95 0%,#3b0764 55%,#1d0849 100%); }
html[data-theme="light"][data-role="atl_trainer"]        { --accent:#0D9488; --accent-lt:rgba(13,148,136,.1); --accent-glow:rgba(13,148,136,.3); --sidebar-bg:linear-gradient(180deg,#134e4a 0%,#0d3b37 55%,#062726 100%); }
html[data-theme="light"][data-role="principal"]          { --accent:#16A34A; --accent-lt:rgba(22,163,74,.1);  --accent-glow:rgba(22,163,74,.3);  --sidebar-bg:linear-gradient(180deg,#14532d 0%,#0d3d20 55%,#052e16 100%); }

/* Role accent colors — dark (same accent, different bg blobs applied via JS) */
html[data-theme="dark"][data-role="state_admin"],
html[data-theme="dark"][data-role="division_master"]     { --accent:#60A5FA; --accent-lt:rgba(96,165,250,.18); --accent-glow:rgba(96,165,250,.35); }
html[data-theme="dark"][data-role="master_trainer"]      { --accent:#A78BFA; --accent-lt:rgba(167,139,250,.18); --accent-glow:rgba(167,139,250,.35); }
html[data-theme="dark"][data-role="atl_trainer"]         { --accent:#2DD4BF; --accent-lt:rgba(45,212,191,.18); --accent-glow:rgba(45,212,191,.35); }
html[data-theme="dark"][data-role="principal"]           { --accent:#4ADE80; --accent-lt:rgba(74,222,128,.18); --accent-glow:rgba(74,222,128,.35); }

/* ════════════════════════════════════════════
   2. RESET & BASE
════════════════════════════════════════════ */
*, *::before, *::after { box-sizing:border-box; margin:0; padding:0; }

html, body {
  height:100%;
  font-family:'Figtree',system-ui,sans-serif;
  font-size:15px;
  line-height:1.6;
  color:var(--text);
  background:var(--bg);
  -webkit-font-smoothing:antialiased;
  transition:background .3s, color .3s;
}

::-webkit-scrollbar { width:5px; height:5px; }
::-webkit-scrollbar-track { background:transparent; }
::-webkit-scrollbar-thumb { background:var(--border2); border-radius:10px; }
::-webkit-scrollbar-thumb:hover { background:var(--text4); }

/* ════════════════════════════════════════════
   3. GLASS UTILITIES (dark mode only)
════════════════════════════════════════════ */
html[data-theme="dark"] .glass {
  background: rgba(255,255,255,.08);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,.13);
}
html[data-theme="dark"] .glass-sm {
  background: rgba(255,255,255,.06);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,.1);
}

/* ════════════════════════════════════════════
   4. APP SHELL
════════════════════════════════════════════ */
#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Dark mode gradient blob background */
html[data-theme="dark"] #app-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}
html[data-theme="dark"][data-role="state_admin"] #app-bg,
html[data-theme="dark"][data-role="division_master"] #app-bg {
  background:
    radial-gradient(ellipse at 15% 25%,rgba(37,99,235,.5) 0%,transparent 50%),
    radial-gradient(ellipse at 85% 75%,rgba(79,70,229,.4) 0%,transparent 50%),
    #06091A;
}
html[data-theme="dark"][data-role="master_trainer"] #app-bg {
  background:
    radial-gradient(ellipse at 15% 25%,rgba(109,40,217,.5) 0%,transparent 50%),
    radial-gradient(ellipse at 85% 75%,rgba(139,92,246,.4) 0%,transparent 50%),
    #08041A;
}
html[data-theme="dark"][data-role="atl_trainer"] #app-bg {
  background:
    radial-gradient(ellipse at 15% 30%,rgba(13,148,136,.45) 0%,transparent 50%),
    radial-gradient(ellipse at 85% 70%,rgba(20,184,166,.3) 0%,transparent 50%),
    #030E0D;
}
html[data-theme="dark"][data-role="principal"] #app-bg {
  background:
    radial-gradient(ellipse at 15% 30%,rgba(22,163,74,.4) 0%,transparent 50%),
    radial-gradient(ellipse at 85% 70%,rgba(34,197,94,.25) 0%,transparent 50%),
    #030D06;
}

/* ════════════════════════════════════════════
   5. SIDEBAR
════════════════════════════════════════════ */
.sidebar {
  width: 256px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  z-index: 10;
  transition: background .3s;
}

/* Light: solid gradient */
html[data-theme="light"] .sidebar {
  background: var(--sidebar-bg);
  box-shadow: 2px 0 16px rgba(0,0,0,.18);
}
/* Dark: glass */
html[data-theme="dark"] .sidebar {
  background: rgba(255,255,255,.06);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border-right: 1px solid rgba(255,255,255,.09);
}

.sidebar-brand {
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--sidebar-border);
}
.sidebar-brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.sidebar-logo {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 18px; color: #fff;
}
.sidebar-brand-name { color:#fff; font-weight:800; font-size:15px; letter-spacing:-.2px; line-height:1.2; }
.sidebar-brand-sub  { color:rgba(255,255,255,.42); font-size:11px; margin-top:1px; }

.sidebar-role-badge {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px; border-radius: 7px;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.15);
}
html[data-theme="light"] .sidebar-role-badge { padding:6px 12px 6px 10px; }
.sidebar-role-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--sidebar-gold);
  flex-shrink: 0;
}
.sidebar-role-label { color:#fff; font-size:12.5px; font-weight:700; line-height:1; }
.sidebar-role-sub   { color:rgba(255,255,255,.4); font-size:11px; margin-top:3px; }

/* Nav */
.sidebar-nav { padding: 10px 10px; flex: 1; }
.nav-section-label {
  padding: 8px 10px 4px;
  font-size: 10.5px; font-weight: 700;
  color: rgba(255,255,255,.35);
  text-transform: uppercase; letter-spacing: 1.2px;
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 12px; margin: 2px 0;
  border-radius: 8px; cursor: pointer;
  transition: all .13s cubic-bezier(.4,0,.2,1);
  color: var(--sidebar-text);
  font-size: 13.5px; font-weight: 500;
  position: relative;
  border: 1px solid transparent;
  user-select: none;
}
.nav-item i { font-size: 16px; width: 16px; text-align: center; flex-shrink: 0; }
.nav-item span { flex: 1; }
.nav-item .badge {
  background: #EF4444; color: #fff;
  font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 10px; line-height: 1.4;
}
.nav-item:hover {
  background: rgba(255,255,255,.1);
  color: #fff;
}
.nav-item.active {
  background: var(--sidebar-item-act);
  color: var(--sidebar-text-act);
  font-weight: 700;
}
/* Gold left inset on active */
html[data-theme="light"] .nav-item.active {
  box-shadow: inset 3px 0 0 var(--sidebar-gold);
}
html[data-theme="dark"] .nav-item.active {
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.18);
  border-color: rgba(255,255,255,.1);
}

/* Sidebar footer */
.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--sidebar-border);
  margin-top: auto;
}
.sidebar-user { display:flex; align-items:center; gap:10px; }
.sidebar-avatar {
  width:34px; height:34px; border-radius:9px;
  background: rgba(255,255,255,.2);
  border: 1px solid rgba(255,255,255,.25);
  display:flex; align-items:center; justify-content:center;
  color:#fff; font-weight:700; font-size:13px; flex-shrink:0;
}
.sidebar-user-name { color:#fff; font-size:13px; font-weight:600; }
.sidebar-user-role { color:rgba(255,255,255,.4); font-size:11px; }
.btn-signout {
  margin-top:10px; width:100%;
  padding:8px; background:rgba(255,255,255,.08);
  border:1px solid rgba(255,255,255,.14);
  border-radius:7px; cursor:pointer;
  color:rgba(255,255,255,.6); font-size:12px; font-weight:600;
  font-family:inherit; transition:.15s;
}
.btn-signout:hover { background:rgba(220,38,38,.22); color:#fca5a5; border-color:rgba(220,38,38,.3); }

/* ════════════════════════════════════════════
   6. MAIN + TOPBAR
════════════════════════════════════════════ */
.main { flex:1; display:flex; flex-direction:column; overflow:hidden; min-width:0; position:relative; z-index:1; }

.topbar {
  height: 56px;
  display: flex; align-items: center;
  padding: 0 22px;
  justify-content: space-between;
  flex-shrink: 0;
  transition: background .3s, border-color .3s;
}
html[data-theme="light"] .topbar {
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  box-shadow: var(--topbar-shadow);
}
html[data-theme="dark"] .topbar {
  background: rgba(255,255,255,.06);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.topbar-left { display:flex; align-items:center; gap:10px; }
.topbar-accent-bar { width:4px; height:18px; background:var(--accent); border-radius:2px; }
.topbar-title { font-weight:800; font-size:17px; color:var(--text); letter-spacing:-.3px; }

.topbar-right { display:flex; align-items:center; gap:9px; }
.topbar-date { font-size:11.5px; color:var(--text3); font-weight:600; }

.topbar-search {
  position:relative;
}
.topbar-search i {
  position:absolute; left:10px; top:50%;
  transform:translateY(-50%);
  color:var(--text3); font-size:13px; pointer-events:none;
}
.topbar-search input {
  padding:7px 12px 7px 30px;
  border-radius:8px;
  border: 1.5px solid var(--border);
  background: var(--surface2);
  color:var(--text); font-size:13px; font-family:inherit;
  outline:none; width:190px; transition:.15s;
}
html[data-theme="dark"] .topbar-search input {
  background: rgba(255,255,255,.08);
  border-color: rgba(255,255,255,.12);
  color: #fff;
}
.topbar-search input:focus { border-color:var(--accent); width:220px; }

.topbar-icon-btn {
  position:relative;
  padding:7px 9px; border-radius:8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  cursor:pointer; line-height:1;
  color:var(--text2); font-size:17px;
  transition:.15s;
}
html[data-theme="dark"] .topbar-icon-btn {
  background: rgba(255,255,255,.08);
  border-color: rgba(255,255,255,.1);
  color: rgba(255,255,255,.65);
}
.topbar-icon-btn:hover { border-color:var(--accent); color:var(--accent); }
.topbar-badge {
  position:absolute; top:4px; right:4px;
  width:8px; height:8px; background:#EF4444;
  border-radius:50%;
}
html[data-theme="light"] .topbar-badge { border:2px solid var(--surface); }

/* Theme toggle button */
.btn-theme-toggle {
  display:flex; align-items:center; gap:6px;
  padding:6px 12px; border-radius:8px;
  border: 1.5px solid var(--border2);
  background: var(--surface2);
  cursor:pointer; font-family:inherit;
  font-size:12px; font-weight:700; color:var(--text2);
  transition:all .15s;
}
html[data-theme="dark"] .btn-theme-toggle {
  background: rgba(255,255,255,.1);
  border-color: rgba(255,255,255,.18);
  color: rgba(255,255,255,.75);
}
.btn-theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-lt);
}
.btn-theme-toggle i { font-size:15px; }

.topbar-avatar {
  width:34px; height:34px;
  border-radius:9px;
  background: var(--accent);
  display:flex; align-items:center; justify-content:center;
  color:#fff; font-weight:700; font-size:13px;
  cursor:pointer; flex-shrink:0;
  box-shadow: 0 2px 8px var(--accent-glow);
}

/* ════════════════════════════════════════════
   7. PAGE CONTENT
════════════════════════════════════════════ */
.page-content {
  flex:1; overflow-y:auto;
  padding: 22px 24px;
  background: var(--bg);
  transition: background .3s;
}
html[data-theme="dark"] .page-content { background: transparent; }

/* ════════════════════════════════════════════
   8. KPI CARDS
════════════════════════════════════════════ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.kpi-card {
  border-radius: var(--r);
  padding: 20px 22px 16px;
  position: relative; overflow: hidden;
  cursor: default;
  transition: transform .2s, box-shadow .2s;
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

/* Light mode KPI */
html[data-theme="light"] .kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  box-shadow: var(--shadow);
}

/* Dark mode KPI */
html[data-theme="dark"] .kpi-card {
  background: rgba(255,255,255,.09);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,.14);
}
/* Shimmer top */
html[data-theme="dark"] .kpi-card::before {
  content:'';
  position:absolute; top:0; left:0; right:0; height:2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}
/* Glow blob */
html[data-theme="dark"] .kpi-card::after {
  content:'';
  position:absolute; top:-20px; right:-20px;
  width:90px; height:90px;
  border-radius:50%;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
  pointer-events:none;
}

.kpi-icon {
  width:40px; height:40px; border-radius:10px;
  background: var(--accent-lt);
  display:flex; align-items:center; justify-content:center;
  margin-bottom:14px;
}
.kpi-icon i { font-size:19px; color:var(--accent); }
html[data-theme="dark"] .kpi-icon { background: rgba(255,255,255,.08); border:1px solid rgba(255,255,255,.1); }

.kpi-value {
  font-size:36px; font-weight:800;
  color: var(--text);
  letter-spacing:-1.5px; line-height:1.1;
  font-variant-numeric: lining-nums tabular-nums;
}
.kpi-card.danger .kpi-value { color:#EF4444 !important; }

.kpi-label {
  font-size:12px; font-weight:700;
  color: var(--text2);
  text-transform:uppercase; letter-spacing:.5px;
  margin-top:6px;
}
.kpi-sub { font-size:12px; color:var(--text3); margin-top:2px; }

.kpi-trend {
  display:inline-flex; align-items:center; gap:3px;
  font-size:11px; font-weight:700;
  padding:2px 8px; border-radius:20px;
  position:absolute; top:16px; right:16px;
}
.kpi-trend.up   { background:rgba(22,163,74,.1);  color:#16A34A; }
.kpi-trend.down { background:rgba(220,38,38,.1);  color:#DC2626; }
html[data-theme="dark"] .kpi-trend.up   { background:rgba(74,222,128,.15); color:#4ADE80; }
html[data-theme="dark"] .kpi-trend.down { background:rgba(248,113,113,.15); color:#F87171; }

/* ════════════════════════════════════════════
   9. CARDS
════════════════════════════════════════════ */
.card {
  border-radius: var(--r);
  overflow: hidden;
  transition: box-shadow .2s;
}
html[data-theme="light"] .card {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
html[data-theme="dark"] .card {
  background: rgba(255,255,255,.08);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,.12);
}
.card:hover { box-shadow: var(--shadow-md); }

.card-header {
  padding: 14px 20px;
  display:flex; align-items:center; justify-content:space-between;
  gap:12px;
}
html[data-theme="light"] .card-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}
html[data-theme="dark"] .card-header {
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.card-title { font-size:15px; font-weight:800; color:var(--text); letter-spacing:-.2px; }
.card-body { padding:20px; }

/* ════════════════════════════════════════════
   10. TABLE
════════════════════════════════════════════ */
.tbl-wrap { overflow-x:auto; }
table { width:100%; border-collapse:collapse; font-family:inherit; }
th {
  padding:10px 16px; text-align:left;
  font-size:11px; font-weight:700;
  color:var(--text3);
  text-transform:uppercase; letter-spacing:.7px;
  white-space:nowrap;
}
html[data-theme="light"] th { background:var(--surface2); border-bottom:2px solid var(--border); }
html[data-theme="dark"] th  { background:rgba(255,255,255,.04); border-bottom:1px solid rgba(255,255,255,.08); }

td {
  padding:12px 16px;
  font-size:14px; color:var(--text);
  border-bottom:1px solid var(--border);
}
html[data-theme="dark"] td { border-bottom-color:rgba(255,255,255,.06); }
tr:last-child td { border-bottom:none; }
tbody tr { transition:background .1s; cursor:default; }
html[data-theme="light"] tbody tr:hover td { background:var(--surface2); }
html[data-theme="dark"] tbody tr:hover td  { background:rgba(255,255,255,.04); }

/* ════════════════════════════════════════════
   11. BADGES
════════════════════════════════════════════ */
.badge {
  display:inline-flex; align-items:center;
  padding:3px 10px; border-radius:5px;
  font-size:12px; font-weight:700; white-space:nowrap;
}
.badge-submitted { background:rgba(37,99,235,.1);  color:#2563EB; }
.badge-reviewed  { background:rgba(22,163,74,.1);  color:#16A34A; }
.badge-draft     { background:rgba(217,119,6,.1);  color:#D97706; }
.badge-overdue   { background:rgba(220,38,38,.1);  color:#DC2626; }
.badge-active    { background:rgba(22,163,74,.1);  color:#16A34A; }
.badge-inactive  { background:rgba(100,116,139,.1); color:#64748B; }
html[data-theme="dark"] .badge-submitted { background:rgba(96,165,250,.2);  color:#93C5FD; }
html[data-theme="dark"] .badge-reviewed  { background:rgba(74,222,128,.2);  color:#86EFAC; }
html[data-theme="dark"] .badge-draft     { background:rgba(251,191,36,.2);  color:#FCD34D; }
html[data-theme="dark"] .badge-overdue   { background:rgba(248,113,113,.2); color:#FCA5A5; }
html[data-theme="dark"] .badge-active    { background:rgba(74,222,128,.2);  color:#86EFAC; }

/* ════════════════════════════════════════════
   12. BUTTONS
════════════════════════════════════════════ */
.btn {
  display:inline-flex; align-items:center; gap:7px;
  padding:9px 18px;
  border-radius:var(--r-sm); font-family:inherit;
  font-size:13px; font-weight:700; cursor:pointer;
  transition:all .15s; white-space:nowrap;
  text-decoration:none; border:1.5px solid transparent;
}
.btn-primary {
  background:var(--accent); color:#fff;
  box-shadow:0 2px 8px var(--accent-glow);
}
.btn-primary:hover { filter:brightness(1.08); }
.btn-ghost {
  background:var(--surface2); color:var(--text2);
  border-color:var(--border);
}
html[data-theme="dark"] .btn-ghost {
  background:rgba(255,255,255,.08);
  border-color:rgba(255,255,255,.12);
  color:rgba(255,255,255,.6);
}
.btn-danger { background:#EF4444; color:#fff; }
.btn-sm { padding:5px 12px; font-size:12px; }
.btn-xs { padding:3px 9px; font-size:11px; border-radius:5px; }

/* ════════════════════════════════════════════
   13. FORMS
════════════════════════════════════════════ */
.form-group { margin-bottom:16px; }
.form-group label {
  display:block; font-size:11.5px; font-weight:700;
  color:var(--text2); margin-bottom:6px;
  text-transform:uppercase; letter-spacing:.5px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width:100%; padding:10px 14px;
  border:1.5px solid var(--border);
  border-radius:var(--r-sm);
  background:var(--surface2); color:var(--text);
  font-size:14px; font-family:inherit;
  outline:none; transition:.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color:var(--accent);
  box-shadow:0 0 0 3px var(--accent-lt);
  background:var(--surface);
}
html[data-theme="dark"] .form-group input,
html[data-theme="dark"] .form-group select,
html[data-theme="dark"] .form-group textarea {
  background:rgba(255,255,255,.07);
  border-color:rgba(255,255,255,.12);
  color:#fff;
}
html[data-theme="dark"] .form-group input::placeholder { color:rgba(255,255,255,.3); }
html[data-theme="dark"] .form-group input:focus,
html[data-theme="dark"] .form-group select:focus { background:rgba(255,255,255,.1); }

/* ════════════════════════════════════════════
   14. MODAL
════════════════════════════════════════════ */
.modal-bg {
  display:none; position:fixed; inset:0;
  background:rgba(10,15,40,.55);
  backdrop-filter:blur(8px);
  z-index:1000; align-items:center; justify-content:center;
  padding:20px;
}
.modal-bg.open { display:flex; }
.modal {
  width:100%; max-width:560px;
  max-height:90vh; overflow-y:auto;
  border-radius:var(--r-lg);
  box-shadow:var(--shadow-lg);
  animation:modalIn .2s ease;
}
html[data-theme="light"] .modal {
  background:var(--surface);
  border:1px solid var(--border);
}
html[data-theme="dark"] .modal {
  background:rgba(13,20,45,.9);
  backdrop-filter:blur(24px);
  border:1px solid rgba(255,255,255,.14);
}
@keyframes modalIn { from{opacity:0;transform:translateY(10px) scale(.97)} to{opacity:1;transform:none} }
.modal-head {
  padding:18px 22px;
  border-bottom:1px solid var(--border);
  display:flex; align-items:center; justify-content:space-between;
}
html[data-theme="dark"] .modal-head { border-color:rgba(255,255,255,.1); }
.modal-head h3 { font-size:15px; font-weight:700; color:var(--text); }
.modal-close {
  background:none; border:none; cursor:pointer;
  color:var(--text3); font-size:20px; line-height:1;
  padding:4px 6px; border-radius:6px; transition:.15s;
}
.modal-close:hover { background:var(--surface2); color:var(--text); }
.modal-body { padding:22px; }
.modal-footer {
  padding:14px 22px;
  border-top:1px solid var(--border);
  display:flex; justify-content:flex-end; gap:8px;
}
html[data-theme="dark"] .modal-footer { border-color:rgba(255,255,255,.08); background:rgba(255,255,255,.03); }

/* ════════════════════════════════════════════
   15. TOAST
════════════════════════════════════════════ */
#toast {
  position:fixed; bottom:24px; right:24px;
  z-index:9999;
  display:flex; flex-direction:column; gap:8px;
  pointer-events:none;
}
.toast-item {
  padding:12px 18px;
  border-radius:10px;
  font-size:13px; font-weight:600; color:#fff;
  box-shadow:var(--shadow-md);
  animation:slideIn .25s ease;
  display:flex; align-items:center; gap:8px;
  pointer-events:auto;
}
@keyframes slideIn { from{transform:translateX(110%);opacity:0} to{transform:none;opacity:1} }
.toast-success { background:#16A34A; }
.toast-error   { background:#DC2626; }
.toast-info    { background:var(--accent,#2563EB); }
.toast-warn    { background:#D97706; }

/* ════════════════════════════════════════════
   16. SKELETON / LOADING
════════════════════════════════════════════ */
.skeleton {
  background:linear-gradient(90deg,var(--surface2) 25%,var(--surface3) 50%,var(--surface2) 75%);
  background-size:200% 100%;
  animation:shimmer 1.4s infinite;
  border-radius:6px;
}
@keyframes shimmer { 0%{background-position:200% 0} 100%{background-position:-200% 0} }
.skel-row { height:42px; margin-bottom:4px; border-radius:var(--r-sm); }

/* ════════════════════════════════════════════
   17. PROGRESS BARS
════════════════════════════════════════════ */
.progress-bar-bg {
  height:8px; border-radius:4px;
  background:var(--surface2);
  overflow:hidden;
}
html[data-theme="dark"] .progress-bar-bg { background:rgba(255,255,255,.1); }
.progress-bar-fill {
  height:100%; border-radius:4px;
  background:linear-gradient(90deg, var(--accent), var(--accent));
  transition:width .5s cubic-bezier(.4,0,.2,1);
}

/* ════════════════════════════════════════════
   18. ALERTS / BANNERS
════════════════════════════════════════════ */
.alert {
  padding:12px 18px;
  border-radius:var(--r-sm);
  display:flex; align-items:center; gap:10px;
  font-size:14px; margin-bottom:18px;
}
.alert i { font-size:18px; flex-shrink:0; }
.alert-danger  {
  background:rgba(254,242,242,1);
  border:1px solid #fecaca;
  color:#7f1d1d;
}
html[data-theme="dark"] .alert-danger {
  background:rgba(239,68,68,.12);
  border-color:rgba(239,68,68,.3);
  color:#FCA5A5;
}
.alert-danger i { color:#EF4444; }

/* ════════════════════════════════════════════
   19. PERIOD SELECTOR
════════════════════════════════════════════ */
.period-bar { display:flex; align-items:center; gap:6px; flex-wrap:wrap; margin-bottom:16px; }
.period-btn {
  padding:5px 14px;
  border:1.5px solid var(--border);
  border-radius:20px;
  background:var(--surface);
  font-size:12px; font-weight:600;
  color:var(--text3); cursor:pointer;
  font-family:inherit; transition:.15s;
}
.period-btn:hover { border-color:var(--accent); color:var(--accent); background:var(--accent-lt); }
.period-btn.active {
  background:var(--accent); color:#fff;
  border-color:var(--accent);
  box-shadow:0 2px 8px var(--accent-glow);
}
html[data-theme="dark"] .period-btn { background:rgba(255,255,255,.06); }

/* ════════════════════════════════════════════
   20. EMPTY STATE
════════════════════════════════════════════ */
.empty-state {
  text-align:center; padding:56px 20px;
  color:var(--text3);
}
.empty-state i  { font-size:42px; display:block; margin-bottom:14px; opacity:.3; }
.empty-state h3 { font-size:16px; font-weight:700; color:var(--text2); margin-bottom:6px; }
.empty-state p  { font-size:13px; }

/* ════════════════════════════════════════════
   21. LAYOUT HELPERS
════════════════════════════════════════════ */
.grid-2  { display:grid; grid-template-columns:1fr 1fr; gap:16px; }
.grid-3  { display:grid; grid-template-columns:1fr 1fr 1fr; gap:16px; }
.grid-4  { display:grid; grid-template-columns:repeat(4,1fr); gap:14px; }
.grid-auto { display:grid; grid-template-columns:repeat(auto-fit,minmax(220px,1fr)); gap:14px; }
@media(max-width:900px) { .grid-2,.grid-3,.grid-4 { grid-template-columns:1fr; } }

.flex     { display:flex; }
.flex-col { display:flex; flex-direction:column; }
.gap-2    { gap:8px; }
.gap-3    { gap:12px; }
.gap-4    { gap:16px; }
.items-center { align-items:center; }
.justify-between { justify-content:space-between; }
.ml-auto  { margin-left:auto; }
.mb-4     { margin-bottom:16px; }
.mb-5     { margin-bottom:20px; }
.mb-6     { margin-bottom:24px; }

.section-title {
  font-size:16px; font-weight:800;
  color:var(--text); letter-spacing:-.3px;
  margin-bottom:14px;
}

/* ════════════════════════════════════════════
   22. CHART CARDS
════════════════════════════════════════════ */
.chart-card { margin-bottom:16px; }
.chart-wrap { position:relative; }

/* ════════════════════════════════════════════
   23. SEARCH BOX (in table headers)
════════════════════════════════════════════ */
.search-box { position:relative; }
.search-box i {
  position:absolute; left:10px; top:50%;
  transform:translateY(-50%);
  color:var(--text4); font-size:13px; pointer-events:none;
}
.search-box input {
  padding:7px 12px 7px 30px;
  border:1.5px solid var(--border);
  border-radius:8px; font-size:13px;
  background:var(--surface2); color:var(--text);
  font-family:inherit; outline:none; transition:.15s; width:210px;
}
.search-box input:focus { border-color:var(--accent); width:240px; background:var(--surface); }
html[data-theme="dark"] .search-box input { background:rgba(255,255,255,.07); border-color:rgba(255,255,255,.12); color:#fff; }

/* ════════════════════════════════════════════
   24. PAGE ENTER ANIMATION
════════════════════════════════════════════ */
.page-section { animation:fadeUp .22s ease; }
@keyframes fadeUp { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:none} }

/* ════════════════════════════════════════════
   25. LOGIN PAGE OVERRIDES
════════════════════════════════════════════ */
#login-page {
  display:flex; height:100vh;
  background:#060C1E;
  font-family:'Figtree',system-ui,sans-serif;
}
.login-canvas-panel {
  flex:1; position:relative; overflow:hidden;
}
.login-canvas-panel canvas { width:100%; height:100%; display:block; }
.login-overlay {
  position:absolute; inset:0;
  display:flex; flex-direction:column;
  justify-content:space-between;
  padding:36px 44px;
  pointer-events:none;
}
.login-brand { display:flex; align-items:center; gap:14px; pointer-events:auto; }
.login-brand-icon {
  width:42px; height:42px;
  background:rgba(96,165,250,.14);
  border:1px solid rgba(96,165,250,.28);
  border-radius:11px;
  display:flex; align-items:center; justify-content:center;
  font-size:22px; color:rgba(148,163,255,1);
}
.login-brand-text h2 { color:#fff; font-weight:800; font-size:17px; letter-spacing:-.2px; }
.login-brand-text p  { color:rgba(148,163,255,.55); font-size:11px; letter-spacing:.5px; text-transform:uppercase; }
.login-hero-title {
  font-size:50px; font-weight:900;
  color:#fff; letter-spacing:-2.5px;
  line-height:1.05; margin-bottom:16px;
}
.login-hero-title span { color:#60A5FA; }
.login-hero-sub { color:rgba(148,163,255,.65); font-size:15px; max-width:380px; line-height:1.6; }
.login-stats {
  display:grid; grid-template-columns:repeat(3,1fr); gap:14px;
}
.login-stat {
  padding:12px 14px;
  background:rgba(255,255,255,.04);
  border:1px solid rgba(96,165,250,.14);
  border-radius:10px;
  backdrop-filter:blur(12px);
}
.login-stat-value { font-size:28px; font-weight:800; color:#fff; letter-spacing:-1px; line-height:1; }
.login-stat-label { font-size:10.5px; letter-spacing:1.4px; color:rgba(148,163,255,.5); margin-top:6px; text-transform:uppercase; font-family:'JetBrains Mono',monospace; }

.login-form-panel {
  width:480px; flex-shrink:0;
  background:#0C1426;
  border-left:1px solid rgba(96,165,250,.1);
  display:flex; flex-direction:column;
  justify-content:center;
  padding:52px 44px; overflow-y:auto;
}
.login-form-label {
  font-family:'JetBrains Mono',monospace;
  font-size:11px; letter-spacing:2px;
  color:rgba(96,165,250,.5); text-transform:uppercase;
  margin-bottom:12px;
}
.login-form-title {
  font-size:32px; font-weight:800; color:#fff;
  letter-spacing:-1.5px; line-height:1.1; margin-bottom:6px;
}
.login-form-sub { font-size:14px; color:rgba(148,163,255,.5); margin-bottom:28px; }

.role-grid { display:grid; grid-template-columns:1fr 1fr; gap:8px; margin-bottom:24px; }
.role-tile {
  padding:12px 14px; border-radius:10px; cursor:pointer;
  background:rgba(255,255,255,.03);
  border:1.5px solid rgba(255,255,255,.07);
  transition:.15s; text-align:left;
}
.role-tile:hover { background:rgba(255,255,255,.06); border-color:rgba(255,255,255,.14); }
.role-tile.active {
  background:rgba(96,165,250,.1);
  border-color:rgba(96,165,250,.4);
  box-shadow:0 0 0 1px rgba(96,165,250,.12);
}
.role-tile-icon { font-size:18px; margin-bottom:6px; }
.role-tile.active .role-tile-icon { color:#60A5FA; }
.role-tile-label { font-size:13px; font-weight:700; color:rgba(255,255,255,.55); line-height:1.2; }
.role-tile.active .role-tile-label { color:#fff; }
.role-tile-sub { font-size:11px; color:rgba(148,163,255,.35); margin-top:2px; }

.login-field { margin-bottom:16px; }
.login-field label {
  display:block; font-size:11.5px; font-weight:700;
  color:rgba(148,163,255,.5); text-transform:uppercase;
  letter-spacing:1px; margin-bottom:8px;
}
.login-field-wrap { position:relative; }
.login-field-wrap i {
  position:absolute; left:14px; top:50%;
  transform:translateY(-50%);
  color:rgba(148,163,255,.35); font-size:15px; pointer-events:none;
}
.login-field input {
  width:100%; padding:12px 14px 12px 40px;
  background:rgba(255,255,255,.04);
  border:1.5px solid rgba(96,165,250,.18);
  border-radius:10px; color:#fff;
  font-size:14px; font-family:inherit; outline:none; transition:.15s;
  box-sizing:border-box;
}
.login-field input:focus { border-color:rgba(96,165,250,.55); background:rgba(255,255,255,.06); }
.login-field-toggle {
  position:absolute; right:12px; top:50%; transform:translateY(-50%);
  background:none; border:none; cursor:pointer;
  color:rgba(148,163,255,.4); font-size:16px; padding:4px;
}

.btn-login {
  width:100%; padding:14px;
  background:linear-gradient(135deg,#2563EB,#4F46E5);
  color:#fff; border:none; border-radius:10px;
  font-family:inherit; font-size:15px; font-weight:700;
  cursor:pointer;
  display:flex; align-items:center; justify-content:center; gap:10px;
  box-shadow:0 4px 20px rgba(37,99,235,.35);
  transition:.2s; margin-bottom:18px;
}
.btn-login:hover { filter:brightness(1.1); transform:translateY(-1px); }
.btn-login:disabled { opacity:.6; cursor:wait; transform:none; }
.btn-login .spinner {
  width:18px; height:18px;
  border:2.5px solid rgba(255,255,255,.3);
  border-top-color:#fff;
  border-radius:50%;
  animation:spin 1s linear infinite;
  flex-shrink:0;
}
@keyframes spin { to { transform:rotate(360deg); } }

.login-err {
  display:none; padding:10px 14px;
  background:rgba(239,68,68,.12);
  border:1px solid rgba(239,68,68,.3);
  border-radius:8px;
  color:#FCA5A5; font-size:13px;
  align-items:center; gap:8px; margin-bottom:14px;
}
.login-err.show { display:flex; }
.login-err i { color:#EF4444; font-size:16px; flex-shrink:0; }

.login-demo {
  padding:12px 16px;
  background:rgba(96,165,250,.06);
  border:1px solid rgba(96,165,250,.12);
  border-radius:9px; margin-top:20px;
}
.login-demo-label { font-size:11px; font-weight:700; color:rgba(96,165,250,.55); text-transform:uppercase; letter-spacing:1px; margin-bottom:6px; font-family:'JetBrains Mono',monospace; }
.login-demo p { font-size:12px; color:rgba(148,163,255,.5); line-height:1.8; }
.login-demo code { color:rgba(148,163,255,.8); background:rgba(255,255,255,.05); padding:1px 5px; border-radius:4px; font-family:'JetBrains Mono',monospace; }

.login-footer {
  margin-top:24px; padding-top:20px;
  border-top:1px solid rgba(255,255,255,.06);
  font-family:'JetBrains Mono',monospace;
  font-size:10.5px; letter-spacing:.5px;
  color:rgba(96,165,250,.2); text-align:center;
}
