:root {
    --bg: #f3f5fb; --card: #ffffff; --text: #1c2333; --muted: #6a7488; --border: #e4e8f1;
    --primary: #4f46e5; --primary-dark: #4338ca; --primary-soft: #eef0ff; --soft: #eef1f8;
    --ok: #16a34a; --ok-soft: #dcfce7; --info: #2563eb; --info-soft: #dbeafe;
    --warn: #d97706; --warn-soft: #fef3c7; --bad: #dc2626; --bad-soft: #fee2e2;
    --shadow: 0 1px 2px rgba(20,30,60,.05), 0 6px 20px rgba(20,30,60,.06);
    --radius: 14px;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f1320; --card: #181d2e; --text: #e8ebf5; --muted: #98a2bb; --border: #272e45;
        --primary: #818cf8; --primary-dark: #a5b4fc; --primary-soft: #232852; --soft: #20263b;
        --ok: #4ade80; --ok-soft: #14351f; --info: #60a5fa; --info-soft: #172a4d;
        --warn: #fbbf24; --warn-soft: #3b2d0c; --bad: #f87171; --bad-soft: #3e1a1a;
        --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
    }
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { font-family: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; color: var(--text); background: var(--bg); line-height: 1.5; font-size: 15px; -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 24px; }
main.wrap { padding-top: 26px; padding-bottom: 48px; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.muted { color: var(--muted); font-size: 14px; }

/* Шапка */
.topbar { background: var(--card); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; backdrop-filter: blur(8px); }
.topbar-in { display: flex; justify-content: space-between; align-items: center; gap: 16px; height: 64px; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); font-weight: 700; font-size: 17px; line-height: 1.15; }
.brand:hover { text-decoration: none; }
.brand small { display: block; font-size: 12px; font-weight: 500; color: var(--muted); }
.logo { width: 38px; height: 38px; border-radius: 11px; background: linear-gradient(135deg, #6366f1, #8b5cf6 60%, #ec4899); color: #fff; display: grid; place-items: center; box-shadow: 0 4px 12px rgba(99,102,241,.4); flex: none; }
.logo svg { width: 22px; height: 22px; }
.who { display: flex; align-items: center; gap: 12px; }
.who-info { text-align: right; line-height: 1.2; }
.who-info b { display: block; font-size: 14px; font-weight: 600; }
.who-info span { font-size: 12px; color: var(--muted); }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-weight: 700; display: grid; place-items: center; font-size: 14px; flex: none; }
.nav { display: flex; gap: 4px; overflow-x: auto; padding: 10px 24px; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a { color: var(--muted); padding: 8px 14px; border-radius: 10px; font-size: 14px; font-weight: 500; white-space: nowrap; display: flex; align-items: center; gap: 7px; transition: .15s; }
.nav a svg { width: 17px; height: 17px; flex: none; }
.nav a:hover { background: var(--soft); color: var(--text); text-decoration: none; }
.nav a.on { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.foot { color: var(--muted); font-size: 13px; padding-bottom: 28px; text-align: center; }

h1 { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin-bottom: 18px; line-height: 1.25; }
h1 .muted { font-weight: 500; font-size: 17px; letter-spacing: 0; }
h2 { font-size: 17px; font-weight: 650; margin: 0 0 14px; }
h3 { font-size: 16px; font-weight: 650; margin: 28px 0 12px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 20px; box-shadow: var(--shadow); }

/* Карточки статистики */
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 22px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.stat::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--primary); opacity: .85; }
.stat b { display: block; font-size: 30px; font-weight: 750; letter-spacing: -.02em; line-height: 1.15; color: var(--text); }
.stat span { color: var(--muted); font-size: 13.5px; }
.stat:has(.g5)::before { background: var(--ok); } .stat:has(.g4)::before { background: var(--info); }
.stat:has(.g3)::before { background: var(--warn); } .stat:has(.g2)::before { background: var(--bad); }
.bar { height: 7px; border-radius: 6px; background: var(--soft); overflow: hidden; margin-top: 10px; }
.bar i { display: block; height: 100%; border-radius: 6px; background: var(--primary); transition: width .6s; }
.bar.ok i { background: var(--ok); } .bar.warn i { background: var(--warn); } .bar.bad i { background: var(--bad); }
.pct { display: flex; align-items: center; gap: 10px; min-width: 130px; }
.pct .bar { flex: 1; margin: 0; }

/* Кнопки и формы */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--primary); color: #fff; border: 0; border-radius: 10px; padding: 9px 18px; font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; transition: .15s; box-shadow: 0 2px 8px rgba(79,70,229,.25); }
.btn:hover { background: var(--primary-dark); text-decoration: none; transform: translateY(-1px); }
.btn-small { padding: 5px 12px; font-size: 13px; border-radius: 8px; box-shadow: none; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); box-shadow: none; }
.btn-ghost:hover { background: var(--soft); color: var(--text); }
.btn-danger { background: var(--bad); box-shadow: none; } .btn-danger:hover { background: #b91c1c; }
.btn-light { background: var(--primary-soft); color: var(--primary); box-shadow: none; }
.btn-light:hover { background: var(--primary); color: #fff; }
.btn-block { width: 100%; margin-top: 14px; padding: 12px; font-size: 15px; }
label { display: block; font-size: 13px; font-weight: 500; margin: 14px 0 5px; color: var(--muted); }
input[type=text], input[type=password], input[type=date], input[type=number], input[type=email], select, textarea {
    width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px; font: inherit; font-size: 14.5px; background: var(--card); color: var(--text); transition: .15s; }
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
textarea { min-height: 80px; resize: vertical; }
.row { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 160px; }
.row > .btn { flex: 0 0 auto; }
.row label { margin-top: 0; }
.inline { display: inline; }
.filters { display: inline-flex; gap: 4px; flex-wrap: wrap; margin-bottom: 18px; background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 4px; box-shadow: var(--shadow); align-items: center; }
.filters a { padding: 6px 16px; border-radius: 9px; font-size: 14px; font-weight: 500; color: var(--muted); }
.filters a.on { background: var(--primary); color: #fff; box-shadow: 0 2px 8px rgba(79,70,229,.3); }
.filters a:hover { text-decoration: none; color: var(--text); } .filters a.on:hover { color: #fff; }
.filters .muted { padding: 0 12px; }

/* Таблицы */
table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
th, td { padding: 11px 14px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { background: var(--soft); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); white-space: nowrap; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--primary-soft); }
tbody tr:last-child td { border-bottom: 0; }
.tablewrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 20px; background: var(--card); box-shadow: var(--shadow); }
.card .tablewrap { box-shadow: none; }
td.num, th.num { text-align: center; }
.empty { text-align: center; color: var(--muted); padding: 30px; }

/* Оценки, бейджи */
.g5 { color: var(--ok); font-weight: 700; } .g4 { color: var(--info); font-weight: 700; }
.g3 { color: var(--warn); font-weight: 700; } .g2 { color: var(--bad); font-weight: 700; }
.chip { display: inline-grid; place-items: center; min-width: 26px; height: 26px; padding: 0 6px; margin: 2px; border-radius: 8px; font-size: 13px; background: var(--soft); cursor: default; }
.chip.g5 { background: var(--ok-soft); } .chip.g4 { background: var(--info-soft); } .chip.g3 { background: var(--warn-soft); } .chip.g2 { background: var(--bad-soft); }
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12.5px; font-weight: 600; background: var(--soft); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); } .badge.bad { background: var(--bad-soft); color: var(--bad); } .badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.info { background: var(--info-soft); color: var(--info); }
.alert { padding: 12px 16px; border-radius: 12px; margin-bottom: 18px; border: 1px solid; font-size: 14.5px; }
.alert-success { background: var(--ok-soft); border-color: var(--ok); color: var(--text); }
.alert-error { background: var(--bad-soft); border-color: var(--bad); color: var(--text); }
.alert-warn { background: var(--warn-soft); border-color: var(--warn); color: var(--text); }

/* Журнал */
.journal th, .journal td { padding: 6px 6px; text-align: center; }
.journal td:first-child, .journal th:first-child { text-align: left; position: sticky; left: 0; background: var(--card); min-width: 190px; z-index: 1; box-shadow: 1px 0 0 var(--border); padding-left: 14px; }
.journal th:first-child { background: var(--soft); }
.journal tbody tr:hover td:first-child { background: var(--primary-soft); }
.journal th { line-height: 1.3; text-transform: none; letter-spacing: 0; font-size: 13px; }
.journal select { width: 50px; padding: 5px 2px; font-size: 13px; font-weight: 600; text-align: center; border-radius: 8px; }
.journal input[type=number] { width: 46px; padding: 5px 4px; font-size: 13px; text-align: center; border-radius: 8px; }
.journal select.st-absent { background: var(--bad-soft); color: var(--bad); border-color: var(--bad); }
.journal select.st-late { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); }
.journal select.st-excused { background: var(--info-soft); color: var(--info); border-color: var(--info); }
.cellpair { display: flex; gap: 4px; justify-content: center; }
.savebar { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.chart { width: 100%; max-width: 860px; height: 260px; display: block; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 8px; font-size: 13px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }
.heat { display: flex; gap: 5px; flex-wrap: wrap; }
.heat span { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font-size: 11px; font-weight: 600; background: var(--ok-soft); color: var(--ok); }
.heat span.absent { background: var(--bad-soft); color: var(--bad); } .heat span.late { background: var(--warn-soft); color: var(--warn); } .heat span.excused { background: var(--info-soft); color: var(--info); }
.hello { display: flex; align-items: center; gap: 16px; margin-bottom: 22px; }
.hello .avatar { width: 56px; height: 56px; font-size: 20px; }
.hello h1 { margin: 0; }

/* Вход */
.login-page { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; background: var(--bg); }
.login-hero { background: linear-gradient(145deg, #4338ca, #7c3aed 55%, #db2777); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: center; position: relative; overflow: hidden; }
.login-hero::after { content: ''; position: absolute; width: 420px; height: 420px; border-radius: 50%; background: rgba(255,255,255,.08); right: -120px; bottom: -120px; }
.login-hero::before { content: ''; position: absolute; width: 260px; height: 260px; border-radius: 50%; background: rgba(255,255,255,.06); left: -80px; top: -80px; }
.login-hero .logo { width: 56px; height: 56px; background: rgba(255,255,255,.2); box-shadow: none; margin-bottom: 26px; }
.login-hero .logo svg { width: 30px; height: 30px; }
.login-hero h2 { font-size: 34px; font-weight: 750; letter-spacing: -.02em; line-height: 1.2; margin-bottom: 14px; }
.login-hero p { opacity: .85; max-width: 420px; font-size: 16px; }
.login-hero ul { list-style: none; margin-top: 28px; display: grid; gap: 12px; position: relative; z-index: 1; }
.login-hero li { display: flex; gap: 10px; align-items: center; font-size: 15px; }
.login-hero li::before { content: '✓'; width: 22px; height: 22px; border-radius: 50%; background: rgba(255,255,255,.2); display: grid; place-items: center; font-size: 12px; flex: none; }
.login-side { display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-box { width: 100%; max-width: 390px; }
.login-box h1 { font-size: 28px; margin-bottom: 6px; }
.login-box .muted { margin-bottom: 22px; }
@media (max-width: 860px) { .login-page { grid-template-columns: 1fr; } .login-hero { display: none; } }

@media (max-width: 700px) {
    .wrap { padding: 0 14px; } .nav { padding: 8px 14px; } h1 { font-size: 22px; }
    .who-info { display: none; } .brand small { display: none; }
    th, td { padding: 9px 10px; font-size: 14px; } .stat b { font-size: 26px; }
    .card { padding: 16px; }
}
