/* =====================================================================
   EduCore Kenya - "Aurora Glass" theme
   Visual layer only: it restyles the existing markup (nav, h2, .card,
   forms, tables) and never changes what the pages do.
   ===================================================================== */
@property --ang { syntax: '<angle>'; inherits: false; initial-value: 0deg; }

:root {
  --bg0: #06050e; --bg1: #0c0a1d;
  --glass: rgba(255,255,255,.065); --glass2: rgba(255,255,255,.11); --glass-brd: rgba(255,255,255,.13);
  --txt: #ecebff; --muted: #a7a3cf; --faint: #7c78a8; --link: #b9a7ff;
  --p1: #8b5cf6; --b1: #3b82f6; --c1: #22d3ee;
  --ok: #34d399; --warn: #fbbf24; --err: #fb7185;
  --field: rgba(255,255,255,.07); --field-brd: rgba(255,255,255,.17);
  --shadow: 0 14px 44px -14px rgba(0,0,0,.65);
  --sbw: 272px;
  --h2a: #ffffff; --h2b: #cfc4ff; --h2c: #8fb4ff;
  --page-a: #2a1a5e; --page-b: #10285f;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg0: #e9ecff; --bg1: #f4f1ff;
  --glass: rgba(255,255,255,.62); --glass2: rgba(255,255,255,.85); --glass-brd: rgba(120,100,200,.22);
  --txt: #1d1a3d; --muted: #5d5a85; --faint: #8481ad; --link: #5b3fd6;
  --field: rgba(255,255,255,.85); --field-brd: rgba(110,90,200,.30);
  --shadow: 0 14px 40px -16px rgba(80,60,160,.35);
  --h2a: #2b1b78; --h2b: #5b3fd6; --h2c: #2563eb;
  --page-a: #d9ccff; --page-b: #c7dcff;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
  font-size: 15px; line-height: 1.55; color: var(--txt);
  background:
    radial-gradient(1200px 700px at 88% -10%, var(--page-a) 0, transparent 60%),
    radial-gradient(900px 620px at -10% 112%, var(--page-b) 0, transparent 55%),
    linear-gradient(160deg, var(--bg1), var(--bg0));
  background-attachment: fixed;
  overflow-x: hidden;
  padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right);
}
/* drifting colour orbs behind everything */
body::before {
  content: ""; position: fixed; inset: -10%; z-index: -1; pointer-events: none;
  background:
    radial-gradient(circle at 18% 28%, rgba(139,92,246,.20), transparent 38%),
    radial-gradient(circle at 82% 72%, rgba(59,130,246,.17), transparent 40%),
    radial-gradient(circle at 60% 12%, rgba(34,211,238,.09), transparent 30%);
  animation: drift 26s ease-in-out infinite alternate;
}
@keyframes drift { to { transform: translate3d(-3%, 2%, 0) scale(1.08) rotate(2deg); } }

/* ---------- type ---------- */
h1, h2 {
  font-weight: 760; letter-spacing: -.02em; line-height: 1.15;
  background: linear-gradient(90deg, var(--h2a), var(--h2b) 55%, var(--h2c));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
h2 { font-size: clamp(1.55rem, 1.1rem + 1.7vw, 2.25rem); margin: 0 0 22px; }
h1 { font-size: clamp(1.6rem, 1.1rem + 2vw, 2.4rem); margin: 0 0 14px; }
h3 { font-size: 1.12rem; margin: 26px 0 10px; font-weight: 700; letter-spacing: -.01em; }
h4 { margin: 14px 0 6px; }
p { margin: .6em 0; }
a { color: var(--link); text-decoration-color: color-mix(in srgb, var(--link) 45%, transparent); text-underline-offset: 3px; transition: color .2s; }
a:hover { color: #fff; }
:root[data-theme="light"] a:hover { color: #2b1b78; }
small { color: var(--muted); }
em { color: var(--muted); }
strong { font-weight: 700; }
ul, ol { padding-left: 1.3rem; } li { margin: 5px 0; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
code { background: var(--glass2); padding: 2px 7px; border-radius: 7px; font-size: .88em; }
pre { background: rgba(0,0,0,.35); border: 1px solid var(--glass-brd); padding: 14px; border-radius: 14px; overflow-x: auto; max-width: 100%; }
:root[data-theme="light"] pre { background: rgba(255,255,255,.7); }
hr { border: 0; height: 1px; background: var(--glass-brd); margin: 20px 0; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.ok { color: var(--ok); } .err { color: var(--err); } .warn { color: var(--warn); }
p.err:not(:empty), p.ok:not(:empty) { padding: 10px 14px; border-radius: 12px; margin: 10px 0; font-weight: 500; }
p.err:not(:empty) { background: rgba(251,113,133,.12); border: 1px solid rgba(251,113,133,.35); }
p.ok:not(:empty)  { background: rgba(52,211,153,.12);  border: 1px solid rgba(52,211,153,.35); }
[style*="#0a7a2f"] { color: var(--ok) !important; }
[style*="#b26a00"] { color: var(--warn) !important; }
[style*="#b00020"] { color: var(--err) !important; }
[style*="#555"] { color: var(--muted) !important; }
tr[style*="fff3cd"] > td { background: rgba(251,191,36,.14) !important; }

/* ---------- glass cards ---------- */
.card {
  position: relative; margin: 14px 0; padding: 18px 20px; border-radius: 20px;
  background: linear-gradient(150deg, rgba(255,255,255,.105), rgba(255,255,255,.035));
  border: 1px solid var(--glass-brd);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,.16);
  backdrop-filter: blur(18px) saturate(150%); -webkit-backdrop-filter: blur(18px) saturate(150%);
}
:root[data-theme="light"] .card { background: linear-gradient(150deg, rgba(255,255,255,.9), rgba(255,255,255,.55)); }
.card > h3:first-child, .card > h4:first-child { margin-top: 0; }
.card.err { background: linear-gradient(150deg, rgba(251,113,133,.16), rgba(251,113,133,.05)); border-color: rgba(251,113,133,.4); }
.card ul { margin: 8px 0; }

/* dashboard tiles (the existing grid of <a class="card">) */
div[style*="display:grid"] { gap: 16px !important; perspective: 1100px; }
div[style*="display:grid"] > a.card {
  display: flex; flex-direction: column; gap: 4px; min-height: 148px; margin: 0; padding: 20px; overflow: hidden;
  transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transition: transform .25s cubic-bezier(.2,.8,.2,1), box-shadow .25s, border-color .25s;
  will-change: transform;
}
div[style*="display:grid"] > a.card:hover { border-color: rgba(167,139,250,.6); box-shadow: 0 24px 50px -16px rgba(124,58,237,.55), inset 0 1px 0 rgba(255,255,255,.28); }
div[style*="display:grid"] > a.card::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .25s;
  background: radial-gradient(260px circle at var(--mx, 50%) var(--my, 0%), rgba(255,255,255,.2), transparent 60%);
}
div[style*="display:grid"] > a.card:hover::after { opacity: 1; }
div[style*="display:grid"] > a.card::before {
  content: "\2192"; position: absolute; right: 18px; bottom: 14px; font-size: 1.3rem; color: var(--link);
  opacity: 0; transform: translateX(-8px); transition: .25s;
}
div[style*="display:grid"] > a.card:hover::before { opacity: 1; transform: none; }
div[style*="display:grid"] > a.card br { display: none; }
div[style*="display:grid"] > a.card strong { font-size: 1.06rem; margin-top: 8px; }
div[style*="display:grid"] > a.card small { line-height: 1.4; }
.tile-ico {
  width: 50px; height: 50px; border-radius: 16px; display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, var(--ia, #8b5cf6), var(--ib, #4f46e5));
  box-shadow: 0 12px 22px -8px var(--ia, #8b5cf6), inset 0 2px 0 rgba(255,255,255,.4), inset 0 -4px 0 rgba(0,0,0,.18);
  transform: translateZ(30px); animation: bob 4.5s ease-in-out infinite;
}
.tile-ico svg { width: 26px; height: 26px; stroke: #fff; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 2px 3px rgba(0,0,0,.3)); }
div[style*="display:grid"] > a.card:nth-child(2) .tile-ico { --ia: #3b82f6; --ib: #4f46e5; animation-delay: -.8s; }
div[style*="display:grid"] > a.card:nth-child(3) .tile-ico { --ia: #14b8a6; --ib: #0ea5e9; animation-delay: -1.6s; }
div[style*="display:grid"] > a.card:nth-child(4) .tile-ico { --ia: #f59e0b; --ib: #ef4444; animation-delay: -2.4s; }
div[style*="display:grid"] > a.card:nth-child(5) .tile-ico { --ia: #ec4899; --ib: #8b5cf6; animation-delay: -3.2s; }
@keyframes bob { 50% { transform: translateZ(30px) translateY(-5px); } }

/* ---------- layout: sidebar + content ---------- */
nav {
  position: fixed; z-index: 50; top: 0; left: 0; bottom: 0; width: var(--sbw);
  display: flex; flex-direction: column; gap: 4px; margin: 0; padding: 22px 16px 18px;
  padding-left: calc(16px + env(safe-area-inset-left));
  background: linear-gradient(180deg, rgba(255,255,255,.085), rgba(255,255,255,.03));
  backdrop-filter: blur(26px) saturate(160%); -webkit-backdrop-filter: blur(26px) saturate(160%);
  border: 0; border-right: 1px solid var(--glass-brd); overflow-y: auto; overscroll-behavior: contain;
}
:root[data-theme="light"] nav { background: linear-gradient(180deg, rgba(255,255,255,.85), rgba(255,255,255,.55)); }
nav strong {
  display: flex; align-items: center; gap: 12px; margin: 2px 6px 22px; font-size: 1.28rem; letter-spacing: -.01em; line-height: 1.1;
}
nav strong em { font-style: normal; display: block; font-size: .72rem; font-weight: 600; letter-spacing: .22em; text-transform: uppercase; color: var(--muted); margin-top: 3px; }
.logo { width: 42px; height: 42px; flex: none; filter: drop-shadow(0 6px 14px rgba(139,92,246,.6)); animation: bob2 5s ease-in-out infinite; }
@keyframes bob2 { 50% { transform: translateY(-3px) rotate(-3deg); } }
nav a {
  position: relative; display: flex; align-items: center; gap: 13px; padding: 11px 14px; border-radius: 14px;
  color: var(--muted); text-decoration: none; font-weight: 550; transition: background .2s, color .2s, transform .2s;
}
nav a svg { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
nav a:hover { background: var(--glass2); color: var(--txt); transform: translateX(4px); }
nav a.active {
  color: #fff; background: linear-gradient(135deg, rgba(139,92,246,.62), rgba(79,70,229,.40));
  box-shadow: 0 10px 26px -10px rgba(139,92,246,.85), inset 0 1px 0 rgba(255,255,255,.28);
}
nav a.active::before { content: ""; position: absolute; left: -16px; top: 10px; bottom: 10px; width: 4px; border-radius: 0 4px 4px 0; background: linear-gradient(var(--c1), var(--p1)); box-shadow: 0 0 14px var(--p1); }
nav a[href="?p=logout"]:hover { background: rgba(251,113,133,.16); color: var(--err); }
nav .sp { flex: 1; min-height: 14px; }
.who { display: flex; align-items: center; gap: 11px; padding: 10px 12px; margin: 4px 0; border-radius: 16px; background: var(--glass); border: 1px solid var(--glass-brd); min-width: 0; }
.who .av { width: 38px; height: 38px; flex: none; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-weight: 750; font-size: .85rem; color: #fff; background: linear-gradient(135deg, #8b5cf6, #3b82f6); box-shadow: 0 6px 14px -4px rgba(99,102,241,.8), inset 0 1px 0 rgba(255,255,255,.4); }
.who .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: .92rem; }
button.themebtn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; width: 100%; margin: 6px 0 2px; padding: 10px 14px;
  background: var(--glass); color: var(--txt); font-weight: 600; font-size: .9rem; border: 1px solid var(--glass-brd);
  box-shadow: none;
}
button.themebtn:hover { background: var(--glass2); box-shadow: none; }
button.themebtn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

main { position: relative; z-index: 1; margin-left: var(--sbw); padding: 34px clamp(18px, 3.2vw, 52px) 70px; min-width: 0; }
main > * { max-width: 1180px; margin-left: auto; margin-right: auto; }
main > h2 { animation-delay: 0s; }
/* gentle entrance for each block */
main > * { animation: rise .6s cubic-bezier(.2,.8,.2,1) both; }
main > :nth-child(2) { animation-delay: .04s; } main > :nth-child(3) { animation-delay: .08s; }
main > :nth-child(4) { animation-delay: .12s; } main > :nth-child(5) { animation-delay: .16s; }
main > :nth-child(6) { animation-delay: .20s; } main > :nth-child(7) { animation-delay: .24s; }
main > :nth-child(n+8) { animation-delay: .28s; }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

/* mobile / tablet top bar + drawer */
.topbar, .scrim { display: none; }
@media (max-width: 1023px) {
  nav { width: min(304px, 86vw); transform: translateX(-104%); transition: transform .38s cubic-bezier(.2,.8,.2,1); box-shadow: 30px 0 80px rgba(0,0,0,.5); }
  body.nav-open nav { transform: none; }
  body.nav-open { overflow: hidden; }
  main { margin-left: 0; padding: calc(78px + env(safe-area-inset-top)) 16px 56px; }
  .topbar {
    display: flex; align-items: center; gap: 12px; position: fixed; z-index: 40; top: 0; left: 0; right: 0;
    height: calc(62px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 12px 0;
    background: linear-gradient(180deg, rgba(20,16,50,.78), rgba(20,16,50,.55));
    backdrop-filter: blur(22px) saturate(160%); -webkit-backdrop-filter: blur(22px) saturate(160%);
    border-bottom: 1px solid var(--glass-brd);
  }
  :root[data-theme="light"] .topbar { background: linear-gradient(180deg, rgba(255,255,255,.9), rgba(255,255,255,.7)); }
  .topbar .tb-brand { flex: 1; display: flex; align-items: center; gap: 10px; font-weight: 750; font-size: 1.08rem; min-width: 0; }
  .topbar .logo { width: 34px; height: 34px; }
  .topbar button { margin: 0; width: 44px; height: 44px; min-height: 44px; padding: 0; display: grid; place-items: center; background: var(--glass2); color: var(--txt); border: 1px solid var(--glass-brd); box-shadow: none; border-radius: 14px; }
  .topbar button svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 45; background: rgba(4,3,14,.6); backdrop-filter: blur(3px); opacity: 0; pointer-events: none; transition: opacity .3s; }
  body.nav-open .scrim { opacity: 1; pointer-events: auto; }
  nav button.themebtn { display: none; }
  .topbar button.themebtn span { display: none; }
  .tablet-only-theme { display: inline-flex; }
}
@media (min-width: 1024px) { .topbar button.themebtn { display: none; } }

/* ---------- forms ---------- */
input, select, textarea, button { font: inherit; color: inherit; }
input:not([type=checkbox]):not([type=radio]):not([type=hidden]):not([type=file]):not([type=submit]):not([type=button]),
select, textarea {
  background: var(--field); border: 1px solid var(--field-brd); border-radius: 13px; padding: 10px 14px; min-height: 44px;
  max-width: 100%; margin: 4px 0; color: var(--txt);
  transition: border-color .2s, box-shadow .25s, background .2s;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:not([type=checkbox]):not([type=radio]):focus, select:focus, textarea:focus {
  outline: 0; border-color: #a78bfa; background: rgba(255,255,255,.12);
  box-shadow: 0 0 0 4px rgba(139,92,246,.25), 0 0 26px -6px rgba(139,92,246,.7);
}
:root[data-theme="light"] input:focus, :root[data-theme="light"] select:focus, :root[data-theme="light"] textarea:focus { background: #fff; }
textarea { width: 100%; min-height: 180px; resize: vertical; line-height: 1.5; }
select:not([multiple]):not([size]) {
  appearance: none; -webkit-appearance: none; padding-right: 40px; cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a78bfa' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 18px;
}
select option, select optgroup { background: #17123a; color: #ecebff; }
:root[data-theme="light"] select option { background: #fff; color: #1d1a3d; }
input[type=checkbox], input[type=radio] { accent-color: #8b5cf6; width: 19px; height: 19px; margin: 0 7px 0 0; vertical-align: -4px; cursor: pointer; }
input[type=file] { max-width: 100%; padding: 8px; border: 1px dashed var(--field-brd); border-radius: 14px; background: var(--glass); }
input[type=file]::file-selector-button { border: 0; margin-right: 12px; padding: 9px 16px; border-radius: 11px; color: #fff; font-weight: 650; cursor: pointer; background: linear-gradient(135deg, #8b5cf6, #3b82f6); }
label { display: inline-block; margin: 5px 0; color: var(--muted); }
label input:not([type=checkbox]):not([type=radio]) { color: var(--txt); }
fieldset { border: 1px solid var(--glass-brd); border-radius: 16px; }
details { margin: 14px 0; padding: 12px 16px; border-radius: 16px; background: var(--glass); border: 1px solid var(--glass-brd); }
summary { cursor: pointer; font-weight: 650; }

button, input[type=submit] {
  position: relative; overflow: hidden; cursor: pointer; border: 0; border-radius: 14px; padding: 11px 22px; min-height: 44px;
  font-weight: 650; letter-spacing: .01em; color: #fff; margin: 4px 6px 4px 0;
  background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 52%, #3b82f6 100%);
  box-shadow: 0 12px 24px -10px rgba(99,102,241,.9), inset 0 1px 0 rgba(255,255,255,.38), inset 0 -3px 0 rgba(0,0,0,.2);
  transition: transform .15s, box-shadow .2s, filter .2s;
  -webkit-tap-highlight-color: transparent;
}
button:hover, input[type=submit]:hover { transform: translateY(-2px); filter: brightness(1.1); box-shadow: 0 18px 30px -10px rgba(99,102,241,.95), inset 0 1px 0 rgba(255,255,255,.42), inset 0 -3px 0 rgba(0,0,0,.2); }
button:active, input[type=submit]:active { transform: translateY(2px) scale(.985); box-shadow: 0 4px 10px -4px rgba(99,102,241,.9), inset 0 2px 4px rgba(0,0,0,.3); }
button:disabled { opacity: .5; cursor: not-allowed; transform: none; filter: grayscale(.4); }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid #c4b5fd; outline-offset: 3px; }
.ripple { position: absolute; border-radius: 50%; pointer-events: none; background: rgba(255,255,255,.45); transform: scale(0); animation: rip .6s ease-out forwards; }
@keyframes rip { to { transform: scale(1); opacity: 0; } }

/* ---------- tables ---------- */
.tablewrap {
  overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 12px 0; border-radius: 18px; max-width: 100%;
  background: var(--glass); border: 1px solid var(--glass-brd); box-shadow: var(--shadow);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
table { border-collapse: separate !important; border-spacing: 0; border: 0; width: 100%; font-size: .94rem; }
th, td { border: 0; padding: 12px 15px; vertical-align: top; text-align: left; border-bottom: 1px solid rgba(255,255,255,.075); }
:root[data-theme="light"] th, :root[data-theme="light"] td { border-bottom-color: rgba(100,80,180,.14); }
th { font-size: .73rem; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); background: rgba(255,255,255,.055); white-space: nowrap; position: sticky; top: 0; }
tr:last-child > td { border-bottom: 0; }
tbody tr { transition: background .15s; }
tbody tr:hover > td { background: rgba(139,92,246,.10); }
td input:not([type=checkbox]):not([type=radio]) { margin: 0; min-height: 40px; }
.card > table, .card > .tablewrap { box-shadow: none; }

/* =====================================================================
   LOGIN / TWO-STEP / INSTALLER SCENE (animated hexagon background)
   ===================================================================== */
canvas#hexbg { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; display: block; background: #050409; }
body.auth { display: grid; place-items: center; padding: 28px 16px; overflow-x: hidden; background: #050409; }
body.auth::before { display: none; }
body.auth::after { content: ""; position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background: radial-gradient(ellipse at 50% 45%, rgba(5,4,9,.05) 0, rgba(5,4,9,.35) 55%, rgba(5,4,9,.82) 100%); }
body.auth nav, body.auth .topbar, body.auth .scrim { display: none !important; }
body.auth main {
  position: relative; z-index: 2; margin: 0; width: min(440px, 100%); padding: 0 30px 32px; border-radius: 28px;
  background: linear-gradient(160deg, rgba(255,255,255,.115), rgba(255,255,255,.035));
  backdrop-filter: blur(22px) saturate(170%); -webkit-backdrop-filter: blur(22px) saturate(170%);
  border: 1px solid rgba(255,255,255,.16);
  box-shadow: 0 40px 90px -24px rgba(0,0,0,.9), 0 0 60px -10px rgba(124,58,237,.35), inset 0 1px 0 rgba(255,255,255,.22);
  animation: cardIn 1s cubic-bezier(.2,.8,.2,1) both; transform-style: preserve-3d;
}
body.auth main > * { max-width: none; animation: none; }
body.auth main::before {
  content: ""; position: absolute; inset: -1px; border-radius: inherit; padding: 1.6px; pointer-events: none;
  background: conic-gradient(from var(--ang), transparent 0 52%, #a855f7 68%, #22d3ee 82%, #3b82f6 90%, transparent 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0); animation: spin 6s linear infinite;
}
@keyframes spin { to { --ang: 360deg; } }
@keyframes cardIn { from { opacity: 0; transform: perspective(900px) translateY(40px) rotateX(14deg) scale(.96); } to { opacity: 1; transform: none; } }
body.auth main.shake { animation: shake .5s both; }
@keyframes shake { 20%, 60% { transform: translateX(-9px); } 40%, 80% { transform: translateX(9px); } }
body.auth h1, body.auth h2 { text-align: center; margin: 0 0 14px; }
body.auth h2 { font-size: 1.55rem; }
body.auth h1 { font-size: 1.55rem; }
body.auth form br { display: none; }
body.auth form > p, body.auth main > p { text-align: center; }
body.auth input:not([type=checkbox]):not([type=radio]):not([type=hidden]) { display: block; width: 100%; margin: 9px 0; background: rgba(8,6,20,.55); }
body.auth form > button { width: 100%; margin: 14px 0 0; }
body.auth .card { background: rgba(8,6,20,.45); }
.auth-brand { display: flex; flex-direction: column; align-items: center; margin: 0 -10px 4px; text-align: center; }
.auth-brand .bot { width: 132px; margin-top: -44px; margin-bottom: -6px; filter: drop-shadow(0 18px 24px rgba(99,102,241,.45)); }
.auth-name { font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; }
.auth-name span { background: linear-gradient(90deg, #c4b5fd, #67e8f9); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.auth-tag { color: var(--muted); font-size: .88rem; margin: 2px 0 16px; }
/* installer (wider page) */
body.auth.wide { place-items: start center; }
body.auth.wide main { width: min(780px, 100%); margin: 36px 0; text-align: left; }
body.auth.wide .auth-brand .bot { width: 104px; margin-top: -36px; }
body.auth.wide form > button { width: auto; }
body.auth.wide table { font-size: .9rem; }

/* =====================================================================
   DASHBOARD HERO (greeting, mascot, progress ring, 3D cube)
   ===================================================================== */
.hero {
  position: relative; display: flex; align-items: center; gap: 22px; padding: 26px 30px; margin-bottom: 26px; border-radius: 26px; overflow: hidden;
  background: linear-gradient(120deg, rgba(139,92,246,.34), rgba(59,130,246,.20) 58%, rgba(34,211,238,.11));
  border: 1px solid var(--glass-brd); box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,.22);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
}
.hero::before { content: ""; position: absolute; width: 340px; height: 340px; right: -90px; top: -150px; border-radius: 50%; background: radial-gradient(circle, rgba(167,139,250,.5), transparent 65%); filter: blur(10px); animation: pulseGlow 6s ease-in-out infinite alternate; pointer-events: none; }
@keyframes pulseGlow { to { transform: scale(1.25); opacity: .6; } }
.hero-txt { position: relative; flex: 1; min-width: 0; z-index: 1; }
.hero-hi { font-size: clamp(1.3rem, 1rem + 1.4vw, 2rem); font-weight: 780; letter-spacing: -.02em; margin: 0 0 6px; line-height: 1.2; }
.hero-hi .wave-emoji { display: inline-block; transform-origin: 70% 70%; animation: waveHand 2.4s ease-in-out infinite; }
@keyframes waveHand { 0%, 60%, 100% { transform: rotate(0); } 10%, 30% { transform: rotate(16deg); } 20%, 40% { transform: rotate(-10deg); } 50% { transform: rotate(8deg); } }
.hero-sub { margin: 0; color: var(--muted); }
.hero .ring { position: relative; width: 92px; height: 92px; flex: none; z-index: 1; filter: drop-shadow(0 8px 16px rgba(139,92,246,.45)); }
.hero .ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.hero .ring .trk { stroke: rgba(255,255,255,.14); } .hero .ring .bar { stroke: url(#ringg); stroke-linecap: round; transition: stroke-dashoffset 1.4s cubic-bezier(.2,.8,.2,1); }
.hero .ring b { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; text-align: center; line-height: 1.1; font-size: 1.25rem; }
.hero .ring b small { display: block; font-size: .62rem; letter-spacing: .12em; text-transform: uppercase; font-weight: 600; margin-top: 2px; }
.hero .bot { width: 118px; flex: none; z-index: 1; margin: -10px 0; filter: drop-shadow(0 14px 18px rgba(0,0,0,.35)); }
.cube-scene { position: absolute; right: 36%; top: 22px; width: 54px; height: 54px; perspective: 500px; opacity: .9; pointer-events: none; }
.cube { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; animation: spin3d 14s linear infinite; }
.cube i { position: absolute; inset: 0; border-radius: 8px; border: 1px solid rgba(255,255,255,.45); background: linear-gradient(135deg, rgba(167,139,250,.55), rgba(34,211,238,.25)); box-shadow: inset 0 0 18px rgba(255,255,255,.25); }
.cube i:nth-child(1) { transform: translateZ(27px); } .cube i:nth-child(2) { transform: rotateY(180deg) translateZ(27px); }
.cube i:nth-child(3) { transform: rotateY(90deg) translateZ(27px); } .cube i:nth-child(4) { transform: rotateY(-90deg) translateZ(27px); }
.cube i:nth-child(5) { transform: rotateX(90deg) translateZ(27px); } .cube i:nth-child(6) { transform: rotateX(-90deg) translateZ(27px); }
@keyframes spin3d { to { transform: rotateX(360deg) rotateY(360deg); } }

/* ---------- mascot animation (SVG classes) ---------- */
.bot svg, svg.bot { overflow: visible; }
.bot .float { animation: botfloat 3.6s ease-in-out infinite; transform-box: fill-box; }
.bot .shadow { animation: botshadow 3.6s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.bot .eyes { transform: translate(calc(var(--ex, 0) * 1px), calc(var(--ey, 0) * 1px)); transition: transform .12s ease-out; }
.bot .eye { transform-box: fill-box; transform-origin: center; animation: blink 5s infinite; }
.bot .eye:nth-child(2) { animation-delay: .02s; }
.bot .hand { transition: transform .45s cubic-bezier(.3,1.4,.5,1); transform-box: fill-box; }
.bot.shy .hand.l { transform: translate(24px, -66px); } .bot.shy .hand.r { transform: translate(-24px, -66px); }
.bot.shy .eyes { opacity: 0; transition: opacity .2s .1s; }
.bot .wave { transform-origin: 50% 100%; animation: botwave 1.8s ease-in-out infinite; }
.bot .led { animation: led 1.6s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.bot .chest { animation: led 2.2s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes botfloat { 50% { transform: translateY(-8px); } }
@keyframes botshadow { 50% { transform: scale(.8); opacity: .6; } }
@keyframes blink { 0%, 92%, 100% { transform: scaleY(1); } 95.5% { transform: scaleY(.08); } }
@keyframes botwave { 0%, 100% { transform: translate(0, 0) rotate(0); } 25% { transform: translate(5px, -12px) rotate(18deg); } 50% { transform: translate(-1px, -6px) rotate(-8deg); } 75% { transform: translate(5px, -12px) rotate(14deg); } }
@keyframes led { 50% { opacity: .35; transform: scale(.7); } }

/* ---------- phones & small screens ---------- */
@media (max-width: 700px) {
  body { font-size: 15.5px; }
  h3 { margin-top: 22px; }
  .card { padding: 16px; border-radius: 18px; }
  input:not([type=checkbox]):not([type=radio]):not([type=hidden]):not([type=file]):not([type=submit]):not([type=button]), select, textarea { font-size: 16px; } /* stops iOS zoom-on-focus */
  form input:not([type=checkbox]):not([type=radio]):not([type=hidden]):not([type=file]):not([style*="width"]), form select:not([style*="width"]) { width: 100%; }
  form button, form input[type=submit] { max-width: 100%; }
  .hero { flex-wrap: wrap; padding: 20px; gap: 14px 16px; }
  .hero .bot { width: 92px; order: -1; margin: -6px 0; }
  .hero-txt { flex: 1 1 60%; }
  .hero .ring { width: 76px; height: 76px; }
  .cube-scene { display: none; }
  div[style*="display:grid"] > a.card { min-height: 0; flex-direction: row; align-items: center; gap: 4px 16px; flex-wrap: wrap; }
  div[style*="display:grid"] > a.card .tile-ico { margin-right: 2px; }
  div[style*="display:grid"] > a.card strong { flex: 1; margin-top: 0; }
  div[style*="display:grid"] > a.card small { flex-basis: 100%; }
  th, td { padding: 10px 12px; }
  body.auth { padding: 22px 12px; }
  body.auth main { padding: 0 20px 26px; border-radius: 24px; }
  body.auth.wide main { margin: 28px 0; }
  .auth-brand .bot { width: 112px; margin-top: -38px; }
}
@media (max-width: 380px) { main { padding-left: 12px; padding-right: 12px; } .hero { padding: 16px; } }
@media (hover: none) { div[style*="display:grid"] > a.card { transform: none !important; } nav a:hover, button:hover { transform: none; } }

/* ---------- accessibility + print ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
@media print {
  html, body { background: #fff !important; color: #000 !important; }
  body { padding: 0 !important; display: block !important; }
  body::before, body::after, nav, .topbar, .scrim, .hero, .noprint, canvas, .cube-scene, .auth-brand { display: none !important; }
  main { margin: 0 !important; padding: 0 !important; width: auto !important; border: 0 !important; box-shadow: none !important; background: none !important; backdrop-filter: none !important; animation: none !important; }
  main > * { max-width: none !important; animation: none !important; opacity: 1 !important; }
  h1, h2, h3 { background: none !important; -webkit-text-fill-color: #000 !important; color: #000 !important; }
  .card, .tablewrap, details { background: #fff !important; border: 1px solid #bbb !important; box-shadow: none !important; backdrop-filter: none !important; color: #000 !important; }
  a, small, em, label, td, th, p, li { color: #000 !important; }
  th { background: #eee !important; position: static; }
  tbody tr:hover > td { background: none !important; }
  .tablewrap { overflow: visible !important; }
}
