@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;600;700&display=swap');

:root {
    --bg-body: #f5f8ff;
    --bg-card: #ffffff;
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --primary: #0d6efd;
    --primary-dark: #0a58ca;
    --border: #e5e7eb;
    --accent: #f0a500;
    --success: #198754;
    --danger: #dc3545;
    --sidebar-bg: #0f172a;
    --sidebar-text: #d1d5db;
    --sidebar-active: rgba(13, 110, 253, 0.12);
    --shadow-card: 0 10px 30px rgba(15, 23, 42, 0.08);
}

body.dark-mode {
    --bg-body: #0b1220;
    --bg-card: #111827;
    --text-main: #e5e7eb;
    --text-muted: #9ca3af;
    --border: #1f2937;
    --sidebar-bg: #0b1020;
    --sidebar-text: #c5d0e0;
    --sidebar-active: rgba(13, 110, 253, 0.2);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    font-family: 'Cairo', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-body);
    color: var(--text-main);
    min-height: 100vh;
}

a {
    text-decoration: none;
}

.app-body.auth-body {
    background: linear-gradient(135deg, #0d6efd 0%, #1e40af 35%, #0b1220 100%);
}

.app-shell {
    min-height: 100vh;
    background: var(--bg-body);
    width: 100%;
    overflow-x: hidden;
}

.app-sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    padding: 16px 14px;
    position: sticky;
    top: 0;
    height: 100vh;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.12);
    transition: transform 0.25s ease, width 0.25s ease;
    overflow-y: auto;
}

.app-sidebar .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    margin-bottom: 12px;
    color: #fff;
}

.app-sidebar .brand .logo {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, #0d6efd, #38bdf8);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 18px;
}

.sidebar-section {
    margin-top: 16px;
}

.sidebar-title {
    font-size: 0.8rem;
    color: #9ca3af;
    letter-spacing: 0.5px;
    padding: 6px 12px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin: 4px 0;
    color: var(--sidebar-text);
    border-radius: 10px;
    transition: all 0.2s ease;
}

.sidebar-link i {
    font-size: 1rem;
}

.sidebar-link:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
}

.sidebar-link.active {
    background: var(--sidebar-active);
    color: #fff;
}

.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
    width: 100%;
}

.app-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 998;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-icon {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-main);
    transition: all 0.2s ease;
}

.btn-icon:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.app-content {
    padding: 24px 20px 32px;
    flex: 1;
    min-width: 0;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}

.page-header .title {
    font-size: 1.3rem;
    font-weight: 700;
}

.card-modern {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px;
    box-shadow: var(--shadow-card);
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.kpi {
    position: relative;
    padding: 14px;
    padding-inline-start: 68px;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(13, 110, 253, 0.08), rgba(56, 189, 248, 0.08));
    border: 1px solid var(--border);
    min-height: 110px;
}

.kpi h3 {
    font-weight: 800;
    margin: 0;
}

.kpi .label {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.kpi .kpi-icon {
    position: absolute;
    top: 12px;
    inset-inline-start: 16px;
    width: 34px;
    height: 34px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #0d6efd;
    color: #fff;
    box-shadow: 0 6px 16px rgba(13, 110, 253, 0.3);
}

.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.table-modern {
    width: 100%;
    border-spacing: 0;
    border-collapse: separate;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}

.table-modern thead th {
    background: #f8fafc;
    position: sticky;
    top: 0;
    z-index: 2;
    font-weight: 700;
    color: #374151;
}

.table-modern th,
.table-modern td {
    padding: 12px;
    vertical-align: middle;
    border-bottom: 1px solid var(--border);
}

.table-modern tbody tr:hover {
    background: rgba(13, 110, 253, 0.06);
}

.status-badge {
    padding: 6px 10px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.88rem;
}

.status-active {
    background: rgba(25, 135, 84, 0.12);
    color: #137752;
    border: 1px solid rgba(25, 135, 84, 0.2);
}

.status-inactive {
    background: rgba(220, 53, 69, 0.1);
    color: #b1202a;
    border: 1px solid rgba(220, 53, 69, 0.2);
}

.btn-primary {
    border-radius: 10px;
    padding: 10px 16px;
}

.btn-outline-primary {
    border-radius: 10px;
}

.form-control,
.form-select {
    border-radius: 10px;
}

.form-label {
    font-weight: 700;
}

.empty-state {
    border: 1px dashed var(--border);
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    color: var(--text-muted);
}

.auth-wrapper {
    min-height: 100vh;
    padding: 16px;
}

.auth-card {
    width: 100%;
    max-width: 440px;
    background: #fff;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

.logo {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 800;
    font-size: 22px;
    overflow: hidden;
    border: 1px solid #e5e7eb;
}

.auth-card .logo {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 800;
    font-size: 22px;
    border: 1px solid #e5e7eb;
}

.logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.app-sidebar .brand .logo {
    background: transparent;
    border: none;
}

.password-toggle {
    position: absolute;
    inset-inline-end: 10px;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    color: var(--text-muted);
}

.toast {
    border-radius: 12px;
    overflow: hidden;
}

.toast-success {
    border-inline-start: 4px solid #198754;
}

.toast-danger,
.toast-error {
    border-inline-start: 4px solid #dc3545;
}

.schedule-table td,
.schedule-table th {
    text-align: center;
    vertical-align: middle;
}

.schedule-slot {
    transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    text-align: center;
    padding-top: 14px;
    padding-bottom: 14px;
    min-height: 56px;
    line-height: 1.5;
    font-weight: 700;
    color: #0d47a1;
}

.schedule-slot.slot-empty {
    background: transparent;
    border-color: #dfe3eb;
    color: #0d47a1;
    box-shadow: inset 0 0 0 1px #e5e7eb;
}

.schedule-slot.slot-filled {
    background: #e9f9f0;
    border-color: #bde7c9;
    color: #0f6a43;
    font-weight: 600;
    box-shadow: inset 0 0 0 1px #bde7c9;
}

.schedule-slot:focus {
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.18);
}

.legend-dot {
    width: 18px;
    height: 18px;
    border-radius: 6px;
    display: inline-block;
    border: 1px solid #d0d7e2;
}

.period-time {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    background: #f4f6ff;
    color: #344054;
    font-size: 0.8rem;
    border: 1px solid #d9e0ff;
}

/* Report grid for consolidated absence */
.report-grid-wrapper {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 18px;
}

.report-card {
    border: 1px solid #dbe7ff;
    border-radius: 14px;
    padding: 14px;
    background: linear-gradient(135deg, #f9fbff 0%, #ffffff 70%);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
    width: 100%;
    max-width: 700px;
}

.report-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.report-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 8px;
}

.report-cell {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #ffffff;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 90px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.report-period {
    font-weight: 700;
    color: #0f3c7c;
    font-size: 0.95rem;
}

.report-class {
    color: #111827;
    font-weight: 600;
    font-size: 0.95rem;
}

.report-sub {
    color: #0f6a43;
    font-size: 0.9rem;
}

.report-table-wrapper {
    overflow-x: auto;
}

.report-table {
    width: 100%;
    border-collapse: collapse;
    text-align: center;
    background: #ffffff;
    border: 1px solid #d0deef;
    border-radius: 12px;
    overflow: hidden;
}

.report-table th,
.report-table td {
    border: 1px solid #d0deef;
    padding: 10px;
    vertical-align: middle;
    font-size: 0.95rem;
}

.report-head-cell {
    background: #dbeafe;
    color: #0f3c7c;
    font-weight: 700;
}

.report-time-row td {
    background: #f2f7ff;
    color: #0f3c7c;
    font-weight: 600;
}

.report-hero {
    padding: 12px 8px;
    margin-bottom: 12px;
    border-radius: 12px;
    background: linear-gradient(180deg, #fdf2f8 0%, #fff 80%);
    border: 1px solid #f1d4e6;
}

.hero-title {
    font-size: 1.3rem;
    font-weight: 800;
    color: #0f3c7c;
}

.hero-subtitle {
    font-size: 0.95rem;
    color: #475467;
    margin-bottom: 6px;
}

.hero-teacher {
    font-size: 1.05rem;
    margin-bottom: 4px;
}

.hero-subject {
    color: #0f3c7c;
    font-weight: 700;
}

.hero-date-row {
    font-size: 0.95rem;
    color: #344054;
    font-weight: 600;
}

.hero-school {
    line-height: 1.3;
    font-weight: 700;
    font-size: 0.95rem;
}

.hero-logo {
    max-height: 60px;
    object-fit: contain;
}

.hero-brand {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.hero-row {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    justify-content: space-between;
}

.hero-side {
    min-width: 100px;
}

.hero-logo-left {
    max-height: 60px;
    object-fit: contain;
}

.stacked-center {
    margin-top: 10px;
}

.hero-name-block {
    text-align: center;
    width: 100%;
}

.hero-name {
    font-size: 1.25rem;
    font-weight: 900;
    color: #0f6a43;
    margin-bottom: 4px;
    padding: 6px 12px;
    border-radius: 10px;
    border: 1px solid #bde7c9;
    background: #e9f9f0;
    display: inline-block;
}

.chip-date {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    background: #f4f6ff;
    color: #0f3c7c;
    font-size: 0.9rem;
    margin: 2px 4px;
    border: 1px solid #d9e0ff;
}

.schedule-header-cover {
    padding: 12px 14px;
    border: 1px solid #dbe7ff;
    border-radius: 12px;
    background: linear-gradient(135deg, #f7fbff 0%, #ffffff 70%);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
}

.schedule-header-cover .hero-logo {
    max-height: 60px;
    object-fit: contain;
}

.schedule-header-cover .hero-logo-left {
    max-height: 60px;
    object-fit: contain;
}

.teacher-tag {
    display: inline-block;
    padding: 6px 12px;
    border: 1px solid #dbe7ff;
    border-radius: 10px;
    background: #ffffff;
    color: #0f3c7c;
    font-size: 1rem;
}

.duty-header .hero-row {
    justify-content: center;
}

.duty-header .hero-side {
    flex: 0 0 130px;
}

.duty-header .hero-center {
    flex: 1 1 0;
    text-align: center;
}

.report-class-row td {
    background: #ffffff;
    color: #111827;
    font-weight: 600;
}

.report-sub-row td {
    background: #f8f5ff;
    color: #0f6a43;
    font-weight: 600;
}

.report-label-cell {
    min-width: 120px;
    font-weight: 700;
    color: #0f3c7c;
    background: #e9f2ff;
}

.report-label-cell.muted {
    color: #475467;
    background: #eef2f7;
}

.report-vertical {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.report-period-row {
    display: flex;
    gap: 10px;
    align-items: stretch;
    border: 1px solid #d0deef;
    border-radius: 12px;
    background: #ffffff;
    padding: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.report-period-badge {
    min-width: 140px;
    padding: 8px 10px;
    border-radius: 10px;
    background: #f4f6ff;
    color: #0f3c7c;
    font-weight: 700;
    border: 1px solid #d9e0ff;
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-start;
    justify-content: center;
    text-align: right;
}

.report-period-badge small {
    font-weight: 600;
    color: #475467;
}

.report-period-body {
    flex: 1 1 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
    align-items: stretch;
}

.report-period-body .report-class {
    font-weight: 700;
    color: #0f3c7c;
}

.report-period-body .report-sub {
    font-weight: 600;
    color: #0f6a43;
}

@media (max-width: 768px) {
    .report-period-row {
        flex-direction: column;
    }
    .report-period-badge {
        width: 100%;
        align-items: center;
        text-align: center;
    }
    .report-period-body {
        grid-template-columns: 1fr;
    }
}

.report-field {
    border: 1px solid #e3e9f3;
    border-radius: 10px;
    padding: 8px 10px;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.report-field-label {
    font-size: 0.9rem;
    color: #475467;
    font-weight: 700;
}

.report-field-value {
    font-weight: 700;
    color: #0f3c7c;
}

.report-matrix {
    display: grid;
    grid-template-columns: repeat(4, minmax(120px, 1fr));
    border: 1px solid #d0deef;
    border-radius: 12px;
    overflow: hidden;
    background: #ffffff;
}

.matrix-head {
    background: #eef4ff;
    color: #0f3c7c;
    font-weight: 800;
    padding: 10px;
    text-align: center;
    border-bottom: 1px solid #d0deef;
    border-inline-end: 1px solid #d0deef;
}

.matrix-head:nth-child(4) {
    border-inline-end: none;
}

.matrix-cell {
    padding: 10px;
    text-align: center;
    border-bottom: 1px solid #eef1f6;
    border-inline-end: 1px solid #f0f2f7;
    font-weight: 700;
    color: #111827;
}

.matrix-cell:nth-child(4n) {
    border-inline-end: none;
}

@media (max-width: 768px) {
    .report-matrix {
        min-width: 520px;
    }
}

.report-stack {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.report-stack-block {
    border: 1px solid #d0deef;
    border-radius: 12px;
    background: #ffffff;
    padding: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.report-stack-title {
    font-weight: 800;
    color: #0f3c7c;
    margin-bottom: 8px;
}

.report-stack-values {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
}

.report-stack-item {
    padding: 8px 10px;
    border: 1px solid #e3e9f3;
    border-radius: 10px;
    background: #ffffff;
    font-weight: 700;
    color: #111827;
    text-align: center;
}

@media (max-width: 992px) {
    .report-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 576px) {
    .report-grid {
        grid-template-columns: repeat(1, minmax(0, 1fr));
    }
}

.report-stack {
    grid-template-columns: 1fr;
}

.placeholder-box {
    border: 1px dashed #bbb;
    padding: 24px;
    text-align: center;
    color: #777;
}

/* Activation cards (A4, two per page) */
.activation-wrapper {
    margin-top: 24px;
}

.activation-page {
    width: 100%;
    max-width: 100%;
    background: #f8f9fb;
    padding: 20px 24px;
    border: 1px solid #d3d9e3;
    margin-bottom: 16px;
    page-break-after: always;
    box-sizing: border-box;
    min-height: 0;
    display: block;
}

.activation-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
}

.activation-grid.single {
    grid-template-columns: 1fr;
}

.activation-card {
    width: 100%;
    box-sizing: border-box;
    background: #fff;
    border: 2px solid #b5b9c1;
    border-radius: 6px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    page-break-inside: avoid;
}

.activation-head {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    align-items: center;
    text-align: center;
    gap: 6px;
    font-size: 12px;
}

.activation-head img {
    max-height: 36px;
    object-fit: contain;
}

.activation-title {
    text-align: center;
    font-weight: 800;
    font-size: 19px;
}

.activation-subtitle {
    font-size: 19px;
    font-weight: 700;
    color: #6c757d;
    margin-top: 2px;
}

.activation-meta {
    border: 1px solid #c2c7d1;
    border-collapse: collapse;
    width: 100%;
    font-size: 18px;
}

.activation-meta td {
    border: 1px solid #c2c7d1;
    padding: 4px 6px;
}

.activation-meta .label {
    background: #f2f3f6;
    font-weight: 700;
    width: 32%;
}

.activation-table {
    width: 100%;
    border: 1px solid #c2c7d1;
    border-collapse: collapse;
    font-size: 18px;
}

.activation-table th,
.activation-table td {
    border: 1px solid #c2c7d1;
    padding: 4px 6px;
    vertical-align: middle;
}

.activation-table th {
    background: #f6f7fa;
    font-weight: 700;
    text-align: center;
}

.duo-box {
    border: 1px solid #dbe7ff;
    border-radius: 10px;
    min-height: 220px;
    background: #f8f9fb;
    padding: 10px;
    overflow-y: auto;
}

.duo-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #ffffff;
    margin-bottom: 6px;
}

.duo-item .duo-name {
    font-weight: 700;
}

.duo-item .duo-subj {
    color: #6c757d;
    font-size: 0.9rem;
}

.duo-item .duo-load {
    color: #0d6efd;
    font-size: 0.9rem;
    font-weight: 600;
}

.duo-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.duo-btn {
    border: 1px solid #ced4da;
    background: #f8f9fa;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 0.85rem;
    cursor: pointer;
}

.duo-btn.primary {
    background: #0d6efd;
    color: #fff;
    border-color: #0d6efd;
}

.duo-btn.danger {
    background: #dc3545;
    color: #fff;
    border-color: #dc3545;
}

.duo-btn.excluded {
    background: #ffeeba;
    border-color: #f0ad4e;
    color: #8a6d3b;
}

.activation-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 2px 8px;
}

.activation-options label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 400;
}

.activation-sign {
    min-width: 80px;
    text-align: center;
    color: #6c757d;
}

.activation-footer {
    border-top: 1px dashed #c2c7d1;
    padding-top: 6px;
    font-size: 11px;
    display: flex;
    justify-content: space-between;
    color: #6c757d;
}

.card-teacher {
    border: 1px solid #dbe7ff;
    border-radius: 12px;
    padding: 14px;
    background: #ffffff;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}

.badge-sub {
    background: #ffc107;
    color: #000;
}

.calendar-card {
    background: linear-gradient(135deg, #f7f9ff 0%, #ffffff 70%);
    border: 1px solid #dbe7ff;
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.calendar-header .teacher-name {
    font-size: 1.1rem;
    font-weight: 700;
}

.calendar-header .date-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    background: #eef4ff;
    color: #0d47a1;
    font-weight: 600;
}

.ai-hero {
    background: linear-gradient(135deg, rgba(13, 110, 253, 0.08), rgba(111, 66, 193, 0.1));
    border: 1px solid #dbe7ff;
}

.ai-pill {
    padding: 6px 12px;
    border-radius: 999px;
    background: #eef4ff;
    color: #0f3c7c;
    border: 1px solid #d9e0ff;
    font-weight: 700;
}

.ai-pill.success {
    background: #e9f9f0;
    color: #0f6a43;
    border: 1px solid #bde7c9;
}

.ai-spark {
    width: 100%;
    height: 10px;
    background: #f3f6ff;
    border-radius: 12px;
    overflow: hidden;
}

.ai-bar {
    height: 10px;
    background: linear-gradient(90deg, #0d6efd, #6f42c1);
}

.mini-bar {
    width: 100%;
    height: 8px;
    background: #f4f6ff;
    border-radius: 999px;
    overflow: hidden;
}

.mini-bar span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, #0f6a43, #6f42c1);
}

.coverage-bar {
    width: 100%;
    height: 14px;
    border-radius: 999px;
    background: #f3f6ff;
    border: 1px solid #d9e0ff;
    overflow: hidden;
}

.coverage-bar span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, #0d6efd, #0f6a43);
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.stat-card {
    min-height: 110px;
}

.ai-advice-text {
    padding: 10px;
    border: 1px dashed #d0deef;
    border-radius: 10px;
    background: #f7fbff;
    line-height: 1.6;
    color: #111827;
}

.schedule-grid {
    border: 1px solid #e3e8f0;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
}

.schedule-row {
    display: grid;
    grid-template-columns: 80px 1fr 1fr;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid #eef1f6;
}

.schedule-row:last-child {
    border-bottom: none;
}

.schedule-slot {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    color: #0d47a1;
}

.slot-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #0d6efd;
    display: inline-block;
}

.slot-dot.dot-sub {
    background: #f0a500;
}

.slot-dot.dot-normal {
    background: #0d6efd;
}

.slot-label {
    font-size: 0.92rem;
}

.schedule-row.has-sub {
    background: #fff9ec;
    border-inline-start: 3px solid #f0a500;
}

.cell {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.original-cell {
    color: #344054;
}

.sub-cell {
    align-items: flex-end;
    color: #3a3a3a;
}

.sub-tag {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.85rem;
    background: #e4f7ea;
    color: #0f6a43;
    border: 1px solid #bde7c9;
}

.card-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.abs-teacher-list {
    max-height: 260px;
    overflow-y: auto;
    padding: 8px;
    background: #fff;
}

.abs-teacher-item {
    padding: 6px 8px;
    border-radius: 8px;
    transition: background 0.15s ease;
    font-size: 0.95rem;
}

.abs-teacher-item:hover {
    background: #ffffff;
}

/* Duty card redesign */
.duty-card {
    width: 100%;
    padding: 18px;
    border: 1px solid #cfd7e3;
    border-radius: 16px;
    background: #ffffff;
    background-color: #ffffff !important;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
}

.duty-header {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: flex-start;
    padding: 10px 12px;
    border-inline-start: 4px solid var(--primary);
    background: #ffffff;
    border-radius: 12px;
}

.duty-title {
    font-size: 1.2rem;
    font-weight: 800;
}

.duty-body {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f5f8ff;
    border: 1px solid #e5e7eb;
    padding: 12px;
    border-radius: 12px;
}

.period-row {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px;
    align-items: flex-start;
    padding: 16px 18px;
    border-radius: 12px;
    border: 1px solid #d7ddea;
    background: #ffffff;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
    transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
    min-height: 64px;
}

.period-row:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.2);
}

.period-row.period-sub {
    background: #f8fff9;
    border-color: #cde9d6;
    border-inline-start: 4px solid #20a16c;
}

.period-badge {
    min-width: 140px;
    padding: 10px 14px;
    min-height: 48px;
    border-radius: 12px;
    background: #f4f6ff;
    color: #4338ca;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-weight: 800;
    font-size: 1.05rem;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.period-row.period-sub .period-badge {
    background: #e4f7ea;
    color: #0f6a43;
}

.period-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    color: var(--text-main);
    border-bottom: 1px solid #f1f3f7;
    padding-bottom: 6px;
}

.period-main {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
}

.period-top {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.period-class {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--text-main);
}

.text-sub {
    color: #0f6a43;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.tag-sub {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.85rem;
    background: #e4f7ea;
    color: #0f6a43;
    border: 1px solid #bde7c9;
    font-weight: 700;
}

.export-large {
    font-size: 1.18em;
}

.export-large .duty-card {
    padding: 24px;
}

.export-large .duty-header {
    padding: 16px 18px;
}

.export-large .hero-title {
    font-size: 1.9rem;
}

.export-large .hero-name {
    font-size: 1.9rem;
}

.export-large .hero-date-row .chip-date {
    font-size: 1.40rem;
    padding: 10px 18px;
}

.export-large .duty-body {
    padding: 18px;
    gap: 14px;
}

.export-large .period-row {
    padding: 22px 24px;
    min-height: 86px;
    border: 4px solid #d9e2f2;
    box-shadow: 0 10px 26px rgba(15, 23, 42, 0.18);
}

.export-large .period-row.period-sub {
    background: rgba(12, 82, 53, 0.12) !important;
    border-color: #62d6a2 !important;
}

.export-large .period-badge {
    min-width: 170px;
    min-height: 58px;
    font-size: 1.80rem;
}

.export-large .period-class {
    font-size: 1.80rem;
}

.export-large .period-info {
    font-size: 1.80rem;
}

.export-large .period-time {
    font-size: 1.08rem;
}

.status-available {
    background: #10b981;
}

.status-sub {
    background: #20a16c;
}

.sub-meta-row {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #0f6a43;
}

.period-original {
    margin-top: 2px;
    font-weight: 600;
}

.duty-footer {
    margin-top: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-top: 1px solid var(--border);
    padding-top: 10px;
}

.duty-footer .card-actions {
    margin-top: 0;
}

.wizard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

.wizard-step {
    padding: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.wizard-step .step-number {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.badge-soft {
    padding: 6px 10px;
    border-radius: 12px;
    background: #f4f6ff;
    color: #4338ca;
    font-weight: 700;
}

.table-responsive {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-card);
}

.sticky-actions {
    position: sticky;
    bottom: 0;
    padding: 10px;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
}

.btn-loading {
    position: relative;
}

.btn-loading.disabled::after,
.btn-loading:disabled::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.6);
    border-radius: inherit;
}

.sidebar-fab {
    position: fixed;
    inset-inline-end: 16px;
    bottom: 16px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.22);
    z-index: 1001;
    display: none;
    align-items: center;
    justify-content: center;
}

.sidebar-fab i {
    font-size: 1.3rem;
}

@media (max-width: 992px) {
    .app-sidebar {
        position: fixed;
        inset: 0 0 0 auto;
        transform: translateX(110%);
        z-index: 999;
        width: min(320px, 90vw);
        max-height: 100vh;
    }

    body.sidebar-open .app-sidebar {
        transform: translateX(0) !important;
    }

    body.sidebar-open {
        overflow: hidden;
    }

    .app-content {
        padding: 18px 14px 28px;
    }

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.25);
        backdrop-filter: blur(1px);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.2s ease;
        z-index: 998;
    }

    body.sidebar-open .sidebar-overlay {
        opacity: 1;
        visibility: visible;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .quick-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .quick-actions form {
        width: 100%;
    }

    .quick-actions input[type="date"],
    .quick-actions input[type="text"],
    .quick-actions select {
        width: 100%;
    }

    .sidebar-fab {
        display: inline-flex;
    }
}

@media (max-width: 576px) {
    .app-topbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .topbar-actions {
        width: 100%;
        flex-wrap: wrap;
        justify-content: flex-start;
        gap: 6px;
    }

    .topbar-actions .dropdown {
        width: 100%;
    }

    .topbar-actions .dropdown .btn {
        width: 100%;
        text-align: start;
    }

    .page-header .title {
        font-size: 1.15rem;
    }
}

@media print {
    .duty-card,
    .period-row {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    body {
        background: #fff;
    }

    .app-sidebar,
    .app-topbar,
    .card-actions,
    .report-actions,
    .page-header,
    .toast-container {
        display: none !important;
    }

    .app-content {
        padding: 0;
    }

    .calendar-card,
    .duty-card {
        box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18) !important;
        border: 1px solid #cfd7e3;
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .duty-footer {
        justify-content: flex-start;
        gap: 16px;
    }

    .period-row {
        box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18) !important;
        border: 1px solid #cfd7e3 !important;
        background: #fff !important;
    }

    .activation-page {
        page-break-after: always;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .activation-card {
        break-inside: avoid;
        page-break-inside: avoid;
    }
    .activation-page:last-child {
        page-break-after: auto;
    }
}
