/* PALLADIO Announcer Styles */

:root {
    --primary-color: #0f6c68;
    --primary-deep: #0a4f4c;
    --secondary-color: #5f6b76;
    --surface-color: rgba(255, 255, 255, 0.92);
    --surface-border: rgba(15, 108, 104, 0.12);
    --text-color: #16313a;
    --muted-color: #60707c;
    --page-bg-start: #f6fbfa;
    --page-bg-end: #eef3f5;
    --page-radial: rgba(15, 108, 104, 0.14);
    --table-head-bg: #1f2b33;
    --table-head-text: #ffffff;
    --table-head-hover-bg: #31424d;
    --table-head-hover-text: #ffffff;
    --table-hover: #f7fbfb;
    --table-mobile-card: rgba(255, 255, 255, 0.98);
    --table-mobile-header: rgba(15, 108, 104, 0.06);
    --input-bg: rgba(255, 255, 255, 0.96);
    --input-border: rgba(15, 108, 104, 0.18);
    --chip-bg: rgba(255, 255, 255, 0.14);
    --chip-border: rgba(255, 255, 255, 0.16);
    --chip-text: rgba(255, 255, 255, 0.92);
    --tab-bg: rgba(255, 255, 255, 0.7);
    --tab-hover-bg: rgba(15, 108, 104, 0.1);
    --tab-hover-text: #0a4f4c;
    --header-btn-hover-bg: rgba(255, 255, 255, 0.22);
    --header-btn-hover-border: rgba(255, 255, 255, 0.72);
    --login-card-bg: rgba(255, 255, 255, 0.95);
    --role-option-bg: rgba(255, 255, 255, 0.8);
    --theme-btn-bg: rgba(255, 255, 255, 0.92);
    --theme-btn-border: rgba(255, 255, 255, 0.2);
    --theme-btn-text: #1b3138;
    --theme-btn-hover: rgba(255, 255, 255, 1);
    --theme-btn-active-bg: #ffffff;
    --theme-btn-active-text: #0a4f4c;
    --theme-btn-shadow: 0 4px 10px rgba(10, 34, 44, 0.12);
    --theme-btn-ring: rgba(255, 255, 255, 0.45);
    --overlay-bg: rgba(0, 0, 0, 0.5);
    --modal-bg: rgba(255, 255, 255, 0.98);
    --modal-border: rgba(15, 108, 104, 0.12);
    --table-bg: rgba(255, 255, 255, 0.7);
    --table-striped-bg: rgba(15, 108, 104, 0.035);
    --table-border: rgba(15, 108, 104, 0.08);
    --action-btn-hover-shadow: 0 8px 18px rgba(10, 34, 44, 0.16);
    --alert-danger-bg: #f8dfe2;
    --alert-danger-border: rgba(207, 77, 77, 0.2);
    --alert-danger-text: #8b2d3d;
    --success-color: #1f8f5f;
    --danger-color: #cf4d4d;
    --warning-color: #d8a227;
    --info-color: #2f7ca8;
    --shadow-soft: 0 16px 40px rgba(13, 42, 54, 0.08);
    --shadow-card: 0 8px 24px rgba(10, 34, 44, 0.08);
}

html[data-theme="dark"] {
    --surface-color: rgba(22, 31, 38, 0.94);
    --surface-border: rgba(134, 211, 207, 0.16);
    --text-color: #e5eff3;
    --muted-color: #bccbd2;
    --page-bg-start: #0f161c;
    --page-bg-end: #121d24;
    --page-radial: rgba(46, 153, 146, 0.18);
    --table-head-bg: #152028;
    --table-head-text: #eaf4f7;
    --table-head-hover-bg: #20303b;
    --table-head-hover-text: #f3fbfd;
    --table-hover: rgba(255, 255, 255, 0.03);
    --table-mobile-card: rgba(19, 27, 33, 0.98);
    --table-mobile-header: rgba(89, 181, 174, 0.12);
    --input-bg: rgba(15, 22, 28, 0.94);
    --input-border: rgba(134, 211, 207, 0.18);
    --chip-bg: rgba(255, 255, 255, 0.08);
    --chip-border: rgba(255, 255, 255, 0.12);
    --chip-text: #eaf4f7;
    --tab-bg: rgba(15, 22, 28, 0.88);
    --tab-hover-bg: rgba(89, 181, 174, 0.14);
    --tab-hover-text: #f5fbfc;
    --header-btn-hover-bg: rgba(255, 255, 255, 0.18);
    --header-btn-hover-border: rgba(255, 255, 255, 0.52);
    --login-card-bg: rgba(22, 31, 38, 0.96);
    --role-option-bg: rgba(15, 22, 28, 0.92);
    --theme-btn-bg: rgba(15, 22, 28, 0.96);
    --theme-btn-border: rgba(255, 255, 255, 0.12);
    --theme-btn-text: #e5eff3;
    --theme-btn-hover: rgba(28, 41, 50, 0.98);
    --theme-btn-active-bg: rgba(89, 181, 174, 0.18);
    --theme-btn-active-text: #f5fbfc;
    --theme-btn-shadow: 0 4px 12px rgba(0, 0, 0, 0.22);
    --theme-btn-ring: rgba(134, 211, 207, 0.34);
    --overlay-bg: rgba(0, 0, 0, 0.64);
    --modal-bg: rgba(22, 31, 38, 0.98);
    --modal-border: rgba(134, 211, 207, 0.14);
    --table-bg: rgba(18, 26, 32, 0.86);
    --table-striped-bg: rgba(255, 255, 255, 0.025);
    --table-border: rgba(134, 211, 207, 0.1);
    --action-btn-hover-shadow: 0 8px 18px rgba(0, 0, 0, 0.24);
    --alert-danger-bg: rgba(139, 45, 61, 0.22);
    --alert-danger-border: rgba(207, 77, 77, 0.24);
    --alert-danger-text: #f4c8cf;
    --shadow-soft: 0 16px 40px rgba(0, 0, 0, 0.28);
    --shadow-card: 0 10px 28px rgba(0, 0, 0, 0.24);
}

@media (prefers-color-scheme: dark) {
    html[data-theme="system"] {
        --surface-color: rgba(22, 31, 38, 0.94);
        --surface-border: rgba(134, 211, 207, 0.16);
        --text-color: #e5eff3;
        --muted-color: #bccbd2;
        --page-bg-start: #0f161c;
        --page-bg-end: #121d24;
        --page-radial: rgba(46, 153, 146, 0.18);
        --table-head-bg: #152028;
        --table-head-text: #eaf4f7;
        --table-head-hover-bg: #20303b;
        --table-head-hover-text: #f3fbfd;
        --table-hover: rgba(255, 255, 255, 0.03);
        --table-mobile-card: rgba(19, 27, 33, 0.98);
        --table-mobile-header: rgba(89, 181, 174, 0.12);
        --input-bg: rgba(15, 22, 28, 0.94);
        --input-border: rgba(134, 211, 207, 0.18);
        --chip-bg: rgba(255, 255, 255, 0.08);
        --chip-border: rgba(255, 255, 255, 0.12);
        --chip-text: #eaf4f7;
        --tab-bg: rgba(15, 22, 28, 0.88);
        --tab-hover-bg: rgba(89, 181, 174, 0.14);
        --tab-hover-text: #f5fbfc;
        --header-btn-hover-bg: rgba(255, 255, 255, 0.18);
        --header-btn-hover-border: rgba(255, 255, 255, 0.52);
        --login-card-bg: rgba(22, 31, 38, 0.96);
        --role-option-bg: rgba(15, 22, 28, 0.92);
        --theme-btn-bg: rgba(15, 22, 28, 0.96);
        --theme-btn-border: rgba(255, 255, 255, 0.12);
        --theme-btn-text: #e5eff3;
        --theme-btn-hover: rgba(28, 41, 50, 0.98);
        --theme-btn-active-bg: rgba(89, 181, 174, 0.18);
        --theme-btn-active-text: #f5fbfc;
        --theme-btn-shadow: 0 4px 12px rgba(0, 0, 0, 0.22);
        --theme-btn-ring: rgba(134, 211, 207, 0.34);
        --overlay-bg: rgba(0, 0, 0, 0.64);
        --modal-bg: rgba(22, 31, 38, 0.98);
        --modal-border: rgba(134, 211, 207, 0.14);
        --table-bg: rgba(18, 26, 32, 0.86);
        --table-striped-bg: rgba(255, 255, 255, 0.025);
        --table-border: rgba(134, 211, 207, 0.1);
        --action-btn-hover-shadow: 0 8px 18px rgba(0, 0, 0, 0.24);
        --alert-danger-bg: rgba(139, 45, 61, 0.22);
        --alert-danger-border: rgba(207, 77, 77, 0.24);
        --alert-danger-text: #f4c8cf;
        --shadow-soft: 0 16px 40px rgba(0, 0, 0, 0.28);
        --shadow-card: 0 10px 28px rgba(0, 0, 0, 0.24);
    }
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text-color);
    background:
        radial-gradient(circle at top left, var(--page-radial), transparent 28%),
        linear-gradient(180deg, var(--page-bg-start) 0%, var(--page-bg-end) 100%);
    overflow-x: hidden;
    min-height: 100vh;
    transition: background 0.2s ease, color 0.2s ease;
}

.container-fluid {
    max-width: 1440px;
    padding: 16px;
}

.app-header {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-deep));
    color: #fff;
    border-radius: 24px;
    padding: 20px 22px;
    box-shadow: var(--shadow-soft);
}

.app-kicker {
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: 0.72rem;
    opacity: 0.72;
    margin-bottom: 6px;
}

.app-title-wrap h1 {
    font-size: clamp(1.4rem, 2.4vw, 2.2rem);
    line-height: 1.1;
}

.header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}

.user-chip {
    background: var(--chip-bg);
    border: 1px solid var(--chip-border);
    border-radius: 999px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    line-height: 1;
}

.user-chip-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    opacity: 0.9;
}

.header-logout {
    border-radius: 999px;
    border-color: rgba(255, 255, 255, 0.45);
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.header-reload {
    border-radius: 999px;
    border-color: rgba(255, 255, 255, 0.45);
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.header-logout i,
.header-reload i,
.header-logout:hover i,
.header-reload:hover i,
.header-logout:focus-visible i,
.header-reload:focus-visible i {
    color: inherit;
    font-size: 1rem;
}

.theme-picker {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--chip-bg);
    border: 1px solid var(--chip-border);
    border-radius: 999px;
    padding: 6px 10px;
}

.theme-picker-label {
    margin: 0;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--chip-text);
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.theme-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 999px;
    border: 1px solid var(--theme-btn-border);
    background: var(--theme-btn-bg);
    color: var(--theme-btn-text);
    box-shadow: var(--theme-btn-shadow);
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.theme-btn i {
    font-size: 0.98rem;
}

.theme-btn:hover {
    background: var(--theme-btn-hover);
    color: var(--theme-btn-active-text);
    transform: translateY(-1px);
}

.theme-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 0.2rem var(--theme-btn-ring);
}

.theme-btn.active {
    background: var(--theme-btn-active-bg);
    color: var(--theme-btn-active-text);
    border-color: rgba(255, 255, 255, 0.28);
    box-shadow: 0 0 0 0.14rem var(--theme-btn-ring), var(--theme-btn-shadow);
}

.header-logout:hover {
    background: var(--header-btn-hover-bg);
    border-color: var(--header-btn-hover-border);
    color: #fff;
}

.header-reload:hover {
    background: var(--header-btn-hover-bg);
    border-color: var(--header-btn-hover-border);
    color: #fff;
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--overlay-bg);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.toast-container-custom {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast-message {
    min-width: 240px;
    max-width: 360px;
    padding: 12px 16px;
    border-radius: 16px;
    color: #fff;
    box-shadow: var(--shadow-card);
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast-visible {
    opacity: 1;
    transform: translateY(0);
}

.toast-success {
    background: linear-gradient(135deg, #1f8f5f, #16724a);
}

.toast-error {
    background: linear-gradient(135deg, #cf4d4d, #a83535);
}

.toast-info {
    background: linear-gradient(135deg, #2f7ca8, #215f83);
}

.table-responsive {
    max-height: 600px;
    overflow-y: auto;
    overflow-x: auto;
    scrollbar-width: thin;
}

@media (hover: none) and (pointer: coarse) {
    .table-responsive {
        scrollbar-width: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-y: contain;
        touch-action: pan-y;
    }

    .table-responsive::-webkit-scrollbar {
        width: 18px;
        height: 18px;
    }

    .table-responsive::-webkit-scrollbar-thumb {
        background: rgba(15, 108, 104, 0.48);
        border-radius: 999px;
        border: 4px solid transparent;
        background-clip: padding-box;
    }

    .table-responsive::-webkit-scrollbar-track {
        background: rgba(15, 108, 104, 0.1);
        border-radius: 999px;
    }
}

/* Status badges */
.status-badge {
    display: inline-block;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.status-0 {
    background-color: #e7ecef;
    color: #42535c;
}

.status-1 {
    background-color: #beddff;
    color: #0d4f86;
}

.status-2 {
    background-color: #ffe59a;
    color: #6f5200;
}

.status-3 {
    background-color: #dbf3e6;
    color: #17613d;
}

.status-4 {
    background-color: #f8dfe2;
    color: #8b2d3d;
}

.view-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.25rem;
    min-height: 1.9rem;
    padding: 0.2rem 0.7rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--surface-strong) 82%, white 18%);
    color: var(--surface-strong-text);
    font-size: 0.82rem;
    font-weight: 700;
    box-shadow: var(--shadow-soft);
}

/* Action buttons */
.action-buttons {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    width: 100%;
}

.action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 7px 10px;
    font-size: 12px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s, box-shadow 0.2s;
    min-height: 38px;
    font-weight: 600;
}

.icon-only-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    min-height: 42px;
    padding-left: 10px;
    padding-right: 10px;
}

.icon-only-btn i {
    font-size: 1rem;
    line-height: 1;
}

.action-btn:hover {
    transform: translateY(-1px);
    opacity: 0.97;
    box-shadow: var(--action-btn-hover-shadow);
    filter: saturate(1.05);
}

.btn-announce-all {
    background-color: #485f7a;
    color: white;
}

.btn-announce-class {
    background-color: #2f7ca8;
    color: white;
}

.btn-announce-cancel {
    background-color: #cf4d4d;
    color: white;
}

.btn-announce-close {
    background-color: #1f8f5f;
    color: white;
}

.activities-mobile-flag {
    display: none;
    align-items: center;
    justify-content: flex-start;
    min-height: 1.25rem;
    font-size: 1rem;
}

.activities-flag-yes {
    color: #1f8f5f;
}

.activities-flag-no {
    color: var(--muted-color);
}

/* Table styling */
.table thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--table-head-bg);
    color: var(--table-head-text);
    white-space: nowrap;
}

.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--text-color);
    --bs-table-striped-bg: var(--table-striped-bg);
    --bs-table-striped-color: var(--text-color);
    --bs-table-hover-bg: var(--table-hover);
    --bs-table-hover-color: var(--text-color);
    --bs-table-border-color: var(--table-border);
    color: var(--text-color);
}

.table tbody td {
    background: var(--table-bg);
}

.table thead th.sortable {
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s;
}

.table thead th.sortable:hover {
    background-color: var(--table-head-hover-bg);
    color: var(--table-head-hover-text);
}

.sort-icon {
    display: inline-block;
    margin-left: 5px;
    font-size: 0.8em;
    opacity: 0.5;
    min-width: 12px;
}

.sort-icon.sort-asc,
.sort-icon.sort-desc {
    opacity: 1;
    font-weight: bold;
}

.table tbody tr:hover {
    background-color: var(--table-hover);
}

.student-row-absent td {
    color: #5f6b76;
    background: color-mix(in srgb, var(--table-bg) 58%, #a7b1b8 42%) !important;
}

.student-row-absent {
    border-color: #98a4ad !important;
    background: color-mix(in srgb, var(--table-mobile-card) 62%, #a7b1b8 38%) !important;
}

.student-row-absent,
.student-row-absent * {
    cursor: not-allowed !important;
}

.student-row-absent .action-buttons {
    pointer-events: none;
}

.table tbody tr.student-row-absent:hover {
    background-color: transparent;
}

.student-row-absent .status-badge {
    opacity: 0.82;
    filter: grayscale(0.35);
}

.student-row-exception td {
    box-shadow: inset 0 0 0 1px rgba(168, 97, 18, 0.22);
}

.student-row-exception:not(.student-row-called):not(.student-row-answered):not(.student-row-closed):not(.student-row-rejected):not(.student-row-absent) td {
    background: rgba(255, 244, 214, 0.22);
}

#classesTable tbody tr.student-row-called > td,
#zonesTable tbody tr.student-row-called > td {
    background: rgba(180, 220, 255, 0.95) !important;
}

#classesTable tbody tr.student-row-answered > td,
#zonesTable tbody tr.student-row-answered > td {
    background: rgba(255, 227, 122, 0.82) !important;
}

#classesTable tbody tr.student-row-closed > td,
#zonesTable tbody tr.student-row-closed > td {
    background: rgba(219, 243, 230, 0.74) !important;
}

#classesTable tbody tr.student-row-rejected > td,
#zonesTable tbody tr.student-row-rejected > td {
    background: rgba(248, 223, 226, 0.74) !important;
}

#classesTable tbody tr.student-row-called:hover > td,
#zonesTable tbody tr.student-row-called:hover > td,
#classesTable tbody tr.student-row-answered:hover > td,
#zonesTable tbody tr.student-row-answered:hover > td,
#classesTable tbody tr.student-row-closed:hover > td,
#zonesTable tbody tr.student-row-closed:hover > td,
#classesTable tbody tr.student-row-rejected:hover > td,
#zonesTable tbody tr.student-row-rejected:hover > td {
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28), 0 0 16px rgba(15, 108, 104, 0.16);
    filter: saturate(1.03);
}

.student-row-absent .action-btn[disabled] {
    opacity: 0.72;
    cursor: not-allowed;
    box-shadow: none;
}

.student-row-absent.student-row-called td,
.student-row-absent.student-row-answered td,
.student-row-absent.student-row-closed td,
.student-row-absent.student-row-rejected td,
.student-row-absent.student-row-exception td {
    background: color-mix(in srgb, var(--table-bg) 58%, #a7b1b8 42%) !important;
    box-shadow: none;
}

html[data-theme="dark"] .status-1 {
    background-color: rgba(54, 132, 214, 0.38);
    color: #d9efff;
}

html[data-theme="dark"] .status-2 {
    background-color: rgba(226, 181, 39, 0.42);
    color: #fff2b0;
}

html[data-theme="dark"] #classesTable tbody tr.student-row-called > td,
html[data-theme="dark"] #zonesTable tbody tr.student-row-called > td {
    background: rgba(34, 79, 126, 0.78) !important;
}

html[data-theme="dark"] #classesTable tbody tr.student-row-answered > td,
html[data-theme="dark"] #zonesTable tbody tr.student-row-answered > td {
    background: rgba(126, 95, 14, 0.74) !important;
}

html[data-theme="dark"] #classesTable tbody tr.student-row-called:hover > td,
html[data-theme="dark"] #zonesTable tbody tr.student-row-called:hover > td,
html[data-theme="dark"] #classesTable tbody tr.student-row-answered:hover > td,
html[data-theme="dark"] #zonesTable tbody tr.student-row-answered:hover > td,
html[data-theme="dark"] #classesTable tbody tr.student-row-closed:hover > td,
html[data-theme="dark"] #zonesTable tbody tr.student-row-closed:hover > td,
html[data-theme="dark"] #classesTable tbody tr.student-row-rejected:hover > td,
html[data-theme="dark"] #zonesTable tbody tr.student-row-rejected:hover > td {
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16), 0 0 18px rgba(110, 189, 255, 0.16);
}

@media (prefers-color-scheme: dark) {
    html[data-theme="system"] .status-1 {
        background-color: rgba(54, 132, 214, 0.38);
        color: #d9efff;
    }

    html[data-theme="system"] .status-2 {
        background-color: rgba(226, 181, 39, 0.42);
        color: #fff2b0;
    }

    html[data-theme="system"] #classesTable tbody tr.student-row-called > td,
    html[data-theme="system"] #zonesTable tbody tr.student-row-called > td {
        background: rgba(34, 79, 126, 0.78) !important;
    }

    html[data-theme="system"] #classesTable tbody tr.student-row-answered > td,
    html[data-theme="system"] #zonesTable tbody tr.student-row-answered > td {
        background: rgba(126, 95, 14, 0.74) !important;
    }

    html[data-theme="system"] #classesTable tbody tr.student-row-called:hover > td,
    html[data-theme="system"] #zonesTable tbody tr.student-row-called:hover > td,
    html[data-theme="system"] #classesTable tbody tr.student-row-answered:hover > td,
    html[data-theme="system"] #zonesTable tbody tr.student-row-answered:hover > td,
    html[data-theme="system"] #classesTable tbody tr.student-row-closed:hover > td,
    html[data-theme="system"] #zonesTable tbody tr.student-row-closed:hover > td,
    html[data-theme="system"] #classesTable tbody tr.student-row-rejected:hover > td,
    html[data-theme="system"] #zonesTable tbody tr.student-row-rejected:hover > td {
        box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16), 0 0 18px rgba(110, 189, 255, 0.16);
    }
}

.student-name-wrap {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.student-flag {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 4px 8px;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.01em;
}

.exception-flag {
    background: rgba(216, 162, 39, 0.18);
    color: #8b5b08;
    border: 1px solid rgba(168, 97, 18, 0.22);
}

html[data-theme="dark"] .exception-flag {
    background: rgba(216, 162, 39, 0.18);
    color: #ffe39b;
    border-color: rgba(255, 214, 128, 0.18);
}

@media (prefers-color-scheme: dark) {
    html[data-theme="system"] .exception-flag {
        background: rgba(216, 162, 39, 0.18);
        color: #ffe39b;
        border-color: rgba(255, 214, 128, 0.18);
    }
}

/* Absent indicator */
.absent-yes {
    color: #b55050;
    font-weight: bold;
}

.absent-no {
    color: #28a745;
}

/* Card styling */
.card {
    box-shadow: var(--shadow-card);
    border-radius: 24px;
    border: 1px solid var(--surface-border);
    background: var(--surface-color);
    backdrop-filter: blur(12px);
    color: var(--text-color);
}

.card-header {
    border-radius: 24px 24px 0 0 !important;
    border-bottom: 1px solid rgba(15, 108, 104, 0.08);
}

.card-body,
.modal-body,
.modal-title,
.form-label,
.form-check-label,
.table,
.table td,
.table th {
    color: var(--text-color);
}

.text-muted {
    color: var(--muted-color) !important;
}

.filters-card .card-header,
.table-card .card-header {
    background: transparent !important;
    color: var(--text-color) !important;
}

.nav-tabs {
    gap: 10px;
    border-bottom: none;
    margin-top: 8px;
}

.nav-tabs .nav-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 999px;
    color: var(--muted-color);
    background: var(--tab-bg);
    box-shadow: var(--shadow-card);
    padding: 12px 18px;
    font-weight: 700;
}

.nav-tabs .nav-link.active {
    background: var(--primary-color);
    color: #fff;
}

.nav-tabs .nav-link:hover:not(.active),
.nav-tabs .nav-link:focus-visible:not(.active) {
    background: var(--tab-hover-bg);
    color: var(--tab-hover-text);
}

.mini-filter-tabs {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.mini-filter-tab {
    border: 1px solid var(--surface-border);
    background: var(--tab-bg);
    color: var(--muted-color);
    border-radius: 999px;
    padding: 8px 12px;
    font-size: 0.84rem;
    font-weight: 700;
    line-height: 1;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.mini-filter-tab:hover,
.mini-filter-tab:focus-visible {
    background: var(--tab-hover-bg);
    color: var(--tab-hover-text);
    border-color: rgba(15, 108, 104, 0.24);
}

.mini-filter-tab.active {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

.zones-search-wrap {
    position: relative;
    min-width: 220px;
    flex: 0 1 280px;
}

.zones-search-input {
    min-height: 38px;
    padding-left: 2.15rem;
    border-radius: 999px;
}

.zones-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted-color);
    pointer-events: none;
}

.table-card .card-header {
    padding-bottom: 0;
}

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

.btn-primary:hover,
.btn-primary:focus {
    background: var(--primary-deep);
    border-color: var(--primary-deep);
}

.form-select,
.form-control {
    min-height: 46px;
    border-radius: 14px;
    border-color: var(--input-border);
    background: var(--input-bg);
    color: var(--text-color);
}

.form-select:focus,
.form-control:focus {
    border-color: rgba(15, 108, 104, 0.55);
    box-shadow: 0 0 0 0.25rem rgba(15, 108, 104, 0.14);
}

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-shell {
    width: 100%;
    max-width: 460px;
}

.login-card {
    background: var(--login-card-bg);
    border-radius: 28px;
    padding: 32px;
    box-shadow: var(--shadow-soft);
    border: 1px solid rgba(15, 108, 104, 0.1);
}

.login-topbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 18px;
}

.login-topbar .theme-picker {
    background: rgba(15, 108, 104, 0.08);
    border-color: rgba(15, 108, 104, 0.12);
}

.login-topbar .theme-picker-label {
    color: var(--muted-color);
}

.login-topbar .theme-btn {
    background: var(--input-bg);
    border-color: var(--input-border);
    color: var(--text-color);
}

.login-topbar .theme-btn:hover {
    color: var(--primary-deep);
}

.login-brand {
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-size: 0.76rem;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.login-title {
    margin-bottom: 8px;
}

.login-subtitle {
    color: var(--muted-color);
    margin-bottom: 24px;
}

.role-picker {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.role-option {
    border: 1px solid rgba(15, 108, 104, 0.12);
    border-radius: 16px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    background: var(--role-option-bg);
    color: var(--text-color);
}

.listener-shell {
    max-width: 1200px;
}

.listener-board .card-body {
    padding-top: 18px;
}

.listener-audio-prompt {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 16px;
    margin-bottom: 16px;
    border: 1px solid rgba(15, 108, 104, 0.18);
    border-radius: 18px;
    background: color-mix(in srgb, var(--table-mobile-card) 72%, var(--page-radial) 28%);
}

.listener-audio-prompt strong {
    display: block;
    margin-bottom: 2px;
}

.listener-empty {
    padding: 30px 18px;
    text-align: center;
    color: var(--muted-color);
    border: 1px dashed rgba(15, 108, 104, 0.2);
    border-radius: 18px;
}

.listener-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

.listener-card {
    border: 1px solid rgba(15, 108, 104, 0.12);
    border-radius: 20px;
    padding: 18px;
    background: var(--table-mobile-card);
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.listener-card.status-2 {
    border-color: rgba(216, 162, 39, 0.42);
    background: linear-gradient(180deg, rgba(255, 244, 214, 0.95), rgba(255, 250, 236, 0.98));
}

.listener-card.status-3 {
    border-color: rgba(31, 143, 95, 0.36);
    background: linear-gradient(180deg, rgba(219, 243, 230, 0.96), rgba(243, 252, 247, 0.98));
}

.listener-card.status-4 {
    border-color: rgba(207, 77, 77, 0.28);
    background: linear-gradient(180deg, rgba(248, 223, 226, 0.95), rgba(253, 244, 246, 0.98));
}

.listener-card-processed {
    box-shadow: 0 0 0 1px rgba(15, 108, 104, 0.08), var(--shadow-card);
}

.listener-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.listener-card-top > :first-child {
    min-width: 0;
    flex: 1 1 auto;
}

.listener-card-top .status-badge {
    flex-shrink: 0;
    align-self: flex-start;
 }

.listener-card-top h3 {
    margin: 0;
    font-size: 1.05rem;
    line-height: 1.25;
    min-height: 2.65rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.listener-label {
    display: block;
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted-color);
    margin-bottom: 6px;
}

.listener-meta {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.listener-meta strong {
    display: block;
}

.listener-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: auto;
}

.modal-content {
    background: var(--modal-bg);
    color: var(--text-color);
    border: 1px solid var(--modal-border);
    box-shadow: var(--shadow-soft);
}

.modal-header,
.modal-footer {
    border-color: var(--table-border);
}

.btn-secondary {
    background: #6d7b85;
    border-color: #6d7b85;
}

.btn-secondary:hover,
.btn-secondary:focus {
    background: #59666f;
    border-color: #59666f;
}

.alert-danger {
    background: var(--alert-danger-bg);
    border-color: var(--alert-danger-border);
    color: var(--alert-danger-text);
}

/* Filters accordion toggle */
#filtersHeading .btn-link {
    font-size: 1rem;
}

#filtersHeading .btn-link:hover {
    opacity: 0.9;
}

#filtersHeading .btn-link .bi-chevron-down {
    transition: transform 0.3s ease;
}

#filtersHeading .btn-link[aria-expanded="true"] .bi-chevron-down {
    transform: rotate(180deg);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .toast-container-custom {
        top: 14px;
        right: 12px;
        left: 12px;
    }

    .toast-message {
        min-width: 0;
        max-width: none;
    }

    .container-fluid {
        padding: 12px;
    }

    .app-header {
        border-radius: 20px;
        padding: 18px 16px;
    }

    .header-actions {
        justify-content: space-between;
    }

    .theme-picker {
        width: 100%;
        justify-content: center;
    }

    .user-chip,
    .header-logout,
    .header-reload {
        width: 100%;
        justify-content: center;
    }

    .nav-tabs {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .nav-tabs .nav-link {
        width: 100%;
        text-align: center;
    }

    .action-btn .btn-text {
        display: inline;
    }

    .card-header h5 {
        font-size: 1rem;
    }

    .card-header .btn {
        font-size: 0.875rem;
    }

    .filters-card .card-body {
        padding-top: 12px;
    }

    .listener-meta {
        grid-template-columns: 1fr;
    }

    .zones-search-wrap {
        width: 100%;
        flex-basis: 100%;
    }

    .listener-actions {
        grid-template-columns: 1fr;
    }

    .listener-audio-prompt {
        flex-direction: column;
        align-items: stretch;
    }

    .role-picker {
        grid-template-columns: 1fr;
    }
}

/* Tablet adjustments */
@media (max-width: 1200px) and (min-width: 769px) {
    .table-responsive {
        overflow-x: clip;
    }

    .table-card .card-body {
        padding: 1rem;
    }

    .table-card .card-header {
        gap: 12px;
    }

    #classesTable,
    #zonesTable {
        width: 100%;
        table-layout: fixed;
    }

    #classesTable th,
    #classesTable td,
    #zonesTable th,
    #zonesTable td {
        white-space: normal;
        overflow-wrap: anywhere;
        word-break: break-word;
        vertical-align: middle;
        padding: 0.55rem 0.45rem;
    }

    #classesTable th,
    #zonesTable th {
        font-size: 0.79rem;
        line-height: 1.2;
    }

    #classesTable td,
    #zonesTable td {
        font-size: 0.84rem;
        line-height: 1.22;
    }

    #classesTable th:nth-child(1),
    #classesTable td:nth-child(1) {
        width: 24%;
    }

    #classesTable th:nth-child(2),
    #classesTable td:nth-child(2),
    #classesTable th:nth-child(3),
    #classesTable td:nth-child(3),
    #zonesTable th:nth-child(4),
    #zonesTable td:nth-child(4),
    #zonesTable th:nth-child(5),
    #zonesTable td:nth-child(5) {
        display: none;
    }

    #classesTable th:nth-child(4),
    #classesTable td:nth-child(4),
    #classesTable th:nth-child(6),
    #classesTable td:nth-child(6) {
        width: 14%;
    }

    #classesTable th:nth-child(5),
    #classesTable td:nth-child(5) {
        width: 20%;
    }

    #classesTable th:nth-child(7),
    #classesTable td:nth-child(7) {
        width: 26%;
    }

    #zonesTable th:nth-child(1),
    #zonesTable td:nth-child(1) {
        width: 18%;
    }

    #zonesTable th:nth-child(2),
    #zonesTable td:nth-child(2) {
        width: 10%;
    }

    #zonesTable th:nth-child(3),
    #zonesTable td:nth-child(3) {
        width: 14%;
    }

    #zonesTable th:nth-child(6),
    #zonesTable td:nth-child(6),
    #zonesTable th:nth-child(8),
    #zonesTable td:nth-child(8) {
        width: 12%;
    }

    #zonesTable th:nth-child(7),
    #zonesTable td:nth-child(7) {
        width: 16%;
    }

    #zonesTable th:nth-child(9),
    #zonesTable td:nth-child(9) {
        width: 18%;
    }

    .mini-filter-tabs {
        width: 100%;
    }

    .mini-filter-tab {
        flex: 1 1 180px;
        justify-content: center;
        text-align: center;
    }

    .zones-search-wrap {
        flex: 1 1 240px;
    }

    .action-btn {
        min-width: 0;
        min-height: 34px;
        padding: 6px;
    }

    .status-badge {
        max-width: 100%;
        font-size: 0.72rem;
        padding: 4px 8px;
    }
}

/* Small mobile devices */
@media (max-width: 576px) {
    body {
        font-size: 0.9rem;
    }

    .container-fluid {
        padding: 10px;
    }

    h1 {
        font-size: 1.35rem;
    }

    .card {
        margin-bottom: 1rem;
    }

    .card-body {
        padding: 0.75rem;
    }

    .form-select,
    .form-control {
        font-size: 0.9rem;
    }

    .login-card {
        padding: 24px 20px;
        border-radius: 24px;
    }

    .table-responsive {
        max-height: none;
        overflow: visible;
    }

    #classesTable,
    #zonesTable {
        width: 100%;
        border-collapse: separate;
        border-spacing: 0 12px;
    }

    #classesTable thead,
    #zonesTable thead {
        display: none;
    }

    #classesTable tbody,
    #zonesTable tbody,
    #classesTable tr,
    #zonesTable tr,
    #classesTable td,
    #zonesTable td {
        display: block;
        width: 100%;
    }

    #classesTable tr,
    #zonesTable tr {
        margin-bottom: 12px;
        border: 1px solid var(--surface-border);
        border-radius: 18px;
        overflow: hidden;
        background: var(--table-mobile-card);
        box-shadow: var(--shadow-card);
    }

    #classesTable tr.student-row-absent,
    #zonesTable tr.student-row-absent {
        border-color: #98a4ad;
    }

    #classesTable td,
    #zonesTable td {
        position: relative;
        width: 100%;
        min-width: 0;
        padding: 0.7rem 0.85rem 0.7rem 7.8rem;
        border: 0;
        background: transparent !important;
        white-space: normal;
        overflow-wrap: anywhere;
        word-break: break-word;
        vertical-align: top;
    }

    #classesTable td::before,
    #zonesTable td::before {
        position: absolute;
        left: 0.85rem;
        top: 0.72rem;
        width: 6rem;
        font-size: 0.72rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        color: var(--muted-color);
        content: "";
    }

    #classesTable td:nth-child(1)::before {
        content: "Μαθητής";
    }

    #classesTable td:nth-child(2)::before {
        content: "Απών";
    }

    #classesTable td:nth-child(3)::before {
        content: "Κατάσταση";
    }

    #classesTable td:nth-child(4)::before {
        content: "Κλήση";
    }

    #classesTable td:nth-child(5)::before {
        content: "Απαντών";
    }

    #classesTable td:nth-child(6)::before {
        content: "Απάντηση";
    }

    #classesTable td:nth-child(7)::before {
        content: "Ενέργειες";
    }

    #zonesTable td:nth-child(1)::before {
        content: "Μαθητής";
    }

    #zonesTable td:nth-child(2)::before {
        content: "Τμήμα";
    }

    #zonesTable td:nth-child(3)::before {
        content: "Δραστηρ.";
    }

    #zonesTable td:nth-child(4)::before {
        content: "Απών";
    }

    #zonesTable td:nth-child(5)::before {
        content: "Κατάσταση";
    }

    #zonesTable td:nth-child(6)::before {
        content: "Κλήση";
    }

    #zonesTable td:nth-child(7)::before {
        content: "Απαντών";
    }

    #zonesTable td:nth-child(8)::before {
        content: "Απάντηση";
    }

    #zonesTable td:nth-child(9)::before {
        content: "Ενέργειες";
    }

    #classesTable td:nth-child(2),
    #classesTable td:nth-child(3),
    #zonesTable td:nth-child(4),
    #zonesTable td:nth-child(5) {
        display: none;
    }

    .activities-desktop-text {
        display: none;
    }

    .activities-mobile-flag {
        display: inline-flex;
    }

    .action-btn,
    .icon-only-btn {
        min-width: 0;
        width: 100%;
        min-height: 38px;
        padding: 6px;
    }

    .icon-only-btn i {
        font-size: 0.95rem;
    }

    .status-badge {
        max-width: 100%;
        font-size: 0.75rem;
        padding: 5px 8px;
    }

    .student-name-wrap {
        align-items: flex-start;
    }
}
