:root {
  --bg: #eef1f5;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #111827;
  --muted: #64748b;
  --line: #d6dde7;
  --primary: #0f3f77;
  --primary-2: #15599e;
  --danger: #b42318;
  --danger-bg: #fff4f2;
  --ok: #157347;
  --ok-bg: #edfdf3;
  --warn: #985a00;
  --warn-bg: #fff8eb;
  --shadow: 0 18px 50px rgba(15, 23, 42, .08);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: radial-gradient(circle at top left, #f8fbff 0, #eef1f5 420px, #eef1f5 100%); color: var(--text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
body { margin: 0; }
button, input, select, textarea { font: inherit; }
button { border: 1px solid var(--line); background: #fff; color: var(--text); border-radius: 11px; padding: 10px 14px; min-height: 42px; cursor: pointer; font-weight: 700; transition: border-color .15s ease, background .15s ease, transform .15s ease; }
button:hover { border-color: #9aa9ba; }
button:active { transform: translateY(1px); }
button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
button.primary:hover { background: var(--primary-2); }
button.secondary { background: #f8fafc; }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
button.small { min-height: 36px; padding: 7px 11px; font-size: .92rem; }
button.link-btn { border: 0; background: transparent; color: var(--primary); padding: 4px; min-height: 0; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 11px; padding: 11px 12px; background: #fff; color: var(--text); min-height: 42px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--primary-2); box-shadow: 0 0 0 3px rgba(21, 89, 158, .12); }
textarea { resize: vertical; }
label { display: grid; gap: 7px; font-weight: 800; color: #243044; }
main { display: grid; gap: 16px; }
h1, h2, h3 { margin: 0; letter-spacing: -.02em; }
h1 { font-size: clamp(1.7rem, 4vw, 2.35rem); }
h2 { font-size: 1.18rem; }
p { margin: 0; }
.hidden { display: none !important; }

.app-shell { width: min(1180px, 100%); margin: 0 auto; padding: 18px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 14px; }
.brand-block { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; background: linear-gradient(135deg, var(--primary), #2d78bd); color: #fff; font-weight: 900; letter-spacing: .03em; box-shadow: 0 12px 28px rgba(15, 63, 119, .2); }
.brand { font-size: 1.14rem; font-weight: 900; white-space: nowrap; }
.version-badge { display: inline-block; margin-left: 7px; padding: 2px 7px; border-radius: 999px; background: #e7eef8; color: var(--primary); font-size: .72rem; font-weight: 900; vertical-align: middle; }
.subtle, .help, .field-help { color: var(--muted); font-weight: 500; }
.help { line-height: 1.45; }
.field-help { font-size: .86rem; }
.eyebrow { color: var(--primary); text-transform: uppercase; letter-spacing: .1em; font-size: .74rem; font-weight: 900; margin-bottom: 5px; }
.top-controls { display: flex; align-items: center; gap: 10px; min-width: 0; }
.small-select { width: auto; min-width: 190px; max-width: 330px; }
.user-badge { color: var(--muted); font-size: .86rem; font-weight: 800; white-space: nowrap; }

.nav { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin: 12px 0 18px; padding: 6px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.76); backdrop-filter: blur(10px); box-shadow: 0 10px 28px rgba(15, 23, 42, .05); }
.nav-btn { border: 0; border-radius: 11px; background: transparent; color: #475569; }
.nav-btn.active { background: var(--primary); color: #fff; }

.page { display: grid; gap: 14px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.card, .setup-card, .admin-card { background: rgba(255,255,255,.95); border: 1px solid rgba(214,221,231,.9); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card.compact { padding: 15px; }
.setup-panel { min-height: calc(100vh - 80px); display: grid; place-items: center; }
.setup-card { width: min(720px, 100%); display: grid; gap: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.form-actions { margin-top: 4px; display: flex; justify-content: flex-end; }
.section-title { margin: 10px 0 2px; font-size: 1rem; font-weight: 900; }
.row-wrap, .simple-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.divider { height: 1px; background: var(--line); margin: 12px 0; }
.stack { display: grid; gap: 9px; }

.pick-list, .student-list, .flag-list { display: grid; gap: 9px; margin-top: 12px; }
.pick-item, .student-row, .flag-row, .data-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid var(--line); border-radius: 14px; background: #fff; padding: 12px; }
.pick-item:hover, .student-row:hover { border-color: #aab8c8; }
.row-title { font-weight: 900; }
.row-meta { color: var(--muted); font-size: .9rem; margin-top: 3px; }
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.chip { border-radius: 999px; min-height: 34px; padding: 6px 12px; color: #475569; background: #fff; }
.chip.active { background: #e7eef8; border-color: #b7c7dc; color: var(--primary); }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 5px 10px; font-size: .82rem; font-weight: 900; }
.badge.clean, .badge.reviewed { background: var(--ok-bg); color: var(--ok); }
.badge.flagged, .badge.open, .badge.kept { background: var(--danger-bg); color: var(--danger); }
.badge.review { background: var(--warn-bg); color: var(--warn); }
.badge.neutral { background: #f1f5f9; color: #475569; }

.check-items { display: grid; gap: 10px; }
.check-line { display: grid; gap: 10px; border: 1px solid var(--line); background: var(--panel-soft); border-radius: 14px; padding: 12px; }
.check-title { font-weight: 900; }
.check-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.check-options label { margin: 0; font-weight: 800; display: flex; align-items: center; gap: 7px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 8px; }
.check-options input, .checkbox-line input, .permission-grid input { width: auto; min-height: auto; margin: 0; }

.profile-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 12px; }
.profile-section { border: 1px solid var(--line); border-radius: 15px; padding: 13px; background: var(--panel-soft); }
.profile-section h3 { font-size: 1rem; margin-bottom: 10px; }
.history-list { display: grid; gap: 8px; }
.device-row { border: 1px solid var(--line); border-radius: 13px; padding: 10px; background: #fff; display: grid; gap: 8px; }
.helper-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 8px 0; }
.metric { border: 1px solid var(--line); border-radius: 12px; padding: 8px; background: #fff; }
.metric strong { display: block; font-size: 1.15rem; }
.file-tree details { border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 8px; margin: 7px 0; }
.file-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; padding: 8px; border-bottom: 1px solid #eef2f7; }
.file-row:last-child { border-bottom: 0; }
.file-path { color: var(--muted); font-size: .82rem; overflow-wrap: anywhere; }

.admin-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.admin-card { display: grid; gap: 12px; align-content: start; }
.admin-card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.permission-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.permission-grid label { display: flex; flex-direction: row; gap: 8px; align-items: center; border: 1px solid var(--line); padding: 8px; border-radius: 12px; background: #fff; font-weight: 700; }
.checkbox-line { display: flex; flex-direction: row; gap: 8px; align-items: center; font-weight: 700; }
.output-box, #reportOutput { width: 100%; background: #111827; color: #e5e7eb; border: 0; border-radius: 13px; padding: 12px; overflow: auto; white-space: pre-wrap; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .86rem; min-height: 70px; }
#reportOutput { margin-top: 12px; }

.toast { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); background: #111827; color: #fff; padding: 12px 16px; border-radius: 999px; box-shadow: var(--shadow); max-width: calc(100% - 24px); z-index: 20; }

@media (max-width: 860px) {
  .app-shell { padding: 12px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .top-controls { width: 100%; align-items: stretch; }
  .small-select { width: 100%; max-width: none; }
  .user-badge { align-self: center; }
  .nav { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .page-head, .form-head { align-items: stretch; flex-direction: column; }
  .grid-2, .profile-grid, .admin-grid, .helper-summary { grid-template-columns: 1fr; }
  .check-options, .permission-grid { grid-template-columns: 1fr; }
  .pick-item, .student-row, .flag-row, .data-row { align-items: stretch; flex-direction: column; }
  .pick-item button, .student-row button, .flag-row button, .data-row button { width: 100%; }
  .brand { white-space: normal; }
}

@media print {
  html, body { background: #fff; }
  .topbar, .nav, button, input, select, textarea, .toast { display: none !important; }
  .card, .admin-card, .setup-card { box-shadow: none; border: 1px solid #aaa; }
}
