*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d0f14;
  --surface: #161921;
  --surface2: #1e2230;
  --surface3: #252a3a;
  --border: #2a3045;
  --border2: #3a4260;
  --accent: #6c8fff;
  --accent2: #4d6fff;
  --green: #3dd68c;
  --red: #ff6b6b;
  --amber: #ffd166;
  --text: #e8eaf6;
  --muted: #7a82a0;
  --dim: #4a5270;
  --mono: 'JetBrains Mono', monospace;
  --sans: 'DM Sans', sans-serif;
  --display: 'Syne', sans-serif;
}

html, body { height: 100%; overflow: hidden; }
body { font-family: var(--sans); background: var(--bg); color: var(--text); font-size: 14px; }
button { font-family: var(--sans); cursor: pointer; border: none; outline: none; }
input, textarea, select { font-family: var(--sans); outline: none; }
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
*::-webkit-scrollbar { width: 6px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── LAYOUT ── */
#app { height: 100vh; display: flex; flex-direction: column; }
.shell { height: 100vh; display: flex; flex-direction: column; }
.main { flex: 1; display: flex; overflow: hidden; }
.content { flex: 1; overflow: hidden; display: flex; flex-direction: column; }

/* ── NAV ── */
.nav { height: 52px; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 20px; gap: 16px; flex-shrink: 0; }
.nav-logo { font-family: var(--display); font-size: 15px; font-weight: 700; color: var(--accent); letter-spacing: -0.3px; }
.nav-logo span { color: var(--text); }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent2); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; color: white; flex-shrink: 0; }
.user-name { font-size: 13px; color: var(--muted); }

/* ── SIDEBAR ── */
.sidebar { width: 220px; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar-section { padding: 14px 12px 8px; font-size: 11px; font-weight: 600; color: var(--dim); text-transform: uppercase; letter-spacing: 0.8px; }
.sidebar-item { display: flex; align-items: center; gap: 10px; padding: 9px 14px; cursor: pointer; font-size: 13px; color: var(--muted); transition: all 0.15s; border-left: 3px solid transparent; border: none; background: none; width: 100%; text-align: left; }
.sidebar-item:hover { background: var(--surface2); color: var(--text); }
.sidebar-item.active { background: rgba(108,143,255,0.08); color: var(--accent); border-left: 3px solid var(--accent); }
.sidebar-item .icon { font-size: 17px; width: 20px; text-align: center; }
.sidebar-bottom { margin-top: auto; padding: 12px; border-top: 1px solid var(--border); }
.logout-btn { width: 100%; padding: 8px; background: transparent; border: 1px solid var(--border); border-radius: 8px; color: var(--muted); font-size: 13px; cursor: pointer; transition: all 0.15s; }
.logout-btn:hover { background: var(--surface2); color: var(--text); }

/* ── BUTTONS ── */
.btn { padding: 10px 20px; border-radius: 8px; font-size: 14px; font-weight: 500; cursor: pointer; transition: all 0.15s; border: none; display: inline-flex; align-items: center; gap: 6px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #7d9fff; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 6px; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface2); color: var(--text); }
.btn-danger { background: rgba(255,107,107,0.15); color: var(--red); border: 1px solid rgba(255,107,107,0.3); }
.btn-danger:hover { background: rgba(255,107,107,0.25); }
.btn-success { background: rgba(61,214,140,0.15); color: var(--green); border: 1px solid rgba(61,214,140,0.3); }
.run-btn { padding: 7px 18px; background: var(--green); color: #0d0f14; border-radius: 6px; font-weight: 600; font-size: 13px; }
.run-btn:hover { background: #52e89e; }
.run-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── FORMS ── */
.form-group { margin-bottom: 16px; }
.form-group-full { margin-bottom: 14px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.form-label { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; display: block; }
.form-input { width: 100%; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; color: var(--text); font-size: 14px; transition: border-color 0.15s; }
.form-input:focus { border-color: var(--accent); }
.form-input::placeholder { color: var(--dim); }
.form-textarea { width: 100%; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; color: var(--text); font-size: 13px; resize: vertical; min-height: 80px; }
.form-textarea:focus { border-color: var(--accent); }
.form-select { width: 100%; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; color: var(--text); font-size: 13px; }

/* ── BADGES / CHIPS ── */
.badge { padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.badge-admin { background: rgba(108,143,255,0.15); color: var(--accent); }
.badge-student { background: rgba(61,214,140,0.15); color: var(--green); }
.chip { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 500; }
.task-type { padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 500; }
.type-io { background: rgba(108,143,255,0.15); color: var(--accent); }
.type-unit { background: rgba(61,214,140,0.15); color: var(--green); }
.type-both { background: rgba(255,209,102,0.15); color: var(--amber); }

/* ── LOGIN ── */
.login-wrap { height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 40px; width: 380px; }
.login-title { font-family: var(--display); font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.login-sub { color: var(--muted); font-size: 13px; margin-bottom: 28px; }
.btn-login { background: var(--accent); color: #fff; width: 100%; margin-top: 8px; justify-content: center; padding: 11px; border-radius: 8px; font-size: 14px; font-weight: 500; }
.btn-login:hover { background: #7d9fff; }
.demo-accounts { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--border); }
.demo-label { font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px; }
.demo-btn { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; cursor: pointer; transition: all 0.15s; width: 100%; margin-bottom: 6px; }
.demo-btn:hover { border-color: var(--border2); }
.demo-name { font-size: 13px; font-weight: 500; color: var(--text); text-align: left; }
.demo-role { font-size: 11px; color: var(--muted); text-align: left; }
.error-msg { background: rgba(255,107,107,0.1); border: 1px solid rgba(255,107,107,0.3); border-radius: 8px; padding: 10px 14px; color: var(--red); font-size: 13px; margin-bottom: 14px; }

/* ── SCROLL AREAS ── */
.scroll { overflow-y: auto; }

/* ── PAGE HEADER ── */
.page-header { margin-bottom: 20px; }
.page-title { font-family: var(--display); font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.page-sub { color: var(--muted); font-size: 13px; }

/* ── STAT CARDS ── */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.stat-grid-3 { grid-template-columns: repeat(3, 1fr); }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; }
.stat-num { font-family: var(--display); font-size: 28px; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ── SECTION CARDS ── */
.section-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px; margin-bottom: 16px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.section-head h3 { font-family: var(--display); font-size: 15px; font-weight: 600; }

/* ── DATA TABLE ── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { font-size: 11px; font-weight: 600; color: var(--dim); text-transform: uppercase; letter-spacing: 0.5px; padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.data-table td { padding: 10px 12px; font-size: 13px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: rgba(255,255,255,0.02); }
.action-btns { display: flex; gap: 6px; }
.prog-bar-wrap { width: 80px; height: 6px; background: var(--surface2); border-radius: 3px; }
.prog-bar { height: 100%; border-radius: 3px; background: var(--green); transition: width 0.3s; }
.user-cell { display: flex; align-items: center; gap: 8px; }
.user-avatar-sm { width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 9px; font-weight: 600; flex-shrink: 0; }

/* ── TASK LIST ── */
.task-list-page { flex: 1; overflow-y: auto; padding: 24px; }
.mini-stats { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin-bottom: 20px; }
.mini-stat { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 18px; }
.mini-stat .num { font-family: var(--display); font-size: 22px; font-weight: 700; }
.mini-stat .lbl { font-size: 12px; color: var(--muted); margin-top: 2px; }
.task-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; margin-bottom: 10px; cursor: pointer; transition: all 0.15s; display: flex; align-items: center; gap: 16px; }
.task-card:hover { border-color: var(--border2); background: var(--surface2); transform: translateX(2px); }
.task-status-icon { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; }
.task-status-icon.done { background: rgba(61,214,140,0.15); color: var(--green); }
.task-status-icon.attempt { background: rgba(255,209,102,0.15); color: var(--amber); }
.task-status-icon.none { background: var(--surface2); color: var(--dim); }
.task-info { flex: 1; }
.task-name { font-weight: 500; font-size: 15px; margin-bottom: 4px; }
.task-meta { font-size: 12px; color: var(--muted); display: flex; gap: 12px; align-items: center; }
.score-pill { padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: 600; background: var(--surface2); color: var(--muted); }
.score-pill.pass { background: rgba(61,214,140,0.15); color: var(--green); }

/* ── CODING VIEW ── */
.coding-view { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.coding-header { background: var(--surface); border-bottom: 1px solid var(--border); padding: 10px 20px; display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.coding-header h2 { font-family: var(--display); font-size: 15px; font-weight: 600; }
.coding-body { flex: 1; display: flex; overflow: hidden; }

.instruction-panel { width: 300px; background: var(--surface); border-right: 1px solid var(--border); overflow-y: auto; padding: 20px; flex-shrink: 0; }
.instr-title { font-family: var(--display); font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.instr-desc { font-size: 13px; color: var(--muted); line-height: 1.7; margin-bottom: 16px; }
.instr-section { font-size: 11px; font-weight: 600; color: var(--dim); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; margin-top: 14px; }
.instr-example { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin-bottom: 8px; font-family: var(--mono); font-size: 12px; }
.instr-example-row { display: flex; gap: 8px; margin-bottom: 3px; }
.ex-label { color: var(--dim); min-width: 55px; flex-shrink: 0; }
.ex-value { color: var(--text); word-break: break-all; }
.hint-box { background: rgba(108,143,255,0.07); border: 1px solid rgba(108,143,255,0.2); border-radius: 8px; padding: 12px; margin-top: 14px; }
.hint-label { font-size: 11px; color: var(--accent); font-weight: 600; text-transform: uppercase; margin-bottom: 4px; }
.hint-text { font-size: 13px; color: var(--muted); line-height: 1.6; }

.editor-panel { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.editor-toolbar { background: var(--surface); border-bottom: 1px solid var(--border); padding: 8px 16px; display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.editor-toolbar .file-label { font-family: var(--mono); font-size: 11px; color: var(--dim); margin-right: auto; }
.editor-area { flex: 1; overflow: hidden; position: relative; }
textarea.code-editor { position: absolute; inset: 0; width: 100%; height: 100%; background: #0a0c10; color: #e8eaf6; font-family: var(--mono); font-size: 13px; line-height: 1.7; padding: 16px; border: none; resize: none; tab-size: 4; }
textarea.code-editor:focus { outline: none; }

.output-panel { height: 210px; background: #08090c; border-top: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; }
.output-tabs { display: flex; border-bottom: 1px solid var(--border); background: var(--surface); flex-shrink: 0; }
.output-tab { padding: 8px 16px; font-size: 12px; font-weight: 500; color: var(--muted); cursor: pointer; transition: all 0.15s; border: none; border-bottom: 2px solid transparent; background: none; }
.output-tab:hover { color: var(--text); }
.output-tab.active { color: var(--accent); border-bottom: 2px solid var(--accent); }
.output-content { flex: 1; overflow-y: auto; padding: 12px 16px; font-family: var(--mono); font-size: 12px; line-height: 1.7; }
.out-line { margin-bottom: 1px; white-space: pre-wrap; word-break: break-all; }
.out-ok { color: #a8e6c1; }
.out-err { color: var(--red); }
.out-info { color: var(--accent); }
.out-dim { color: var(--dim); }
.test-result { padding: 8px 12px; border-radius: 6px; margin-bottom: 6px; display: flex; align-items: flex-start; gap: 10px; }
.test-result.pass { background: rgba(61,214,140,0.08); border: 1px solid rgba(61,214,140,0.2); }
.test-result.fail { background: rgba(255,107,107,0.08); border: 1px solid rgba(255,107,107,0.2); }
.test-icon { font-size: 14px; flex-shrink: 0; margin-top: 1px; }
.test-info { flex: 1; }
.test-name { font-size: 12px; font-weight: 500; color: var(--text); }
.test-detail { font-size: 11px; color: var(--muted); margin-top: 2px; font-family: var(--mono); }

/* ── ADMIN AREAS ── */
.admin-page { flex: 1; overflow-y: auto; padding: 24px; }

/* ── QUESTION BUILDER ── */
.builder-layout { flex: 1; display: flex; overflow: hidden; }
.builder-list { width: 260px; background: var(--surface); border-right: 1px solid var(--border); overflow-y: auto; flex-shrink: 0; display: flex; flex-direction: column; }
.builder-list-head { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.builder-list-head span { font-size: 13px; font-weight: 600; }
.qlist-item { padding: 12px 16px; cursor: pointer; border-bottom: 1px solid var(--border); transition: all 0.15s; border-left: 3px solid transparent; }
.qlist-item:hover { background: rgba(108,143,255,0.05); }
.qlist-item.active { background: rgba(108,143,255,0.08); border-left-color: var(--accent); }
.qlist-name { font-size: 13px; font-weight: 500; margin-bottom: 3px; }
.qlist-meta { font-size: 11px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.builder-form { flex: 1; overflow-y: auto; padding: 24px; }
.test-case-row { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin-bottom: 8px; display: grid; gap: 10px; align-items: start; }
.test-case-row.io { grid-template-columns: 1fr 1fr auto; }
.test-case-row.unit { grid-template-columns: 1fr 1fr 1fr auto; }
.add-test-btn { background: rgba(108,143,255,0.07); border: 1px dashed rgba(108,143,255,0.4); border-radius: 8px; padding: 10px; text-align: center; color: var(--accent); font-size: 13px; cursor: pointer; transition: all 0.15s; margin-bottom: 4px; }
.add-test-btn:hover { background: rgba(108,143,255,0.15); }
.save-bar { background: var(--surface); border-top: 1px solid var(--border); padding: 12px 24px; display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.save-bar .spacer { flex: 1; }
.saved-msg { font-size: 13px; color: var(--green); }
.test-type-btns { display: flex; gap: 8px; }

/* ── MARKBOOK ── */
.markbook-page { flex: 1; overflow: auto; padding: 24px; }
.markbook-table-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid var(--border); }
.markbook-table { border-collapse: collapse; width: 100%; }
.markbook-table th { background: var(--surface); padding: 10px 14px; font-size: 11px; font-weight: 600; color: var(--dim); text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); text-align: center; white-space: nowrap; }
.markbook-table th:first-child { text-align: left; min-width: 150px; }
.markbook-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); text-align: center; font-size: 13px; background: var(--bg); }
.markbook-table td:first-child { text-align: left; background: var(--surface); font-weight: 500; white-space: nowrap; }
.markbook-table tr:last-child td { border-bottom: none; }
.mark-cell { display: inline-flex; align-items: center; justify-content: center; min-width: 40px; padding: 2px 8px; height: 24px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.mark-pass { background: rgba(61,214,140,0.15); color: var(--green); }
.mark-fail { background: rgba(255,107,107,0.12); color: var(--red); }
.mark-none { background: var(--surface2); color: var(--dim); }
.mark-partial { background: rgba(255,209,102,0.15); color: var(--amber); }

/* ── MODAL ── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.65); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 28px; width: 440px; max-height: 85vh; overflow-y: auto; }
.modal h3 { font-family: var(--display); font-size: 17px; font-weight: 700; margin-bottom: 20px; }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }

/* ── LOADING / EMPTY ── */
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 40px; color: var(--muted); font-size: 13px; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-state .empty-icon { font-size: 36px; margin-bottom: 10px; }
.empty-state p { font-size: 14px; }

/* ── PROGRESS MARKBOOK STUDENT ── */
.my-progress-table { width: 100%; border-collapse: collapse; }
.my-progress-table th { font-size: 11px; font-weight: 600; color: var(--dim); text-transform: uppercase; letter-spacing: 0.5px; padding: 8px 14px; border-bottom: 1px solid var(--border); text-align: left; }
.my-progress-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 13px; }
.my-progress-table tr:last-child td { border-bottom: none; }