/* ========================================
   Smart Study Web - Modern Stylesheet
   ======================================== */

:root {
    --primary: #4A6FA5;
    --primary-light: #6B8DC0;
    --primary-dark: #3A5A8A;
    --primary-bg: #EEF2F8;
    --primary-hover-bg: #E4EAF4;
    --success: #4CAF82;
    --success-bg: #EBF7F2;
    --completed: #16A34A;
    --completed-bg: #DCFCE7;
    --warning: #D4930D;
    --warning-bg: #FEF8E8;
    --danger: #D44D4D;
    --danger-bg: #FEF0F0;
    --info: #6C63FF;
    --info-bg: #F0EFFE;
    --bg: #E8EEF4;
    --surface: #FFFFFF;
    --surface-2: #F4F7FB;
    --border: #DDE3ED;
    --border-light: #EEF2F7;
    --text: #2D3A4A;
    --text-secondary: #6B7A90;
    --text-muted: #9AAABD;
    --radius: 10px;
    --radius-sm: 7px;
    --shadow-sm: 0 1px 3px rgba(45, 58, 74, 0.06);
    --shadow: 0 2px 10px rgba(45, 58, 74, 0.08);
    --shadow-lg: 0 8px 32px rgba(45, 58, 74, 0.12);
    --shadow-card: 0 1px 3px rgba(45, 58, 74, 0.05), 0 4px 16px rgba(45, 58, 74, 0.06);
    --font: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', -apple-system, BlinkMacSystemFont, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 13px;
    line-height: 1.5;
    overflow-x: hidden;
}

/* ---- App Container ---- */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* ---- Header ---- */
.header {
    background: var(--surface);
    color: var(--text);
    padding: 0 24px;
    height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    position: relative;
    z-index: 10;
}

.header::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: 0 2px 2px 0;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-brand .brand-icon {
    width: 34px;
    height: 34px;
    background: linear-gradient(145deg, var(--primary), var(--primary-dark));
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(74, 111, 165, 0.3);
    flex-shrink: 0;
}

.header-brand .brand-icon svg { stroke: white; }

.header-brand h1 { font-size: 15px; font-weight: 700; color: var(--text); letter-spacing: 0.2px; }

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: var(--text-secondary);
}

.status-indicator .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #86EFAC;
}

.status-indicator.warning .dot { background: #FCD34D; }
.status-indicator.error .dot { background: #FCA5A5; }

.worker-count {
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--surface-2);
    padding: 3px 10px;
    border-radius: 20px;
    border: 1px solid var(--border);
}

/* ---- Navigation ---- */
.nav-tabs {
    background: var(--surface);
    display: flex;
    padding: 0 24px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.tab-btn {
    background: none;
    border: none;
    padding: 14px 18px;
    font-size: 13px;
    font-family: var(--font);
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
    font-weight: 500;
    margin-bottom: -1px;
}

.tab-btn:hover { color: var(--primary); }

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

/* ---- Main Content ---- */
.main-content {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.tab-panel {
    display: none;
    flex: 1;
    overflow-y: auto;
    padding: 20px 28px;
    flex-direction: column;
}

.tab-panel.active { display: flex; }

/* ---- Panel Header ---- */
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    flex-shrink: 0;
}

.panel-header h2 { font-size: 15px; font-weight: 700; color: var(--text); }

.mobile-panel-toggle,
.mobile-filter-toggle {
    display: none;
}

.header-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-family: var(--font);
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s;
    white-space: nowrap;
    line-height: 1.4;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 1px 3px rgba(74, 111, 165, 0.2);
}
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); box-shadow: 0 2px 6px rgba(74, 111, 165, 0.3); }

.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-2); border-color: #C8D0DE; }

.btn-success {
    background: var(--success);
    color: white;
    box-shadow: 0 1px 3px rgba(76, 175, 130, 0.2);
}
.btn-success:hover { background: #3D9469; box-shadow: 0 2px 6px rgba(76, 175, 130, 0.3); }

.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { background: #B37D0A; }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #B83D3D; }

.btn-info { background: var(--info); color: white; }
.btn-info:hover { background: #5A50E0; }

.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-sm { padding: 4px 10px; font-size: 11px; }

.btn-outline {
    background: transparent;
    color: var(--primary);
    border-color: var(--primary);
}
.btn-outline:hover { background: var(--primary-bg); }

/* ---- Data List (replaces card grid) ---- */
.data-list {
    flex: 1;
    overflow-y: auto;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border);
}

.list-item {
    display: flex;
    align-items: center;
    padding: 13px 18px;
    border-bottom: 1px solid var(--border-light);
    gap: 12px;
    transition: background 0.1s;
}

.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--primary-bg); }
.list-item.selected { background: var(--primary-hover-bg); }

.list-item-main { flex: 1; min-width: 0; }
.list-item-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.list-item-title .name-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item-meta { font-size: 11px; color: var(--text-muted); }

.list-item-stats {
    display: flex;
    gap: 16px;
    flex-shrink: 0;
}

.list-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 44px;
}

.list-stat-value {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}

.list-stat-label {
    font-size: 10px;
    color: var(--text-muted);
    white-space: nowrap;
}

.list-stat-value.success { color: var(--success); }
.list-stat-value.warning { color: var(--warning); }
.list-stat-value.danger { color: var(--danger); }
.list-stat-value.primary { color: var(--primary); }

.list-item-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

/* ---- Tables ---- */
.table-container {
    flex: 1;
    overflow: auto;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.pagination-wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-top: 1px solid var(--border);
    background: var(--surface);
    gap: 12px;
    flex-wrap: wrap;
}
.pagination-wrap .pagination-btns {
    display: flex;
    align-items: center;
    gap: 4px;
}
.pagination-wrap .btn {
    min-width: 36px;
}
.pagination-wrap .page-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 30px;
    padding: 0 6px;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    border-radius: 4px;
    border: 1px solid transparent;
}
.pagination-wrap .page-num:hover { background: var(--primary-hover-bg); }
.pagination-wrap .page-num.active {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    cursor: default;
}
.pagination-wrap .page-ellipsis {
    color: var(--text-muted);
    padding: 0 4px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.data-table thead {
    background: var(--surface-2);
    position: sticky;
    top: 0;
    z-index: 1;
}

.data-table th {
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
    color: var(--text);
}

.data-table tbody tr:hover { background: var(--primary-bg); }
.data-table tbody tr:last-child td { border-bottom: none; }

.user-tree-group td {
    padding: 0;
    background: var(--surface-2);
    border-bottom-color: var(--border);
}

.user-tree-toggle {
    flex: 1;
    min-width: 240px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 12px;
    border: 0;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}

.user-tree-toggle::before {
    content: "\25BE";
    width: 14px;
    color: var(--text-muted);
    transform-origin: center;
}

.user-tree-toggle[aria-expanded="false"]::before { transform: rotate(-90deg); }
.user-tree-header { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.user-tree-org-meta { display: flex; flex-wrap: wrap; gap: 12px; color: var(--text-muted); font-size: 11px; font-weight: 400; }
.user-tree-actions { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 10px 6px 0; }
.user-tree-count { margin-left: auto; color: var(--text-muted); font-size: 11px; font-weight: 400; }
.user-tree-child td:nth-child(2) { padding-left: 30px; }
.user-tree-child[hidden] { display: none; }

/* ---- Status Pills ---- */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.status-pill.running { background: var(--info-bg); color: var(--info); }
.status-pill.completed { background: var(--completed-bg); color: var(--completed); }
.status-pill.failed { background: var(--danger-bg); color: var(--danger); }
.status-pill.pending { background: var(--warning-bg); color: var(--warning); }
.status-pill.in_progress { background: var(--info-bg); color: var(--info); }
.status-pill.stopped { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }
.status-pill.incomplete { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning); }

.phase-info {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 20px;
    background: var(--success-bg);
    color: var(--success);
    font-size: 12px;
    font-weight: 500;
}

.sub-task-summary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

.sub-task-summary span {
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--bg-secondary);
    font-size: 11px;
}

.status-pill::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.7;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.status-pill.running::before { animation: pulse-dot 1.5s infinite; }

/* ---- Progress Bar ---- */
.progress-bar {
    width: 100%;
    height: 5px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-light), var(--primary));
    border-radius: 3px;
    transition: width 0.4s ease;
}

.progress-bar-fill.success { background: linear-gradient(90deg, #66BB8A, var(--success)); }
.progress-bar-fill.warning { background: linear-gradient(90deg, #E8A830, var(--warning)); }

/* ---- Form Elements ---- */
.form-group { margin-bottom: 14px; }
.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 5px;
    color: var(--text);
}

.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }

.input, .select, .textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-family: var(--font);
    background: var(--surface);
    transition: border-color 0.15s, box-shadow 0.15s;
    color: var(--text);
}

.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(74, 111, 165, 0.1);
}

.textarea { resize: vertical; min-height: 72px; }

.form-hint {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
    display: block;
    background: var(--surface-2);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    line-height: 1.6;
    border: 1px solid var(--border-light);
}

.form-hint-inline {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
    display: block;
}

.input-with-unit {
    display: flex;
    align-items: center;
    gap: 6px;
}
.input-with-unit .input {
    width: 80px;
    flex-shrink: 0;
}
.input-unit {
    font-size: 13px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.checkbox-group, .radio-group { display: flex; flex-wrap: wrap; gap: 10px; }
.checkbox-label, .radio-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    cursor: pointer;
    color: var(--text);
}

.checkbox-list {
    overflow-y: auto;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px;
    background: var(--surface);
}

.task-student-list {
    flex: 1;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px;
    min-height: 200px;
    background: var(--surface);
}

.task-student-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 4px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.task-student-item:last-child {
    border-bottom: none;
}

.task-student-item:hover {
    background: var(--primary-bg);
}

.checkbox-list label {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 4px;
    cursor: pointer;
    border-radius: 4px;
    font-size: 12px;
}

.checkbox-list label:hover { background: var(--primary-bg); }

/* ---- Modal ---- */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(30, 40, 60, 0.45);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.show { display: flex; }

.modal.modal-top {
    align-items: flex-start;
    justify-content: center;
    padding-top: 28px;
}

.modal.modal-top .modal-dialog {
    margin-top: 0;
}

.modal-dialog {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 480px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    animation: modalIn 0.2s ease;
    border: 1px solid var(--border);
}

.modal-dialog.modal-lg { max-width: 620px; }
.modal-dialog.modal-xl { max-width: 960px; }
.modal-dialog.modal-xxl { max-width: 1200px; }

.task-modal-layout {
    display: flex;
    gap: 20px;
    min-height: 500px;
}

.task-config-panel {
    width: 320px;
    flex-shrink: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    background: var(--bg-secondary);
}

.task-student-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    background: var(--bg-secondary);
    min-width: 0;
}

.task-panel-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

.task-filters {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.task-filter-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.task-filter-row > * {
    flex: 1;
    min-width: 120px;
}

.task-filter-row input,
.task-filter-row select {
    width: 100%;
}

.task-filter-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.task-config-area {
    display: inline-block;
    width: 340px;
    vertical-align: top;
    padding-right: 16px;
    border-right: 1px solid var(--border);
    margin-right: 16px;
}

.task-student-area {
    display: inline-block;
    width: calc(100% - 380px);
    vertical-align: top;
    min-height: 200px;
}

/* ---- Enrollment Modal ---- */
.enrollment-modal-layout {
    display: flex;
    gap: 20px;
    min-height: 520px;
}

.enrollment-config-panel {
    width: 340px;
    flex-shrink: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    background: var(--bg-secondary);
}

.enrollment-student-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    background: var(--bg-secondary);
    min-width: 0;
}

.enrollment-panel-title {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

.enrollment-filters {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
}

.enrollment-filter-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.enrollment-filter-row > * {
    flex: 1;
    min-width: 120px;
}

.enrollment-filter-row input,
.enrollment-filter-row select {
    width: 100%;
}

.enrollment-filter-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.enrollment-student-list {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.enrollment-student-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 6px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.1s;
}

.enrollment-student-item:hover {
    background: var(--primary-bg);
}

.enrollment-student-item input[type="checkbox"] {
    width: 14px;
    height: 14px;
    cursor: pointer;
    flex-shrink: 0;
}

.enrollment-student-item .stu-name {
    font-weight: 500;
    color: var(--text-primary);
    min-width: 60px;
}

.enrollment-student-item .stu-username {
    color: var(--text-secondary);
    font-size: 11px;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.enrollment-student-item.selected {
    background: var(--primary-bg);
}

.enrollment-empty-hint {
    padding: 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

.enrollment-courses-section {
    font-size: 12px;
}

/* Student rows inside enrollment modal (rendered by renderEnrollmentStudents) */
.task-student-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 6px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.1s;
}

.task-student-row:hover {
    background: var(--primary-bg);
}

.task-student-row input[type="checkbox"] {
    width: 14px;
    height: 14px;
    cursor: pointer;
    flex-shrink: 0;
}

.task-student-name {
    font-weight: 500;
    color: var(--text-primary);
    min-width: 60px;
}

.task-student-username {
    color: var(--text-secondary);
    font-size: 11px;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.task-student-school {
    color: var(--text-muted);
    font-size: 10px;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.task-student-row input[type="checkbox"]:checked + .task-student-name {
    color: var(--primary);
}

@keyframes modalIn {
    from { transform: translateY(-16px) scale(0.98); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 22px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 15px; font-weight: 700; }

.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.1s;
}

.modal-close:hover { background: var(--danger-bg); color: var(--danger); }

.modal-body {
    padding: 20px 22px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 22px;
    border-top: 1px solid var(--border);
}

.hidden { display: none !important; }

/* ---- Task Detail ---- */
.task-detail-header {
    background: var(--surface-2);
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
    font-size: 12px;
    border: 1px solid var(--border-light);
}

.task-detail-header .stat-row { display: flex; gap: 20px; flex-wrap: wrap; }
.task-detail-header .stat-item { display: flex; gap: 5px; }
.task-detail-header .stat-label { color: var(--text-secondary); }
.task-detail-header .stat-value { font-weight: 600; }

.task-detail-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }

/* ---- Progress Items ---- */
.student-info-header {
    background: var(--surface-2);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
    font-size: 12px;
    border: 1px solid var(--border-light);
}

.progress-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
}

.progress-item:last-child { border-bottom: none; }
.progress-item-info { flex: 1; min-width: 0; }
.progress-item-title { font-weight: 500; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress-item-meta { font-size: 11px; color: var(--text-muted); margin-top: 1px; }
.progress-item-status { text-align: right; flex-shrink: 0; margin-left: 12px; }
.progress-item-score { font-weight: 600; font-size: 14px; }

/* ---- Course Catalog (course > chapter > video) ---- */
.catalog-stats {
    display: flex;
    gap: 16px;
    padding: 10px 14px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 14px;
    font-size: 13px;
}
.catalog-stats span { color: var(--text-secondary); }
.catalog-stats strong { color: var(--primary); margin: 0 4px; }

.catalog-course {
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 10px;
    overflow: hidden;
}
.catalog-course-header {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    background: #f0f4ff;
    cursor: pointer;
    gap: 8px;
    user-select: none;
}
.catalog-course-header:hover { background: #e8eeff; }
.catalog-course-name {
    flex: 1;
    font-weight: 600;
    font-size: 13px;
    color: var(--primary);
}
.catalog-course-meta { font-size: 11px; color: var(--text-secondary); }
.catalog-course-progress {
    font-size: 11px;
    color: var(--text-secondary);
    margin-left: auto;
}
.catalog-course-arrow {
    font-size: 11px;
    transition: transform 0.2s;
    color: var(--text-muted);
}
.catalog-course-arrow.expanded { transform: rotate(90deg); }

.catalog-chapters { display: none; padding: 6px 0; }
.catalog-chapters.expanded { display: block; }

.catalog-chapter {
    padding: 6px 14px 6px 30px;
    border-bottom: 1px dashed #eee;
    font-size: 12px;
}
.catalog-chapter:last-child { border-bottom: none; }
.catalog-chapter-header {
    display: flex;
    align-items: center;
    padding: 4px 0;
    cursor: pointer;
    gap: 6px;
}
.catalog-chapter-header:hover .catalog-chapter-name { color: var(--primary); }
.catalog-chapter-arrow {
    font-size: 10px;
    transition: transform 0.2s;
    color: var(--text-muted);
    flex-shrink: 0;
}
.catalog-chapter-arrow.expanded { transform: rotate(90deg); }
.catalog-chapter-name { flex: 1; font-weight: 500; }
.catalog-chapter-video-count { font-size: 11px; color: var(--text-muted); }

.catalog-videos { display: none; padding: 2px 0 2px 20px; }
.catalog-videos.expanded { display: block; }

.catalog-video {
    display: flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 6px;
    gap: 8px;
    font-size: 12px;
}
.catalog-video:hover { background: #f5f5f5; }
.catalog-video-icon { flex-shrink: 0; }
.catalog-video-name { flex: 1; }
.catalog-video-status { flex-shrink: 0; font-size: 11px; }
.catalog-video-status.done { color: var(--success); }
.catalog-video-status.pending { color: var(--warning); }

.catalog-refreshing {
    text-align: center;
    padding: 20px;
    color: var(--text-secondary);
    font-size: 13px;
}

/* ---- Tabs within Modal ---- */
.modal-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

#taskDetailTabs {
    margin-top: 14px;
}

.modal-tab-btn {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 8px 14px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
    margin-bottom: -1px;
}

.modal-tab-btn:hover { color: var(--primary); }
.modal-tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* ---- Log Display ---- */
.log-container { flex: 1; overflow: hidden; display: flex; flex-direction: column; }

.log-display {
    flex: 1;
    overflow-y: auto;
    background: #1A2332;
    color: #8899BB;
    border-radius: var(--radius);
    padding: 14px 16px;
    font-family: 'Cascadia Code', 'Consolas', 'Courier New', monospace;
    font-size: 11px;
    line-height: 1.7;
}

.log-entry { padding: 1px 0; word-break: break-all; border-bottom: 1px solid rgba(148, 163, 184, 0.18); }
.log-entry:last-child { border-bottom: none; }
.log-entry .log-time { color: #4A5C78; margin-right: 8px; }
.log-entry .log-user { color: #6BA4E0; margin-right: 8px; }
.log-entry .log-msg { color: #A8B8CC; }

/* ---- Enrollment Detail Modal ---- */
.enr-detail-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
}
.enr-detail-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 10px 16px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    margin-bottom: -1px;
}
.enr-detail-tab:hover { color: var(--primary); }
.enr-detail-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

.enr-detail-loading {
    text-align: center;
    padding: 32px;
    color: var(--text-muted);
    font-size: 13px;
}

.enr-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}
.enr-stat-card {
    background: var(--surface-2);
    border-radius: 8px;
    padding: 12px 14px;
    text-align: center;
}
.enr-stat-label { font-size: 11px; color: var(--text-secondary); margin-bottom: 4px; }
.enr-stat-value { font-size: 20px; font-weight: 700; }

.enr-info-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px 20px;
    padding: 14px;
    background: var(--surface-2);
    border-radius: 8px;
}
.enr-info-item { display: flex; gap: 8px; font-size: 13px; line-height: 1.6; }
.enr-info-label { color: var(--text-secondary); flex-shrink: 0; min-width: 60px; }
.enr-info-value { color: var(--text); word-break: break-all; }

.enr-section-title { font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 8px; }

.enr-course-list { display: flex; flex-direction: column; gap: 6px; }
.enr-course-item {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 8px 12px;
    background: var(--surface-2);
    border-radius: 6px;
    font-size: 13px;
}
.enr-course-name { flex: 1; font-weight: 500; }
.enr-course-id { color: var(--text-secondary); font-size: 12px; }
.enr-course-type { color: var(--primary); font-size: 11px; }

.enr-log-line { padding: 1px 0; border-bottom: 1px solid rgba(148, 197, 255, 0.12); }
.enr-log-line:last-child { border-bottom: none; }

.enr-detail-panel .data-table { font-size: 12px; }

/* ---- Empty State ---- */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
    font-size: 13px;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94A8C0; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .header { padding: 0 16px; height: 54px; }
    .tab-btn { padding: 12px 12px; font-size: 12px; }
    .tab-panel { padding: 16px; }
    .panel-header { flex-direction: column; align-items: flex-start; gap: 10px; }
    .list-item-stats { display: none; }
    .form-row { flex-direction: column; }
    .org-account-layout { grid-template-columns: 1fr; }
    .account-info-grid { grid-template-columns: 1fr; }
}

/* ---- Login Page ---- */
.login-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: #E8EEF4;
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(99, 126, 180, 0.12) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 20%, rgba(82, 145, 140, 0.10) 0%, transparent 50%),
        radial-gradient(ellipse at 60% 80%, rgba(120, 100, 170, 0.08) 0%, transparent 50%);
    position: relative;
    overflow: hidden;
}

.login-wrap::before {
    content: '';
    position: absolute;
    top: -120px;
    right: -120px;
    width: 480px;
    height: 480px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(180, 200, 230, 0.3) 0%, transparent 70%);
    pointer-events: none;
}

.login-wrap::after {
    content: '';
    position: absolute;
    bottom: -80px;
    left: -60px;
    width: 320px;
    height: 320px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(160, 190, 180, 0.25) 0%, transparent 70%);
    pointer-events: none;
}

.login-card {
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(18px) saturate(1.4);
    -webkit-backdrop-filter: blur(18px) saturate(1.4);
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: 20px;
    box-shadow: 0 8px 40px rgba(80, 100, 140, 0.12), 0 1px 0 rgba(255,255,255,0.8) inset;
    padding: 48px 40px;
    width: 100%;
    max-width: 380px;
    position: relative;
    z-index: 1;
}

.login-header { text-align: center; margin-bottom: 36px; }
.login-header .logo-icon {
    width: 52px;
    height: 52px;
    margin: 0 auto 16px;
    background: linear-gradient(145deg, #4A6FA5, #2D5F8B);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(45, 95, 139, 0.3);
}
.login-header .logo-icon svg { stroke: white; }
.login-header h1 { font-size: 20px; font-weight: 700; color: #2D3A4A; margin-bottom: 4px; letter-spacing: 0.3px; }
.login-header p { font-size: 12px; color: #8896A8; }

.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-form .input { padding: 10px 13px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; padding: 11px; font-size: 14px; }

.form-error {
    color: var(--danger);
    font-size: 12px;
    padding: 9px 12px;
    background: var(--danger-bg);
    border-radius: var(--radius-sm);
    border: 1px solid #FECACA;
}

.login-hint {
    text-align: center;
    margin-top: 20px;
    font-size: 11px;
    color: #A0AABB;
}

.login-hint code {
    background: #EEF2F7;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: Consolas, monospace;
    color: #4A6FA5;
}
.login-footer-link {
    margin-top: 10px;
    text-align: center;
    font-size: 12px;
    color: #7A8AAA;
}
.login-footer-link a {
    color: #4A6FA5;
    text-decoration: none;
    font-weight: 500;
}
.login-footer-link a:hover {
    text-decoration: underline;
}
}

.user-display {
    color: var(--text-secondary);
    font-size: 12px;
    padding: 3px 10px;
    background: var(--surface-2);
    border-radius: 20px;
    border: 1px solid var(--border);
}

/* ---- Misc ---- */
.batch-tag {
    display: inline-block;
    background: var(--primary-bg);
    color: var(--primary);
    font-size: 10px;
    padding: 1px 7px;
    border-radius: 10px;
    font-weight: 600;
}

.log-cell {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
    color: var(--text-muted);
}

/* ---- Balance List ---- */
.balance-list { display: flex; flex-direction: column; }
.balance-item {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-light);
    gap: 12px;
}
.balance-item:last-child { border-bottom: none; }
.balance-item:hover { background: var(--primary-bg); }
.balance-item-main { flex: 1; }
.balance-item-name { font-weight: 600; font-size: 13px; margin-bottom: 3px; }
.balance-item-stats { display: flex; gap: 20px; }
.balance-stat { font-size: 12px; }
.balance-stat-label { color: var(--text-muted); }
.balance-stat-val { font-weight: 600; margin-left: 4px; }
.balance-stat-val.pos { color: var(--success); }
.balance-stat-val.neg { color: var(--danger); }
.balance-item-actions { flex-shrink: 0; }

/* ---- Media Page ---- */
.media-stats-bar {
    display: flex;
    gap: 0;
    margin-bottom: 14px;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border);
    overflow: hidden;
}

.media-stat-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 14px 8px;
    border-right: 1px solid var(--border-light);
}
.media-stat-item:last-child { border-right: none; }

.media-stat-num { font-size: 22px; font-weight: 700; background: linear-gradient(135deg, var(--primary), var(--primary-dark)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; line-height: 1.2; }
.media-stat-label { font-size: 10px; color: var(--text-muted); margin-top: 2px; }

.media-thumb-wrap {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-2);
    flex-shrink: 0;
    border: 1px solid var(--border-light);
}
.media-thumb { width: 100%; height: 100%; object-fit: cover; }
.media-video-thumb { cursor: pointer; }

.media-preview-area {
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 180px;
    border: 1px solid var(--border-light);
}
.media-full-img { max-width: 100%; max-height: 360px; border-radius: var(--radius-sm); }
.media-full-video { max-width: 100%; max-height: 360px; border-radius: var(--radius-sm); }

.media-student-info {
    background: var(--surface-2);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    font-size: 12px;
    border: 1px solid var(--border-light);
}
.media-preview-thumb {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    margin-top: 8px;
}
.media-preview-img { max-width: 72px; max-height: 54px; border-radius: 4px; object-fit: cover; }

/* ---- Billing Page ---- */
.billing-summary-row {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}
.billing-card {
    flex: 1;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border);
}
.billing-card-title {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 500;
}
.billing-card-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}
.billing-card-desc {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ---- Chart Styles ---- */
.chart-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 20px;
}
.chart-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border);
    flex: 1 1 300px;
    transition: box-shadow 0.2s ease;
}
.chart-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}
.chart-card .chart-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.notice-panel {
    margin-bottom: 20px;
}

.notice-list {
    height: 88px;
    overflow: hidden;
}

.notice-item {
    height: 100%;
    overflow: auto;
    padding: 8px 2px;
    animation: notice-slide-in 0.35s ease-out;
}

@keyframes notice-slide-in {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    .notice-item { animation: none; }
}

.notice-item-title {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
    font-weight: 600;
    color: var(--text-primary);
}

.notice-item-time {
    flex: 0 0 auto;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 400;
}

.notice-item-content {
    margin-top: 6px;
    color: var(--text-secondary);
    white-space: pre-wrap;
    line-height: 1.55;
    font-size: 13px;
}

.notice-counter {
    float: right;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 400;
}

.overview-task-section {
    margin-bottom: 20px;
    border-color: #93c5fd;
    box-shadow: 0 6px 18px rgba(37, 99, 235, 0.10);
}

.overview-task-section .chart-title {
    color: #1d4ed8;
    border-bottom-color: #bfdbfe;
}

.overview-task-section .task-card {
    border-left: 4px solid #3b82f6;
    background: #f8fbff;
}

.overview-section {
    margin-top: 20px;
}
.dashboard-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}
.kpi-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow-card);
}
.kpi-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.kpi-info {
    min-width: 0;
}
.kpi-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}
.kpi-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}
.chart-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-light);
}

.billing-settings-preview {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border);
}
.billing-settings-preview h3 {
      font-size: 13px;
      margin-bottom: 12px;
      color: var(--text);
  }
  .credit-stats-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 12px;
      margin: 0 0 18px;
  }
  .credit-stat-group {
      min-width: 0;
      overflow: hidden;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      box-shadow: var(--shadow-sm);
  }
  .credit-stat-group h4 {
      margin: 0;
      padding: 10px 12px;
      background: var(--surface-2);
      border-bottom: 1px solid var(--border);
      color: var(--text);
      font-size: 13px;
  }
  .credit-stat-group .table-container {
      border: 0;
      border-radius: 0;
      box-shadow: none;
  }
  .credit-stat-group .data-table th,
  .credit-stat-group .data-table td {
      padding: 8px 10px;
  }
  .credit-chart-box {
      width: 100%;
      height: 320px;
  }
  .credit-pagination {
      display: flex;
      flex-wrap: wrap;
      justify-content: center;
      align-items: center;
      gap: 6px;
      margin: 10px 0 18px;
  }
  .credit-pagination span {
      margin: 0 8px;
      font-size: 13px;
      color: var(--text);
  }
  @media (max-width: 900px) {
      .credit-stats-grid { grid-template-columns: 1fr; }
  }
#tab-billing .table-container,
#tab-balance .table-container {
    flex: 0 0 auto;
    min-height: 64px;
}
#orgCreditRechargeRows,
#orgCreditTxRows {
    display: table-row-group !important;
    visibility: visible !important;
}
#orgCreditRechargeRows > tr,
#orgCreditTxRows > tr {
    display: table-row !important;
    visibility: visible !important;
    opacity: 1 !important;
}
.billing-rules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
}
.billing-rule-item {
    background: var(--surface-2);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    text-align: center;
}
.billing-rule-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 4px;
}
.billing-rule-value {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}
.billing-rule-value.disabled {
    color: var(--text-muted);
}

.billing-records-section {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border);
}
.billing-records-section h3 {
    font-size: 13px;
    margin-bottom: 12px;
    color: var(--text);
}

/* Billing Settings Modal */
.billing-type-selector {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
}
.billing-type-option {
    flex: 1;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}
.billing-type-option:hover {
    border-color: var(--primary-light);
    background: var(--primary-bg);
}
.billing-type-option.active {
    border-color: var(--primary);
    background: var(--primary-bg);
}
.billing-type-icon {
    margin-bottom: 8px;
    color: var(--primary);
}
.billing-type-name {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text);
}
.billing-type-desc {
    font-size: 11px;
    color: var(--text-muted);
}
.billing-settings-section {
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    padding: 16px;
    border: 1px solid var(--border-light);
}
.billing-hint {
    margin-top: 10px;
    padding: 8px 12px;
    background: var(--info-bg);
    border-radius: var(--radius-sm);
    font-size: 11px;
    color: var(--info);
}
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
}
.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* ---- Student Filter Bar ---- */
.filter-bar {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    flex-shrink: 0;
}

.filter-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.filter-group label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

.filter-group .input,
.filter-group .select {
    width: auto;
    min-width: 120px;
    padding: 5px 10px;
    font-size: 12px;
}

.filter-group .select {
    min-width: 110px;
}

.filter-group input[type="date"] {
    width: 130px;
}

/* ---- Select (dropdown) style ---- */
select.input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}

/* ---- Table Loading Spinner ---- */
.table-spinner-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 24px 0;
    color: var(--text-muted);
    font-size: 13px;
    gap: 8px;
}
.table-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    flex-shrink: 0;
}
.btn-spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid rgba(255,255,255,0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    vertical-align: middle;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ---- Login Error State ---- */
.login-error {
    color: var(--danger) !important;
    font-weight: 600;
    cursor: not-allowed;
}

/* ---- Table Loading Overlay ---- */
.table-loading-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(232, 238, 244, 0.92);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 14px;
    z-index: 10;
    border-radius: 8px;
}
.table-loading-overlay .table-spinner {
    width: 36px;
    height: 36px;
    border-width: 3px;
    border-color: var(--border);
    border-top-color: var(--primary);
}
.table-loading-overlay .loading-text {
    color: var(--text-secondary);
    font-size: 14px;
    letter-spacing: 0.5px;
}
.table-container {
    position: relative;
}

/* ---- Full-screen Modal Loading Overlay (e.g. during batch import) ---- */
.global-loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: none;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    gap: 18px;
    z-index: 99999;
    backdrop-filter: blur(2px);
}
.global-loading-overlay.active {
    display: flex;
}
.global-loading-overlay .loading-spinner {
    width: 56px;
    height: 56px;
    border: 5px solid rgba(255, 255, 255, 0.25);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
.global-loading-overlay .loading-text {
    color: #fff;
    font-size: 16px;
    letter-spacing: 1px;
    font-weight: 500;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}
.global-loading-overlay .loading-subtext {
    color: rgba(255, 255, 255, 0.75);
    font-size: 13px;
    margin-top: -8px;
}

/* ---- Institution Portal Styles ---- */
.org-badge {
    display: inline-block;
    padding: 3px 10px;
    background: var(--primary-bg);
    color: var(--primary);
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    margin-left: 10px;
    border: 1px solid var(--border);
}

.form-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    max-width: 480px;
}

.org-account-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(320px, 420px);
    gap: 18px;
    align-items: start;
}

.account-info-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow-card);
}

.account-profile-head {
    display: flex;
    align-items: center;
    gap: 14px;
    padding-bottom: 18px;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--border-light);
}

.account-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--primary-bg);
    color: var(--primary-dark);
    font-size: 22px;
    font-weight: 700;
}

.account-profile-head h3 {
    font-size: 18px;
    line-height: 1.3;
    color: var(--text);
}

.account-profile-head p,
.account-panel-title p {
    color: var(--text-secondary);
    font-size: 12px;
    margin-top: 3px;
}

.account-info-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.account-info-item {
    padding: 12px;
    background: var(--surface-2);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
}

.account-info-wide {
    grid-column: 1 / -1;
}

.account-info-item span {
    display: block;
    color: var(--text-secondary);
    font-size: 12px;
    margin-bottom: 5px;
}

.account-info-item strong {
    display: block;
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.org-password-card {
    max-width: none;
    box-shadow: var(--shadow-card);
}

.account-panel-title {
    margin-bottom: 18px;
}

.account-panel-title h3 {
    font-size: 16px;
    color: var(--text);
}

.org-password-btn {
    width: 100%;
    justify-content: center;
    margin-top: 4px;
}

.catalog-course {
    margin-bottom: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.catalog-course-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border-light);
    font-size: 13px;
    font-weight: 500;
}

.catalog-course-name {
    color: var(--text);
    flex: 1;
}

.catalog-progress {
    color: var(--text-secondary);
    font-size: 12px;
    white-space: nowrap;
    margin-left: 12px;
}

.catalog-video {
    display: flex;
    align-items: center;
    padding: 5px 12px;
    font-size: 12px;
    border-bottom: 1px solid var(--border-light);
}

.catalog-video:last-child {
    border-bottom: none;
}

.catalog-video-icon {
    width: 20px;
    flex-shrink: 0;
}

.catalog-video-name {
    flex: 1;
    color: var(--text);
}

.catalog-video-progress {
    color: var(--text-secondary);
    margin-left: 8px;
    min-width: 36px;
    text-align: right;
}

.catalog-video-done {
    background: var(--completed-bg);
}

.catalog-video-done .catalog-video-icon {
    color: var(--completed);
}

.catalog-video-done .catalog-video-progress {
    color: var(--completed);
}

.catalog-video-pending {
    background: transparent;
}

.catalog-video-pending .catalog-video-icon {
    color: var(--text-muted);
}

.task-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.task-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    cursor: pointer;
    transition: box-shadow 0.2s, border-color 0.2s;
}

.task-card:hover {
    box-shadow: 0 4px 16px rgba(74, 111, 165, 0.12);
    border-color: var(--primary-light);
}

.task-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.task-card-header h4 {
    margin: 0;
    font-size: 15px;
    color: var(--text);
    font-weight: 600;
}

.task-status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
}
.task-status-badges {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 4px;
}
.task-status-badge.status-waiting-start {
    background: #fef3c7;
    color: #92400e;
}

.status-running { background: var(--completed-bg); color: var(--completed); }
.status-stopped { background: var(--warning-bg); color: var(--warning); }
.status-idle { background: var(--surface-2); color: var(--text-secondary); }

.task-card-body {
    display: flex;
    gap: 12px;
}

.task-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    padding: 8px;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
}

.task-stat-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.task-stat-value {
    font-size: 16px;
    font-weight: 600;
    color: var(--primary);
}

.task-detail-header {
    padding: 12px 16px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
}

.task-detail-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 24px;
    font-size: 13px;
    color: var(--text);
}

.task-detail-row span {
    white-space: nowrap;
}

/* ---- Toast Card Notification ---- */
#toast-card {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 99999;
    min-width: 280px;
    max-width: 420px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.15);
    padding: 16px 20px;
    display: none;
    font-family: 'Segoe UI', 'PingFang SC', sans-serif;
}
#toast-card.show { display: block; animation: slideIn 0.25s ease; }
#toast-card.hide { animation: slideOut 0.3s ease forwards; }
@keyframes slideIn {
    from { transform: translateX(120%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes slideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(120%); opacity: 0; }
}
.toast-title {
    font-size: 14px;
    font-weight: 600;
    color: #222;
    margin-bottom: 8px;
}
.toast-body { font-size: 13px; color: #555; line-height: 1.6; }
.toast-stats {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}
.toast-stat {
    background: #f0f4ff;
    border-radius: 6px;
    padding: 6px 14px;
    font-size: 13px;
    color: #333;
    font-weight: 500;
}
.toast-stat strong { color: #1a73e8; margin-right: 4px; }
.toast-stat.success { background: #e6f4ea; }
.toast-stat.success strong { color: #1e8e3e; }
.toast-stat.error { background: #fce8e6; }
.toast-stat.error strong { color: #d93025; }

/* ---- System Settings Tab ---- */
.settings-card {
    background: #fff;
    border-radius: 10px;
    border: 1px solid #e4eaf4;
    overflow: hidden;
    max-width: 800px;
}

.settings-card-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 22px;
    background: var(--primary-bg);
    border-bottom: 1px solid #dce6f5;
}

.settings-card-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.settings-card-header h3 {
    margin: 0 0 4px;
    font-size: 16px;
    color: var(--primary-dark);
}

.settings-card-header p {
    margin: 0;
    font-size: 13px;
    color: #666;
}

.settings-card-body {
    padding: 20px 22px;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.settings-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid #f0f4fa;
}

.settings-toggle-row:last-child {
    border-bottom: none;
}

.settings-toggle-info {
    flex: 1;
}

.toggle-label {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    cursor: pointer;
}

.toggle-desc {
    display: block;
    font-size: 12px;
    color: #888;
    margin-top: 2px;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 42px;
    height: 24px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #ccc;
    transition: 0.25s;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.25s;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--primary);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(18px);
}

/* Inline type switches in settings */
.type-switches-row {
    gap: 24px !important;
    flex-wrap: nowrap !important;
    align-items: center;
}
.type-switches-label {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    flex-shrink: 0;
}
.type-switch-item {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}
.type-toggle {
    width: 42px !important;
    height: 24px !important;
    flex-shrink: 0;
    display: inline-block !important;
    position: relative !important;
}
.type-switch-text {
    font-size: 13px;
    white-space: nowrap;
    user-select: none;
}

.settings-divider {
    height: 1px;
    background: #e4eaf4;
    margin: 8px 0;
}

.settings-section-title {
    font-size: 13px;
    font-weight: 600;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 12px 0 4px;
}

.settings-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 10px 0;
}

#tab-settings .form-group {
    padding: 8px 0;
}

#tab-settings textarea.input {
    resize: vertical;
    font-family: monospace;
    font-size: 13px;
}

/* ---- Settings Accordion ---- */
.settings-accordion {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 800px;
}

.settings-section {
    background: #fff;
    border-radius: 10px;
    border: 1px solid #e4eaf4;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s;
}

.settings-section:hover {
    box-shadow: var(--shadow);
}

.settings-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}

.settings-section-header:hover {
    background: #f8fafc;
}

.settings-section-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.settings-section-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.settings-section-left h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 3px;
}

.settings-section-left p {
    font-size: 12px;
    color: #888;
    margin: 0;
}

.settings-section-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.settings-section-status {
    font-size: 12px;
    font-weight: 500;
    padding: 3px 10px;
    border-radius: 20px;
    background: #f0f0f0;
    color: #888;
}

.settings-section-status.active {
    background: #e6f4ea;
    color: #1e8e3e;
}

.settings-section-arrow {
    color: #bbb;
    display: flex;
    align-items: center;
    transition: transform 0.2s;
}

.settings-section.open .settings-section-arrow {
    transform: rotate(180deg);
}

.settings-section.open .settings-section-arrow svg {
    stroke: var(--primary);
}

.settings-section-body {
    border-top: 1px solid #e4eaf4;
    padding: 20px 22px;
    display: flex;
    flex-direction: column;
}

.settings-action-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    padding: 10px 0;
}

.settings-checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    padding: 8px 0;
}

.settings-checkbox-item {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 13px;
    color: #555;
}

/* Scheduler refresh stats box */
.scheduler-stats-box {
    background: #f4f7fb;
    border: 1px solid #dde3ed;
    border-radius: 8px;
    padding: 14px 16px;
    margin: 8px 0;
}

.scheduler-stats-title {
    font-size: 13px;
    font-weight: 600;
    color: #2d3a4a;
    margin-bottom: 12px;
}

.scheduler-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

@media (max-width: 768px) {
    .scheduler-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.stat-item {
    text-align: center;
}

.stat-label {
    font-size: 11px;
    color: #6b7a90;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 14px;
    font-weight: 600;
    color: #2d3a4a;
}

.stat-value.text-success { color: #4caf82; }
.stat-value.text-danger { color: #d44d4d; }
.stat-value.text-muted { color: #9aaabd; }

/* Data Health Dashboard */
.data-health-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

@media (max-width: 768px) {
    .data-health-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.data-health-card {
    background: #f4f7fb;
    border: 1px solid #dde3ed;
    border-radius: 8px;
    padding: 14px;
    text-align: center;
    border-left: 3px solid transparent;
}

.data-health-card.card-trusted { border-left-color: #4caf82; background: #f0faf5; }
.data-health-card.card-stale { border-left-color: #d4930d; background: #fef8e8; }
.data-health-card.card-danger { border-left-color: #d44d4d; background: #fef0f0; }
.data-health-card.card-info { border-left-color: #6c63ff; background: #f0effe; }

.data-health-label {
    font-size: 11px;
    color: #6b7a90;
    margin-bottom: 6px;
    font-weight: 500;
}

.data-health-value {
    font-size: 22px;
    font-weight: 700;
    color: #2d3a4a;
    line-height: 1.2;
}

.data-health-sub {
    font-size: 10px;
    color: #9aaabd;
    margin-top: 2px;
}

/* Task management */
.task-worker-bar {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 10px 14px;
    margin-bottom: 10px;
    background: #f6f9fc;
    border: 1px solid #dde6f0;
    border-radius: 8px;
    color: #3d4c5f;
    font-size: 13px;
}

.task-worker-bar .btn {
    margin-left: auto;
}

.task-list-item .batch-tag {
    margin-left: 8px;
}

.task-list-item {
    gap: 18px;
}

.task-list-item .list-item-main {
    min-width: 320px;
}

.task-list-actions {
    width: 370px;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.task-action-group {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px;
    border: 1px solid var(--border-light);
    border-radius: 7px;
    background: var(--surface);
}

.task-action-run {
    background: #f8fafc;
}

.task-action-danger {
    border-color: #f2c7c7;
    background: #fff8f8;
}

.task-action-group .btn {
    min-width: 44px;
}

@media (max-width: 1280px) {
    .task-list-actions {
        width: 100%;
        justify-content: flex-start;
    }
}

.task-student-pagination {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 10px 0 2px;
    color: #6b7a90;
    font-size: 12px;
}

/* Enrollment queue modal */
.queue-modal { max-width: 1240px; }

.queue-modal-body {
    padding: 18px 22px;
    overflow: auto;
    max-height: 74vh;
    background: #f8fafc;
}

.queue-modal-footer {
    gap: 8px;
    flex-wrap: wrap;
}

.queue-stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 14px;
}

.queue-stat-card {
    min-height: 86px;
    padding: 14px 16px;
    border: 1px solid var(--border-light);
    border-left: 4px solid var(--primary);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.queue-stat-card span {
    display: block;
    color: var(--text-secondary);
    font-size: 12px;
    margin-bottom: 8px;
}

.queue-stat-card strong {
    color: var(--text);
    font-size: 26px;
    line-height: 1;
}

.queue-stat-card.accent-worker { border-left-color: var(--success); }
.queue-stat-card.accent-total { border-left-color: var(--primary); }
.queue-stat-card.accent-active { border-left-color: var(--warning); }
.queue-stat-card.accent-redis { border-left-color: var(--info); }
.queue-stat-card.accent-success { border-left-color: var(--success); }
.queue-stat-card.accent-warning { border-left-color: var(--warning); }
.queue-stat-card.accent-danger { border-left-color: var(--danger); }
.queue-stat-card.accent-muted { border-left-color: var(--text-muted); }

.queue-note {
    margin: 0 0 14px;
    padding: 10px 12px;
    border: 1px solid #d8e5f4;
    border-radius: 8px;
    background: #f2f7fd;
    color: var(--primary-dark);
    font-weight: 600;
}
.queue-note.is-warning {
    border-color: #fed7aa;
    background: #fff7ed;
    color: #9a3412;
}

.queue-section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 16px 0 8px;
    color: var(--text);
    font-size: 15px;
    font-weight: 700;
}

.queue-section-title::after {
    content: "";
    height: 1px;
    flex: 1;
    background: var(--border-light);
}

.queue-table-card {
    border-radius: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.queue-table-card .data-table {
    min-width: 900px;
    table-layout: fixed;
}
.queue-table-card .queue-worker-table { min-width: 1040px; }
.queue-table-card .queue-redis-table { min-width: 920px; }

.queue-table-card .data-table th,
.queue-table-card .data-table td {
    box-sizing: border-box;
}

.queue-table-card .data-table th {
    background: #eef3f9;
    color: #65758b;
    font-size: 12px;
    letter-spacing: 0;
}

.queue-table-card .data-table td {
    height: 48px;
    vertical-align: middle;
    overflow-wrap: anywhere;
}

.queue-table-card .num,
.queue-mini-table td:last-child {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.queue-worker-table .queue-col-worker { width: 28%; }
.queue-worker-table .queue-col-status { width: 72px; }
.queue-worker-table .queue-col-queues { width: 21%; }
.queue-worker-table .queue-col-num { width: 68px; }
.queue-worker-table .queue-col-heartbeat { width: 76px; }

.queue-redis-table .queue-col-name { width: 260px; }
.queue-redis-table .queue-col-length { width: 88px; }
.queue-redis-table .queue-col-summary { width: auto; }

.queue-num-alert {
    color: var(--danger) !important;
    font-weight: 700;
}

.queue-worker-table td:first-child,
.queue-redis-table td:first-child strong,
.queue-redis-table td:first-child .queue-muted {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.queue-muted {
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 12px;
}

.queue-status-badge,
.queue-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    height: 24px;
    padding: 0 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.queue-status-badge.online {
    background: var(--success-bg);
    color: var(--completed);
}

.queue-status-badge.offline {
    background: var(--danger-bg);
    color: var(--danger);
}

.queue-count {
    background: var(--surface-2);
    color: var(--text-secondary);
}

.queue-count.hot {
    background: var(--warning-bg);
    color: var(--warning);
}

.queue-detail-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-top: 14px;
    align-items: start;
}
.queue-detail-grid-wide {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}
.queue-detail-card-wide {
    grid-column: 1 / -1;
    min-width: 0;
}
.queue-audit-time {
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 500;
}
.queue-audit-table {
    min-width: 980px;
}
.queue-audit-table td {
    height: 46px;
}
.queue-audit-table .empty-state {
    padding: 20px 12px;
}

.queue-detail-card {
    padding: 12px 14px;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.queue-detail-card h4 {
    margin: 0 0 8px;
    color: var(--text);
    font-size: 14px;
}

.queue-mini-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
}

.queue-mini-table td {
    padding: 9px 0;
    border-top: 1px solid var(--border-light);
    color: var(--text-secondary);
}

.queue-mini-table tr:first-child td { border-top: 0; }
.queue-mini-table td:last-child { color: var(--text); font-weight: 700; }

@media (max-width: 900px) {
    .queue-stat-grid,
    .queue-detail-grid {
        grid-template-columns: 1fr;
    }
}

/* ---- Enterprise UI Refresh (admin + org) ---- */
:root {
    --primary: #1677ff;
    --primary-light: #4096ff;
    --primary-dark: #0958d9;
    --primary-bg: #e6f4ff;
    --primary-hover-bg: #f0f7ff;
    --success: #16a34a;
    --success-bg: #f0fdf4;
    --completed: #15803d;
    --completed-bg: #dcfce7;
    --warning: #d97706;
    --warning-bg: #fff7ed;
    --danger: #dc2626;
    --danger-bg: #fef2f2;
    --info: #4f46e5;
    --info-bg: #eef2ff;
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --border: #e5e7eb;
    --border-light: #eef2f7;
    --text: #111827;
    --text-secondary: #4b5563;
    --text-muted: #94a3b8;
    --radius: 8px;
    --radius-sm: 6px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04);
    --shadow: 0 8px 24px rgba(16, 24, 40, 0.06);
    --shadow-lg: 0 18px 48px rgba(16, 24, 40, 0.14);
    --shadow-card: 0 1px 2px rgba(16, 24, 40, 0.04);
}

html,
body {
    background: var(--bg);
    color: var(--text);
    font-size: 13px;
}

.app-container {
    background: var(--bg);
}

.header {
    height: 56px;
    padding: 0 24px;
    border-bottom: 1px solid var(--border);
    box-shadow: none;
}

.header::before {
    display: none;
}

.header-brand .brand-icon,
.login-header .logo-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: #1f2937;
    box-shadow: none;
}

.header-brand h1 {
    font-size: 15px;
    font-weight: 700;
    color: #0f172a;
}

.org-badge,
.worker-count,
.status-indicator {
    height: 28px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text-secondary);
}

.header-actions {
    gap: 8px;
}

.nav-tabs {
    height: 48px;
    padding: 0 24px;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 0 rgba(16, 24, 40, 0.02);
    overflow-x: auto;
}

.tab-btn {
    height: 48px;
    padding: 0 14px;
    border-bottom-width: 2px;
    color: #475569;
}

.tab-btn:hover {
    color: var(--primary);
    background: var(--primary-hover-bg);
}

.tab-btn.active {
    color: var(--primary);
    background: transparent;
}

.tab-panel {
    padding: 20px 24px;
}

.panel-header {
    min-height: 36px;
    margin-bottom: 14px;
}

.panel-header h2 {
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
}

.header-toolbar,
.list-item-actions,
.modal-footer,
.queue-modal-footer {
    gap: 8px;
}

.btn {
    height: 32px;
    padding: 0 12px;
    border-radius: 6px;
    font-weight: 600;
    box-shadow: none !important;
}

.btn-sm {
    height: 28px;
    padding: 0 10px;
    font-size: 12px;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-secondary {
    background: #fff;
    color: #334155;
    border-color: #dbe3ef;
}

.btn-secondary:hover {
    color: var(--primary);
    border-color: #91caff;
    background: #f8fbff;
}

.btn-success,
.btn-warning,
.btn-danger,
.btn-info {
    border-color: transparent;
}

.data-list,
.table-container,
.filter-bar,
.chart-card,
.kpi-card,
.billing-card,
.settings-card,
.account-info-card,
.org-password-card,
.queue-table-card,
.queue-detail-card,
.queue-stat-card,
.form-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow-card);
    background: var(--surface);
}

.data-list {
    overflow: auto;
}

.list-item {
    min-height: 66px;
    padding: 14px 16px;
    gap: 16px;
    border-bottom-color: var(--border-light);
}

.list-item:hover {
    background: #fafcff;
}

.list-item-title {
    margin-bottom: 4px;
    font-size: 14px;
    color: #0f172a;
}

.list-item-meta {
    color: #64748b;
}

.list-stat {
    min-width: 66px;
    align-items: flex-start;
}

.list-stat-value {
    font-variant-numeric: tabular-nums;
    font-size: 15px;
    color: #0f172a;
}

.list-stat-label {
    margin-top: 2px;
    color: #94a3b8;
}

.data-table {
    font-size: 13px;
}

.data-table thead {
    background: #f8fafc;
}

.data-table th {
    height: 42px;
    padding: 0 14px;
    color: #64748b;
    font-size: 12px;
    letter-spacing: 0;
    text-transform: none;
}

.data-table td {
    height: 44px;
    padding: 9px 14px;
}

.data-table tbody tr:hover {
    background: #f8fbff;
}

.input,
.select,
.textarea,
select.input,
textarea.input {
    border-color: #dbe3ef;
    border-radius: 6px;
    background-color: #fff;
    color: var(--text);
    box-shadow: none;
}

.input:focus,
.select:focus,
.textarea:focus,
select.input:focus,
textarea.input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(22, 119, 255, 0.12);
    outline: none;
}

.filter-bar {
    padding: 14px 16px;
    margin-bottom: 14px;
}

.filter-row {
    gap: 12px;
}

.filter-group label {
    color: #64748b;
}

.status-pill,
.phase-info,
.badge,
.batch-tag,
.queue-status-badge,
.queue-count {
    border-radius: 999px;
    font-weight: 700;
}

.modal {
    background: rgba(15, 23, 42, 0.42);
    backdrop-filter: blur(2px);
}

.modal-dialog {
    border-radius: 10px;
    border: 1px solid rgba(226, 232, 240, 0.9);
    box-shadow: var(--shadow-lg);
}

.modal-header {
    min-height: 52px;
    padding: 0 20px;
    border-bottom-color: var(--border);
}

.modal-header h3 {
    font-size: 16px;
}

.modal-body {
    padding: 18px 20px;
}

.modal-footer {
    padding: 12px 20px;
    border-top-color: var(--border);
    background: #f8fafc;
}

.modal-close {
    border-radius: 6px;
}

.dashboard-kpi-grid,
.billing-summary-row {
    gap: 14px !important;
}

.kpi-card,
.billing-card {
    min-height: 104px;
    padding: 18px;
}

.kpi-icon {
    border-radius: 8px;
}

.kpi-value,
.billing-card-value,
.queue-stat-card strong {
    font-variant-numeric: tabular-nums;
    color: #0f172a;
}

.chart-card {
    padding: 18px;
}

.chart-card:hover {
    transform: none;
    box-shadow: var(--shadow);
}

.chart-card .chart-title {
    color: #0f172a;
    font-size: 15px;
}

.login-wrap {
    background:
        radial-gradient(circle at 20% 10%, rgba(22, 119, 255, 0.10), transparent 28%),
        linear-gradient(180deg, #f8fafc 0%, #eef4ff 100%);
}

.login-card {
    border-radius: 12px;
    border: 1px solid rgba(226, 232, 240, 0.9);
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.12);
}

.task-worker-bar {
    min-height: 44px;
    padding: 8px 12px;
    border-color: var(--border);
    border-radius: 8px;
    background: #fff;
    box-shadow: var(--shadow-card);
}

.task-worker-bar > div {
    color: #475569;
}

.task-worker-bar strong {
    color: #0f172a;
}

.task-list-item {
    align-items: center;
    gap: 18px;
}

.task-list-item .list-item-main {
    min-width: 260px;
}

.task-list-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(64px, 86px));
    gap: 10px;
    flex-shrink: 0;
}

.task-list-actions {
    width: 390px;
    gap: 6px;
}

.task-action-group {
    height: 34px;
    padding: 2px;
    border-color: #e2e8f0;
    border-radius: 7px;
    background: #f8fafc;
}

.task-action-run {
    background: #f0fdf4;
    border-color: #bbf7d0;
}

.task-action-danger {
    background: #fef2f2;
    border-color: #fecaca;
}

.task-action-group .btn {
    height: 28px;
    min-width: 48px;
}

.queue-modal-body {
    background: #f5f7fb;
}

.queue-stat-grid,
.queue-detail-grid {
    gap: 14px;
}

.queue-stat-card {
    border-left-width: 3px;
}

.queue-table-card .data-table th {
    background: #f8fafc;
}

@media (max-width: 1280px) {
    .task-list-item {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .task-list-stats {
        order: 2;
        width: 100%;
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .task-list-actions {
        order: 3;
        width: 100%;
        justify-content: flex-start;
    }
}

@media (max-width: 760px) {
    .header,
    .nav-tabs {
        padding-left: 14px;
        padding-right: 14px;
    }

    .tab-panel {
        padding: 14px;
    }

    .panel-header,
    .header-toolbar {
        align-items: flex-start;
        flex-wrap: wrap;
        gap: 10px;
    }

    .task-list-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* Enrollment detail: keep identity, progress and actions scannable. */
.enr-stat-card {
    text-align: left;
    border: 1px solid var(--border-light);
}
.enr-stat-card.is-completed { border-color: #bbf7d0; background: #f0fdf4; }
.enr-stat-card.is-running { border-color: #bfdbfe; background: #eff6ff; }
.enr-stat-card.is-pending-review { border-color: #fde68a; background: #fffbeb; }
.enr-stat-card.is-failed { border-color: #fecaca; background: #fef2f2; }
.enr-stat-card.is-completed .enr-stat-value { color: var(--success); }
.enr-stat-card.is-running .enr-stat-value { color: var(--primary); }
.enr-stat-card.is-pending-review .enr-stat-value { color: #b45309; }
.enr-stat-card.is-failed .enr-stat-value { color: var(--danger); }
.enr-stat-note { margin-top: 3px; color: var(--text-secondary); font-size: 11px; }
.enr-student-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border-light);
    border-radius: 8px;
}
.enr-student-table { min-width: 920px; font-size: 13px; }
.enr-student-table th { white-space: nowrap; }
.enr-student-table th:nth-child(1) { width: 17%; }
.enr-student-table th:nth-child(2) { width: 19%; }
.enr-student-table th:nth-child(3) { width: 28%; }
.enr-student-table th:nth-child(4) { width: 18%; }
.enr-student-table th:nth-child(5) { width: 18%; }
.enr-student-name { font-weight: 600; color: var(--text); }
.enr-student-sub { margin-top: 3px; color: var(--text-secondary); font-size: 11px; }
.enr-progress-head { display: flex; align-items: baseline; gap: 4px; min-height: 20px; }
.enr-progress-track { height: 5px; margin: 7px 0 6px; overflow: hidden; background: var(--surface-2); border-radius: 999px; }
.enr-progress-track span { display: block; height: 100%; min-width: 0; background: var(--success); border-radius: inherit; transition: width .2s ease; }
.enr-progress-meta { display: flex; flex-wrap: wrap; gap: 4px; }
.enr-progress-tag { padding: 2px 6px; border-radius: 999px; background: var(--surface-2); color: var(--text-secondary); font-size: 10px; line-height: 1.3; white-space: nowrap; }
.enr-progress-tag.is-running { background: #dbeafe; color: #1d4ed8; }
.enr-progress-tag.is-failed { background: #fee2e2; color: #b91c1c; }
.enr-progress-tag.is-pending-review { background: #fef3c7; color: #92400e; }
.enr-student-status { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.enr-student-status.is-completed { background: #dcfce7; color: #166534; }
.enr-student-status.is-running { background: #dbeafe; color: #1d4ed8; }
.enr-student-status.is-waiting { background: #fef3c7; color: #92400e; }
.enr-student-status.is-pending_review { background: #fef3c7; color: #92400e; }
.enr-student-status.is-failed { background: #fee2e2; color: #b91c1c; }
.enr-student-status.is-cancelled { background: #e5e7eb; color: #4b5563; }
.enr-student-actions { display: flex; flex-wrap: nowrap; gap: 5px; }
.student-actions {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 6px;
    position: relative;
    white-space: nowrap;
}
.student-row-more .task-more-menu-popover {
    width: 164px;
}
.table-container:has(.student-row-more[open]) {
    overflow: visible;
}

@media (max-width: 760px) {
    .enr-stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .enr-stat-card { padding: 10px 12px; }
    .enr-stat-value { font-size: 18px; }
}

/* Task list */
#enrollmentList {
    display: grid;
    align-content: start;
    align-items: start;
    gap: 10px;
    padding: 0;
    overflow: visible;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}
#enrollmentList > .task-worker-bar {
    justify-self: start;
    align-self: start;
    width: fit-content;
    height: auto;
    max-width: 100%;
}
.task-worker-bar {
    display: flex;
    justify-content: flex-start;
    gap: 28px;
    min-height: 42px;
    margin: 0;
    padding: 8px 12px 8px 14px;
    box-shadow: none;
}
.task-worker-state,
.task-worker-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}
.task-worker-state > span:not(.task-worker-dot) { color: var(--text-secondary); }
.task-worker-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #94a3b8;
}
.task-worker-dot.is-online { background: var(--success); }
.enrollment-task-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 24px;
    align-items: center;
    padding: 16px 18px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow-card);
}
.enrollment-task-filter-bar { margin-bottom: 10px; }
.enrollment-task-filter-row { align-items: center; }
.enrollment-task-filter-row .filter-group { min-width: 150px; }
.enrollment-task-search {
    flex: 1 1 260px;
    max-width: 440px;
}
.enrollment-task-result-count {
    margin-left: auto;
    padding-bottom: 8px;
    color: var(--text-secondary);
    font-size: 12px;
}
.enrollment-task-daily-status {
    display: none;
    margin-bottom: 10px;
    padding: 9px 12px;
    border: 1px solid #dbeafe;
    border-radius: 8px;
    background: #f8fbff;
    color: #475569;
    font-size: 12px;
}
.enrollment-task-daily-status.is-visible { display: block; }
.enrollment-task-org-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.enrollment-task-org-group {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
}
.enrollment-task-org-header {
    width: 100%;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 13px 16px;
    border: 0;
    border-bottom: 1px solid var(--border);
    background: #f8fafc;
    color: var(--text);
    text-align: left;
    font: inherit;
    cursor: pointer;
}
.enrollment-task-org-header:hover { background: #f1f5f9; }
.enrollment-task-org-chevron {
    color: var(--text-muted);
    transition: transform 0.18s ease;
}
.enrollment-task-org-group.is-collapsed .enrollment-task-org-chevron {
    transform: rotate(-90deg);
}
.enrollment-task-org-group.is-collapsed .enrollment-task-org-header {
    border-bottom-color: transparent;
}
.enrollment-task-org-title {
    min-width: 0;
}
.enrollment-task-org-title strong {
    display: block;
    overflow: hidden;
    color: var(--text);
    font-size: 14px;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.enrollment-task-org-title small {
    color: var(--text-muted);
    font-size: 11px;
}
.enrollment-task-org-stats {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
}
.enrollment-task-org-stats span {
    padding: 3px 7px;
    border-radius: 999px;
    background: #fff;
    color: var(--text-secondary);
    font-size: 11px;
}
.enrollment-task-org-stats .is-running { color: #1d4ed8; }
.enrollment-task-org-stats .is-failed { color: var(--danger); }
.enrollment-task-org-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
}
.enrollment-task-org-group.is-collapsed .enrollment-task-org-body {
    display: none;
}
.task-card-matched-students {
    margin-top: 7px;
    color: #1d4ed8;
    font-size: 11px;
}
.enrollment-task-card:hover { border-color: #bfdbfe; }
.task-card-main { min-width: 0; }
.task-card-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.task-card-heading .list-item-title { min-width: 0; }
.task-card-status {
    flex: 0 0 auto;
    padding: 3px 8px;
    border-radius: 999px;
    background: var(--surface-2);
    font-size: 11px;
    font-weight: 600;
}
.task-card-statuses {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 6px;
}
.task-card-progress {
    height: 6px;
    margin: 12px 0 8px;
    overflow: hidden;
    border-radius: 999px;
    background: var(--surface-2);
}
.task-card-progress span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--success);
}
.task-card-summary {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 5px 12px;
    color: var(--text-secondary);
    font-size: 11px;
}
.task-card-summary strong { color: var(--text); font-size: 13px; }
.task-card-summary .is-running { color: #1d4ed8; }
.task-card-summary .is-failed { color: var(--danger); }
.task-card-summary .is-pending-review { color: #b45309; }
.task-card-status.status-warning { background: #fef3c7; color: #92400e; }
.task-card-status.status-waiting-start { background: #fef3c7; color: #92400e; }
.badge.badge-warning { background: #fef3c7; color: #92400e; }
.overview-task-more {
    display: flex;
    justify-content: center;
    padding-top: 12px;
}
.overview-task-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.overview-task-row {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-left: 4px solid #3b82f6;
    border-radius: 8px;
    background: #f8fbff;
    color: var(--text);
    text-align: left;
    font: inherit;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.overview-task-row:hover {
    border-color: #93c5fd;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.10);
}
.overview-task-row-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
}
.overview-task-row-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-muted);
    font-size: 12px;
    white-space: nowrap;
}
.overview-task-row-meta strong {
    margin-left: 2px;
    color: var(--text);
}
@media (max-width: 760px) {
    .enrollment-task-filter-row .filter-group,
    .enrollment-task-search {
        flex: 1 1 100%;
        max-width: none;
    }
    .enrollment-task-result-count {
        width: 100%;
        margin-left: 0;
        padding-bottom: 0;
    }
    .enrollment-task-org-header {
        grid-template-columns: auto minmax(0, 1fr);
    }
    .enrollment-task-org-stats {
        grid-column: 1 / -1;
        justify-content: flex-start;
    }
    .overview-task-row {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 8px 12px;
    }
    .overview-task-row-meta {
        grid-column: 1 / -1;
        grid-row: 2;
        justify-content: flex-start;
    }
}
.task-card-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 6px;
}
.task-daily-retry-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 12px;
    white-space: nowrap;
    cursor: pointer;
}
.task-daily-retry-toggle .toggle-switch {
    width: 36px;
    height: 20px;
}
.task-daily-retry-toggle .toggle-slider:before {
    width: 14px;
    height: 14px;
}
.task-daily-retry-toggle .toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(16px);
}
.task-daily-retry-toggle input:disabled + .toggle-slider {
    cursor: wait;
    opacity: 0.6;
}
.task-more-menu { position: relative; }
.task-more-menu > summary { list-style: none; cursor: pointer; }
.task-more-menu > summary::-webkit-details-marker { display: none; }
.task-more-menu-popover {
    position: absolute;
    z-index: 20;
    top: calc(100% + 6px);
    right: 0;
    width: 168px;
    padding: 5px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
}
.task-more-menu-popover::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: -7px;
    height: 7px;
}
.task-more-menu-popover button {
    display: block;
    width: 100%;
    padding: 8px 10px;
    border: 0;
    border-radius: 5px;
    background: transparent;
    color: var(--text);
    text-align: left;
    cursor: pointer;
}
.task-more-menu-popover button:hover { background: var(--surface-2); }
.task-more-menu-popover button.is-danger { color: var(--danger); }

.new-term-filter-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}
.new-term-picker {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 96px minmax(0, 1fr);
    gap: 10px;
    align-items: stretch;
}
.new-term-panel {
    display: flex;
    flex-direction: column;
    height: min(55vh, 520px);
    min-height: 340px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}
.new-term-panel-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}
.new-term-panel-actions {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}
.new-term-list {
    flex: 1;
    overflow: auto;
    padding: 8px;
}
.new-term-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px;
    border-bottom: 1px solid var(--border-light);
}
.new-term-item:last-child { border-bottom: none; }
.new-term-item-main { flex: 1; min-width: 0; }
.new-term-item-name { font-weight: 600; }
.new-term-item-meta {
    color: var(--text-muted);
    font-size: 12px;
    word-break: break-all;
}
.new-term-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
}
.new-term-arrow .btn { width: 100%; }
.new-term-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 14px;
    flex-wrap: wrap;
}
.new-term-credit-hint {
    color: var(--text-muted);
    font-size: 13px;
}
.new-term-empty {
    padding: 24px 8px;
    text-align: center;
    color: var(--text-muted);
}
.new-term-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 12px;
}
.new-term-pagination .btn {
    min-width: 68px;
}
@media (max-width: 900px) {
    .new-term-filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .new-term-picker { grid-template-columns: 1fr; }
    .new-term-arrow { transform: rotate(90deg); padding: 6px 0; }
}

.deadline-summary {
    display: grid;
    min-width: 172px;
    gap: 2px;
    font-size: 11px;
    line-height: 1.4;
}
.deadline-line {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    white-space: nowrap;
}
.deadline-line > span,
.deadline-empty { color: var(--text-muted); }
.deadline-line time { color: var(--text-secondary); font-variant-numeric: tabular-nums; }

.progress-with-deadline {
    display: grid;
    gap: 4px;
    min-width: 128px;
}
.progress-deadline {
    color: var(--text-muted);
    font-size: 10px;
    line-height: 1.2;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

@media (max-width: 760px) {
    .task-worker-bar,
    .enrollment-task-card { align-items: flex-start; }
    .task-worker-state { flex-wrap: wrap; gap: 6px 10px; }
    .enrollment-task-card { grid-template-columns: 1fr; gap: 12px; padding: 14px; }
    .task-card-actions { justify-content: flex-start; }
}

/* ---- Mobile platform layout ---- */
@media (max-width: 820px) {
    html,
    body {
        min-width: 0;
        overscroll-behavior-y: contain;
    }

    .app-container {
        height: 100dvh;
        min-height: 100dvh;
    }

    .header {
        height: auto;
        min-height: 0;
        padding: max(8px, env(safe-area-inset-top)) 12px 8px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .header-brand {
        width: 100%;
        min-width: 0;
    }

    .header-brand h1 {
        flex: 1;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .org-badge {
        max-width: 42%;
        margin-left: auto;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .header-actions {
        width: 100%;
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto auto;
        gap: 6px;
    }

    .header-actions .user-display {
        min-width: 0;
        display: flex;
        align-items: center;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .header-actions .status-indicator,
    .header-actions .worker-count {
        display: none;
    }

    .nav-tabs {
        height: 46px;
        padding: 0 8px;
        gap: 0;
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }

    .nav-tabs::-webkit-scrollbar {
        display: none;
    }

    .tab-btn {
        flex: 0 0 auto;
        min-width: max-content;
        height: 46px;
        padding: 0 13px;
        white-space: nowrap;
        word-break: keep-all;
    }

    .main-content,
    .tab-panel {
        min-width: 0;
        min-height: 0;
    }

    .tab-panel {
        padding: 12px;
        overscroll-behavior-y: contain;
    }

    .panel-header {
        width: 100%;
        min-height: 0;
        margin-bottom: 12px;
    }

    .panel-header.has-mobile-panel-tools {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        gap: 8px;
    }

    .panel-header.has-mobile-panel-tools > h2 {
        min-width: 0;
    }

    .mobile-panel-toggle,
    .mobile-filter-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 5px;
        min-height: 36px;
        border: 1px solid var(--border);
        border-radius: 6px;
        background: var(--surface);
        color: var(--text-secondary);
        font-size: 13px;
        font-weight: 600;
    }

    .mobile-panel-toggle svg,
    .mobile-filter-toggle svg {
        width: 14px;
        height: 14px;
        fill: none;
        stroke: currentColor;
        stroke-linecap: round;
        stroke-linejoin: round;
        stroke-width: 2;
        transition: transform 0.15s ease;
    }

    .mobile-panel-toggle[aria-expanded="false"] svg,
    .mobile-filter-toggle[aria-expanded="false"] svg {
        transform: rotate(-90deg);
    }

    .panel-header.has-mobile-panel-tools > .mobile-panel-tools {
        grid-column: 1 / -1;
        min-width: 0;
    }

    .panel-header.has-mobile-panel-tools > div.mobile-panel-tools {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 8px;
        width: 100%;
    }

    .panel-header.has-mobile-panel-tools > div.mobile-panel-tools .select,
    .panel-header.has-mobile-panel-tools > div.mobile-panel-tools .input {
        flex: 1 1 170px;
        min-width: 0;
    }

    .panel-header.mobile-tools-collapsed > .mobile-panel-tools {
        display: none !important;
    }

    .header-toolbar,
    .list-item-actions,
    .task-card-actions,
    .task-worker-actions {
        width: 100%;
        flex-wrap: wrap;
        justify-content: flex-start;
    }

    .btn,
    .btn-sm {
        height: auto;
        min-height: 36px;
        padding: 7px 12px;
    }

    .input,
    .select,
    .textarea,
    .login-form .input,
    select.input,
    textarea.input {
        min-height: 40px;
        font-size: 16px;
    }

    .form-row,
    .task-filter-row,
    .enrollment-filter-row,
    .billing-type-selector,
    .task-modal-layout {
        flex-direction: column;
    }

    .filter-bar {
        padding: 12px;
    }

    .filter-bar.has-mobile-filter-toggle {
        display: block;
    }

    .mobile-filter-toggle {
        width: 100%;
        justify-content: space-between;
        padding: 7px 10px;
        margin-bottom: 10px;
    }

    .filter-bar.mobile-filter-collapsed {
        padding: 10px 12px;
    }

    .filter-bar.mobile-filter-collapsed > :not(.mobile-filter-toggle) {
        display: none;
    }

    .filter-row {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: end;
        gap: 10px;
    }

    .filter-group {
        display: block;
        width: 100%;
        min-width: 0;
    }

    .filter-group label {
        display: block;
        margin-bottom: 4px;
    }

    .filter-group .input,
    .filter-group .select,
    .filter-group input[type="date"] {
        width: 100%;
        min-width: 0;
    }

    .filter-row > .btn {
        width: 100%;
        justify-content: center;
    }

    .dashboard-kpi-grid,
    .billing-summary-row,
    .billing-rules-grid {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .kpi-card,
    .billing-card {
        min-width: 0;
        min-height: 92px;
        padding: 12px;
    }

    .kpi-icon {
        width: 36px;
        height: 36px;
    }

    .billing-card-value {
        font-size: 22px;
        overflow-wrap: anywhere;
    }

    .chart-row {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) !important;
        gap: 12px !important;
    }

    .chart-card {
        width: 100%;
        min-width: 0 !important;
        padding: 14px;
    }

    .data-list,
    .table-container {
        width: 100%;
        min-width: 0;
        -webkit-overflow-scrolling: touch;
    }

    .table-container > .data-table {
        min-width: 560px;
    }

    /* Phone views retain the identity, status, and action columns first. */
    #studentTable,
    #mediaTable,
    #faceRecordsTable,
    #userTable,
    #creditTiersTable,
    #creditTransactionsTable,
    #creditRechargesTable,
    #orgStudentTable,
    #orgMediaTable,
    #orgFaceRecordsTable,
    #orgCreditTiersTable,
    #orgCreditRechargesTable,
    #orgCreditTransactionsTable,
    .enr-student-table,
    .queue-redis-table,
    #jobExceptionsBody .data-table {
        min-width: 0 !important;
        table-layout: fixed;
    }

    .credit-stat-group .data-table {
        min-width: 0 !important;
        table-layout: fixed;
    }

    #studentTable th,
    #studentTable td,
    #mediaTable th,
    #mediaTable td,
    #faceRecordsTable th,
    #faceRecordsTable td,
    #userTable th,
    #userTable td,
    #orgStudentTable th,
    #orgStudentTable td,
    #orgMediaTable th,
    #orgMediaTable td,
    #orgFaceRecordsTable th,
    #orgFaceRecordsTable td,
    .enr-student-table th,
    .enr-student-table td,
    #jobExceptionsBody .data-table th,
    #jobExceptionsBody .data-table td {
        padding: 8px 6px;
        overflow-wrap: anywhere;
        white-space: normal;
    }

    .credit-stat-group .data-table th,
    .credit-stat-group .data-table td {
        padding: 8px 6px;
        overflow-wrap: anywhere;
    }

    #studentTable th:nth-child(2),
    #studentTable td:nth-child(2),
    #studentTable th:nth-child(n + 5):nth-child(-n + 8),
    #studentTable td:nth-child(n + 5):nth-child(-n + 8),
    #studentTable th:nth-child(n + 10):nth-child(-n + 13),
    #studentTable td:nth-child(n + 10):nth-child(-n + 13),
    #mediaTable th:nth-child(3),
    #mediaTable td:nth-child(3),
    #mediaTable th:nth-child(n + 5):nth-child(-n + 8),
    #mediaTable td:nth-child(n + 5):nth-child(-n + 8),
    #faceRecordsTable th:nth-child(2),
    #faceRecordsTable td:nth-child(2),
    #faceRecordsTable th:nth-child(4),
    #faceRecordsTable td:nth-child(4),
    #faceRecordsTable th:nth-child(6),
    #faceRecordsTable td:nth-child(6),
    #faceRecordsTable th:nth-child(8),
    #faceRecordsTable td:nth-child(8),
    #userTable th:nth-child(1),
    #userTable td:nth-child(1),
    #userTable th:nth-child(3),
    #userTable td:nth-child(3),
    #userTable th:nth-child(5),
    #userTable td:nth-child(5),
    #userTable th:nth-child(6),
    #userTable td:nth-child(6),
    #orgStudentTable th:nth-child(2),
    #orgStudentTable td:nth-child(2),
    #orgStudentTable th:nth-child(n + 5):nth-child(-n + 8),
    #orgStudentTable td:nth-child(n + 5):nth-child(-n + 8),
    #orgStudentTable th:nth-child(n + 10):nth-child(-n + 12),
    #orgStudentTable td:nth-child(n + 10):nth-child(-n + 12),
    #orgMediaTable th:nth-child(3),
    #orgMediaTable td:nth-child(3),
    #orgMediaTable th:nth-child(n + 4):nth-child(-n + 6),
    #orgMediaTable td:nth-child(n + 4):nth-child(-n + 6),
    #orgFaceRecordsTable th:nth-child(3),
    #orgFaceRecordsTable td:nth-child(3),
    #orgFaceRecordsTable th:nth-child(5),
    #orgFaceRecordsTable td:nth-child(5),
    #orgFaceRecordsTable th:nth-child(7),
    #orgFaceRecordsTable td:nth-child(7),
    .enr-student-table th:nth-child(2),
    .enr-student-table td:nth-child(2),
    .enr-student-table th:nth-child(4),
    .enr-student-table td:nth-child(4),
    #jobExceptionsBody .data-table th:nth-child(2),
    #jobExceptionsBody .data-table td:nth-child(2),
    #jobExceptionsBody .data-table th:nth-child(3),
    #jobExceptionsBody .data-table td:nth-child(3),
    #jobExceptionsBody .data-table th:nth-child(n + 6):nth-child(-n + 8),
    #jobExceptionsBody .data-table td:nth-child(n + 6):nth-child(-n + 8) {
        display: none;
    }

    #creditTransactionsTable th:nth-child(1),
    #creditTransactionsTable td:nth-child(1),
    #creditTransactionsTable th:nth-child(4),
    #creditTransactionsTable td:nth-child(4),
    #creditTransactionsTable th:nth-child(6),
    #creditTransactionsTable td:nth-child(6),
    #creditTransactionsTable th:nth-child(8),
    #creditTransactionsTable td:nth-child(8),
    #creditTransactionsTable th:nth-child(9),
    #creditTransactionsTable td:nth-child(9),
    #creditRechargesTable th:nth-child(1),
    #creditRechargesTable td:nth-child(1),
    #creditRechargesTable th:nth-child(n + 4):nth-child(-n + 7),
    #creditRechargesTable td:nth-child(n + 4):nth-child(-n + 7),
    #creditRechargesTable th:nth-child(9),
    #creditRechargesTable td:nth-child(9),
    #orgCreditRechargesTable th:nth-child(1),
    #orgCreditRechargesTable td:nth-child(1),
    #orgCreditRechargesTable th:nth-child(n + 4):nth-child(-n + 7),
    #orgCreditRechargesTable td:nth-child(n + 4):nth-child(-n + 7),
    #orgCreditRechargesTable th:nth-child(9),
    #orgCreditRechargesTable td:nth-child(9),
    #orgCreditTransactionsTable th:nth-child(1),
    #orgCreditTransactionsTable td:nth-child(1),
    #orgCreditTransactionsTable th:nth-child(4),
    #orgCreditTransactionsTable td:nth-child(4),
    #orgCreditTransactionsTable th:nth-child(6),
    #orgCreditTransactionsTable td:nth-child(6),
    #orgCreditTransactionsTable th:nth-child(8),
    #orgCreditTransactionsTable td:nth-child(8),
    #orgCreditTransactionsTable th:nth-child(9),
    #orgCreditTransactionsTable td:nth-child(9) {
        display: none;
    }

    .queue-worker-table {
        min-width: 0 !important;
        table-layout: fixed;
    }

    .queue-worker-table th:nth-child(3),
    .queue-worker-table td:nth-child(3),
    .queue-worker-table th:nth-child(4),
    .queue-worker-table td:nth-child(4),
    .queue-worker-table th:nth-child(6),
    .queue-worker-table td:nth-child(6),
    .queue-worker-table th:nth-child(7),
    .queue-worker-table td:nth-child(7) {
        display: none;
    }

    .log-display,
    .code-block {
        overflow-x: hidden;
        overflow-wrap: anywhere;
        white-space: pre-wrap;
    }

    .list-item {
        align-items: flex-start;
        flex-wrap: wrap;
        gap: 10px;
        padding: 12px;
    }

    .list-item-main {
        width: 100%;
        flex-basis: 100%;
    }

    .list-item-stats {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .list-stat {
        min-width: 0;
        align-items: flex-start;
    }

    .pagination-wrap {
        align-items: stretch;
        flex-direction: column;
    }

    .pagination-wrap .pagination-btns {
        width: 100%;
        overflow-x: auto;
        padding-bottom: 2px;
    }

    .settings-card-header,
    .settings-toggle-row,
    .settings-section-header {
        align-items: flex-start;
    }

    .settings-card-body,
    .settings-section-header {
        padding-left: 14px;
        padding-right: 14px;
    }

    .settings-form-grid,
    .account-info-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .task-worker-bar {
        width: 100%;
        flex-direction: column;
        gap: 10px;
    }

    .task-worker-state,
    .task-worker-actions {
        width: 100%;
    }

    .task-config-panel {
        width: 100%;
    }

    .task-student-panel {
        min-height: 360px;
    }

    .modal,
    .modal.modal-top {
        padding: 0;
        align-items: flex-end;
    }

    .modal-dialog,
    .modal.modal-top .modal-dialog {
        width: 100%;
        max-width: none;
        max-height: calc(100dvh - env(safe-area-inset-top));
        margin: 0;
        border-radius: 10px 10px 0 0;
    }

    .modal-header {
        min-height: 50px;
        padding: 0 14px;
        flex-shrink: 0;
    }

    .modal-body {
        padding: 14px;
        overflow: auto;
        overscroll-behavior: contain;
    }

    .modal-footer {
        padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
        flex-wrap: wrap;
        flex-shrink: 0;
    }

    .modal-footer .btn {
        flex: 1 1 auto;
        justify-content: center;
    }

    .modal-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .modal-tab-btn {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    .task-detail-row span {
        white-space: normal;
    }

    #toast-card {
        top: max(12px, env(safe-area-inset-top));
        left: 12px;
        right: 12px;
        min-width: 0;
        max-width: none;
    }

    .login-wrap {
        padding: 16px;
        overflow-y: auto;
    }

    .login-card {
        max-width: 100%;
        padding: 28px 20px;
    }

    .login-header {
        margin-bottom: 24px;
    }
}

@media (max-width: 360px) {
    .filter-row,
    .dashboard-kpi-grid,
    .billing-summary-row,
    .billing-rules-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* Task management: shared admin filter and modal patterns */
.filter-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.filter-result-count {
    margin-left: auto;
    color: var(--text-secondary);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.filter-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    color: var(--text-secondary);
    font-size: 12px;
    white-space: nowrap;
    cursor: pointer;
}

.filter-checkbox input {
    width: 14px;
    height: 14px;
    margin: 0;
    accent-color: var(--primary);
}

.modal-title-meta {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    margin: 0 16px;
}

.modal-title-meta .badge {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.modal-filter-bar {
    margin: 0 0 12px;
    padding: 10px 12px;
    box-shadow: none;
}

.modal-filter-bar .filter-row {
    gap: 8px 10px;
}

.modal-filter-bar .filter-group {
    min-width: 0;
}

.modal-filter-bar .filter-group .input,
.modal-filter-bar .filter-group .select {
    min-width: 128px;
    height: 30px;
}

.enrollment-task-filter-bar {
    box-shadow: var(--shadow-card);
}

.enrollment-task-filter-actions {
    flex: 0 0 auto;
}

.enrollment-task-result-count {
    padding-bottom: 0;
}

.enrollment-task-daily-status {
    align-items: center;
    gap: 10px;
    border-color: #d6e7ff;
    background: #f5f9ff;
    color: var(--text-secondary);
}

.enrollment-task-daily-status.is-visible {
    display: flex;
}

.enrollment-task-daily-status > span:last-child {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 10px;
    min-width: 0;
}

.enrollment-task-daily-status strong {
    color: var(--text);
    font-weight: 600;
}

.enrollment-task-daily-status small {
    color: var(--text-secondary);
    font-size: 12px;
}

.daily-status-dot {
    width: 8px;
    height: 8px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 0 3px var(--success-bg);
}

.daily-status-dot.has-error {
    background: var(--danger);
    box-shadow: 0 0 0 3px var(--danger-bg);
}

.enrollment-task-org-header {
    background: var(--surface-2);
}

.enrollment-task-org-header:hover {
    background: var(--primary-hover-bg);
}

.enrollment-task-org-stats span {
    border: 1px solid var(--border-light);
}

.enrollment-task-org-stats .is-running {
    border-color: #bfdbfe;
    background: #eff6ff;
}

.enrollment-task-org-stats .is-failed {
    border-color: #fecaca;
    background: #fef2f2;
}

.enrollment-task-card {
    border-radius: 8px;
}

.enrollment-task-card:hover {
    border-color: #91caff;
    background: #fbfdff;
}

.task-card-progress span {
    background: linear-gradient(90deg, var(--primary), var(--success));
}

.task-more-menu-popover button {
    width: 100%;
    padding: 7px 9px;
    border: 0;
    border-radius: 5px;
    background: transparent;
    color: var(--text);
    text-align: left;
    font: inherit;
    font-size: 12px;
    cursor: pointer;
}

.task-detail-toolbar {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

.enr-detail-filter-bar {
    margin: 12px 0;
    padding: 10px 12px;
    box-shadow: none;
}

.enr-detail-filter-bar .filter-group {
    min-width: 128px;
}

.enr-detail-filter-bar .filter-group .input,
.enr-detail-filter-bar .filter-group .select {
    height: 30px;
}

.enr-detail-filter-bar .filter-result-count {
    padding: 4px 0;
}

.enr-student-actions {
    align-items: center;
}

.student-log-filter-bar {
    border-width: 0 0 1px;
    border-radius: 0;
    background: var(--surface-2);
}

.student-log-filter-bar .filter-group .input {
    min-width: 220px;
}

.student-jobs-table-wrap {
    max-height: 58vh;
    overflow: auto;
}

.student-jobs-table-wrap .data-table {
    min-width: 1120px;
}

.enrollment-student-filter-bar {
    gap: 8px;
    margin-bottom: 10px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
}

.enrollment-student-filter-bar .filter-row {
    flex-wrap: nowrap;
    gap: 8px;
}

.enrollment-student-filter-bar .filter-group {
    flex: 1 1 0;
    min-width: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
}

.enrollment-student-filter-bar .filter-group label {
    color: var(--text-secondary);
    font-size: 11px;
}

.enrollment-student-filter-bar .filter-group .input,
.enrollment-student-filter-bar .filter-group .select {
    width: 100%;
    min-width: 0;
    height: 30px;
}

.enrollment-student-filter-bar .filter-actions {
    flex: 0 0 auto;
}

.enrollment-student-list {
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}

.task-student-list-head,
.task-student-row {
    display: grid;
    grid-template-columns: 20px minmax(88px, 1.2fr) minmax(88px, 1.2fr) minmax(92px, 1fr) minmax(92px, 1fr) minmax(76px, .9fr);
    align-items: center;
    gap: 8px;
    min-width: 520px;
}

.task-student-list-head {
    position: sticky;
    z-index: 1;
    top: 0;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 600;
}

.task-student-row {
    padding: 7px 10px;
    border-bottom: 1px solid var(--border-light);
    border-radius: 0;
}

.task-student-row:last-of-type {
    border-bottom: 0;
}

.task-student-row:hover {
    background: var(--primary-hover-bg);
}

.task-student-name,
.task-student-username,
.task-student-school {
    min-width: 0;
    max-width: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.task-student-school {
    color: var(--text-secondary);
    font-size: 11px;
}

.job-exceptions-modal-body {
    padding: 16px 20px;
    overflow: auto;
    max-height: 72vh;
}

.job-exceptions-table-wrap {
    overflow: auto;
    max-height: calc(72vh - 92px);
}

.job-exceptions-table {
    min-width: 1180px;
}

.job-exceptions-table .exception-cell-clip {
    max-width: 230px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.table-row-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.modal-section-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.text-muted {
    color: var(--text-secondary);
}

.exception-detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.exception-section-title {
    margin: 14px 0 8px;
}

.exception-log-display {
    max-height: 260px;
}

@media (max-width: 900px) {
    .enrollment-modal-layout {
        flex-direction: column;
    }

    .enrollment-config-panel {
        width: 100%;
    }

    .exception-detail-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    .filter-result-count,
    .filter-checkbox {
        width: 100%;
        margin-left: 0;
        white-space: normal;
    }

    .modal-filter-bar .filter-group,
    .enr-detail-filter-bar .filter-group,
    .enrollment-student-filter-bar .filter-row {
        flex: 1 1 100%;
        width: 100%;
    }

    .modal-filter-bar .filter-group .input,
    .modal-filter-bar .filter-group .select,
    .enr-detail-filter-bar .filter-group .input,
    .enr-detail-filter-bar .filter-group .select,
    .student-log-filter-bar .filter-group .input {
        width: 100%;
        min-width: 0;
    }

    .enrollment-student-filter-bar .filter-row {
        flex-direction: column;
    }

    .enrollment-task-filter-actions,
    .enrollment-task-filter-actions .btn {
        width: 100%;
    }

    .job-exceptions-modal-body {
        padding: 12px;
    }
}

/* ========================================
   Feedback Center
   ======================================== */
.fb-nav-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    margin-left: 4px;
    border-radius: 9px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    line-height: 1;
}

.fb-nav-badge[hidden] { display: none; }

.fb-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}

.fb-stat {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.fb-stat:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.fb-stat.active { box-shadow: 0 0 0 2px rgba(74, 111, 165, 0.25); }
.fb-stat span { font-size: 22px; font-weight: 700; line-height: 1.1; }
.fb-stat em { font-style: normal; font-size: 12px; color: var(--text-muted); }
.fb-stat-urgent span { color: #b91c1c; }
.fb-stat-high span { color: #c2410c; }
.fb-stat-medium span { color: #1d4ed8; }
.fb-stat-low span { color: #15803d; }

.fb-status-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.fb-status-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
}

.fb-status-tab span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 11px;
}

.fb-status-tab.active {
    border-color: var(--primary);
    background: var(--primary-bg);
    color: var(--primary-dark);
    font-weight: 600;
}

.fb-status-tab.active span { background: #fff; color: var(--primary-dark); }

.fb-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: 11px;
    line-height: 1.6;
    white-space: nowrap;
}

.fb-cat { background: var(--primary-bg); color: var(--primary-dark); border-color: #dbe5f3; }
.fb-sev-urgent { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.fb-sev-high { background: #fff7ed; color: #c2410c; border-color: #fed7aa; }
.fb-sev-medium { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.fb-sev-low { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }
.fb-status-pending { background: #fffbeb; color: #b45309; border-color: #fde68a; }
.fb-status-processing { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.fb-status-resolved { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }
.fb-status-closed { background: #f8fafc; color: #475569; border-color: #e2e8f0; }

.fb-summary {
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fb-students-cell {
    display: inline-block;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
}

.fb-muted { color: var(--text-muted); }

.fb-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 12px 2px 4px;
    color: var(--text-secondary);
    font-size: 12px;
}

.fb-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.fb-field { margin-bottom: 14px; }
.fb-field > label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}
.fb-required { color: var(--danger); font-weight: 500; font-size: 12px; }

.fb-range-row {
    display: flex;
    align-items: center;
    gap: 12px;
}
.fb-range-row input[type="range"] { flex: 1; accent-color: var(--primary); }
.fb-range-value {
    min-width: 110px;
    text-align: right;
    color: var(--primary-dark);
    font-size: 13px;
    font-weight: 600;
}

.fb-inline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.fb-editor {
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    background: var(--surface);
}
.fb-editor-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}
#fbContent {
    width: 100%;
    min-height: 170px;
    padding: 12px;
    border: 0;
    outline: none;
    resize: vertical;
    background: var(--surface);
    color: var(--text);
    font-family: var(--font);
    font-size: 13px;
    line-height: 1.7;
}
.fb-editor-preview {
    display: none;
    min-height: 170px;
    max-height: 380px;
    overflow: auto;
    padding: 12px;
    font-size: 13px;
    line-height: 1.7;
}
.fb-editor.previewing #fbContent { display: none; }
.fb-editor.previewing .fb-editor-preview { display: block; }
.fb-editor-preview p { margin: 0 0 10px; }
.fb-editor-preview h3,
.fb-editor-preview h4,
.fb-editor-preview h5 { margin: 12px 0 8px; }
.fb-editor-preview ul,
.fb-editor-preview ol { margin: 0 0 10px 20px; }
.fb-editor-preview pre {
    margin: 0 0 10px;
    padding: 10px 12px;
    border-radius: 8px;
    background: #0f172a;
    color: #dbeafe;
    overflow: auto;
}
.fb-editor-preview code {
    padding: 1px 5px;
    border-radius: 4px;
    background: #eef2f7;
    font-family: Consolas, Monaco, monospace;
}
.fb-editor-preview pre code { padding: 0; background: transparent; color: inherit; }
.fb-editor-preview a { color: var(--primary); }

.fb-editor-hint {
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.5;
}

.fb-student-picked {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 24px;
    margin-top: 8px;
}

.fb-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border: 1px solid #dbe5f3;
    border-radius: 999px;
    background: var(--primary-bg);
    color: var(--primary-dark);
    font-size: 12px;
}
.fb-chip button {
    border: 0;
    background: transparent;
    color: var(--primary-dark);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    padding: 0 1px;
}
.fb-chip-meta { color: var(--text-muted); font-size: 11px; }

.fb-attach-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.fb-attach-item {
    position: relative;
    width: 96px;
    height: 72px;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: var(--surface-2);
}
.fb-attach-item img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.fb-attach-item button {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    border: 0;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.72);
    color: #fff;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
}
.fb-img-error { min-height: 40px; background: var(--surface-2); }

.fb-picker-list {
    max-height: 360px;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
}
.fb-picker-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-bottom: 1px solid var(--border-light);
    font-size: 13px;
    cursor: pointer;
}
.fb-picker-item:last-child { border-bottom: none; }
.fb-picker-item:hover { background: var(--primary-bg); }
.fb-picker-item input { width: 15px; height: 15px; accent-color: var(--primary); }
.fb-picker-name { font-weight: 600; }
.fb-picker-meta { margin-left: auto; color: var(--text-muted); font-size: 12px; }
.fb-picker-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 10px;
}

.fb-detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 22px;
    margin-bottom: 16px;
}
.fb-detail-grid label {
    display: block;
    margin-bottom: 2px;
    color: var(--text-muted);
    font-size: 12px;
}
.fb-detail-grid strong { font-size: 13px; font-weight: 600; }

.fb-detail-section { margin-top: 16px; }
.fb-detail-section h4 { margin-bottom: 8px; font-size: 13px; }
.fb-detail-content {
    max-height: 42vh;
    overflow: auto;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-2);
    font-size: 13px;
    line-height: 1.7;
}
.fb-detail-content p { margin: 0 0 10px; }
.fb-detail-content ul,
.fb-detail-content ol { margin: 0 0 10px 20px; }
.fb-md-img {
    display: block;
    max-width: 100%;
    margin: 8px 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: zoom-in;
}

.fb-admin-box {
    margin-top: 18px;
    padding: 14px;
    border: 1px solid #fed7aa;
    border-radius: 10px;
    background: #fff7ed;
}

.fb-toast {
    position: fixed;
    left: 50%;
    bottom: 28px;
    z-index: 4000;
    max-width: min(520px, calc(100vw - 32px));
    padding: 10px 18px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.9);
    color: #fff;
    font-size: 13px;
    text-align: center;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 12px);
    transition: opacity 0.2s, transform 0.2s;
}
.fb-toast.show { opacity: 1; transform: translate(-50%, 0); }
.fb-toast.success { background: #166534; }
.fb-toast.warning { background: #b45309; }
.fb-toast.error { background: #b91c1c; }

@media (max-width: 900px) {
    .fb-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .fb-form-grid { grid-template-columns: 1fr; }
    .fb-detail-grid { grid-template-columns: 1fr; }
    .fb-range-row { flex-wrap: wrap; }
    .fb-range-value { min-width: 0; }
    .fb-summary { max-width: 180px; }
}
/* ---- Finance: recharge receivables ---- */
.finance-status-unpaid {
    background: #fff7ed;
    color: #c2410c;
    border: 1px solid #fed7aa;
}
.finance-status-partial {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}
.finance-status-paid {
    background: #f0fdf4;
    color: #15803d;
    border: 1px solid #bbf7d0;
}