:root {
    color-scheme: light;

    --bg: #f1f4f8;
    --surface: #ffffff;
    --surface-2: #f7f9fc;
    --header-bg: rgba(241, 244, 248, 0.88);
    --border: #e2e7ee;
    --border-strong: #cdd5df;
    --text: #0f2133;
    --text-muted: #5b6a7b;
    --text-subtle: #8e9bab;

    --nav-bg: #0d2840;
    --nav-text: #b6c4d3;
    --nav-text-strong: #ffffff;
    --nav-label: #7f93a8;
    --nav-hover: rgba(255, 255, 255, 0.07);
    --nav-divider: rgba(255, 255, 255, 0.08);

    --accent: #0a72b8;
    --accent-hover: #075c95;
    --accent-soft: #e5f1fa;
    --accent-ring: rgba(10, 114, 184, 0.18);
    --brand-yellow: #ffe500;

    --success: #08754a;
    --success-dot: #16b46e;
    --success-soft: #e6f6ee;
    --danger: #c0282f;
    --danger-dot: #ef4444;
    --danger-soft: #fdeced;
    --warning: #8a4b06;
    --warning-soft: #fff6df;
    --warning-border: #f6d58c;
    --neutral-soft: #eef2f6;
    --neutral-dot: #94a3b8;

    --radius: 14px;
    --radius-sm: 9px;
    --shadow: 0 1px 2px rgba(15, 33, 51, 0.04), 0 1px 3px rgba(15, 33, 51, 0.04);
    --shadow-md: 0 6px 20px rgba(15, 33, 51, 0.08);
    --shadow-lg: 0 24px 48px rgba(15, 33, 51, 0.18);
    --backdrop: rgba(8, 20, 33, 0.5);
}

:root[data-theme="dark"] {
    color-scheme: dark;

    --bg: #0c1622;
    --surface: #13212f;
    --surface-2: #182a3b;
    --header-bg: rgba(12, 22, 34, 0.88);
    --border: #22364b;
    --border-strong: #2f4862;
    --text: #e6edf5;
    --text-muted: #9cadbf;
    --text-subtle: #6d8197;

    --nav-bg: #08111b;
    --nav-text: #9fb1c4;
    --nav-text-strong: #ffffff;
    --nav-label: #5f7389;
    --nav-hover: rgba(255, 255, 255, 0.06);
    --nav-divider: rgba(255, 255, 255, 0.07);

    --accent: #3b9de2;
    --accent-hover: #62b2ec;
    --accent-soft: rgba(59, 157, 226, 0.15);
    --accent-ring: rgba(59, 157, 226, 0.3);

    --success: #5fd39b;
    --success-dot: #34c47c;
    --success-soft: rgba(52, 196, 124, 0.14);
    --danger: #ff8a8f;
    --danger-dot: #f05252;
    --danger-soft: rgba(240, 82, 82, 0.14);
    --warning: #f6c56b;
    --warning-soft: rgba(246, 197, 107, 0.1);
    --warning-border: rgba(246, 197, 107, 0.3);
    --neutral-soft: #1d3042;
    --neutral-dot: #6d8197;

    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 24px 48px rgba(0, 0, 0, 0.5);
    --backdrop: rgba(0, 0, 0, 0.6);
}

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

body {
    font-family: 'Poppins', 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.25s ease, color 0.25s ease;
}

a {
    color: inherit;
}

svg {
    flex-shrink: 0;
}

/* App shell */

.app {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 252px;
    flex-shrink: 0;
    background: var(--nav-bg);
    color: var(--nav-text);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    transition: background-color 0.25s ease;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 22px 18px 20px;
}

.brand-logo {
    width: 46px;
    height: 46px;
    border-radius: 10px;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.brand-name {
    color: var(--nav-text-strong);
    font-weight: 600;
    font-size: 15px;
    line-height: 1.2;
}

.brand-sub {
    font-size: 11.5px;
    color: var(--nav-text);
}

.nav {
    padding: 6px 0 16px 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-label {
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--nav-label);
    padding: 0 12px;
    margin: 16px 0 6px;
}

.nav-label:first-child {
    margin-top: 4px;
}

.nav a,
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 14px;
    border: none;
    border-radius: 12px 0 0 12px;
    background: transparent;
    font: inherit;
    font-weight: 500;
    font-size: 13.5px;
    text-align: left;
    text-decoration: none;
    color: var(--nav-text);
    cursor: pointer;
    transition: background-color 0.18s, color 0.18s, padding-left 0.18s;
}

.nav a:hover,
.nav-item:hover {
    background: var(--nav-hover);
    color: var(--nav-text-strong);
    padding-left: 17px;
}

.nav a.active {
    background: var(--bg);
    color: var(--text);
    padding-left: 14px;
    position: relative;
}

.nav a.active svg {
    color: var(--accent);
    opacity: 1;
}

.nav svg {
    width: 18px;
    height: 18px;
    opacity: 0.85;
}

.theme-switch {
    margin-left: auto;
    width: 36px;
    height: 20px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.18);
    position: relative;
    flex-shrink: 0;
    transition: background-color 0.2s;
}

.theme-switch::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    transition: transform 0.2s ease;
}

:root[data-theme="dark"] .theme-switch {
    background: var(--accent);
}

:root[data-theme="dark"] .theme-switch::after {
    transform: translateX(16px);
}

.theme-icon-dark,
:root[data-theme="dark"] .theme-icon-light {
    display: none;
}

:root[data-theme="dark"] .theme-icon-dark {
    display: inline;
}

.main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.page-header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--header-bg);
    backdrop-filter: saturate(160%) blur(10px);
    padding: 20px 32px 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.page-heading {
    flex: 1 1 280px;
    min-width: 0;
}

.page-header .header-actions,
.page-header > .btn {
    margin-left: auto;
}

.header-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.breadcrumb {
    font-size: 12.5px;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.breadcrumb a {
    color: var(--text-muted);
    text-decoration: none;
}

.breadcrumb a:hover {
    color: var(--accent);
}

.page-title {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.page-subtitle {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 2px;
}

.content {
    padding: 8px 32px 40px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Header account and mobile menu */

.account {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 4px 4px 5px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    flex-shrink: 0;
}

.user-avatar.small {
    width: 30px;
    height: 30px;
    font-size: 12px;
}

.user-meta {
    min-width: 0;
    line-height: 1.2;
}

.account .user-name {
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    max-width: 140px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.account .user-role {
    color: var(--text-muted);
    font-size: 11px;
}

.logout-btn {
    border-radius: 999px;
    color: var(--text-muted);
}

.logout-btn:hover {
    background: var(--danger-soft);
    color: var(--danger);
    border-color: transparent;
}

.menu-toggle,
.nav-close {
    display: none;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    transition: transform 0.15s;
}

.menu-toggle:active,
.nav-close:active {
    transform: scale(0.94);
}

.menu-toggle svg,
.nav-close svg {
    width: 20px;
    height: 20px;
}

.nav-close {
    margin-left: auto;
    width: 34px;
    height: 34px;
    background: transparent;
    border-color: rgba(255, 255, 255, 0.14);
    color: var(--nav-text-strong);
}

.nav-backdrop {
    display: none;
}

/* Building blocks */

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: background-color 0.25s, border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.search {
    position: relative;
    flex: 1;
    min-width: 240px;
    display: flex;
    gap: 8px;
}

.search-field {
    position: relative;
    flex: 1;
}

.search-field svg {
    position: absolute;
    left: 13px;
    top: 50%;
    transform: translateY(-50%);
    width: 17px;
    height: 17px;
    color: var(--text-subtle);
    pointer-events: none;
}

.input {
    width: 100%;
    height: 42px;
    padding: 0 12px 0 38px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font: inherit;
    color: var(--text);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s, background-color 0.25s;
}

.input::placeholder {
    color: var(--text-subtle);
}

.input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring);
}

.select {
    padding-left: 12px;
    height: 44px;
    appearance: auto;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 42px;
    padding: 0 18px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-weight: 500;
    font-size: 13.5px;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s, transform 0.1s;
}

.btn:hover {
    background: var(--surface-2);
}

.btn:active {
    transform: translateY(1px);
}

.btn svg {
    width: 17px;
    height: 17px;
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    box-shadow: 0 2px 6px var(--accent-ring);
}

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    box-shadow: 0 6px 16px var(--accent-ring);
}

.btn-ghost {
    border-color: transparent;
    background: transparent;
    color: var(--text-muted);
}

.btn-sm {
    height: 32px;
    padding: 0 12px;
    font-size: 12.5px;
}

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

.btn-danger:hover {
    background: var(--danger-soft);
    border-color: var(--danger-soft);
}

.btn-danger-solid {
    background: var(--danger-dot);
    border-color: var(--danger-dot);
    color: #fff;
}

.btn-danger-solid:hover {
    background: #b91c1c;
    border-color: #b91c1c;
}

.btn-block {
    width: 100%;
    height: 46px;
    margin-top: 8px;
}

.link-btn {
    border: none;
    background: none;
    font: inherit;
    font-weight: 600;
    color: inherit;
    text-decoration: underline;
    cursor: pointer;
}

.segmented {
    display: inline-flex;
    padding: 3px;
    gap: 2px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
}

.segmented a {
    padding: 0 16px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 13px;
    transition: background-color 0.15s, color 0.15s;
}

.segmented a:hover {
    color: var(--text);
    background: var(--surface-2);
}

.segmented a.active {
    background: var(--accent);
    color: #fff;
}

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

.section-title {
    font-size: 15px;
    font-weight: 600;
}

.tag {
    font-size: 11.5px;
    padding: 2px 9px;
    border-radius: 999px;
    background: var(--neutral-soft);
    color: var(--text-muted);
    font-weight: 500;
}

.tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.alert {
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    background: var(--danger-soft);
    color: var(--danger);
    border: 1px solid transparent;
    margin-bottom: 18px;
}

.alert-success {
    background: var(--success-soft);
    color: var(--success);
    margin-bottom: 0;
}

.alert-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.empty-state {
    padding: 48px 20px;
    text-align: center;
    color: var(--text-muted);
}

.empty-state strong {
    display: block;
    color: var(--text);
    font-size: 15px;
    margin-bottom: 4px;
}

/* Stats */

.stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.stats-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stat {
    padding: 18px 20px;
}

.stat-label {
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.stat-value {
    font-size: 28px;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-top: 4px;
}

.stat-filter {
    display: block;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.stat-filter:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-filter.active {
    border-color: var(--accent);
    background: var(--accent-soft);
    box-shadow: 0 0 0 1px var(--accent);
}

.stat-filter.active .stat-label {
    color: var(--accent);
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.dot.in { background: var(--success-dot); }
.dot.out { background: var(--danger-dot); }
.dot.none { background: var(--neutral-dot); }
.dot.all { background: var(--accent); }

/* Badges */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.badge.in { background: var(--success-soft); color: var(--success); }
.badge.out { background: var(--danger-soft); color: var(--danger); }
.badge.none { background: var(--neutral-soft); color: var(--text-muted); }

.badge .dot {
    width: 6px;
    height: 6px;
}

.badge .dot.in {
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { box-shadow: 0 0 0 0 rgba(22, 180, 110, 0.45); }
    50% { box-shadow: 0 0 0 4px rgba(22, 180, 110, 0); }
}

/* Student directory */

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}

.card-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    height: 100%;
    transition: background-color 0.25s, border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}

.card-link:hover .card {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.card-top {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--neutral-soft);
    border: 2px solid var(--surface);
    box-shadow: 0 0 0 1px var(--border);
    flex-shrink: 0;
    transition: transform 0.25s ease;
}

.card-link:hover .card .avatar {
    transform: scale(1.06);
}

.card-name {
    font-weight: 600;
    font-size: 14px;
    line-height: 1.3;
}

.card-id {
    font-size: 12px;
    color: var(--text-subtle);
    font-variant-numeric: tabular-nums;
}

.card-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    margin-top: auto;
}

.card-time {
    font-size: 11.5px;
    color: var(--text-subtle);
    text-align: right;
}

/* Profile */

.profile {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
}

.profile .avatar {
    width: 76px;
    height: 76px;
}

.profile-name {
    font-size: 20px;
    font-weight: 600;
}

.profile-meta {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 6px;
}

.profile-status {
    margin-left: auto;
    text-align: right;
}

.photo-form {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.photo-form .btn {
    cursor: pointer;
}

.photo-flash {
    font-size: 13px;
}

.photo-flash.ok { color: var(--success); }
.photo-flash.err { color: var(--danger); }

/* Tables */

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    text-align: left;
    padding: 11px 20px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table th:first-child {
    border-top-left-radius: var(--radius);
}

.table th:last-child {
    border-top-right-radius: var(--radius);
}

.table td {
    padding: 13px 20px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table tbody tr {
    transition: background-color 0.15s;
}

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

.cell-name {
    font-weight: 500;
}

.cell-time {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.cell-actions {
    text-align: right;
    width: 1%;
    white-space: nowrap;
}

.direction {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
}

.direction svg {
    width: 15px;
    height: 15px;
}

.direction.entry { color: var(--success); }
.direction.exit { color: var(--danger); }

/* Pagination */

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

.pagination {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.pagination a,
.pagination span {
    min-width: 34px;
    height: 34px;
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-weight: 500;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.pagination a:hover {
    background: var(--neutral-soft);
    color: var(--text);
}

.pagination .current {
    background: var(--accent);
    color: #fff;
}

.pagination .gap {
    min-width: 20px;
    padding: 0;
}

.pagination .disabled {
    color: var(--border-strong);
}

.pagination svg {
    width: 16px;
    height: 16px;
}

.cap-note {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 12px 20px;
    background: var(--warning-soft);
    border-top: 1px solid var(--warning-border);
    color: var(--warning);
    font-size: 13px;
    border-radius: 0 0 var(--radius) var(--radius);
}

.cap-note svg {
    width: 16px;
    height: 16px;
    margin-top: 2px;
}

/* Login */

.auth {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr 1fr;
}

.auth-aside {
    background: var(--nav-bg);
    color: var(--nav-text);
    padding: 48px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}

.auth-aside::after {
    content: "";
    position: absolute;
    right: -200px;
    bottom: -200px;
    width: 640px;
    height: 460px;
    transform: rotate(-24deg);
    background: repeating-linear-gradient(90deg, rgba(255, 229, 0, 0.08) 0 2px, transparent 2px 24px);
    -webkit-mask-image: linear-gradient(to top, #000 15%, transparent 80%);
    mask-image: linear-gradient(to top, #000 15%, transparent 80%);
    pointer-events: none;
}

.auth-aside .brand {
    padding: 0;
}

.auth-headline {
    color: #fff;
    font-size: 32px;
    font-weight: 600;
    line-height: 1.25;
    letter-spacing: -0.02em;
    max-width: 440px;
}

.auth-copy {
    margin-top: 12px;
    max-width: 400px;
}

.auth-foot {
    font-size: 12px;
    color: var(--nav-label);
}

.auth-main {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    background: var(--surface);
}

.auth-form-wrap {
    width: 100%;
    max-width: 360px;
}

.auth-form-wrap h1 {
    font-size: 26px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.auth-form-wrap > p {
    color: var(--text-muted);
    margin: 4px 0 28px;
}

.auth-note {
    margin-top: 24px;
    font-size: 12px;
    color: var(--text-subtle);
    text-align: center;
}

.auth-mobile-brand {
    display: none;
}

.field {
    margin-bottom: 16px;
}

.field label {
    display: block;
    font-weight: 500;
    font-size: 13px;
    color: var(--text);
    margin-bottom: 6px;
}

.field .input {
    padding-left: 12px;
    height: 44px;
}

.hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Password show/hide */

.password-field {
    position: relative;
    display: block;
}

.password-field .input {
    padding-right: 46px;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: 6px;
    transform: translateY(-50%);
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
}

.password-toggle:hover {
    background: var(--neutral-soft);
    color: var(--text);
}

.password-toggle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.password-toggle svg {
    width: 18px;
    height: 18px;
}

input::-ms-reveal,
input::-ms-clear {
    display: none;
}

/* Import */

.import-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    overflow: hidden;
}

.import-form {
    padding: 24px;
}

.import-help {
    padding: 24px;
    border-left: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-muted);
}

.import-help .section-title {
    color: var(--text);
}

.import-help ol,
.import-help ul {
    margin: 8px 0 0 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field .dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 180px;
    padding: 24px;
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface-2);
    text-align: center;
    cursor: pointer;
    position: relative;
    font-weight: 400;
    transition: border-color 0.15s, background-color 0.15s;
}

.field .dropzone:hover,
.field .dropzone.dragging {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.field .dropzone.has-file {
    border-style: solid;
    border-color: var(--accent);
}

.dropzone svg {
    width: 30px;
    height: 30px;
    color: var(--accent);
}

.dropzone-title {
    font-weight: 500;
    color: var(--text);
}

.dropzone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.confirm-bar {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.confirm-actions {
    display: flex;
    gap: 8px;
}

.panel-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
}

.reasons {
    margin: 0;
    padding-left: 16px;
    color: var(--danger);
}

/* Accounts */

.account-name {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.account-text {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}

.account-email {
    font-size: 12px;
    font-weight: 400;
    color: var(--text-muted);
}

.role-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    background: var(--neutral-soft);
    color: var(--text-muted);
}

.role-admin { background: var(--accent-soft); color: var(--accent); }
.role-teacher { background: var(--success-soft); color: var(--success); }

.role-disabled {
    background: var(--danger-soft);
    color: var(--danger);
    margin-left: 4px;
}

.row-disabled td {
    color: var(--text-subtle);
}

.row-disabled .user-avatar {
    background: var(--text-subtle);
}

.modal {
    width: min(480px, calc(100vw - 32px));
    margin: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 0;
    color: var(--text);
    background: var(--surface);
}

.modal-sm {
    width: min(420px, calc(100vw - 32px));
}

.modal::backdrop {
    background: var(--backdrop);
}

.modal[open] {
    animation: modal-in 0.18s ease-out;
}

@keyframes modal-in {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to { opacity: 1; transform: none; }
}

.modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border);
}

.modal-close {
    border: none;
    background: none;
    font-size: 24px;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 4px;
}

.modal-body {
    padding: 20px 24px 4px;
}

.modal-sm .modal-body {
    padding-bottom: 20px;
    color: var(--text-muted);
}

.modal-sm .modal-body strong {
    color: var(--text);
}

.modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
    border-radius: 0 0 var(--radius) var(--radius);
}

.role-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.field .role-option {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 400;
    margin: 0;
    transition: border-color 0.15s, background-color 0.15s;
}

.role-option span {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 12.5px;
}

.role-option strong {
    font-size: 14px;
    color: var(--text);
}

.role-option input {
    margin-top: 3px;
    accent-color: var(--accent);
}

.field .role-option:has(input:checked) {
    border-color: var(--accent);
    background: var(--accent-soft);
}

/* Page loading and entrance */

body.is-loading::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 100%;
    z-index: 1000;
    background: linear-gradient(90deg, transparent, var(--accent), var(--brand-yellow), transparent);
    background-size: 50% 100%;
    background-repeat: no-repeat;
    animation: loading-bar 0.9s ease-in-out infinite;
}

@keyframes loading-bar {
    from { background-position: -50% 0; }
    to { background-position: 150% 0; }
}

body.is-loading .main {
    opacity: 0.6;
    transition: opacity 0.15s;
}

.app.is-entering .content > * {
    animation: enter-up 0.35s ease both;
}

.app.is-entering .content > *:nth-child(2) { animation-delay: 0.04s; }
.app.is-entering .content > *:nth-child(3) { animation-delay: 0.08s; }
.app.is-entering .content > *:nth-child(4) { animation-delay: 0.12s; }
.app.is-entering .content > *:nth-child(n+5) { animation-delay: 0.16s; }

.app.is-entering .grid .card-link {
    animation: enter-up 0.35s ease both;
}

.app.is-entering .grid .card-link:nth-child(2) { animation-delay: 0.03s; }
.app.is-entering .grid .card-link:nth-child(3) { animation-delay: 0.06s; }
.app.is-entering .grid .card-link:nth-child(4) { animation-delay: 0.09s; }
.app.is-entering .grid .card-link:nth-child(n+5) { animation-delay: 0.12s; }

@keyframes enter-up {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

/* Responsive */

@media (max-width: 1280px) {
    .logout-btn span {
        display: none;
    }

    .logout-btn {
        width: 32px;
        padding: 0;
    }
}

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

@media (max-width: 900px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        height: 100%;
        width: min(280px, 84vw);
        z-index: 60;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
    }

    body.nav-open .sidebar {
        transform: none;
        box-shadow: 8px 0 32px rgba(0, 0, 0, 0.3);
    }

    .nav {
        padding-right: 12px;
    }

    .nav a,
    .nav-item {
        border-radius: 12px;
    }

    .nav-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 50;
        background: var(--backdrop);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.25s ease;
    }

    body.nav-open .nav-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    body.nav-open {
        overflow: hidden;
    }

    .menu-toggle,
    .nav-close {
        display: inline-grid;
    }

    .page-header {
        padding: 14px 16px;
    }

    .menu-toggle {
        order: -2;
    }

    .account {
        order: -1;
        margin-left: auto;
    }

    .account .user-meta,
    .logout-btn span {
        display: none;
    }

    .page-header .page-heading {
        order: 0;
        flex-basis: 100%;
    }

    .page-header > .btn,
    .page-header .header-actions {
        order: 1;
        margin-left: 0;
    }

    .content {
        padding-left: 16px;
        padding-right: 16px;
    }

    .import-card {
        grid-template-columns: 1fr;
    }

    .import-help {
        border-left: none;
        border-top: 1px solid var(--border);
    }

    .stats-3 {
        grid-template-columns: 1fr;
    }

    .auth {
        grid-template-columns: 1fr;
    }

    .auth-aside {
        display: none;
    }

    .auth-mobile-brand {
        display: flex;
        align-items: center;
        gap: 10px;
        margin-bottom: 28px;
    }

    .auth-mobile-brand .brand-logo {
        width: 42px;
        height: 42px;
    }
}

@media (max-width: 560px) {
    .stats {
        gap: 10px;
    }

    .stat-value {
        font-size: 22px;
    }

    .profile-status {
        margin-left: 0;
        text-align: left;
    }

    .table th,
    .table td {
        padding-left: 14px;
        padding-right: 14px;
    }

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

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Header school name (PC) */

.header-brand {
    order: -2;
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    font-size: 13px;
    white-space: nowrap;
}

.header-brand-name {
    font-weight: 600;
    color: var(--text);
    position: relative;
    padding-left: 12px;
}

.header-brand-name::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    width: 4px;
    height: 16px;
    border-radius: 2px;
    transform: translateY(-50%);
    background: var(--brand-yellow);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06);
}

.header-brand-sep {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--text-subtle);
}

.header-brand-sub {
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-break {
    order: 0;
    flex-basis: 100%;
    height: 0;
}

.page-header .account {
    order: -1;
}

.page-header .page-heading {
    order: 1;
}

.page-header > .btn,
.page-header .header-actions {
    order: 2;
}

@media (min-width: 901px) {
    .page-header {
        padding-top: 16px;
        row-gap: 10px;
    }

    .sidebar .brand {
        justify-content: center;
        padding: 26px 18px 18px;
    }

    .sidebar .brand-text {
        display: none;
    }

    .sidebar .brand-logo {
        width: 64px;
        height: 64px;
        border-radius: 14px;
    }
}

@media (max-width: 900px) {
    .header-brand,
    .header-break {
        display: none;
    }

    .page-header .page-heading {
        order: 0;
    }

    .page-header > .btn,
    .page-header .header-actions {
        order: 1;
    }
}

/* Sidebar without logo */

.sidebar .brand-logo {
    display: none;
}

@media (min-width: 901px) {
    .sidebar .brand {
        display: none;
    }

    .sidebar .nav {
        padding-top: 22px;
    }
}

/* Sidebar items (all sizes) */

.nav-icon {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    flex-shrink: 0;
    transition: background-color 0.2s, color 0.2s, box-shadow 0.2s;
}

.nav-icon svg {
    width: 18px;
    height: 18px;
}

.nav-text {
    white-space: nowrap;
}

.nav-sub {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Collapsible icon rail (PC) */

@media (min-width: 901px) {
    .sidebar {
        --rail: 76px;
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 40;
        width: var(--rail);
        overflow-x: hidden;
        transition: width 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.3s ease, background-color 0.25s ease;
    }

    .main {
        margin-left: 76px;
    }

    .sidebar:hover,
    .sidebar:has(:focus-visible) {
        width: 252px;
        box-shadow: 10px 0 36px rgba(0, 0, 0, 0.22);
    }

    .sidebar .nav {
        padding: 22px 16px 16px;
        gap: 4px;
    }

    .sidebar .nav a,
    .sidebar .nav-item {
        height: 44px;
        padding: 0 5px;
        gap: 12px;
        border-radius: 12px;
        overflow: hidden;
    }

    .sidebar .nav a:hover,
    .sidebar .nav-item:hover {
        padding-left: 5px;
    }

    .sidebar .nav-icon {
        width: 34px;
        height: 34px;
        background: rgba(255, 255, 255, 0.1);
        box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
    }

    .sidebar .nav a.active {
        background: transparent;
        color: var(--nav-text-strong);
    }

    .sidebar .nav a.active .nav-icon {
        background: var(--bg);
        color: var(--accent);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    }

    .sidebar .nav a.has-active-child .nav-icon {
        box-shadow: inset 0 0 0 1.5px var(--brand-yellow);
    }

    .sidebar .nav a:hover .nav-icon,
    .sidebar .nav-item:hover .nav-icon {
        background: rgba(255, 255, 255, 0.14);
    }

    .sidebar .nav a.active:hover .nav-icon {
        background: var(--bg);
    }

    .sidebar .nav-text,
    .sidebar .theme-switch {
        opacity: 0;
        transform: translateX(-8px);
        transition: opacity 0.18s ease, transform 0.18s ease;
    }

    .sidebar:hover .nav-text,
    .sidebar:hover .theme-switch,
    .sidebar:has(:focus-visible) .nav-text,
    .sidebar:has(:focus-visible) .theme-switch {
        opacity: 1;
        transform: none;
        transition-delay: 0.1s;
    }

    .sidebar .nav-label {
        position: relative;
        height: 28px;
        margin: 10px 0 2px;
        padding: 0;
        display: flex;
        align-items: center;
    }

    .sidebar .nav-label:first-child {
        margin-top: 0;
    }

    .sidebar .nav-label span {
        padding-left: 7px;
        opacity: 0;
        white-space: nowrap;
        transition: opacity 0.18s ease;
    }

    .sidebar .nav-label::before {
        content: "";
        position: absolute;
        left: 12px;
        width: 20px;
        height: 2px;
        border-radius: 2px;
        background: var(--nav-divider);
        transition: opacity 0.18s ease;
    }

    .sidebar:hover .nav-label span,
    .sidebar:has(:focus-visible) .nav-label span {
        opacity: 1;
        transition-delay: 0.1s;
    }

    .sidebar:hover .nav-label::before,
    .sidebar:has(:focus-visible) .nav-label::before {
        opacity: 0;
    }

    .sidebar .nav-sub {
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.35s ease;
    }

    .sidebar:hover .nav-sub,
    .sidebar:has(:focus-visible) .nav-sub {
        max-height: 250px;
        transition: max-height 0.4s ease 0.15s;
    }

    .sidebar .nav-sub a {
        height: 38px;
        padding-left: 22px;
        opacity: 0;
        transform: translateY(-6px);
        transition: opacity 0.2s ease, transform 0.2s ease, background-color 0.18s, color 0.18s;
    }

    .sidebar .nav-sub a:hover {
        padding-left: 22px;
    }

    .sidebar .nav-sub .nav-icon {
        width: 28px;
        height: 28px;
        background: transparent;
    }

    .sidebar .nav-sub .nav-icon svg {
        width: 16px;
        height: 16px;
    }

    .sidebar .nav-sub a.active .nav-icon {
        background: var(--bg);
    }

    .sidebar:hover .nav-sub a,
    .sidebar:has(:focus-visible) .nav-sub a {
        opacity: 1;
        transform: none;
    }

    .sidebar:hover .nav-sub a:nth-child(1) { transition-delay: 0.2s; }
    .sidebar:hover .nav-sub a:nth-child(2) { transition-delay: 0.25s; }
    .sidebar:hover .nav-sub a:nth-child(3) { transition-delay: 0.3s; }
    .sidebar:hover .nav-sub a:nth-child(4) { transition-delay: 0.35s; }
    .sidebar:hover .nav-sub a:nth-child(5) { transition-delay: 0.4s; }

    .sidebar:hover .nav-sub a:hover {
        transition-delay: 0s;
    }
}

/* Dashboard filters */

.filter-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px 24px;
    margin-top: -6px;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.filter-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-subtle);
    white-space: nowrap;
}

.filter-label svg {
    width: 15px;
    height: 15px;
}

.segmented-scroll {
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
}

.segmented-scroll::-webkit-scrollbar {
    display: none;
}

.segmented a {
    flex-shrink: 0;
}

.segmented a.active {
    box-shadow: 0 2px 8px var(--accent-ring);
}

@media (max-width: 900px) {
    .filter-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .filter-group {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .filter-group .segmented {
        max-width: 100%;
    }
}

/* Header: system name only */

.header-brand-name,
.header-brand-sep {
    display: none;
}

.header-brand-sub {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}

/* PC sidebar: logo with school name */

@media (min-width: 901px) {
    .sidebar .brand {
        display: flex;
        justify-content: flex-start;
        align-items: center;
        gap: 12px;
        padding: 22px 21px 4px;
    }

    .sidebar .brand-logo {
        display: block;
        width: 34px;
        height: 34px;
        border-radius: 10px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    }

    .sidebar .brand-text {
        display: block;
        opacity: 0;
        transform: translateX(-8px);
        white-space: nowrap;
        transition: opacity 0.18s ease, transform 0.18s ease;
    }

    .sidebar .brand-sub {
        display: none;
    }

    .sidebar:hover .brand-text,
    .sidebar:has(:focus-visible) .brand-text {
        opacity: 1;
        transform: none;
        transition-delay: 0.1s;
    }

    .sidebar .nav {
        padding-top: 14px;
    }
}

/* Header without system line; system name under school name in PC sidebar */

.header-brand,
.header-break {
    display: none;
}

@media (min-width: 901px) {
    .page-header .page-heading {
        order: 1;
    }

    .page-header > .btn,
    .page-header .header-actions {
        order: 2;
    }

    .page-header .account {
        order: 3;
    }

    .page-header > .btn + .account,
    .page-header .header-actions + .account {
        margin-left: 0;
    }

    .sidebar .brand-sub {
        display: block;
        font-size: 11px;
        margin-top: 1px;
    }

    .sidebar .brand-name {
        font-size: 14px;
    }
}

/* Account chip: role pill + name */

.account {
    gap: 10px;
    padding: 4px 4px 4px 4px;
}

.role-pill {
    display: inline-flex;
    align-items: center;
    height: 32px;
    padding: 0 14px;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
    box-shadow: 0 2px 6px var(--accent-ring);
}

.account .user-meta {
    display: flex;
    align-items: center;
    height: 32px;
}

.account .user-name {
    font-size: 13.5px;
    line-height: 1;
}

.account {
    padding-left: 14px;
}

/* Account chip: avatar, name, soft role tag, divider, log out */

.account {
    gap: 8px;
    padding: 4px 4px 4px 4px;
}

.account .user-avatar {
    width: 30px;
    height: 30px;
    font-size: 12px;
}

.account .user-meta {
    height: auto;
    padding-left: 2px;
}

.account .user-name {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
}

.role-pill {
    height: 22px;
    padding: 0 9px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    background: var(--accent-soft);
    color: var(--accent);
    box-shadow: none;
}

.account-divider {
    width: 1px;
    height: 20px;
    margin: 0 2px 0 4px;
    background: var(--border);
}

.logout-btn {
    height: 30px;
    padding: 0 12px 0 10px;
}

@media (max-width: 1280px) {
    .logout-btn {
        width: 30px;
        padding: 0;
    }
}

@media (max-width: 900px) {
    .account .user-meta,
    .account .role-pill,
    .account-divider {
        display: none;
    }
}

/* Account chip: role tag under the name */

.account .user-meta {
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 3px;
}

.account .role-pill {
    height: 18px;
    padding: 0 7px;
    font-size: 10.5px;
}

/* Account chip: role as plain text under the name, Log out label on PC */

.account .role-pill {
    height: auto;
    padding: 0;
    background: none;
    color: var(--text-muted);
    font-size: 11.5px;
    font-weight: 500;
    line-height: 1.2;
    letter-spacing: 0;
}

.account .user-meta {
    gap: 1px;
}

@media (min-width: 901px) {
    .account .logout-btn {
        width: auto;
        padding: 0 12px 0 10px;
    }

    .account .logout-btn span {
        display: inline;
    }
}

/* Accounts: view filter and columns */

.accounts-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.accounts-toolbar .search {
    flex: 1;
}

.seg-count {
    display: inline-grid;
    place-items: center;
    min-width: 20px;
    height: 20px;
    margin-left: 8px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--neutral-soft);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
}

.segmented a.active .seg-count {
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
}

.cell-email {
    color: var(--text-muted);
    font-size: 13px;
}

.account-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
}

.account-status .muted {
    font-weight: 400;
}

/* Overall tone */

:root {
    --bg-glow-1: rgba(10, 114, 184, 0.09);
    --bg-glow-2: rgba(255, 229, 0, 0.08);
    --shadow: 0 1px 2px rgba(15, 33, 51, 0.05), 0 4px 14px rgba(15, 33, 51, 0.05);
    --shadow-md: 0 10px 28px rgba(15, 33, 51, 0.1);
}

:root[data-theme="dark"] {
    --bg-glow-1: rgba(59, 157, 226, 0.1);
    --bg-glow-2: rgba(255, 229, 0, 0.04);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.25), 0 4px 14px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 10px 28px rgba(0, 0, 0, 0.35);
}

body {
    background:
        radial-gradient(1100px 560px at 100% -10%, var(--bg-glow-1), transparent 60%),
        radial-gradient(900px 520px at 0% 110%, var(--bg-glow-2), transparent 60%),
        var(--bg);
    background-attachment: fixed;
}

.sidebar {
    background: linear-gradient(180deg, #113352 0%, var(--nav-bg) 55%);
}

:root[data-theme="dark"] .sidebar {
    background: linear-gradient(180deg, #0d1c2b 0%, var(--nav-bg) 55%);
}

.stat {
    position: relative;
    overflow: hidden;
}

.stat::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 3px;
    background: var(--accent);
    opacity: 0.85;
}

.stat:has(.dot.in)::before { background: var(--success-dot); }
.stat:has(.dot.out)::before { background: var(--danger-dot); }
.stat:has(.dot.none)::before { background: var(--neutral-dot); }

.card {
    background: linear-gradient(180deg, var(--surface-2) 0%, var(--surface) 72px);
}

.table th {
    background: linear-gradient(180deg, var(--surface-2), var(--surface));
}

.auth-main {
    background:
        radial-gradient(700px 420px at 100% 0%, var(--bg-glow-1), transparent 60%),
        radial-gradient(600px 380px at 0% 100%, var(--bg-glow-2), transparent 60%),
        var(--bg);
}

.auth-form-wrap {
    max-width: 420px;
    padding: 36px 32px 28px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow-md);
}

@media (max-width: 900px) {
    .auth-form-wrap {
        padding: 28px 22px 22px;
    }
}

/* Tinted surfaces */

:root:not([data-theme="dark"]) {
    --bg: #e9eef5;
    --surface: #fbfcfe;
    --surface-2: #f2f5f9;
    --header-bg: rgba(233, 238, 245, 0.9);
    --border: #dbe2eb;
    --neutral-soft: #e9eef4;
}

:root:not([data-theme="dark"]) .input {
    background: #ffffff;
}

@media (min-width: 901px) {
    .sidebar .nav {
        margin-top: 23px;
    }
}

/* Header spacing */

@media (min-width: 901px) {
    .page-header {
        padding: 28px 32px 22px;
        gap: 12px;
    }

    .page-title {
        font-size: 26px;
        line-height: 1.25;
    }

    .page-subtitle {
        font-size: 13.5px;
        margin-top: 4px;
    }
}

.header-date {
    order: 3;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 48px;
    padding: 0 18px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    box-shadow: var(--shadow);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
}

.header-date svg {
    width: 16px;
    height: 16px;
    color: var(--accent);
}

.account {
    gap: 12px;
    height: 48px;
    padding: 0 6px 0 7px;
}

.account .user-avatar {
    width: 34px;
    height: 34px;
    font-size: 13px;
}

.account .user-name {
    font-size: 13.5px;
}

.account .logout-btn {
    height: 34px;
}

@media (max-width: 1100px) {
    .header-date {
        display: none;
    }
}

@media (max-width: 900px) {
    .account {
        height: auto;
        padding: 4px;
    }
}

@media (min-width: 901px) {
    .page-header > .btn {
        order: 3;
        height: 48px;
        padding: 0 20px;
        border-radius: 999px;
    }
}

/* Forms in dialogs and cards */

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

.field-grid .field-wide {
    grid-column: 1 / -1;
}

.modal:has(.field-grid) {
    width: min(620px, calc(100vw - 32px));
}

.form-card {
    max-width: 520px;
    padding: 28px;
}

.form-card .alert {
    margin-bottom: 18px;
}

.inline-form {
    display: inline;
}

.cell-actions .btn + .btn,
.cell-actions .btn + .inline-form,
.cell-actions form .btn + .btn {
    margin-left: 6px;
}

.btn svg {
    width: 15px;
    height: 15px;
}

/* Student profile */

.profile-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.profile-actions .photo-form {
    margin-top: 0;
}

.tag-icon {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.tag-icon svg {
    width: 12px;
    height: 12px;
}

/* Teachers */

.day-chips {
    display: flex;
    gap: 4px;
}

.day-chip {
    display: inline-grid;
    place-items: center;
    min-width: 34px;
    height: 24px;
    padding: 0 6px;
    border-radius: 7px;
    font-size: 11px;
    font-weight: 600;
    background: var(--neutral-soft);
    color: var(--text-subtle);
}

.day-chip.on {
    background: var(--accent-soft);
    color: var(--accent);
}

.day-picker {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.day-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.day-option span {
    display: inline-grid;
    place-items: center;
    min-width: 56px;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--surface);
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}

.day-option input:checked + span {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.day-option input:focus-visible + span {
    box-shadow: 0 0 0 3px var(--accent-ring);
}

.info-note {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 14px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--accent-soft);
    color: var(--text-muted);
    font-size: 13px;
}

.info-note svg {
    width: 16px;
    height: 16px;
    margin-top: 2px;
    color: var(--accent);
    flex-shrink: 0;
}

/* Logs filters */

.log-filters {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.log-filters .search-field {
    flex: 1 1 280px;
}

.date-field {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.date-field span {
    position: absolute;
    left: 12px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-subtle);
    pointer-events: none;
}

.date-field .input {
    width: 192px;
    padding-left: 48px;
    padding-right: 10px;
}

.export-btn {
    margin-left: auto;
}

.student-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.student-link:hover span {
    color: var(--accent);
}

.avatar.avatar-xs {
    width: 30px;
    height: 30px;
    border-width: 1px;
}

@media (max-width: 900px) {
    .field-grid {
        grid-template-columns: 1fr;
    }

    .log-filters .search-field,
    .date-field,
    .date-field .input,
    .export-btn {
        flex: 1 1 100%;
        width: 100%;
        margin-left: 0;
    }

    .day-chips {
        flex-wrap: wrap;
    }
}

.table .cell-name,
.table .cell-nowrap {
    white-space: nowrap;
}

@media (max-width: 1280px) {
    .day-chip:not(.on) {
        display: none;
    }

    .cell-actions .btn-sm svg {
        display: none;
    }
}

.filter-group {
    min-width: 0;
    max-width: 100%;
}

.filter-group .segmented-scroll {
    max-width: 100%;
    overflow-x: auto;
}

/* Student profile details */

.profile-details {
    display: flex;
    flex-wrap: wrap;
    margin: 10px 0 0;
}

.profile-details > div {
    padding: 2px 18px;
    border-left: 1px solid var(--border);
}

.profile-details > div:first-child {
    padding-left: 0;
    border-left: none;
}

.profile-details dt {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-subtle);
}

.profile-details dd {
    margin: 2px 0 0;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

@media (max-width: 900px) {
    .profile-details {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px 16px;
    }

    .profile-details > div {
        padding: 0;
        border-left: none;
    }
}

.missing {
    color: var(--warning);
    font-size: 12.5px;
    font-weight: 500;
}

.input[readonly] {
    background: var(--surface-2);
    color: var(--text-muted);
    border-style: dashed;
    cursor: not-allowed;
}

.input[readonly]:focus {
    border-color: var(--border-strong);
    box-shadow: none;
}

.hint-block {
    margin: -4px 0 16px;
}

.hint a {
    color: var(--accent);
    font-weight: 500;
}

select.input:invalid {
    color: var(--text-subtle);
}

select.input option {
    color: var(--text);
}

/* Profile */

.profile-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
    max-width: 1040px;
}

.profile-card {
    padding: 28px;
}

.profile-card-head {
    display: flex;
    align-items: center;
    gap: 16px;
    padding-bottom: 20px;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--border);
}

.profile-card-head .profile-name {
    margin-bottom: 4px;
}

.user-avatar.large {
    width: 56px;
    height: 56px;
    font-size: 22px;
}

.info-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 20px;
    margin: 0 0 18px;
}

.info-list dt {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-subtle);
}

.info-list dd {
    margin: 3px 0 0;
    font-weight: 500;
    overflow-wrap: anywhere;
}

.profile-grid .form-card {
    max-width: none;
}

.form-card-title {
    margin-bottom: 18px;
}

.account-link {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
    border-radius: 999px;
}

.account-link:hover .user-name {
    color: var(--accent);
}

@media (max-width: 900px) {
    .profile-grid {
        grid-template-columns: 1fr;
    }

    .account .user-meta {
        display: none;
    }
}

.profile-card {
    max-width: 620px;
}

.profile-alert {
    max-width: 620px;
}

.profile-card-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

.profile-card .info-list {
    margin-bottom: 20px;
}

.profile-card-foot .hint {
    margin: 0;
}

.profile-card-foot {
    justify-content: flex-end;
    gap: 8px;
}

/* Centered sign-in */

.login {
    position: relative;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 22px;
    padding: 40px 16px 28px;
    overflow: hidden;
    background:
        radial-gradient(900px 520px at 50% -10%, rgba(59, 157, 226, 0.28), transparent 65%),
        radial-gradient(700px 460px at 100% 100%, rgba(255, 229, 0, 0.1), transparent 60%),
        linear-gradient(180deg, #11355a 0%, var(--nav-bg) 60%);
}

.login::before,
.login::after {
    content: "";
    position: absolute;
    pointer-events: none;
}

/* Diagonal yellow stripes rising from the bottom-right corner */
.login::before {
    width: 1100px;
    height: 820px;
    right: -300px;
    bottom: -380px;
    transform: rotate(-24deg);
    background:
        linear-gradient(90deg, transparent 0 34%, rgba(255, 229, 0, 0.32) 34% 34.5%, transparent 34.5% 41%, rgba(255, 229, 0, 0.18) 41% 41.3%, transparent 41.3% 100%),
        repeating-linear-gradient(90deg, rgba(255, 229, 0, 0.12) 0 2px, transparent 2px 22px);
    -webkit-mask-image: linear-gradient(to top, #000 30%, transparent 92%);
    mask-image: linear-gradient(to top, #000 30%, transparent 92%);
}

/* Fine dot grid fading in from the top-left corner */
.login::after {
    width: 520px;
    height: 380px;
    left: 0;
    top: 0;
    background-image: radial-gradient(rgba(255, 255, 255, 0.13) 1.3px, transparent 1.8px);
    background-size: 22px 22px;
    -webkit-mask-image: radial-gradient(ellipse at top left, #000 25%, transparent 70%);
    mask-image: radial-gradient(ellipse at top left, #000 25%, transparent 70%);
}

.login-card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 420px;
    padding: 36px 34px 28px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: 0 30px 70px rgba(0, 0, 0, 0.35);
}

.login-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding-bottom: 22px;
    margin-bottom: 22px;
    border-bottom: 1px solid var(--border);
}

.login-logo {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    box-shadow: 0 8px 20px rgba(13, 40, 64, 0.25);
    margin-bottom: 12px;
}

.login-school {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.login-system {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
}

.login-heading {
    margin-bottom: 18px;
}

.login-heading h1 {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.login-heading p {
    color: var(--text-muted);
    font-size: 13.5px;
    margin-top: 2px;
}

.login-card .alert {
    margin-bottom: 16px;
}

.login-card .btn-block {
    height: 46px;
    margin-top: 6px;
}

.login-note {
    margin-top: 18px;
    text-align: center;
    font-size: 12px;
    color: var(--text-subtle);
}

.login-foot {
    position: relative;
    z-index: 1;
    font-size: 12px;
    color: var(--nav-label);
}

:root[data-theme="dark"] .login {
    background:
        radial-gradient(900px 520px at 50% -10%, rgba(59, 157, 226, 0.18), transparent 65%),
        radial-gradient(700px 460px at 100% 100%, rgba(255, 229, 0, 0.06), transparent 60%),
        linear-gradient(180deg, #0d1c2b 0%, var(--nav-bg) 60%);
}

@media (max-width: 480px) {
    .login-card {
        padding: 28px 22px 22px;
        border-radius: 16px;
    }
}

/* Forgot password */

.label-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.label-row label {
    margin-bottom: 6px;
}

.forgot-link,
.login-note a {
    color: var(--accent);
    font-size: 12.5px;
    font-weight: 500;
    text-decoration: none;
}

.forgot-link:hover,
.login-note a:hover {
    text-decoration: underline;
}

.code-input {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: 0.4em;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.resend-form {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 14px;
    font-size: 12.5px;
}

.resend-form .link-btn {
    color: var(--accent);
    text-decoration: none;
    font-size: 12.5px;
}

.resend-form .link-btn:hover {
    text-decoration: underline;
}

.login-note-sub {
    margin-top: 6px;
}

.method-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.method-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.method-option span {
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: 10px;
    align-items: center;
    padding: 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    cursor: pointer;
    transition: border-color 0.15s, background-color 0.15s, box-shadow 0.15s;
}

.method-option svg {
    grid-row: span 2;
    width: 20px;
    height: 20px;
    color: var(--text-muted);
}

.method-option strong {
    font-size: 13.5px;
}

.method-option small {
    font-size: 11.5px;
    color: var(--text-muted);
}

.method-option input:checked + span {
    border-color: var(--accent);
    background: var(--accent-soft);
    box-shadow: 0 0 0 1px var(--accent);
}

.method-option input:checked + span svg {
    color: var(--accent);
}

.method-option input:focus-visible + span {
    box-shadow: 0 0 0 3px var(--accent-ring);
}

/* Password rule checklist */

.pw-rules {
    list-style: none;
    margin: 8px 0 0;
    padding: 0;
    display: grid;
    gap: 3px;
    font-size: 12px;
    color: var(--text-muted);
}

.pw-rules li {
    display: flex;
    align-items: center;
    gap: 7px;
    transition: color 0.15s;
}

.pw-rules li::before {
    content: "";
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    border-radius: 50%;
    border: 1.5px solid var(--border-strong);
    background: var(--surface);
    transition: background-color 0.15s, border-color 0.15s;
}

.pw-rules li.ok {
    color: var(--success);
}

.pw-rules li.ok::before {
    border-color: var(--success-dot);
    background: var(--success-dot) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12 5 5 9-10'/%3E%3C/svg%3E") center / 10px no-repeat;
}

.method-option.is-disabled span {
    opacity: 0.55;
    cursor: not-allowed;
}

.code-sent-to {
    font-size: 13.5px;
    margin-bottom: 16px;
}

.modal-resend {
    margin: 0;
    padding: 0 20px 18px;
}

/* SMS time setting */

.sms-time {
    order: 3;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 48px;
    padding: 0 6px 0 16px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    box-shadow: var(--shadow);
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
}

.sms-time svg {
    width: 16px;
    height: 16px;
    color: var(--accent);
}

.sms-time label[for] {
    font-weight: 500;
}

.sms-hour {
    width: 38px;
    height: 32px;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    font-weight: 600;
    text-align: center;
}

.sms-hour:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring);
}

.sms-hour:invalid {
    border-color: var(--danger-dot);
}

.sms-colon {
    margin-left: -4px;
    font-weight: 600;
    color: var(--text);
}

.sms-meridiem {
    display: inline-flex;
    padding: 2px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-2);
}

.sms-meridiem input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.sms-meridiem span {
    display: inline-grid;
    place-items: center;
    height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-muted);
}

.sms-meridiem input:checked + span {
    background: var(--accent);
    color: #fff;
}

.sms-meridiem input:focus-visible + span {
    box-shadow: 0 0 0 3px var(--accent-ring);
}

.sms-time .btn-sm {
    height: 34px;
    border-radius: 999px;
    padding: 0 14px;
}

@media (max-width: 900px) {
    .sms-time {
        order: 5;
        width: 100%;
        justify-content: flex-start;
    }

    .sms-time .btn-sm {
        margin-left: auto;
    }
}

@media (min-width: 901px) and (max-width: 1400px) {
    .page-header:has(.sms-time)::after {
        content: "";
        order: 5;
        flex-basis: 100%;
        height: 0;
    }

    .page-header .sms-time {
        order: 6;
        margin-left: auto;
        margin-top: -4px;
    }
}

/* Searchable dropdown (Teacher account) */

.combo {
    position: relative;
}

.combo .combo-input {
    padding-right: 40px;
}

.combo-toggle {
    position: absolute;
    top: 0;
    right: 0;
    width: 40px;
    height: 100%;
    display: grid;
    place-items: center;
    border: none;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
}

.combo-toggle svg {
    width: 16px;
    height: 16px;
}

.combo-list {
    position: absolute;
    z-index: 30;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    margin: 0;
    padding: 4px;
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
}

.combo-list li {
    padding: 9px 12px;
    border-radius: 7px;
    font-size: 13.5px;
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.combo-list li:hover,
.combo-list li.active {
    background: var(--accent-soft);
    color: var(--accent);
}

.combo-list li[aria-selected="true"] {
    font-weight: 600;
}

.combo-list .combo-empty {
    color: var(--text-muted);
    cursor: default;
}

.combo-list .combo-empty:hover {
    background: none;
    color: var(--text-muted);
}

.combo-source {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.modal:has(.combo-list:not([hidden])) .modal-body {
    overflow: visible;
}

/* Sign-in: STI yellow accents */


.login .btn-primary {
    background: var(--brand-yellow);
    border-color: var(--brand-yellow);
    color: #0d2840;
    font-weight: 600;
    box-shadow: 0 6px 18px rgba(255, 229, 0, 0.22);
}

.login .btn-primary:hover {
    background: #f5d900;
    border-color: #f5d900;
    color: #0d2840;
}

.login .btn-primary:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 229, 0, 0.4);
}

.login .input:focus {
    border-color: #e6c800;
    box-shadow: 0 0 0 3px rgba(255, 229, 0, 0.22);
}

.login .method-option input:checked + span {
    border-color: #e6c800;
    background: rgba(255, 229, 0, 0.12);
    box-shadow: 0 0 0 1px #e6c800;
}

.login .method-option input:checked + span svg {
    color: #b39b00;
}

:root[data-theme="dark"] .login .method-option input:checked + span svg,
:root[data-theme="dark"] .forgot-link,
:root[data-theme="dark"] .login-note a,
:root[data-theme="dark"] .resend-form .link-btn {
    color: var(--brand-yellow);
}

.grid-footer {
    margin-top: 4px;
    padding: 12px 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

/* STI yellow accents (shared with the sign-in page and the scanner) */

.brand-logo {
    box-shadow: 0 0 0 2px rgba(255, 229, 0, 0.18), 0 6px 16px rgba(0, 0, 0, 0.25);
}

.user-avatar {
    background: var(--brand-yellow);
    color: #0d2840;
}


/* Import preview: search above each table */

.preview-search {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
}

.panel-head > div > .muted {
    display: block;
    margin-top: 2px;
    font-size: 12.5px;
}

/* Term badge beside the date */

.header-term {
    color: var(--text);
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--brand-yellow), var(--shadow);
}

/* Filters beside the strand and grade buttons */

.filter-select {
    width: auto;
    min-width: 150px;
    height: 40px;
    padding-top: 0;
    padding-bottom: 0;
}

.term-picker {
    display: flex;
    align-items: center;
    gap: 10px;
}

.term-picker .input {
    width: auto;
    min-width: 230px;
    height: 44px;
    padding-top: 0;
    padding-bottom: 0;
}

.toolbar-end {
    justify-content: flex-end;
}

.tag-link {
    text-decoration: none;
    color: var(--accent);
    transition: background-color 0.15s;
}

.tag-link:hover {
    background: var(--accent-soft);
}

.section-code {
    font-size: 18px;
    letter-spacing: -0.01em;
}

/* Weekly timetable */

.timetable-wrap {
    overflow-x: auto;
    padding: 14px;
}

.timetable {
    display: grid;
    grid-template-columns: 78px repeat(var(--tt-days), minmax(132px, 1fr));
    grid-template-rows: 42px repeat(var(--tt-slots), 35px);
    min-width: calc(78px + var(--tt-days) * 132px);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--surface);
}

.tt-corner,
.tt-day {
    grid-row: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border-strong);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.tt-corner {
    grid-column: 1;
}

.tt-day {
    font-size: 0;
    letter-spacing: 0;
}

.tt-day span {
    font-size: 12px;
    letter-spacing: 0.04em;
}

.tt-day.today {
    color: var(--text);
    box-shadow: inset 0 -3px 0 var(--brand-yellow);
}

.tt-time {
    grid-column: 1;
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    padding: 3px 10px 0 0;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--surface-2);
    border-top: 1px solid var(--border);
    white-space: nowrap;
}

.tt-time.half {
    font-weight: 400;
    color: var(--text-subtle);
    border-top-style: dashed;
}

.tt-slot {
    border-top: 1px solid var(--border);
    border-left: 1px solid var(--border);
}

.tt-slot.half {
    border-top-style: dashed;
}

.tt-slot.today {
    background: rgba(255, 229, 0, 0.05);
}

.tt-class {
    --tone: var(--accent);
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
    margin: 2px 3px;
    padding: 6px 8px;
    overflow: hidden;
    border-radius: 8px;
    border-left: 3px solid var(--tone);
    background: color-mix(in srgb, var(--tone) 13%, var(--surface));
    box-shadow: 0 1px 2px rgba(15, 33, 51, 0.08);
}

.tone-0 { --tone: #0a72b8; }
.tone-1 { --tone: #16a06a; }
.tone-2 { --tone: #d9a400; }
.tone-3 { --tone: #7c5cd6; }
.tone-4 { --tone: #0e9aa7; }
.tone-5 { --tone: #d9536f; }

.tt-subject {
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.25;
    color: var(--text);
    overflow-wrap: anywhere;
}

.tt-meta {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    line-height: 1.35;
    color: var(--text-muted);
}

.tt-meta svg {
    width: 11px;
    height: 11px;
    flex-shrink: 0;
}

.tt-sections {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin-top: 3px;
}

.tt-chip {
    padding: 1px 6px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: var(--surface);
    font: inherit;
    font-size: 10.5px;
    font-weight: 600;
    line-height: 1.5;
    color: var(--text);
    text-decoration: none;
    cursor: pointer;
}

.tt-chip:hover {
    border-color: var(--tone);
}

/* Admin actions */

.admin-term {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 20px;
    padding: 22px 24px;
    border-left: 4px solid var(--brand-yellow);
}

.admin-term-now {
    margin: 6px 0 4px;
    font-size: 24px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text);
}

.admin-term-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
    min-width: 280px;
    max-width: 480px;
}

.admin-add {
    display: flex;
    gap: 8px;
}

.admin-add .input {
    flex: 1;
    min-width: 0;
}

.admin-add .btn {
    flex-shrink: 0;
}

.admin-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 16px 20px 20px;
}

.admin-list .admin-add {
    max-width: 420px;
}

.admin-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.admin-chip {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 3px 4px 3px 11px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-2);
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text);
}

.admin-chip button {
    display: grid;
    place-items: center;
    width: 20px;
    height: 20px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-subtle);
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
}

.admin-chip button:hover {
    background: var(--danger-soft);
    color: var(--danger);
}

/* Printable access logs report */

.report-page {
    background: var(--bg);
    color: var(--text);
}

.report-actions {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 18px 16px 0;
}

.report {
    max-width: 880px;
    margin: 16px auto 40px;
    padding: 36px 40px;
    background: #fff;
    color: #0f2133;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.report-head {
    display: flex;
    align-items: center;
    gap: 14px;
    padding-bottom: 14px;
    border-bottom: 3px solid #ffe500;
}

.report-logo {
    width: 52px;
    height: 52px;
    border-radius: 10px;
}

.report-school {
    font-size: 13px;
    color: #5b6a7b;
}

.report-title {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.report-info {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px 20px;
    margin: 18px 0;
}

.report-info dt {
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #5b6a7b;
}

.report-info dd {
    margin: 1px 0 0;
    font-size: 13px;
    font-weight: 500;
}

.report-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11.5px;
}

.report-table th {
    padding: 7px 8px;
    text-align: left;
    background: #0d2840;
    color: #fff;
    font-weight: 600;
}

.report-table td {
    padding: 6px 8px;
    border-bottom: 1px solid #e2e7ee;
}

.report-table tr:nth-child(even) td {
    background: #f7f9fc;
}

.report-note {
    margin: 10px 0 0;
    font-size: 11.5px;
    color: #5b6a7b;
}

.report-signatures {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 28px;
    margin-top: 56px;
    break-inside: avoid;
    font-size: 11.5px;
    text-align: center;
    color: #5b6a7b;
}

.report-line {
    display: block;
    min-height: 22px;
    margin-bottom: 4px;
    border-bottom: 1px solid #0f2133;
    font-size: 12.5px;
    font-weight: 600;
    color: #0f2133;
}

@media print {
    .report-page {
        background: #fff;
    }

    .report-actions {
        display: none;
    }

    .report {
        max-width: none;
        margin: 0;
        padding: 0;
        border: none;
        box-shadow: none;
    }

    .report-table thead {
        display: table-header-group;
    }

    .report-table tr {
        break-inside: avoid;
    }

    @page {
        margin: 14mm;
    }
}

@media (max-width: 640px) {
    .report {
        margin: 12px;
        padding: 20px 16px;
    }

    .report-info {
        grid-template-columns: repeat(2, 1fr);
    }

    .term-picker,
    .term-picker .input,
    .filter-select {
        width: 100%;
    }
}

.admin-add input.input {
    padding-left: 14px;
}

/* Dashboard filters sit together in one row */

.filter-bar {
    justify-content: flex-start;
    gap: 12px 28px;
}

.filter-select {
    height: 44px;
    min-width: 170px;
    border-radius: 999px;
    padding-left: 18px;
}

.stats-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.modal-foot [hidden] {
    display: none;
}

select.filter-select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 42px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238e9bab' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 15px 15px;
}

/* Timetable blocks: time and room share a line so short classes fit */

.timetable {
    grid-template-columns: 78px repeat(var(--tt-days), minmax(150px, 1fr));
    min-width: calc(78px + var(--tt-days) * 150px);
}

.tt-meta {
    gap: 8px;
    white-space: nowrap;
    overflow: hidden;
}

.tt-room {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    min-width: 0;
}

.tt-editable {
    cursor: pointer;
    transition: box-shadow 0.15s;
}

.tt-editable:hover,
.tt-editable:focus-visible {
    outline: none;
    box-shadow: 0 0 0 1.5px var(--tone);
}

/* School years in Admin actions */

.admin-year {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.admin-year:last-child {
    padding-bottom: 0;
    border-bottom: none;
}

.admin-year strong {
    min-width: 90px;
    color: var(--text);
}

.admin-year form:last-child {
    margin-left: auto;
}

.admin-chip-fixed {
    padding: 5px 12px;
    color: var(--text-muted);
}

.tt-meta {
    flex-wrap: wrap;
    gap: 0 8px;
}

/* Rooms in Admin actions */

.admin-room-forms {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 24px;
}

.admin-room-forms .admin-add {
    flex: 1 1 340px;
    max-width: none;
}

.admin-room-forms select.input {
    flex: 0 1 150px;
}

.admin-room-forms .admin-add input.input {
    min-width: 110px;
}

.admin-room-form {
    display: flex;
    flex: 1 1 340px;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.admin-room-form .admin-add {
    flex: 0 0 auto;
}

.toolbar-spread {
    justify-content: space-between;
    flex-wrap: wrap;
}

.admin-room-form {
    max-width: 640px;
}

.btn-danger-solid:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.teacher-free,
select.input option.teacher-free {
    color: var(--success);
}

.teacher-busy,
select.input option.teacher-busy {
    color: var(--danger);
}

/* Class days calendar (Admin actions) */
.modal-cal {
    width: min(460px, calc(100vw - 24px));
}

.modal-cal::backdrop {
    background: rgba(5, 12, 20, 0.72);
    backdrop-filter: blur(3px);
}

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

.cal-month {
    font-size: 16px;
    font-weight: 600;
}

.cal-week,
.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
}

.cal-week {
    margin-bottom: 6px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    text-align: center;
    color: var(--text-subtle);
}

.cal-grid {
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.cal-day {
    aspect-ratio: 1;
    min-height: 38px;
    border: 1px solid transparent;
    border-radius: 10px;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.08s ease;
}

.cal-day:active {
    transform: scale(0.94);
}

.cal-day.is-class,
.cal-swatch.is-class {
    background: var(--success-soft);
    border-color: var(--success-dot);
    color: var(--success);
}

.cal-day.no-class,
.cal-swatch.no-class {
    background: var(--danger-soft);
    border-color: var(--danger-dot);
    color: var(--danger);
}

.cal-day.is-weekend,
.cal-swatch.is-weekend {
    background: var(--neutral-soft);
    border-color: var(--border);
    color: var(--text-muted);
}

.cal-day.is-sunday {
    background: none;
    color: var(--text-subtle);
    cursor: default;
}

.cal-day.is-today {
    box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent);
}

.cal-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin: 14px 0 6px;
    font-size: 12.5px;
    color: var(--text-muted);
}

.cal-legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.cal-swatch {
    width: 14px;
    height: 14px;
    border: 1px solid;
    border-radius: 4px;
}

.cal-foot {
    align-items: center;
    justify-content: space-between;
}

.cal-status {
    font-size: 12.5px;
    color: var(--text-muted);
}

/* Phone layout: bottom navigation bar, compact header, cards instead of wide tables */
.bottom-nav,
.mobile-logo,
.tt-agenda {
    display: none;
}

@media (max-width: 900px) {
    .bottom-nav {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 40;
        display: grid;
        grid-auto-columns: 1fr;
        grid-auto-flow: column;
        padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
        background: var(--surface);
        border-top: 1px solid var(--border);
        box-shadow: 0 -6px 20px rgba(15, 33, 51, 0.08);
    }

    .bottom-nav a,
    .bottom-nav button {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        min-height: 52px;
        border: none;
        border-radius: 12px;
        background: none;
        font: inherit;
        font-size: 11px;
        font-weight: 500;
        color: var(--text-muted);
        text-decoration: none;
        cursor: pointer;
    }

    .bottom-nav svg {
        width: 22px;
        height: 22px;
    }

    .bottom-nav .active {
        color: var(--accent);
        background: var(--accent-soft);
    }

    .main {
        padding-bottom: calc(76px + env(safe-area-inset-bottom));
    }

    .page-header .menu-toggle {
        display: none;
    }

    .mobile-logo {
        display: inline-flex;
        order: -3;
        flex: none;
    }

    .mobile-logo img {
        width: 36px;
        height: 36px;
        border-radius: 9px;
    }

    .page-header {
        position: static;
        backdrop-filter: none;
        background: none;
        gap: 10px;
        padding: 14px 16px 4px;
    }

    .page-header .header-term {
        display: inline-flex;
        order: -2;
        min-width: 0;
        height: 36px;
        padding: 0 12px;
        font-size: 12px;
    }

    .page-header .header-term span {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .page-header .header-date:not(.header-term) {
        display: none;
    }

    .page-title {
        font-size: 22px;
    }

    .page-header > .btn {
        order: 1;
    }
}

@media (max-width: 640px) {
    .input,
    select.input,
    textarea.input {
        font-size: 16px;
    }

    .btn {
        min-height: 42px;
    }

    .btn-sm {
        min-height: 36px;
    }

    .page-header > .btn {
        flex: 1 1 auto;
        justify-content: center;
    }

    .content {
        padding-top: 8px;
    }

    /* Dashboard */
    .stats {
        gap: 8px;
    }

    .stat {
        padding: 12px 14px;
    }

    .stat-value {
        font-size: 20px;
    }

    .segmented {
        max-width: 100%;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .segmented::-webkit-scrollbar {
        display: none;
    }

    .segmented a {
        flex: none;
    }

    .grid {
        gap: 10px;
    }

    .card {
        padding: 14px;
        gap: 10px;
    }

    /* Dialogs open as bottom sheets */
    .modal {
        width: 100vw;
        max-width: 100vw;
        max-height: 92dvh;
        margin: auto 0 0;
        border-radius: 18px 18px 0 0;
    }

    .modal-foot {
        border-radius: 0;
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }

    .modal-foot .btn {
        flex: 1;
        justify-content: center;
    }

    .modal-cal .cal-foot .btn {
        flex: none;
    }

    /* Wide tables become cards */
    .table-cards thead {
        display: none;
    }

    .table-cards,
    .table-cards tbody {
        display: block;
    }

    .table-cards tbody tr {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 6px 12px;
        align-items: center;
        padding: 14px 16px;
        border-bottom: 1px solid var(--border);
    }

    .table-cards tbody td {
        display: block;
        padding: 0;
        border: none;
        min-width: 0;
    }

    .table-cards tbody td.empty-state {
        grid-column: 1 / -1;
    }

    .table-logs tbody tr {
        grid-template-areas: "name dir" "meta place" "time time";
    }

    .table-logs td:nth-child(1) { grid-area: name; }
    .table-logs td:nth-child(2) { grid-area: meta; font-size: 12.5px; }
    .table-logs td:nth-child(3) { grid-area: time; font-size: 12.5px; color: var(--text-muted); }
    .table-logs td:nth-child(4) { grid-area: dir; justify-self: end; }
    .table-logs td:nth-child(5) { grid-area: place; justify-self: end; }

    .table-accounts tbody tr {
        grid-template-areas: "name status" "email role" "actions actions";
    }

    .table-accounts td:nth-child(1) { grid-area: name; }
    .table-accounts td:nth-child(2) { grid-area: email; font-size: 12.5px; overflow-wrap: anywhere; }
    .table-accounts td:nth-child(3) { grid-area: role; justify-self: end; }
    .table-accounts td:nth-child(4) { grid-area: status; justify-self: end; }
    .table-accounts td:nth-child(5) { grid-area: actions; }

    .table-accounts .cell-actions {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        justify-content: flex-start;
        gap: 6px;
        width: auto;
        text-align: left;
    }

    .table-accounts .cell-actions form {
        display: contents;
    }

    .table-accounts .cell-actions .btn {
        flex: none;
        width: auto;
        margin: 0;
    }

    /* Timetables show one day at a time */
    .timetable-wrap {
        display: none;
    }

    .tt-agenda {
        display: block;
        padding: 12px;
    }

    .tt-tabs {
        display: grid;
        grid-auto-columns: 1fr;
        grid-auto-flow: column;
        gap: 6px;
        margin-bottom: 12px;
    }

    .tt-tabs button {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        padding: 8px 0;
        border: 1px solid var(--border);
        border-radius: 12px;
        background: var(--surface);
        font: inherit;
        font-size: 13px;
        font-weight: 600;
        color: var(--text);
        cursor: pointer;
    }

    .tt-tabs button span {
        font-size: 11px;
        font-weight: 500;
        color: var(--text-muted);
    }

    .tt-tabs button.active {
        border-color: var(--accent);
        background: var(--accent);
        color: #fff;
    }

    .tt-tabs button.active span {
        color: rgba(255, 255, 255, 0.85);
    }

    .tt-agenda-day {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .tt-agenda-day[hidden] {
        display: none;
    }

    .tt-item {
        margin: 0;
        padding: 12px 14px;
        gap: 4px;
    }

    .tt-item .tt-subject {
        font-size: 14px;
    }

    .tt-item .tt-meta {
        flex-wrap: wrap;
        gap: 4px 12px;
        font-size: 12.5px;
    }

    .tt-free {
        padding: 24px 12px;
        text-align: center;
        color: var(--text-muted);
    }
}

@media (max-width: 640px) {
    .log-filters {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .log-filters > * {
        width: 100%;
        min-width: 0;
        margin: 0;
    }

    .log-filters .search-field,
    .log-filters .btn-primary {
        grid-column: 1 / -1;
    }

    .log-filters:has(.btn-ghost) .btn-primary {
        grid-column: auto;
    }

    .log-filters .btn {
        justify-content: center;
    }

    .log-filters .date-field .input {
        min-width: 0;
        padding-right: 8px;
    }
}

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

    .stats-3 .stat-label {
        font-size: 11.5px;
        align-items: flex-start;
    }

    .user-avatar.large {
        width: 44px;
        height: 44px;
        font-size: 18px;
    }
}

@media (max-width: 640px) {
    #class-dialog .field-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px 10px;
    }
}

@media (max-width: 640px) {
    .modal:has(.field-grid),
    .modal-sm,
    .modal-cal {
        width: 100vw;
        max-width: 100vw;
    }
}

@media (max-width: 640px) {
    .table-history tbody tr {
        grid-template-areas: "time place" "dir place";
    }

    .table-history td:nth-child(1) { grid-area: time; }
    .table-history td:nth-child(2) { grid-area: dir; font-size: 13px; }
    .table-history td:nth-child(3) { grid-area: place; justify-self: end; }
}

.tt-noroom {
    color: var(--danger);
    font-weight: 600;
}

/* Admin actions: terms without remove buttons, add-year summary, term switch, danger zone */
.admin-chip-static {
    padding-right: 11px;
}

.summary-list {
    margin: 4px 0 12px;
    padding-left: 18px;
    color: var(--text);
}

.summary-list li {
    margin: 3px 0;
}

.export-note {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    margin: 12px 0;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    font-size: 12.5px;
    color: var(--text-muted);
}

.export-note svg {
    flex: none;
    width: 16px;
    height: 16px;
    margin-top: 1px;
    color: var(--accent);
}

.export-note strong {
    color: var(--text);
    overflow-wrap: anywhere;
}

.export-status {
    margin: 0;
    padding: 0 24px 14px;
    font-size: 12.5px;
    color: var(--text-muted);
    text-align: right;
}

.export-status:empty {
    display: none;
}

.term-view {
    flex-basis: 100%;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.switch-row {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
}

.switch-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.switch {
    position: relative;
    width: 38px;
    height: 22px;
    border-radius: 999px;
    background: var(--border-strong);
    transition: background-color 0.2s;
}

.switch::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease;
}

.switch-input:checked + .switch {
    background: var(--accent);
}

.switch-input:checked + .switch::after {
    transform: translateX(16px);
}

.switch-input:focus-visible + .switch {
    box-shadow: 0 0 0 3px var(--accent-ring);
}

.term-view-pick {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.term-view-pick[hidden] {
    display: none;
}

.term-view-pick .input {
    min-width: 260px;
}

.term-view-note {
    flex-basis: 100%;
    display: flex;
    gap: 8px;
    margin: 0;
    font-size: 13px;
    color: var(--warning);
}

.term-view-note svg,
.term-view-banner svg {
    flex: none;
    width: 16px;
    height: 16px;
}

.term-view-banner {
    margin-bottom: 16px;
    border: 1px solid var(--warning-border);
    border-radius: var(--radius);
}

.danger-zone {
    border-color: color-mix(in srgb, var(--danger-dot) 45%, var(--border));
}

.danger-zone-body {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px 24px;
    padding: 16px 20px 20px;
}

.danger-zone-body p {
    margin: 0;
    max-width: 720px;
    color: var(--text-muted);
    font-size: 13.5px;
}

/* Access logs: clear/export button turns red past 50,000 records */
.clear-btn {
    position: relative;
}

.clear-btn.is-full {
    border-color: var(--danger-dot);
    color: var(--danger);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger-dot) 18%, transparent);
}

.clear-bubble {
    position: absolute;
    top: -9px;
    right: -9px;
    min-width: 22px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--danger-dot);
    color: #fff;
    font-size: 10.5px;
    font-weight: 600;
    line-height: 20px;
    text-align: center;
    animation: bubble-pop 1.6s ease-in-out infinite;
}

@keyframes bubble-pop {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.12); }
}

.clear-warning {
    margin: 0 0 14px;
    border: 1px solid var(--warning-border);
    border-radius: var(--radius);
}

.clear-warning svg {
    flex: none;
    width: 16px;
    height: 16px;
}

.month-pick {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 6px;
}

.clear-summary {
    margin-top: 14px;
}

.clear-count {
    margin: 0;
    font-size: 14px;
}

#clear-dialog .field-grid {
    grid-template-columns: 1fr 1fr;
}

@media (max-width: 640px) {
    .term-view-pick .input {
        min-width: 0;
        flex: 1;
    }
}

.class-error {
    margin: 4px 0 14px;
}

.class-error[hidden] {
    display: none;
}

a.is-busy {
    opacity: 0.6;
    pointer-events: none;
}

.busy-note {
    margin-top: 6px;
    font-size: 12.5px;
    line-height: 1.45;
    color: var(--danger);
}

.busy-note:empty {
    display: none;
}

.scope-pick {
    display: flex;
    width: 100%;
    margin-bottom: 14px;
}

.scope-pick button {
    flex: 1;
    height: 34px;
    border: none;
    border-radius: 999px;
    background: none;
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
}

.scope-pick button.active {
    background: var(--danger-dot);
    color: #fff;
}

/* Admin actions: group titles, side-by-side lists, end-of-year rows */
.admin-group-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 12px 0 -4px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.admin-group-title svg {
    width: 15px;
    height: 15px;
}

.admin-term-years {
    flex-basis: 100%;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.admin-term-years .admin-list {
    padding: 8px 0 0;
}

.admin-grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr));
    gap: 16px;
    align-items: start;
}

.admin-grid-2 .panel {
    margin: 0;
}

.records-panel {
    padding: 4px 0;
}

.records-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 20px;
}

.records-row + .records-row {
    border-top: 1px solid var(--border);
}

.records-step {
    flex: none;
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 13px;
    font-weight: 700;
}

.records-step svg {
    width: 15px;
    height: 15px;
}

.records-step-plain {
    border-radius: 8px;
    background: var(--danger-soft);
    color: var(--danger);
}

.records-text {
    flex: 1;
    min-width: 0;
    display: grid;
    gap: 2px;
}

.records-text strong {
    font-size: 14px;
}

.records-text span {
    color: var(--text-muted);
    font-size: 13px;
}

.records-row .btn {
    flex: none;
}

.records-row .btn:disabled {
    opacity: .5;
    cursor: not-allowed;
    box-shadow: none;
}

.promote-table {
    max-height: 280px;
    overflow: auto;
    margin: 10px 0;
}

.toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

@media (max-width: 640px) {
    .records-row {
        flex-wrap: wrap;
        padding: 14px 16px;
    }

    .records-row .btn {
        margin-left: 44px;
    }
}
