:root {
    --bg: #f1f3f8;
    --card: #ffffff;
    --line: #e5e7eb;
    --text: #111827;
    --muted: #6b7280;
    --nav: #0c1539;
    --nav-active: #1c2c63;
    --accent: #1f5ed6;
    --danger: #c91e3a;
    --warn: #d97706;
    --ok: #1d4ed8;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: "Segoe UI", Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
}
a { color: var(--accent); text-decoration: none; }

.app-shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 230px;
    background: var(--nav);
    color: #fff;
    padding: 16px 12px;
}
.brand { font-size: 20px; font-weight: 700; margin-bottom: 20px; line-height: 1.2; }
.brand span { font-size: 12px; opacity: 0.8; text-transform: uppercase; }
.menu { display: flex; flex-direction: column; gap: 6px; }
.menu a {
    color: #dde4ff;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 14px;
}
.menu a.active, .menu a:hover { background: var(--nav-active); color: #fff; }

.main-content { flex: 1; padding: 18px; }
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
h2, h3, h4 { margin: 0 0 10px; }
.muted { color: var(--muted); font-size: 13px; }

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 14px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 14px;
}
.stat-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 14px;
}
.stat-value { font-size: 28px; font-weight: 700; color: #b91c1c; }

table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 10px; overflow: hidden; }
th, td { border-bottom: 1px solid var(--line); text-align: left; padding: 10px; font-size: 14px; }
th { color: var(--muted); font-weight: 600; background: #f8fafc; }

input, select, textarea, button {
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 14px;
}
textarea { width: 100%; min-height: 100px; }
button, .button {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 9px 12px;
    border-radius: 8px;
    display: inline-block;
}
.button-secondary {
    background: #e5e7eb;
    color: #1f2937;
}

.filter-form { display: flex; flex-direction: column; gap: 12px; }
.filter-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(180px, 1fr));
    gap: 10px 12px;
}
.filter-item { display: flex; flex-direction: column; gap: 6px; }
.filter-item label { font-size: 12px; color: var(--muted); font-weight: 600; }
.filter-item input,
.filter-item select { width: 100%; background: #fff; }
.filter-actions { display: flex; gap: 8px; align-items: center; }

.badge { font-size: 12px; border-radius: 999px; padding: 4px 9px; color: #fff; font-weight: 600; }
.badge-blue { background: var(--ok); }
.badge-red { background: var(--danger); }
.badge-orange { background: var(--warn); }
.badge-gray { background: #6b7280; }

.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 16px; }
.tab {
    background: #eef2ff;
    color: #233876;
    border: 1px solid #dbe4ff;
    padding: 7px 10px;
    border-radius: 999px;
    font-size: 13px;
}
.tab-button { cursor: pointer; }
.tab-button.active {
    background: #1f5ed6;
    color: #fff;
    border-color: #1f5ed6;
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.alert {
    background: #ecfeff;
    border: 1px solid #a5f3fc;
    color: #0e7490;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 10px;
}

/* ── Login page ── */
.login-page {
    background: var(--bg);
    min-height: 100vh;
}

.login-shell {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 100vh;
}

.login-hero {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
    background: linear-gradient(145deg, #0c1539 0%, #1a2d6b 50%, #1f5ed6 100%);
    color: #fff;
    overflow: hidden;
}

.login-hero-content {
    position: relative;
    z-index: 1;
    max-width: 420px;
}

.login-hero-glow {
    position: absolute;
    width: 500px;
    height: 500px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255,255,255,0.08) 0%, transparent 70%);
    top: -120px;
    right: -100px;
    pointer-events: none;
}

.login-logo {
    margin-bottom: 28px;
}

.login-hero h1 {
    font-size: 32px;
    font-weight: 700;
    line-height: 1.25;
    margin: 0 0 16px;
    letter-spacing: -0.02em;
}

.login-tagline {
    font-size: 15px;
    line-height: 1.6;
    color: rgba(255,255,255,0.75);
    margin: 0 0 32px;
}

.login-features {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.login-features li {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: rgba(255,255,255,0.85);
}

.login-features li::before {
    content: "";
    flex-shrink: 0;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #60a5fa;
}

.login-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 24px;
    background: var(--bg);
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 36px 32px;
    box-shadow: 0 4px 24px rgba(12, 21, 57, 0.08);
}

.login-card-header {
    margin-bottom: 28px;
}

.login-card-header h2 {
    font-size: 24px;
    font-weight: 700;
    margin: 0 0 6px;
    letter-spacing: -0.02em;
}

.login-card-header p {
    margin: 0;
    font-size: 14px;
    color: var(--muted);
}

.login-error {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.45;
    margin-bottom: 20px;
}

.login-error svg {
    flex-shrink: 0;
    margin-top: 1px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.login-field {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.login-field label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.login-input-wrap {
    position: relative;
}

.login-input-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    pointer-events: none;
}

.login-input-wrap input {
    width: 100%;
    padding: 11px 12px 11px 40px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    font-size: 14px;
    background: #f9fafb;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.login-input-wrap input:focus {
    outline: none;
    border-color: var(--accent);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(31, 94, 214, 0.12);
}

.login-input-wrap input::placeholder {
    color: #9ca3af;
}

.login-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 16px;
    margin-top: 4px;
    background: linear-gradient(135deg, #1f5ed6 0%, #1a4bb8 100%);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
}

.login-submit:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(31, 94, 214, 0.35);
}

.login-submit:active {
    transform: translateY(0);
    box-shadow: none;
}

.login-footer {
    margin: 24px 0 0;
    text-align: center;
    font-size: 12px;
    color: var(--muted);
}

@media (max-width: 900px) {
    .login-shell {
        grid-template-columns: 1fr;
    }

    .login-hero {
        padding: 36px 28px;
        min-height: auto;
    }

    .login-hero h1 {
        font-size: 26px;
    }

    .login-features {
        display: none;
    }

    .login-panel {
        padding: 24px 20px 40px;
    }

    .login-card {
        box-shadow: none;
        border: none;
        padding: 8px 4px;
    }
}

/* ── Settings page ── */
.settings-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 4px;
    width: fit-content;
}

.settings-tab {
    padding: 8px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--muted);
    transition: background 0.15s, color 0.15s;
}

.settings-tab:hover { color: var(--text); background: #f3f4f6; }
.settings-tab.active {
    background: var(--accent);
    color: #fff;
}

.settings-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 14px;
    align-items: start;
}

.settings-sidebar { padding: 12px; }
.settings-sidebar-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin-bottom: 10px;
    padding: 0 8px;
}

.settings-group { margin-bottom: 14px; }
.settings-group-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    padding: 4px 8px;
    margin-bottom: 2px;
}

.settings-nav-item {
    display: block;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 13px;
    color: var(--text);
}

.settings-nav-item:hover { background: #f3f4f6; }
.settings-nav-item.active {
    background: #eef2ff;
    color: var(--accent);
    font-weight: 600;
}

.settings-main { display: flex; flex-direction: column; gap: 14px; }

.settings-add-card h4 { margin-bottom: 12px; }
.settings-add-form { display: flex; flex-direction: column; gap: 12px; }
.settings-add-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}

.settings-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    min-width: 200px;
}

.settings-field label {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
}

.settings-field input { width: 100%; }

.settings-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
    padding-bottom: 8px;
}

.settings-checkbox input { width: auto; margin: 0; }

.settings-table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.settings-table-header h4 { margin: 0; }

.settings-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    white-space: nowrap;
}

.inline-form { display: inline; margin: 0; }

.link-button {
    background: none;
    border: none;
    color: var(--accent);
    padding: 0;
    font-size: 14px;
    cursor: pointer;
    text-decoration: underline;
}

.link-button:hover { color: #1a4bb8; }

.row-inactive td { opacity: 0.55; }

.settings-user-form .form-section {
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--line);
}

.settings-user-form .form-section:last-of-type { border-bottom: none; }

.settings-user-form h4 {
    font-size: 14px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 14px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-field-wide { grid-column: 1 / -1; }
.form-field label { font-size: 13px; font-weight: 600; }
.form-field input, .form-field select { width: 100%; }

.field-hint {
    font-size: 12px;
    color: var(--muted);
}

.field-error {
    font-size: 12px;
    color: var(--danger);
}

.form-field-check {
    justify-content: center;
}

.form-checks {
    display: flex;
    flex-direction: column;
    gap: 10px;
    justify-content: center;
}

.checkbox-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px;
    background: #f9fafb;
    border: 1px solid var(--line);
    border-radius: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.checkbox-list label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 400;
    cursor: pointer;
}

.checkbox-list input { width: auto; }

.form-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

@media (max-width: 900px) {
    .settings-layout { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
}

/* ── Student profile ── */
.back-link {
    display: inline-block;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 14px;
    transition: color 0.15s;
}

.back-link:hover { color: var(--accent); }

.profile-hero {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    padding: 20px 24px;
    margin-bottom: 16px;
    background: linear-gradient(135deg, #fff 0%, #f8faff 100%);
    border-color: #dbe4ff;
}

.profile-hero-main {
    display: flex;
    align-items: center;
    gap: 18px;
}

.profile-avatar {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background: linear-gradient(135deg, #1f5ed6, #0c1539);
    color: #fff;
    font-size: 22px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    letter-spacing: -0.02em;
}

.profile-hero-info h3 {
    font-size: 22px;
    font-weight: 700;
    margin: 0 0 6px;
    letter-spacing: -0.02em;
}

.profile-meta {
    font-size: 14px;
    color: var(--muted);
    margin-bottom: 10px;
}

.profile-meta-dot { margin: 0 4px; }

.profile-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.profile-tabs {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 5px;
}

.profile-tab {
    background: transparent;
    color: var(--muted);
    border: none;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.profile-tab:hover { color: var(--text); background: #f3f4f6; }
.profile-tab.active {
    background: var(--accent);
    color: #fff;
}

.section-card { padding: 20px 24px; }

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
}

.section-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
}

.section-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.section-edit {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
}

.section-edit:hover { text-decoration: underline; }

.button-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px 20px;
}

.info-grid-2 { grid-template-columns: repeat(2, 1fr); }

.info-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.info-item-wide { grid-column: 1 / -1; }

.info-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
}

.info-value {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    line-height: 1.45;
}

.info-value-lg {
    font-size: 20px;
    font-weight: 700;
    color: var(--accent);
}

.member-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 16px;
}

.member-card {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    background: #f9fafb;
    border: 1px solid var(--line);
    border-radius: 10px;
}

.member-name {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 2px;
}

.member-meta {
    font-size: 13px;
    color: var(--muted);
}

.member-detail {
    font-size: 13px;
    color: var(--text);
    margin-top: 4px;
}

.member-tags {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    flex-shrink: 0;
}

.tag {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 999px;
    background: #e5e7eb;
    color: #374151;
}

.tag-blue {
    background: #dbeafe;
    color: #1d4ed8;
}

.member-delete {
    font-size: 12px;
    color: var(--danger);
}

.benefits-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.benefit-chip {
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    background: #f3f4f6;
    color: #9ca3af;
    border: 1px solid var(--line);
}

.benefit-chip.active {
    background: #ecfdf5;
    color: #047857;
    border-color: #a7f3d0;
}

.ai-stats {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
    margin-bottom: 18px;
    padding: 14px 16px;
    background: #f8fafc;
    border-radius: 10px;
}

.ai-stat {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ai-stat-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
}

.ai-blocks {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.ai-block {
    padding: 14px 16px;
    border-radius: 10px;
    background: #f9fafb;
    border: 1px solid var(--line);
}

.ai-block-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    margin-bottom: 8px;
}

.ai-block p {
    margin: 0;
    font-size: 14px;
    line-height: 1.55;
}

.ai-block-green { background: #f0fdf4; border-color: #bbf7d0; }
.ai-block-green .ai-block-title { color: #15803d; }
.ai-block-red { background: #fef2f2; border-color: #fecaca; }
.ai-block-red .ai-block-title { color: #b91c1c; }
.ai-block-blue { background: #eff6ff; border-color: #bfdbfe; }
.ai-block-blue .ai-block-title { color: #1d4ed8; }

.ai-disclaimer {
    margin: 16px 0 0;
    font-size: 12px;
    color: var(--muted);
    font-style: italic;
}

.empty-state {
    text-align: center;
    padding: 32px 16px;
    color: var(--muted);
    font-size: 14px;
}

.empty-state .button { margin-top: 12px; }

/* ── Student forms ── */
.form-page-header {
    margin-bottom: 16px;
}

.form-page-header h3 { margin-bottom: 4px; }

.student-form-card {
    padding: 24px 28px;
    max-width: 860px;
}

.student-form .form-section {
    margin-bottom: 28px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--line);
}

.student-form .form-section:last-of-type { border-bottom: none; margin-bottom: 8px; }

.form-section-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    margin: 0 0 16px;
}

.student-form .form-field input,
.student-form .form-field select,
.student-form .form-field textarea {
    padding: 10px 12px;
    background: #f9fafb;
    border-color: #d1d5db;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.student-form .form-field input:focus,
.student-form .form-field select:focus,
.student-form .form-field textarea:focus {
    outline: none;
    border-color: var(--accent);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(31, 94, 214, 0.1);
}

.student-form .form-field-wide { grid-column: 1 / -1; }

@media (max-width: 1100px) {
    .info-grid { grid-template-columns: repeat(2, 1fr); }
    .ai-blocks { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
    .profile-hero { flex-direction: column; align-items: flex-start; }
    .info-grid, .info-grid-2 { grid-template-columns: 1fr; }
    .member-card { flex-direction: column; }
    .member-tags { flex-direction: row; align-items: center; }
    .profile-tabs { overflow-x: auto; flex-wrap: nowrap; }
}

/* ── Reports ── */
.report-table-wrap {
    overflow-x: auto;
}

.completion-table th,
.completion-table td {
    font-size: 13px;
    white-space: nowrap;
}

.completion-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.completion-good { background: #dcfce7; color: #15803d; }
.completion-mid { background: #fef3c7; color: #b45309; }
.completion-low { background: #fee2e2; color: #b91c1c; }

.completion-pct {
    font-size: 13px;
    color: var(--muted);
    font-weight: 600;
}

@media (max-width: 1280px) {
    .filter-grid { grid-template-columns: repeat(3, minmax(180px, 1fr)); }
}
@media (max-width: 980px) {
    .filter-grid { grid-template-columns: repeat(2, minmax(180px, 1fr)); }
    .stats-grid { grid-template-columns: 1fr; }
}
