:root {
    --bg: #1A1208;
    --bg-wash: rgba(26, 18, 8, 0.96);
    --bg-card: #2C1E0A;
    --bg-card-hover: #3A2810;
    --fg: #F2EAD3;
    --fg-dim: #C8C8B8;
    --accent: #C8831A;
    --accent-light: #E8A84A;
    --accent-soft: rgba(200, 131, 26, 0.14);
    --danger: #f0a8a8;
    --danger-strong: #8B2A1A;
    --danger-soft: rgba(139, 42, 26, 0.14);
    --border: rgba(200, 131, 26, 0.2);
    --radius: 2px;
    --font: 'Crimson Text', Georgia, serif;
    --font-heading: 'Playfair Display', serif;
    --mono: 'Courier Prime', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--fg);
    min-height: 100vh;
    line-height: 1.6;
}

h1, h2, h3 {
    font-family: var(--font-heading);
    font-weight: 700;
}

input[type="checkbox"] { accent-color: var(--accent); }

.screen { display: none; }
.screen.active { display: block; }

/* ── Auth Screen ─────────────────────────────────────────── */

#auth-screen {
    display: none;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
}
#auth-screen.active {
    display: flex;
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-top: 3px solid var(--accent);
    border-radius: var(--radius);
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
}

.auth-header { text-align: center; margin-bottom: 2rem; }
.auth-header .logo { font-size: 3rem; }
.auth-header h1 {
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--accent-light);
    letter-spacing: 0.03em;
    margin: 0.5rem 0 0.25rem;
}
.auth-header .subtitle { color: var(--fg-dim); font-size: 0.9rem; font-style: italic; }
.auth-header .brand {
    font-family: var(--mono);
    font-size: 0.62rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--accent);
    margin-top: 0.75rem;
    opacity: 0.8;
}

.auth-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}
.auth-tabs .tab {
    flex: 1;
    background: none;
    border: none;
    color: var(--fg-dim);
    padding: 0.75rem;
    cursor: pointer;
    font-family: var(--mono);
    font-size: 0.7rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}
.auth-tabs .tab.active {
    color: var(--fg);
    border-bottom-color: var(--accent);
}
.auth-tabs .tab:hover { color: var(--fg); }

.auth-form { display: none; }
.auth-form.active { display: block; }

/* ── Forms ───────────────────────────────────────────────── */

.form-group { margin-bottom: 1rem; }
.form-group label {
    display: block;
    font-family: var(--mono);
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 0.4rem;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.6rem 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 0;
    color: var(--fg);
    font-family: var(--font);
    font-size: 1rem;
    transition: border-color 0.2s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
}
.form-group textarea { resize: vertical; }
.form-row { display: flex; gap: 1rem; }
.form-row .form-group { flex: 1; }

.form-group input[type="range"] {
    padding: 0;
    accent-color: var(--accent);
    cursor: pointer;
}
#progress-display {
    font-size: 0.85rem;
    color: var(--accent);
    font-weight: 600;
    margin-top: 0.25rem;
}

.error-msg { color: var(--danger); font-size: 0.8rem; margin-top: 0.75rem; min-height: 1.2em; }

/* ── Buttons ─────────────────────────────────────────────── */

.btn {
    padding: 0.6rem 1.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: transparent;
    color: var(--accent-light);
    font-family: var(--mono);
    font-size: 0.75rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s;
}
.btn:hover { border-color: var(--accent-light); background: rgba(200, 131, 26, 0.08); }
.btn-primary {
    background: var(--accent);
    color: var(--bg);
    border-color: var(--accent);
    font-weight: 700;
}
.btn-primary:hover { background: var(--accent-light); border-color: var(--accent-light); }
.btn-secondary { color: var(--fg-dim); }
.btn-secondary:hover { color: var(--fg); }
.btn-danger {
    background: transparent;
    color: var(--danger);
    border-color: var(--danger-strong);
}
.btn-danger:hover { background: var(--danger-strong); color: var(--fg); }
.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.65rem; letter-spacing: 0.1em; }

/* ── Dashboard ───────────────────────────────────────────── */

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-wash);
    backdrop-filter: blur(8px);
    position: sticky;
    top: 0;
    z-index: 10;
}
.header-left { display: flex; align-items: center; gap: 0.75rem; }
.header-left .logo { font-size: 1.5rem; }
.header-left h1 {
    font-size: 1.4rem;
    font-weight: 900;
    color: var(--accent-light);
    letter-spacing: 0.04em;
}
.header-right { display: flex; align-items: center; gap: 1rem; }
#user-info {
    color: var(--fg-dim);
    font-family: var(--mono);
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.dashboard-main { padding: 1.5rem; }

.stats-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}
.stat-card {
    flex: 1;
    min-width: 120px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-top: 3px solid var(--accent);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
    transition: border-color 0.2s, transform 0.2s;
}
.stat-card:hover { border-color: rgba(200, 131, 26, 0.4); border-top-color: var(--accent-light); transform: translateY(-2px); }
.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--accent-light);
    font-family: var(--mono);
}
.stat-card .stat-label {
    font-size: 0.65rem;
    color: var(--fg-dim);
    font-family: var(--mono);
    text-transform: uppercase;
    letter-spacing: 0.14em;
    margin-top: 0.25rem;
}

/* ── Teacher Panel ───────────────────────────────────────── */

.teacher-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    padding: 1rem;
}
.teacher-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}
.teacher-panel-header h2 {
    font-size: 1.1rem;
}
.student-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.student-item {
    padding: 0.6rem 1rem;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.15s;
    border: 1px solid var(--border);
    min-width: 180px;
    flex: 1;
}
.student-item:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent);
}
.student-item.active {
    background: var(--accent-soft);
    border-color: var(--accent);
}
.student-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}
.student-item-name {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 0.2rem;
}
.student-edit-btn {
    flex-shrink: 0;
    padding: 0.2rem 0.5rem;
    font-family: var(--mono);
    font-size: 0.7rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--fg-dim);
    cursor: pointer;
    transition: all 0.15s;
}
.student-edit-btn:hover {
    border-color: var(--accent);
    color: var(--accent-light);
}
.student-item-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
}
.student-item-username {
    color: var(--fg-dim);
    font-family: var(--mono);
}
.student-item-status {
    font-family: var(--mono);
    font-weight: 700;
    font-size: 0.65rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}
.status-active {
    color: #7dd3a0;
}
.status-inactive {
    color: var(--fg-dim);
}
.student-item-notes {
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: var(--fg-dim);
    font-style: italic;
}

/* ── Teacher List ──────────────────────────────────────────── */

.teacher-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.teacher-item {
    padding: 0.6rem 1rem;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.15s;
    border: 1px solid var(--border);
    min-width: 180px;
    flex: 1;
}

.teacher-item:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent);
}

.teacher-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.teacher-item-name {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.95rem;
}

.teacher-item-stats {
    font-size: 0.75rem;
    color: var(--fg-dim);
}

.teacher-item-username {
    color: var(--fg-dim);
    font-family: var(--mono);
    font-size: 0.75rem;
}

/* ── Course List ─────────────────────────────────────────── */

.course-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.course-item {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
}
.course-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}
.course-item-name {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.95rem;
}
.course-color-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}
.course-item-desc {
    margin-top: 0.35rem;
    font-size: 0.8rem;
    color: var(--fg-dim);
}
.lesson-list {
    margin-top: 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.lesson-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.6rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.85rem;
}
.lesson-item-name { flex: 1; }
.lesson-empty {
    font-size: 0.8rem;
    color: var(--fg-dim);
    font-style: italic;
}
.lesson-add-btn {
    align-self: flex-start;
    margin-top: 0.1rem;
}
.form-group input[type="color"] {
    padding: 0.2rem;
    height: 2.5rem;
    cursor: pointer;
}
.lessons-checklist {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    max-height: 160px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.6rem 0.75rem;
}
.lesson-checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    cursor: pointer;
}
.lesson-checkbox-item input[type="checkbox"] {
    width: auto;
}

/* ── Main Layout ─────────────────────────────────────────── */

.main-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    min-height: 500px;
}

.session-list-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
}
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}
.panel-header h2 { font-size: 1.1rem; }

.session-filters {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}
.session-filters select {
    flex: 1;
    padding: 0.4rem 0.5rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--fg);
    font-size: 0.8rem;
    font-family: var(--font);
}

.session-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}
.session-item {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.15s;
    border: 1px solid transparent;
    margin-bottom: 0.25rem;
}
.session-item:hover { background: var(--bg-card-hover); border-color: var(--border); }
.session-item.active { background: var(--accent-soft); border-color: var(--accent); }
.session-item-title { font-family: var(--font-heading); font-weight: 700; font-size: 0.95rem; }
.session-item-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.25rem;
}
.session-item-type {
    font-family: var(--mono);
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius);
    background: var(--accent-soft);
    color: var(--accent-light);
    font-weight: 700;
}
.session-item-date { font-size: 0.75rem; color: var(--fg-dim); font-family: var(--mono); letter-spacing: 0.05em; }
.session-item-student { font-size: 0.75rem; color: var(--accent-light); margin-left: auto; font-family: var(--mono); letter-spacing: 0.05em; }
.session-item-progress {
    width: 60px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 0.4rem;
}
.session-item-progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.2s;
}
.session-item-rating { color: var(--accent-light); font-size: 0.75rem; }
.session-item-user {
    font-size: 0.7rem;
    color: var(--fg-dim);
    font-style: italic;
    margin-top: 0.15rem;
}

/* ── Detail Panel ────────────────────────────────────────── */

.detail-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
}
.detail-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--fg-dim);
    font-size: 0.9rem;
    font-style: italic;
}
.detail-content { padding: 1.5rem; overflow-y: auto; flex: 1; }
.detail-field { margin-bottom: 1.25rem; }
.detail-label {
    font-family: var(--mono);
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--accent);
    margin-bottom: 0.3rem;
}
.detail-value { font-size: 1rem; line-height: 1.5; }
.detail-value.large { font-family: var(--font-heading); font-size: 1.3rem; font-weight: 700; }

/* ── Modal ───────────────────────────────────────────────── */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}
.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    max-width: 550px;
    max-height: 90vh;
    overflow-y: auto;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 1rem; }
.modal-close {
    background: none;
    border: none;
    color: var(--fg-dim);
    font-size: 1.5rem;
    cursor: pointer;
}
.modal-close:hover { color: var(--fg); }
.modal-actions {
    display: flex;
    align-items: center;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    gap: 0.5rem;
}
.modal-spacer { flex: 1; }

/* ── Utility ─────────────────────────────────────────────── */

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--fg-dim);
    font-size: 0.9rem;
    font-style: italic;
}

/* ── Responsive ──────────────────────────────────────────── */

@media (max-width: 768px) {
    .main-layout {
        grid-template-columns: 1fr;
    }
    .form-row { flex-direction: column; gap: 0; }
}
