:root {
  color-scheme: light;
  --navy:#0b1e3d; --navy-light:#142c52; --purple:#7137d8; --purple-dark:#5721b0;
  --lavender:#eee6fd; --ink:#152340; --muted:#53627c; --line:#dbe3f0; --canvas:#f3f6fc;
  --white:#fff; --green:#16644c; --red:#a12c3d;
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  font-size:16px;
}
* {box-sizing:border-box}
body {margin:0;background:var(--canvas);color:var(--ink);min-width:280px}
button,input,select,textarea {font:inherit}
button,a,input,select,textarea {touch-action:manipulation}
button {cursor:pointer}
button:disabled {opacity:.57;cursor:default}
:focus-visible {outline:3px solid #ae87ff;outline-offset:3px}
button {border:0;border-radius:10px;padding:10px 15px;min-height:42px;font-weight:650;background:#edf1f9;color:var(--navy)}
button.primary {background:var(--purple-dark);color:white}
button.primary:hover {background:#702cd4}
button.secondary {background:var(--lavender);color:#502399}
button.ghost {background:transparent;color:inherit}
button.danger {background:#fce9ed;color:var(--red)}
button.small {font-size:.875rem;padding:6px 10px;min-height:36px}
input,select,textarea {padding:10px 12px;border:1px solid #b9c8df;border-radius:9px;min-height:42px;width:100%;background:#fff;color:var(--ink)}
textarea {min-height:80px;resize:vertical}
input[type=checkbox] {width:auto;min-height:auto;accent-color:var(--purple)}
label {display:grid;gap:6px;font-size:.875rem;font-weight:650}
label.check {display:flex;align-items:center;gap:9px}
p {line-height:1.55;margin:0 0 12px}
h1,h2,h3,h4 {margin:0;font-family:"Poppins","Segoe UI",system-ui,sans-serif}
h1 {font-size:clamp(1.85rem,4vw,2.7rem);letter-spacing:-.045em}
h2 {font-size:1.22rem;letter-spacing:-.015em}
h3 {font-size:1.05rem}
a {color:var(--purple-dark)}
small,.small-text {font-size:.875rem}
.muted {color:var(--muted)}
.error {color:var(--red)}
.success {color:var(--green)}
.brand {display:flex;align-items:center;gap:10px;font-size:1.27rem;font-weight:800;white-space:nowrap;letter-spacing:-.035em}
.brand img {width:40px;height:40px;border-radius:10px}
.brand em {color:#bb95ff;font-style:normal}
.auth {min-height:100svh;display:grid;place-items:center;background:linear-gradient(#08163070,#081630a0),center 44% / cover no-repeat url("./assets/librarian.webp") #081630;color:white}
.auth-main {display:grid;place-items:center;width:min(100%,528px);padding:24px}
.auth-card {width:min(100%,480px);background:#111f41f5;border:1px solid #777299;border-radius:23px;padding:clamp(20px,4vw,34px);box-shadow:0 24px 64px #03081775}
.auth-card h2 {margin:20px 0 5px;font-size:1.65rem}
.auth-card .muted {color:#cec9e0}
.auth-card form {margin-top:18px}
.auth-card .switcher {background:#222c50;padding:4px;margin-top:18px}
.auth-card .switcher button {background:transparent;color:#e7dfff}
.auth-card .switcher .chosen {background:#7036d9;color:white}
.auth-card button.primary {background:#783bda}
.auth-links {display:flex;justify-content:space-between;flex-wrap:wrap;gap:5px;margin:6px 0}
.auth-card .ghost {color:#e1ccff;padding-left:0;padding-right:0}
.auth-error {color:#ffb8c5;margin:0}
.demo-box {margin-top:16px;padding-top:15px;border-top:1px solid #4c4670}
.demo-box p {color:#ddd3f5;margin-bottom:8px}
.prototype-text {margin:14px 0 0;color:#c9bde5;font-size:.82rem}
.form-grid,.flow {display:grid;gap:12px}
.form-grid.two {grid-template-columns:repeat(2,minmax(0,1fr))}
.form-grid .span {grid-column:1/-1}
.password-wrap {display:flex;gap:6px}
.password-wrap button {flex-shrink:0}
.switcher {display:flex;gap:5px;border-radius:12px}
.switcher button {flex:1}
.switcher .chosen {background:var(--purple-dark);color:white}
.shell {min-height:100svh;display:grid;grid-template-columns:246px minmax(0,1fr)}
.sidebar {background:linear-gradient(160deg,#0b1e3d,#102947);padding:20px 14px;color:#e6eeff;position:sticky;top:0;height:100svh;overflow:auto;display:flex;flex-direction:column;gap:18px}
.sidebar .brand {margin:0 4px}
.school-name {background:#1b345a;padding:12px;border-radius:10px;font-size:.875rem;line-height:1.45}
.school-name strong {display:block;color:white}
.sidebar nav {display:grid;gap:4px}
.sidebar button {background:none;color:#e1eafe;text-align:left;display:flex;align-items:center;gap:9px;padding:9px 12px;min-height:40px;border-radius:8px;font-size:.9rem}
.sidebar button.active {background:#6334c2;color:white}
.sidebar button:hover {background:#273e62}
.sidebar .side-bottom {margin-top:auto}
.ico {display:inline-grid;place-items:center;min-width:1.3rem;font-weight:800}
.topbar {display:flex;align-items:center;justify-content:space-between;gap:12px;background:white;border-bottom:1px solid var(--line);padding:13px clamp(16px,3vw,34px);min-height:65px}
.topbar .right {display:flex;align-items:center;gap:8px}
.mobile-toggle {display:none}
.avatar {display:grid;place-items:center;border-radius:50%;background:#e7dcff;color:#512aa1;width:36px;height:36px;font-size:.82rem;font-weight:800;flex-shrink:0}
.main {padding:25px clamp(16px,3vw,36px) 40px;max-width:1380px;margin:auto}
.page-head {display:flex;align-items:flex-end;justify-content:space-between;gap:12px;margin-bottom:20px}
.page-head p {margin:5px 0 0;color:var(--muted)}
.pill {display:inline-flex;align-items:center;gap:6px;white-space:nowrap;border-radius:20px;padding:5px 9px;background:#eef1f7;color:#40516e;font-size:.78rem;font-weight:700}
.pill.ok {background:#e1f4ec;color:#16644c}
.pill.warn {background:#fcedd4;color:#754809}
.pill.bad {background:#fbe7ec;color:var(--red)}
.pill.accent {background:#eee5ff;color:#5328a0}
.grid {display:grid;gap:16px}
.metrics {grid-template-columns:repeat(4,minmax(0,1fr));margin-bottom:16px}
.split {grid-template-columns:minmax(0,1.4fr) minmax(260px,1fr);margin-bottom:16px;align-items:start}
.equal {grid-template-columns:repeat(2,minmax(0,1fr))}
.panel,.metric,.book-card {background:white;border:1px solid var(--line);border-radius:15px;padding:18px;box-shadow:0 6px 16px #10234c06}
.panel p:last-child {margin-bottom:0}
.panel-head {display:flex;justify-content:space-between;gap:10px;align-items:center;margin-bottom:14px}
.metric label {color:#52607b;display:block}
.metric strong {display:block;font-size:clamp(1.28rem,4vw,2.05rem);margin:5px 0;letter-spacing:-.04em}
.metric .ico {color:#6b31bd;background:#f0e8fc;border-radius:9px;width:34px;height:34px;display:grid}
.metric:nth-child(2) .ico {color:#186099;background:#e5f1ff}
.metric:nth-child(3) .ico {color:#187255;background:#e3f6ed}
.metric:nth-child(4) .ico {color:#ae354c;background:#fce7ed}
.chart {min-height:164px;display:grid;grid-template-columns:repeat(7,minmax(0,1fr));align-items:end;gap:6px;border-bottom:1px solid var(--line)}
.column {display:grid;grid-template-rows:1fr auto;justify-items:center;align-items:end;height:150px;font-size:.75rem;color:var(--muted);gap:4px}
.bar {width:min(65%,38px);min-height:4px;background:linear-gradient(0deg,#6125be,#aa77fb);border-radius:6px 6px 0 0;display:flex;justify-content:center;align-items:flex-start;color:#fff;font-size:.74rem}
.quick {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
.quick button {padding:13px 8px;background:#eef1fb;display:grid;justify-items:center;align-content:center;gap:6px;min-height:75px}
.quick .ico {color:#632aba;font-size:1.25rem}
.tools {display:flex;align-items:flex-end;flex-wrap:wrap;gap:9px;margin-bottom:14px}
.tools label {flex:1 1 175px}
.table-scroll {overflow:auto}
table {border-collapse:collapse;width:100%;font-size:.875rem}
th,td {padding:11px 9px;text-align:left;border-bottom:1px solid #e6ecf5;vertical-align:middle}
th {color:var(--muted);background:#f5f7fc;font-size:.78rem;white-space:nowrap}
td small {display:block;margin-top:4px;color:var(--muted)}
.actions {display:flex;gap:6px;flex-wrap:wrap}
.empty {padding:20px 4px;color:var(--muted)}
.book-grid {grid-template-columns:repeat(auto-fit,minmax(min(100%,220px),1fr))}
.cover {width:43px;height:55px;display:grid;place-items:center;color:white;background:linear-gradient(125deg,#4f26a9,#9460eb);border-radius:4px 8px 8px 4px;box-shadow:inset 3px 0 #ffffff44;flex-shrink:0;font-weight:800}
.cover.science {background:linear-gradient(125deg,#07305b,#397daa)}
.cover.fiction {background:linear-gradient(125deg,#642743,#aa557e)}
.cover.agriculture {background:linear-gradient(125deg,#144c40,#2b9072)}
.book-name {display:flex;gap:10px;align-items:center}
.book-card .actions {margin-top:12px}
.book-card h3 {margin:4px 0}
.card-list {display:grid;gap:9px;margin:12px 0}
.line-item {display:flex;justify-content:space-between;align-items:center;gap:12px;padding:10px 0;border-bottom:1px solid var(--line)}
.line-item p {margin:4px 0 0}
.steps {display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:7px;margin:12px 0 16px}
.step {background:#f0f3fa;border:1px solid var(--line);border-radius:10px;padding:10px;font-size:.875rem}
.step b {display:block;color:#6229be;margin-bottom:3px}
.qr-samples {display:flex;flex-wrap:wrap;gap:10px;margin-top:12px}
.qr-samples figure {margin:0;text-align:center;font-size:.82rem}
.qr-samples img {width:96px;height:96px;display:block;image-rendering:pixelated}
.scanner video {width:100%;max-height:250px;background:#0b1e3d;border-radius:12px}
.settings-grid {align-items:start}
details summary {cursor:pointer;font-weight:650;margin-bottom:9px}
details + details {margin-top:14px}
dialog {width:min(550px,calc(100% - 28px));border:1px solid var(--line);border-radius:15px;padding:20px;color:var(--ink);max-height:90svh}
dialog::backdrop {background:#08113099}
.dialog-title {display:flex;justify-content:space-between;align-items:center;gap:10px;margin-bottom:14px}
#toast {position:fixed;bottom:16px;right:16px;z-index:5;background:var(--navy);color:white;padding:11px 16px;border-radius:10px;max-width:calc(100% - 32px);box-shadow:0 8px 30px #12234150;font-weight:650}
#toast:empty {display:none}

.owner-topbar {background:var(--navy);color:white}
@media(min-width:768px) and (max-width:1100px) {
  :root {font-size:17px}
  .shell {grid-template-columns:210px minmax(0,1fr)}
  .metrics,.equal {grid-template-columns:repeat(2,minmax(0,1fr))}
  .split {grid-template-columns:1fr}
  .sidebar button,.actions button {min-height:44px}
  .main {padding:22px 18px 38px}
}

@media(max-width:767px) {
  .auth-main {padding:14px}
  .shell {display:block}
  .sidebar {display:none;height:auto;max-height:70svh;z-index:3;position:absolute;top:62px;left:0;right:0;box-shadow:0 12px 20px #08113055}
  .sidebar.open {display:flex}
  .sidebar nav {grid-template-columns:repeat(2,minmax(0,1fr))}
  .mobile-toggle {display:block}
  .topbar {min-height:62px}
  .topbar .school-top {font-size:.85rem}
  .topbar .right .name {display:none}
  .metrics,.equal {grid-template-columns:repeat(2,minmax(0,1fr))}
  .metric,.panel,.book-card {padding:12px}
}
@media(max-width:420px) {
  .page-head {align-items:flex-start;flex-direction:column}
  .form-grid.two,.equal {grid-template-columns:1fr}
  .topbar .right .connection {display:none}
  .sidebar .brand {display:none}
}
@media(prefers-reduced-motion:reduce) {*,*::before,*::after {transition:none!important;animation:none!important}}

.auth-card .form-error {color:#ffb8c5}
.mobile-nav {display:none}
@media(max-width:767px) {
  .student-main {padding-bottom:95px}
  .mobile-nav {display:flex;position:fixed;inset:auto 0 0;z-index:2;justify-content:space-evenly;gap:4px;background:white;border-top:1px solid var(--line);padding:6px 8px max(6px,env(safe-area-inset-bottom))}
  .mobile-nav button {flex:1;display:grid;gap:2px;place-items:center;padding:5px 2px;font-size:.8rem;background:white;color:var(--navy)}
  .mobile-nav button[aria-current] {color:var(--purple-dark);background:var(--lavender)}
  body:has(.mobile-nav) #toast {bottom:72px}
}

@media(max-width:767px) {
  .split,.equal {grid-template-columns:1fr}
  .table-scroll table,.table-scroll tbody {display:block}
  .table-scroll thead {position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)}
  .table-scroll tr {display:grid;margin:0 0 10px;padding:8px;border:1px solid var(--line);border-radius:10px}
  .table-scroll td {display:grid;grid-template-columns:minmax(85px,33%) minmax(0,1fr);gap:8px;overflow-wrap:anywhere;padding:6px 4px}
  .table-scroll td:first-child {display:block}
  .table-scroll td:not(:first-child)::before {content:attr(data-label);font-weight:650;color:var(--muted)}
  .table-scroll td:empty {display:none}
  .table-scroll td:last-child {border-bottom:0}
  .actions button,.table-scroll button {min-height:44px}
}

.auth-heading {display:flex;align-items:center;justify-content:space-between;gap:8px;flex-wrap:wrap}
.theme-toggle {white-space:nowrap}
.auth-card .theme-toggle,.owner-topbar .theme-toggle {background:#292d54;color:#f4edff}
:root[data-theme="dark"] {
  color-scheme:dark;
  --canvas:#0c1528;--ink:#e8eefc;--muted:#aebbd4;--line:#34435e;
  --lavender:#392a60;--green:#8de1bc;--red:#ffb0bd;
  --surface:#16223a;--field:#0f192d;--subtle:#202e48;
}
[data-theme="dark"] :is(.panel,.metric,.book-card,.topbar:not(.owner-topbar),dialog,.mobile-nav) {
  background:var(--surface);color:var(--ink);
}
[data-theme="dark"] :is(input,select,textarea) {background:var(--field);color:var(--ink);border-color:#566786}
[data-theme="dark"] button:not(.ghost,.primary,.danger,.secondary,.chosen) {color:var(--ink);background:var(--subtle)}
[data-theme="dark"] .sidebar button.active {background:#6334c2}
[data-theme="dark"] button.secondary {color:#e7d8ff}
[data-theme="dark"] button.danger {background:#542837;color:var(--red)}
[data-theme="dark"] :is(th,.step) {background:var(--subtle)}
[data-theme="dark"] td {border-color:var(--line)}
[data-theme="dark"] .metric label {color:var(--muted)}
[data-theme="dark"] .step b,[data-theme="dark"] .quick .ico,[data-theme="dark"] a {color:#c9abff}
[data-theme="dark"] .pill {background:#2c3956;color:#e1eaff}
[data-theme="dark"] .pill.ok {background:#183c36;color:#9aebc6}
[data-theme="dark"] .pill.warn {background:#493820;color:#ffdf9e}
[data-theme="dark"] .pill.bad {background:#522939;color:#ffc1ce}
[data-theme="dark"] .pill.accent,[data-theme="dark"] .mobile-nav button[aria-current] {background:#3d2c67;color:#ede0ff}
@media(max-width:420px) {
  .topbar {flex-wrap:wrap}
  .topbar .right {flex-wrap:wrap}
}

.subscription-alert {
  display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:8px;
  margin-bottom:16px;padding:12px 14px;border:1px solid #e2bf74;border-radius:10px;
  background:#fff1d6;color:#704811;
}
[data-theme="dark"] .subscription-alert {background:#392c19;color:#ffdf9e;border-color:#785a29}

.package-grid {grid-template-columns:repeat(auto-fit,minmax(min(100%,200px),1fr));margin:14px 0}
.package-card {display:grid;justify-items:start;align-content:start;gap:8px}

.company-credit {
  display:flex;flex-wrap:wrap;justify-content:space-between;gap:6px 16px;
  margin-top:24px;padding-top:12px;border-top:1px solid var(--line);
  color:var(--muted);font-size:.82rem;
}
.company-credit a {overflow-wrap:anywhere}
.auth-card .company-credit {border-color:#4c4670;color:#ddd3f5}
.auth-card .company-credit a {color:#ead8ff}
