:root {
  --brand: #1565c0;
  --brand-dark: #0b3d91;
  --brand-soft: #eaf3ff;
  --accent: #38bdf8;
  --ink: #17212b;
  --muted: #667085;
  --line: #e6eaf0;
  --surface: #ffffff;
  --canvas: #f4f7fb;
  --danger: #b42318;
  --warning: #b54708;
  --shadow: 0 14px 36px rgba(16, 24, 40, .08);
  --radius: 18px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  font-size: 14px;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); }

.app-shell { min-height: 100vh; display: flex; }

.app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 1030;
  width: 268px;
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  color: #fff;
  overflow-y: auto;
  background:
    radial-gradient(circle at 15% 4%, rgba(56, 189, 248, .28), transparent 28%),
    linear-gradient(165deg, #0b58ad 0%, #072d62 100%);
}

.brand-wrap { display: flex; gap: 12px; align-items: center; padding: 2px 8px 20px; }
.brand-logo { width: 44px; height: 52px; object-fit: contain; filter: drop-shadow(0 6px 12px rgba(0,0,0,.16)); }
.brand-title { font-weight: 800; font-size: 17px; letter-spacing: -.2px; line-height: 1.15; }
.brand-school { color: rgba(255,255,255,.65); font-size: 11px; margin-top: 4px; }

.period-chip {
  margin: 0 6px 18px;
  padding: 12px 13px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 14px;
  background: rgba(255,255,255,.08);
}
.period-chip small { color: rgba(255,255,255,.62); display: block; margin-bottom: 3px; }
.period-chip strong { font-size: 12px; }

.nav-section { color: rgba(255,255,255,.48); font-size: 10px; font-weight: 800; letter-spacing: 1.3px; margin: 14px 12px 7px; text-transform: uppercase; }
.app-nav { display: grid; gap: 5px; }
.app-nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 42px;
  padding: 10px 12px;
  border-radius: 12px;
  color: rgba(255,255,255,.78);
  font-weight: 600;
  transition: .18s ease;
}
.app-nav a:hover { color: #fff; background: rgba(255,255,255,.09); }
.app-nav a.active { color: #0b3d91; background: #fff; box-shadow: 0 8px 20px rgba(0,0,0,.14); }
.app-nav i { width: 18px; text-align: center; font-size: 17px; }

.sidebar-user {
  margin-top: auto;
  padding: 16px 8px 0;
  border-top: 1px solid rgba(255,255,255,.10);
}
.sidebar-user-name { font-size: 12px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-meta { color: rgba(255,255,255,.56); font-size: 10px; margin-top: 2px; text-transform: uppercase; }
.sidebar-logout { display: inline-flex; gap: 7px; align-items: center; margin-top: 12px; color: #fff; font-size: 12px; }
.sidebar-logout:hover { color: #ffe29c; }

.app-main { width: 100%; min-width: 0; margin-left: 268px; }
.desktop-sidebar-toggle { position: fixed; z-index: 1040; left: 246px; top: 22px; width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.55); border-radius: 50%; color: var(--brand); background: #fff; box-shadow: 0 8px 20px rgba(16,24,40,.15); transition: left .2s ease, transform .2s ease; }
.app-sidebar, .app-main { transition: width .2s ease, margin-left .2s ease, transform .2s ease; }
body.sidebar-collapsed .app-sidebar { transform: translateX(-100%); }
body.sidebar-collapsed .app-main { margin-left: 0; }
body.sidebar-collapsed .desktop-sidebar-toggle { left: 14px; }
.mobile-topbar { display: none; }
.page-content { max-width: 1460px; margin: 0 auto; padding: 28px 30px 44px; }
.page-footer { color: var(--muted); font-size: 11px; text-align: center; padding: 8px 20px 24px; }

.page-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; margin-bottom: 24px; }
.page-heading h1 { font-size: 25px; font-weight: 800; letter-spacing: -.5px; margin: 0 0 6px; }
.page-heading p { color: var(--muted); margin: 0; }

.card {
  border: 1px solid rgba(230,234,240,.95);
  border-radius: var(--radius);
  box-shadow: 0 6px 18px rgba(16,24,40,.035);
  overflow: hidden;
}
.card-body { padding: 22px; }
.card-title { font-weight: 750; letter-spacing: -.2px; }

.stat-card { height: 100%; position: relative; overflow: hidden; }
.stat-card::after { content: ""; position: absolute; width: 90px; height: 90px; border-radius: 50%; right: -34px; top: -35px; background: var(--brand-soft); }
.stat-label { color: var(--muted); font-size: 12px; font-weight: 650; }
.stat-value { font-size: 30px; font-weight: 850; line-height: 1.1; letter-spacing: -1px; margin-top: 9px; }
.stat-note { color: var(--muted); font-size: 11px; margin-top: 7px; }
.stat-icon { width: 39px; height: 39px; display: grid; place-items: center; border-radius: 12px; color: var(--brand); background: var(--brand-soft); font-size: 18px; }

.chart-wrap { position: relative; min-height: 280px; }
.chart-wrap.compact { min-height: 225px; }

.analysis-list { display: grid; gap: 11px; }
.analysis-item { display: flex; align-items: flex-start; gap: 11px; padding: 12px 13px; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.analysis-item i { margin-top: 1px; color: var(--brand); }
.analysis-item strong { display: block; font-size: 12px; }
.analysis-item span { color: var(--muted); font-size: 11px; }

.period-banner { display: flex; gap: 12px; align-items: center; padding: 14px 16px; border: 1px solid #bfdbfe; border-radius: 14px; color: #0b4f9c; background: #eff6ff; }
.period-banner.archived { color: #7a4b08; border-color: #f1d79c; background: #fff8e8; }

.badge-soft-success { color: #067647; background: #ecfdf3; border: 1px solid #abefc6; }
.badge-soft-warning { color: #93370d; background: #fffaeb; border: 1px solid #fedf89; }
.badge-soft-danger { color: #b42318; background: #fef3f2; border: 1px solid #fecdca; }
.badge-soft-neutral { color: #475467; background: #f2f4f7; border: 1px solid #e4e7ec; }
.badge { padding: .45em .7em; font-weight: 650; }

.table { margin-bottom: 0; }
.table > :not(caption) > * > * { border-bottom-color: var(--line); padding: 13px 12px; }
.table thead th { color: #475467; background: #f7faff; font-size: 10px; font-weight: 800; letter-spacing: .45px; text-transform: uppercase; white-space: nowrap; }
.table tbody td { vertical-align: middle; }
.table-hover tbody tr:hover > * { background: #f7faff; }

.form-label { color: #344054; font-size: 12px; font-weight: 700; }
.form-control, .form-select { min-height: 43px; border-color: #d9dee6; border-radius: 11px; font-size: 13px; }
.form-control:focus, .form-select:focus { border-color: #60a5fa; box-shadow: 0 0 0 .2rem rgba(21,101,192,.11); }
.btn { min-height: 40px; border-radius: 11px; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.btn-sm { min-height: 32px; border-radius: 9px; }
.btn-primary { background: var(--brand); border-color: var(--brand); }
.btn-primary:hover, .btn-primary:focus { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-outline-primary { color: var(--brand); border-color: #93c5fd; }
.btn-outline-primary:hover { background: var(--brand); border-color: var(--brand); }

.score-circle { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 800; background: var(--brand); box-shadow: 0 7px 16px rgba(21,101,192,.20); }
.avatar-initial { width: 38px; height: 38px; flex: 0 0 38px; display: grid; place-items: center; border-radius: 12px; color: #0b4f9c; background: var(--brand-soft); font-weight: 800; }

.empty-state { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty-state i { display: block; color: #98a2b3; font-size: 34px; margin-bottom: 10px; }

.filter-card { padding: 16px; margin-bottom: 18px; background: #fff; border: 1px solid var(--line); border-radius: 15px; }
.history-tabs { display: flex; gap: 7px; padding: 4px; border: 1px solid var(--line); background: #fff; border-radius: 12px; width: fit-content; }
.history-tabs a { padding: 8px 12px; border-radius: 9px; color: var(--muted); font-size: 12px; font-weight: 700; }
.history-tabs a.active { color: #fff; background: var(--brand); }

.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(420px, .92fr);
  background: #f7faff;
}
.login-visual {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 52px;
  overflow: hidden;
  color: #fff;
  background:
    radial-gradient(circle at 72% 18%, rgba(56,189,248,.34), transparent 23%),
    radial-gradient(circle at 14% 78%, rgba(96,165,250,.28), transparent 31%),
    linear-gradient(150deg, #146ac1 0%, #0b3d91 66%, #071f4a 100%);
}
.login-visual::before, .login-visual::after { content: ""; position: absolute; border: 1px solid rgba(255,255,255,.10); border-radius: 50%; }
.login-visual::before { width: 420px; height: 420px; right: -130px; bottom: -130px; }
.login-visual::after { width: 260px; height: 260px; right: -55px; bottom: -55px; }
.login-logo-line { position: relative; z-index: 1; display: flex; align-items: center; gap: 13px; }
.login-logo-line img { width: 54px; height: 64px; object-fit: contain; }
.login-logo-line strong { display: block; font-size: 18px; }
.login-logo-line span { color: rgba(255,255,255,.62); font-size: 12px; }
.login-copy { position: relative; z-index: 1; max-width: 650px; }
.login-kicker { color: #bae6fd; font-size: 11px; font-weight: 800; letter-spacing: 1.5px; text-transform: uppercase; }
.login-copy h1 { max-width: 590px; margin: 12px 0 17px; font-size: clamp(36px, 4.7vw, 65px); line-height: 1.02; letter-spacing: -2.4px; font-weight: 850; }
.login-copy p { max-width: 560px; color: rgba(255,255,255,.67); font-size: 15px; line-height: 1.65; }
.login-bullets { position: relative; z-index: 1; display: flex; gap: 18px; flex-wrap: wrap; }
.login-bullets span { display: flex; align-items: center; gap: 7px; color: rgba(255,255,255,.72); font-size: 11px; }
.login-bullets i { color: #7dd3fc; }
.login-panel { min-height: 100vh; display: grid; place-items: center; padding: 40px; }
.login-card { width: min(100%, 430px); }
.login-card h2 { font-weight: 850; letter-spacing: -.6px; margin-bottom: 8px; }
.login-card .lead-copy { color: var(--muted); margin-bottom: 28px; }
.nip-input { position: relative; }
.nip-input i { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: #667085; }
.nip-input input { padding-left: 43px; font-size: 16px; letter-spacing: .7px; min-height: 52px; }
.login-help { color: var(--muted); font-size: 11px; line-height: 1.55; margin-top: 18px; }

@media (max-width: 991.98px) {
  .app-sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: 18px 0 45px rgba(0,0,0,.22); }
  body.sidebar-open .app-sidebar { transform: translateX(0); }
  body.sidebar-open::after { content: ""; position: fixed; inset: 0; z-index: 1020; background: rgba(7,31,74,.45); }
  .app-main { margin-left: 0; }
  .mobile-topbar { position: sticky; top: 0; z-index: 1010; display: flex; align-items: center; justify-content: space-between; min-height: 62px; padding: 10px 16px; color: #fff; background: #0b4f9c; box-shadow: 0 8px 22px rgba(7,45,98,.18); }
  .desktop-sidebar-toggle { display: none; }
  .mobile-topbar button { border: 0; color: #fff; background: transparent; font-size: 22px; }
  .mobile-topbar strong { font-size: 13px; }
  .page-content { padding: 22px 16px 36px; }
  .login-page { grid-template-columns: 1fr; }
  .login-visual { min-height: 330px; padding: 32px 28px; }
  .login-copy h1 { font-size: 38px; }
  .login-copy p, .login-bullets { display: none; }
  .login-panel { min-height: auto; padding: 42px 22px 60px; }
}

@media (max-width: 575.98px) {
  .page-heading { display: block; }
  .page-heading > :last-child { margin-top: 14px; }
  .card-body { padding: 17px; }
  .login-visual { min-height: 285px; }
  .login-copy h1 { font-size: 32px; letter-spacing: -1.2px; }
}

@media print {
  .app-sidebar, .mobile-topbar, .page-footer, .no-print { display: none !important; }
  .app-main { margin-left: 0; }
  .page-content { max-width: none; padding: 0; }
  body { background: #fff; }
  .card { box-shadow: none; }
}
