:root {
  --bg: #f5f6fb; --surface: #ffffff; --surface-2: #f0f2fa; --line: #e4e7f2; --ink: #141632; --muted: #6b6f8e; --faint: #9a9db5;
  --side: #0f1130; --side-ink: #c7cae6; --side-active: #ffffff;
  --blue: #5b6bff; --violet: #8b1cff; --cyan: #22c8ff; --green: #12a26f; --amber: #d98b06; --red: #e23b52;
  --brand: linear-gradient(90deg, #22c8ff, #5b6bff 45%, #8b1cff);
  --radius: 14px; --shadow: 0 1px 2px rgba(20,22,50,.04), 0 8px 24px -12px rgba(20,22,50,.12);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 'Lexend', system-ui, sans-serif; }
a { color: var(--blue); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 15px; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }

/* Layout */
.layout { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: #fff; }
.brand img { width: 34px; height: 34px; }
.brand b { font-size: 16px; letter-spacing: .02em; } .brand span { display: block; font-size: 11px; color: var(--side-ink); font-weight: 400; }
.navlabel { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: #6f74a3; padding: 14px 12px 6px; }
.nav { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 10px; color: var(--side-ink); cursor: pointer; font-size: 13.5px; }
.nav svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav.active { background: rgba(91,107,255,.22); color: var(--side-active); box-shadow: inset 3px 0 0 #8b97ff; }
.side .spacer { flex: 1; }
.me { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; background: rgba(255,255,255,.05); }
.me .av { width: 32px; height: 32px; border-radius: 50%; background: var(--brand); display: grid; place-items: center; color: #fff; font-weight: 600; }
.me .who { flex: 1; min-width: 0; font-size: 12.5px; color: #fff; } .me .who small { display: block; color: var(--side-ink); }
.main { min-width: 0; }
.top { display: flex; align-items: center; gap: 14px; padding: 18px 28px; border-bottom: 1px solid var(--line); background: rgba(245,246,251,.85); backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 5; }
.top .title { flex: 1; } .top .title p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.content { padding: 24px 28px 60px; display: grid; gap: 20px; }
.burger { display: none; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; min-width: 0; }
.card > header { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; } .card > header h2 { flex: 1; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi { display: flex; gap: 14px; align-items: flex-start; }
.kpi .ic { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-2); color: var(--blue); flex: none; }
.kpi .ic svg { width: 21px; height: 21px; }
.kpi .v { font-size: 24px; font-weight: 600; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--muted); font-size: 12.5px; } .kpi .d { font-size: 12px; color: var(--green); }
.chart { position: relative; height: 230px; }

/* Bits */
.btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 8px 14px; cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { border-color: #c9cde3; } .btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; } .btn.primary:hover { filter: brightness(1.06); }
.btn.grad { background: var(--brand); border: 0; color: #fff; }
.btn.danger { color: var(--red); border-color: #f3c4cc; } .btn.danger:hover { background: #fff1f3; }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill.ok { background: #e3f6ee; color: var(--green); } .pill.warn { background: #fdf2dc; color: var(--amber); } .pill.bad { background: #fde7eb; color: var(--red); } .pill.info { background: #eceeff; color: var(--blue); } .pill.vio { background: #f3e8ff; color: var(--violet); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; } .grow { flex: 1; min-width: 0; }
.field { display: grid; gap: 6px; } .field > span { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.input, select.input, textarea.input { width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 9px 12px; outline: none; }
.input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(91,107,255,.15); }
textarea.input { min-height: 90px; resize: vertical; font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; }
textarea.input.prose { font-family: inherit; font-size: 14px; }
.toggle { position: relative; width: 40px; height: 23px; flex: none; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle span { position: absolute; inset: 0; background: #d5d8e8; border-radius: 99px; transition: .2s; cursor: pointer; }
.toggle span::after { content: ''; position: absolute; left: 3px; top: 3px; width: 17px; height: 17px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.toggle input:checked + span { background: var(--blue); } .toggle input:checked + span::after { transform: translateX(17px); }
.setting { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.setting:last-child { border-bottom: 0; } .setting .t { flex: 1; } .setting .t small { display: block; color: var(--muted); }
.form { display: grid; gap: 14px; } .form.cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* Tables */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; background: #fafbfe; }
th, td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
tr:last-child td { border-bottom: 0; } tbody tr { cursor: pointer; } tbody tr:hover { background: #fafbff; }
td.wrap { white-space: normal; }
.user-cell { display: flex; align-items: center; gap: 10px; }
.user-cell .av { width: 32px; height: 32px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 13px; flex: none; }
.pager { display: flex; align-items: center; gap: 10px; justify-content: flex-end; margin-top: 12px; color: var(--muted); }
.empty { text-align: center; padding: 40px; color: var(--muted); }
.bars { display: grid; gap: 9px; } .bar { display: grid; grid-template-columns: 120px 1fr 44px; align-items: center; gap: 10px; font-size: 13px; }
.bar i { display: block; height: 8px; border-radius: 6px; background: var(--brand); }
.bar .track { background: var(--surface-2); border-radius: 6px; }

/* Drawer + modal */
.scrim { position: fixed; inset: 0; background: rgba(15,17,48,.35); z-index: 20; opacity: 0; pointer-events: none; transition: .2s; }
.scrim.open { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; right: 0; top: 0; bottom: 0; width: min(640px, 100vw); background: var(--bg); z-index: 21; transform: translateX(100%); transition: .25s ease; overflow-y: auto; box-shadow: -10px 0 40px rgba(15,17,48,.2); }
.drawer.open { transform: none; }
.drawer > header { position: sticky; top: 0; background: #fff; border-bottom: 1px solid var(--line); padding: 16px 20px; display: flex; align-items: center; gap: 12px; z-index: 2; }
.drawer .body { padding: 18px 20px 40px; display: grid; gap: 16px; }
.modal { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -48%) scale(.98); width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 60px); overflow-y: auto; background: #fff; border-radius: 18px; z-index: 31; opacity: 0; pointer-events: none; transition: .18s; box-shadow: 0 30px 80px rgba(15,17,48,.3); }
.modal.open { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%); }
.modal header { padding: 18px 20px 4px; } .modal .body { padding: 12px 20px; } .modal footer { padding: 12px 20px 18px; display: flex; gap: 10px; justify-content: flex-end; }
.modal-scrim { z-index: 30; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tab { padding: 9px 12px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tab.active { color: var(--ink); border-color: var(--blue); font-weight: 500; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 14px; font-size: 13.5px; } .kv dt { color: var(--muted); } .kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.transcript { display: grid; gap: 8px; } .msg { padding: 9px 12px; border-radius: 12px; max-width: 86%; }
.msg.tutor { background: var(--surface-2); } .msg.user { background: #eceeff; justify-self: end; }
.msg b { display: block; font-size: 11px; color: var(--muted); font-weight: 500; }
.tutor-card { display: grid; grid-template-columns: 84px 1fr; gap: 16px; }
.tutor-card img { width: 84px; height: 84px; border-radius: 18px; object-fit: cover; object-position: top; background: linear-gradient(135deg,#e6f6ff,#ede6ff); }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 12px; z-index: 50; opacity: 0; transition: .2s; pointer-events: none; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%); } .toast.err { background: var(--red); }
.spinner { width: 18px; height: 18px; border: 2.5px solid var(--line); border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: grid; place-items: center; padding: 60px; }
.tree details { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin-bottom: 10px; background: #fff; }
.tree summary { cursor: pointer; font-weight: 500; }
.lesson-row { display: grid; grid-template-columns: 34px 1fr 110px 110px 90px auto; gap: 10px; align-items: center; padding: 9px 4px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.lesson-row:last-child { border-bottom: 0; }
.banner { display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-radius: 12px; background: #fdf2dc; color: #7a4f00; }
.banner.info { background: #eceeff; color: #2e3aa8; } .banner.bad { background: #fde7eb; color: #8e1c2f; }

/* Login */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login .art { background: radial-gradient(1200px 600px at 20% 10%, #2a2f86 0, #0f1130 60%); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login .art::after { content: ''; position: absolute; width: 520px; height: 520px; right: -140px; bottom: -160px; border-radius: 50%; background: var(--brand); filter: blur(90px); opacity: .45; }
.login .art h1 { font-size: 36px; line-height: 1.15; max-width: 440px; position: relative; z-index: 1; }
.login .art p { color: #c7cae6; max-width: 420px; position: relative; z-index: 1; }
.login .box { display: grid; place-items: center; padding: 32px; }
.login form { width: min(380px, 100%); display: grid; gap: 16px; }

@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 25; width: 260px; transform: translateX(-100%); transition: .25s; }
  .side.open { transform: none; }
  .burger { display: inline-flex; }
  .g2, .g3, .g4, .form.cols { grid-template-columns: 1fr; }
  .content { padding: 18px 16px 50px; } .top { padding: 14px 16px; }
  .login { grid-template-columns: 1fr; } .login .art { display: none; }
  .lesson-row { grid-template-columns: 30px 1fr auto; } .lesson-row .hide-m { display: none; }
}
.banner svg { width: 20px; height: 20px; flex: none; }
.btn.burger { display: none; }
.drawer:not(.open) { box-shadow: none; }
@media (max-width: 860px) { .btn.burger { display: inline-flex; } }
