:root {
  --brand: #5b21b6;
  --brand-dark: #4c1d95;
  --brand-soft: #f1ebfd;
  --brand-softer: #f8f5ff;
  --bg: #f6f6fa;
  --card: #ffffff;
  --line: #e9e8f0;
  --text: #1b1a24;
  --muted: #6b6a7b;
  --good: #15803d;
  --good-soft: #e8f6ed;
  --warn: #b45309;
  --warn-soft: #fdf3e2;
  --bad: #b91c1c;
  --bad-soft: #fdecec;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 16, 40, 0.04), 0 4px 16px rgba(20, 16, 40, 0.04);
  --font: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* ------------------------------------------------------------------ login */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.login-hero { background: radial-gradient(1200px 600px at 10% 10%, #7c3aed 0%, #4c1d95 45%, #2e1065 100%); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; }
.login-hero h1 { font-size: 40px; letter-spacing: -0.02em; margin: 28px 0 14px; max-width: 520px; }
.login-hero p { color: #e4dcfb; max-width: 520px; font-size: 17px; }
.hero-points { display: grid; gap: 14px; margin-top: 28px; max-width: 520px; }
.hero-point { display: flex; gap: 12px; align-items: flex-start; background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.14); padding: 14px 16px; border-radius: 12px; }
.hero-point strong { display: block; }
.hero-point span { color: #ddd3fa; font-size: 14px; }
.login-panel { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.login-card { width: 100%; max-width: 440px; }
.login-card h2 { font-size: 26px; margin-bottom: 6px; }
.account-list { display: grid; gap: 12px; margin: 22px 0; }
.account { display: flex; align-items: center; gap: 14px; text-align: left; width: 100%; padding: 14px 16px; border: 1px solid var(--line); background: var(--card); border-radius: 12px; cursor: pointer; transition: border-color .15s, box-shadow .15s, transform .15s; }
.account:hover, .account:focus-visible { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); outline: none; }
.account .who { flex: 1; }
.account .who strong { display: block; }
.account .role { font-size: 12px; font-weight: 600; color: var(--brand); background: var(--brand-soft); padding: 4px 10px; border-radius: 999px; }

/* ------------------------------------------------------------------ shell */
.shell { display: grid; grid-template-columns: 264px 1fr; min-height: 100vh; }
.sidebar { background: var(--card); border-right: 1px solid var(--line); padding: 18px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 18px; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--brand); display: grid; place-items: center; color: #fff; }
.brand-name { font-weight: 700; color: var(--brand); font-size: 18px; line-height: 1.1; }
.brand-sub { font-size: 10px; letter-spacing: .12em; color: var(--muted); font-weight: 600; }
.school-chip { display: flex; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin: 0 4px 16px; }
.avatar { width: 34px; height: 34px; border-radius: 10px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.school-chip strong { display: block; font-size: 14px; line-height: 1.2; }
.nav-group { font-size: 11px; letter-spacing: .1em; color: var(--muted); font-weight: 600; padding: 14px 12px 6px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 10px; color: var(--text); font-size: 14.5px; }
.nav a:hover { background: var(--brand-softer); }
.nav a.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav a .lock { margin-left: auto; font-size: 10px; font-weight: 700; color: var(--muted); background: #f1f0f6; padding: 2px 7px; border-radius: 999px; }
.nav a.locked { color: var(--muted); }
.nav svg { width: 18px; height: 18px; flex: none; }
.sidebar-foot { margin-top: auto; padding-top: 16px; }
.btn-copilot { width: 100%; display: flex; gap: 10px; align-items: center; justify-content: center; background: var(--brand); color: #fff; border: 0; padding: 11px 14px; border-radius: 10px; font-weight: 600; cursor: pointer; }
.btn-copilot:hover { background: var(--brand-dark); }

.main { min-width: 0; }
.topbar { height: 68px; background: var(--card); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 16px; padding: 0 28px; position: sticky; top: 0; z-index: 5; }
.crumbs { color: var(--muted); font-size: 14px; }
.crumbs b { color: var(--text); font-weight: 600; }
.topbar .spacer { flex: 1; }
.term-pill { font-size: 13px; color: var(--brand); background: var(--brand-softer); border: 1px solid var(--brand-soft); padding: 6px 12px; border-radius: 999px; font-weight: 600; }
.user { display: flex; gap: 10px; align-items: center; }
.user strong { display: block; font-size: 14px; line-height: 1.2; }
.user span { font-size: 12px; color: var(--muted); }
.link-btn { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 13px; padding: 6px 8px; border-radius: 8px; }
.link-btn:hover { background: var(--bg); color: var(--text); }
.btn.menu-btn { display: none; }

.content { padding: 28px; max-width: 1320px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 28px; letter-spacing: -0.01em; }
.page-head p { margin: 6px 0 0; color: var(--muted); }

/* ------------------------------------------------------------------ parts */
.grid { display: grid; gap: 18px; }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.split { grid-template-columns: 1.4fr 1fr; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px 22px; }
.card-head { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.card-head h3 { font-size: 16px; }
.card-head p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.stat .label { color: var(--muted); font-size: 14px; display: flex; justify-content: space-between; align-items: center; }
.stat .value { font-size: 32px; font-weight: 700; letter-spacing: -0.02em; margin: 10px 0 4px; }
.stat .foot { font-size: 13px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand-soft); display: inline-block; }
.dot.good { background: #86efac; } .dot.warn { background: #fcd34d; }

.btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--card); padding: 9px 14px; border-radius: 10px; cursor: pointer; font-weight: 600; font-size: 14px; }
.btn:hover { border-color: #d7d5e3; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn.sm { padding: 6px 10px; font-size: 13px; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: 12px 16px; border-bottom: 1px solid var(--line); background: #fbfbfd; }
td { padding: 13px 16px; border-bottom: 1px solid var(--line); font-size: 14.5px; }
tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: #f1f0f6; color: var(--muted); }
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.brand { background: var(--brand-soft); color: var(--brand); }
.name-cell { display: flex; gap: 10px; align-items: center; }

.bars { display: grid; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 150px 1fr 52px; gap: 12px; align-items: center; font-size: 14px; }
.bar-track { height: 10px; background: #f0eff6; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--brand); }
.bar-fill.warn { background: #f59e0b; } .bar-fill.bad { background: #ef4444; } .bar-fill.good { background: #22c55e; }

.insight { background: linear-gradient(180deg, #faf7ff, #f6f1ff); border: 1px solid #e7dcfb; border-radius: 12px; padding: 16px; }
.insight .tag { font-size: 13px; font-weight: 600; color: var(--brand); display: flex; gap: 6px; align-items: center; }
.insight p { margin: 8px 0 12px; }

.empty, .error-box { text-align: center; padding: 36px 20px; color: var(--muted); }
.error-box { color: var(--bad); }
.skeleton { background: linear-gradient(90deg, #f0eff6 25%, #f7f6fb 37%, #f0eff6 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* ------------------------------------------------------------------ forms */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 600; }
.field input, .field select, .field textarea { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 10px 12px; width: 100%; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.field textarea { resize: vertical; min-height: 90px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.modal-back { position: fixed; inset: 0; background: rgba(20, 16, 40, 0.45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--card); border-radius: 16px; width: 100%; max-width: 480px; box-shadow: 0 20px 60px rgba(20,16,40,.25); }
.modal .card-head { border-bottom: 1px solid var(--line); }
.modal .body { padding: 20px 22px; }
.modal .foot { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }

.toast { position: fixed; right: 20px; bottom: 20px; background: #1b1a24; color: #fff; padding: 12px 16px; border-radius: 10px; font-size: 14px; z-index: 60; box-shadow: 0 10px 30px rgba(0,0,0,.2); }
.toast.bad { background: var(--bad); }

/* ------------------------------------------------------------------ copilot */
.copilot-hero { display: flex; gap: 14px; align-items: center; }
.spark { width: 44px; height: 44px; border-radius: 12px; background: var(--brand); color: #fff; display: grid; place-items: center; flex: none; }
.thinking { display: grid; gap: 10px; padding: 26px 22px; }
.step { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: 14px; }
.step.done { color: var(--good); }
.step.now { color: var(--brand); font-weight: 600; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--brand-soft); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.result-section { padding: 20px 22px; border-bottom: 1px solid var(--line); }
.result-section:last-child { border-bottom: 0; }
.result-section h4 { font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--brand); margin-bottom: 12px; display: flex; gap: 8px; align-items: center; }
.result-section ul { margin: 0; padding-left: 20px; display: grid; gap: 8px; }
.concern { border: 1px solid #f5d5a6; background: var(--warn-soft); border-radius: 12px; padding: 14px 16px; }
.concern-head { display: flex; justify-content: space-between; gap: 10px; font-weight: 700; margin-bottom: 6px; }
.attention { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px dashed var(--line); }
.attention:last-child { border-bottom: 0; }
.stage { display: grid; grid-template-columns: 86px 1fr; gap: 16px; padding: 14px 0; border-bottom: 1px dashed var(--line); }
.stage:last-child { border-bottom: 0; }
.stage .mins { font-weight: 700; color: var(--brand); }
.stage h5 { margin: 0 0 6px; font-size: 15px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { font-size: 13px; background: var(--brand-softer); border: 1px solid var(--brand-soft); color: var(--brand-dark); padding: 4px 10px; border-radius: 999px; }
.meta-line { font-size: 12px; color: var(--muted); padding: 12px 22px; border-top: 1px solid var(--line); display: flex; gap: 14px; flex-wrap: wrap; }

.soon { text-align: center; padding: 64px 24px; }
.soon .lock-ring { width: 72px; height: 72px; border-radius: 20px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; margin: 0 auto 18px; }
.soon h2 { font-size: 26px; margin-bottom: 8px; }
.soon p { color: var(--muted); max-width: 520px; margin: 0 auto 18px; }

/* ------------------------------------------------------------------ mobile */
@media (max-width: 1100px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.cols-3, .grid.split { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .login { grid-template-columns: 1fr; }
  .login-hero { padding: 32px 24px; }
  .login-hero h1 { font-size: 30px; }
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 40; width: 264px; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 10px 40px rgba(0,0,0,.15); }
  .shell.nav-open .sidebar { transform: none; }
  .btn.menu-btn { display: inline-flex; }
  .topbar { padding: 0 16px; }
  .term-pill, .crumbs { display: none; }
  .content { padding: 18px 16px; }
  .grid.cols-2, .row { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 110px 1fr 44px; }
}
