:root {
  --bg: #0c1018;
  --bg-2: #121826;
  --card: #161d2e;
  --card-2: #1c2536;
  --border: #273043;
  --border-2: #344056;
  --text: #e7ecf4;
  --muted: #93a0b8;
  --faint: #65718a;
  --accent: #5b8cff;
  --accent-2: #7c5cff;
  --green: #34d399;
  --green-bg: #103527;
  --red: #f87171;
  --red-bg: #3a1820;
  --amber: #fbbf24;
  --amber-bg: #3a2e12;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background:
    radial-gradient(1100px 500px at 80% -10%, rgba(124, 92, 255, 0.12), transparent),
    radial-gradient(900px 500px at -10% 10%, rgba(91, 140, 255, 0.10), transparent),
    var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
input, select { font-family: inherit; }
a { color: var(--accent); }

/* ── Login ───────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
}
.login-card {
  width: 100%; max-width: 380px; background: var(--card);
  border: 1px solid var(--border); border-radius: 18px; padding: 34px 30px;
  box-shadow: var(--shadow);
}
.login-logo { font-size: 42px; text-align: center; margin-bottom: 8px; }
.login-card h1 { font-size: 22px; text-align: center; margin-bottom: 4px; }
.login-card p.sub { text-align: center; color: var(--muted); font-size: 14px; margin-bottom: 24px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
.input {
  width: 100%; background: var(--bg-2); border: 1px solid var(--border-2);
  color: var(--text); border-radius: 10px; padding: 11px 13px; font-size: 15px;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(91,140,255,.18); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent); color: white; border: none; border-radius: 10px;
  padding: 11px 18px; font-size: 15px; font-weight: 600; transition: filter .15s, transform .05s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; border: 1px solid var(--border-2); color: var(--text); }
.btn-ghost:hover { background: var(--card-2); filter: none; }
.btn-danger { background: var(--red-bg); color: var(--red); border: 1px solid #5a2530; }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 8px; }
.error { color: var(--red); font-size: 13px; margin-top: 4px; min-height: 18px; }

/* ── App shell ───────────────────────────────────────── */
.app { max-width: 1120px; margin: 0 auto; padding: 0 20px 80px; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 0 14px; position: sticky; top: 0; z-index: 20;
  background: linear-gradient(var(--bg) 70%, transparent);
}
.brand { display: flex; align-items: center; gap: 11px; font-weight: 700; font-size: 18px; }
.brand .logo { font-size: 24px; }
.brand .tag { font-size: 11px; color: var(--faint); font-weight: 600; background: var(--card); border: 1px solid var(--border); padding: 3px 8px; border-radius: 999px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.user-pill { color: var(--muted); font-size: 14px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 26px; overflow-x: auto; }
.tab {
  background: none; border: none; color: var(--muted); padding: 12px 16px;
  font-size: 15px; font-weight: 600; border-bottom: 2px solid transparent;
  white-space: nowrap; transition: color .15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

/* ── Cards / grid ────────────────────────────────────── */
.grid { display: grid; gap: 16px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
}
.card h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; margin-bottom: 12px; }

.stat .big { font-size: 38px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.stat .unit { font-size: 16px; color: var(--muted); font-weight: 600; }
.stat .label { font-size: 13px; color: var(--muted); margin-top: 4px; }
.stat-grade .big { background: linear-gradient(120deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }

.progress { height: 9px; background: var(--bg-2); border-radius: 999px; overflow: hidden; margin-top: 14px; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 999px; transition: width .4s; }

.bar-track { height: 26px; background: var(--bg-2); border-radius: 8px; overflow: hidden; display: flex; }
.bar-seg { display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: #fff; transition: width .4s; }
.bar-seg.b1 { background: linear-gradient(90deg, #3b6fd4, #5b8cff); }
.bar-seg.b2 { background: linear-gradient(90deg, #6d4ddb, #9b7bff); }

.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; }
.badge.ok { background: var(--green-bg); color: var(--green); }
.badge.fail { background: var(--red-bg); color: var(--red); }
.badge.warn { background: var(--amber-bg); color: var(--amber); }

.checklist { list-style: none; display: grid; gap: 9px; }
.checklist li { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.checklist .ic { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 800; flex-shrink: 0; }
.checklist .ic.ok { background: var(--green-bg); color: var(--green); }
.checklist .ic.no { background: var(--red-bg); color: var(--red); }
.checklist li .val { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 600; }

.notice { border-radius: 10px; padding: 11px 14px; font-size: 13.5px; display: flex; gap: 9px; align-items: flex-start; }
.notice.warn { background: var(--amber-bg); color: #f3d692; border: 1px solid #4a3a14; }
.notice.info { background: rgba(91,140,255,.10); color: #b9ccf3; border: 1px solid #2c3a5c; }
.notice + .notice { margin-top: 8px; }

/* ── Section header ──────────────────────────────────── */
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.section-head h2 { font-size: 21px; font-weight: 700; }
.section-head p { color: var(--muted); font-size: 14px; }

/* ── Subject card ────────────────────────────────────── */
.subject {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; margin-bottom: 14px; border-left: 4px solid var(--sub-color, var(--accent));
}
.subject-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.subject-name { font-size: 17px; font-weight: 700; flex: 1; min-width: 160px; background: none; border: none; color: var(--text); }
.subject-name:focus { outline: none; }
.subject-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.chip-select {
  background: var(--bg-2); border: 1px solid var(--border-2); color: var(--text);
  border-radius: 8px; padding: 6px 9px; font-size: 13px; font-weight: 500;
}
.chip-select:focus { outline: none; border-color: var(--accent); }
.lk-toggle { display: inline-flex; border: 1px solid var(--border-2); border-radius: 8px; overflow: hidden; }
.lk-toggle button { background: var(--bg-2); border: none; color: var(--muted); padding: 6px 12px; font-size: 13px; font-weight: 700; }
.lk-toggle button.active { background: var(--accent); color: #fff; }

.hj-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 16px; }
.hj-group { background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.hj-group .gtitle { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); font-weight: 700; margin-bottom: 8px; }
.hj-group.no-count { opacity: .72; }
.hj-cells { display: flex; gap: 8px; }
.hj-cell { flex: 1; text-align: center; }
.hj-cell .hlabel { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.note-input {
  width: 100%; text-align: center; background: var(--card-2); border: 1px solid var(--border-2);
  color: var(--text); border-radius: 8px; padding: 8px 2px; font-size: 16px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.note-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(91,140,255,.16); }
.note-input.has-kl { border-color: var(--accent-2); }
.note-input.def { color: var(--red); border-color: #5a2530; }
.note-cell-wrap { position: relative; }
.kl-dot { position: absolute; top: -4px; right: -4px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent-2); }
.note-cell-wrap button.kl-btn { font-size: 10px; color: var(--faint); background: none; border: none; margin-top: 2px; }
.note-cell-wrap button.kl-btn:hover { color: var(--accent); }

/* ── Table (abitur / einbringung) ────────────────────── */
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--border); }
.tbl tr:last-child td { border-bottom: none; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.pill { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; }
.pill.lk { background: rgba(124,92,255,.16); color: #b3a0ff; }
.pill.gk { background: rgba(91,140,255,.14); color: #9bbcff; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }

/* ── Modal ───────────────────────────────────────────── */
.modal-bg { position: fixed; inset: 0; background: rgba(5, 8, 14, .65); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 100; padding: 20px; }
.modal { background: var(--card); border: 1px solid var(--border-2); border-radius: 16px; width: 100%; max-width: 460px; padding: 24px; box-shadow: var(--shadow); max-height: 90vh; overflow: auto; }
.modal h3 { font-size: 18px; margin-bottom: 4px; }
.modal .msub { color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

.kl-row { display: grid; grid-template-columns: 1fr 64px 64px 30px; gap: 8px; align-items: center; margin-bottom: 8px; }
.kl-row input { font-size: 14px; padding: 8px 10px; }
.kl-head { font-size: 11px; color: var(--faint); text-transform: uppercase; letter-spacing: .04em; }
.icon-btn { background: var(--card-2); border: 1px solid var(--border); color: var(--muted); border-radius: 8px; width: 30px; height: 34px; font-size: 16px; display: grid; place-items: center; }
.icon-btn:hover { color: var(--red); border-color: #5a2530; }

.predict-box { background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-top: 14px; display: flex; align-items: center; justify-content: space-between; }
.predict-box .pval { font-size: 22px; font-weight: 800; }

.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty .big { font-size: 40px; margin-bottom: 12px; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }
.hidden { display: none !important; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--card-2); border: 1px solid var(--border-2); color: var(--text); padding: 10px 18px; border-radius: 10px; font-size: 14px; box-shadow: var(--shadow); z-index: 200; opacity: 0; transition: opacity .25s, transform .25s; pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 640px) {
  .hj-grid { grid-template-columns: 1fr; }
  .stat .big { font-size: 32px; }
}
