:root {
    --bg: #f4f6fb;
    --card: #ffffff;
    --text: #172033;
    --muted: #6b7280;
    --border: #e5e7eb;
    --primary: #3157d5;
    --primary-dark: #2445ad;
    --danger-bg: #fee2e2;
    --danger-text: #991b1b;
    --success-bg: #dcfce7;
    --success-text: #166534;
    --radius: 18px;
    --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
    --header-bg: #172554;
    --header-bg-soft: #1e3a8a;
    --header-text: #ffffff;
    --header-muted: #dbeafe;
    --header-border: rgba(255, 255, 255, 0.14);
    --header-control-bg: rgba(255, 255, 255, 0.10);
    --header-control-hover: rgba(255, 255, 255, 0.16);
    --app-header-height: 68px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
}

a {
    color: inherit;
    text-decoration: none;
}

/* LOGOWANIE */

.auth-page {
    min-height: 100vh;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    place-items: center;
    gap: 18px;
    padding: 24px;
}

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

.auth-card {
    background: var(--card);
    border-radius: 28px;
    padding: 32px;
    box-shadow: var(--shadow);
}

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

.auth-logo {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    background: var(--primary);
    color: #fff;
    font-weight: 800;
}

.auth-brand h1 {
    margin: 0;
    font-size: 24px;
}

.auth-brand p {
    margin: 4px 0 0;
    color: var(--muted);
}

/* UKŁAD APLIKACJI */

.app-layout {
    min-height: 0;
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
    position: fixed;
    top: var(--app-header-height);
    left: 0;
    bottom: 0;
    width: 280px;
    height: calc(100vh - var(--app-header-height));
    overflow-y: auto;
    overscroll-behavior: contain;
    background: #0f172a;
    color: #fff;
    padding: 24px;
    z-index: 9000;
}

.app-layout > .main {
    grid-column: 2;
    min-width: 0;
    min-height: calc(100vh - var(--app-header-height) - 92px);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 28px;
    min-width: 0;
}

.sidebar-brand strong {
    display: block;
    max-width: 170px;
    overflow-wrap: anywhere;
}

.sidebar-brand span {
    display: block;
    color: #94a3b8;
    font-size: 13px;
    margin-top: 3px;
}

/* Logo w sidebarze:
 *  - jeśli jest obrazek: pokazuje samo logo bez fioletowego tła,
 *  - jeśli nie ma obrazka: pokazuje fioletowy box ze skrótem.
 */

.sidebar-logo {
    width: 52px;
    height: 52px;
    min-width: 52px;
    max-width: 52px;
    display: grid;
    place-items: center;
    overflow: hidden;
    flex: 0 0 52px;
}

.sidebar-logo:not(:has(img)) {
    border-radius: 16px;
    background: var(--primary);
    color: #fff;
    font-weight: 800;
}

.sidebar-logo:has(img) {
    border-radius: 10px;
    background: transparent;
}

.sidebar-logo-image {
    display: block;
    max-width: 52px;
    max-height: 52px;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
}

.sidebar-nav {
    display: grid;
    gap: 8px;
}

.sidebar-nav a {
    padding: 12px 14px;
    border-radius: 14px;
    color: #cbd5e1;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

/* MOBILNY SIDEBAR ROZWIJANY */

.mobile-sidebar {
    display: none;
}

.main {
    padding: 32px;
    padding-bottom: 92px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 28px;
}

.topbar h1 {
    margin: 0;
    font-size: 30px;
}

.topbar p {
    margin: 5px 0 0;
    color: var(--muted);
}

/* KARTY */

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

.card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
    min-height: 150px;
}

.card-label {
    display: block;
    color: var(--muted);
    font-size: 14px;
    margin-bottom: 10px;
}

.card strong {
    display: block;
    font-size: 24px;
    margin-bottom: 8px;
}

.card p {
    margin: 0;
    color: var(--muted);
    line-height: 1.5;
}

.page-section {
    margin-bottom: 22px;
}

.page-section h2 {
    margin: 0 0 18px;
    font-size: 20px;
}

/* SEKCJE */

.section-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.section-header h2 {
    margin-bottom: 4px;
}

/* FORMULARZE */

.form,
.form-grid {
    display: grid;
    gap: 18px;
}

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

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

.form-field {
    display: grid;
    gap: 7px;
    font-size: 14px;
    font-weight: 600;
}

.form-field-full {
    grid-column: 1 / -1;
}

.form-field input,
.form-field select,
.form-field textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 13px 14px;
    font-size: 16px;
    outline: none;
    background: #fff;
    font-family: inherit;
}

.form-field textarea {
    resize: vertical;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(49, 87, 213, 0.12);
}

.form-subtitle {
    margin-top: 8px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
    font-weight: 800;
    color: var(--text);
}

.form-actions {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.checkbox-field {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

/* PRZYCISKI */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 14px;
    padding: 12px 18px;
    font-weight: 700;
    cursor: pointer;
    font-size: 15px;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-light {
    background: #fff;
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-full {
    width: 100%;
}

.btn-small {
    padding: 7px 10px;
    border-radius: 10px;
    font-size: 12px;
    white-space: nowrap;
}

.btn-danger {
    background: #dc2626;
    color: #fff;
}

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

/* ALERTY */

.alert {
    padding: 12px 14px;
    border-radius: 14px;
    margin-bottom: 18px;
    font-size: 14px;
}

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

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

/* TABELE */

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

.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
}

.data-table th,
.data-table td {
    padding: 13px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

.data-table th {
    font-size: 13px;
    color: var(--muted);
    font-weight: 800;
    background: #f8fafc;
}

.data-table tr:hover td {
    background: #f9fafb;
}

.table-actions {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    gap: 8px !important;
    white-space: nowrap;
}

.table-actions > a,
.table-actions > form {
    display: inline-flex !important;
    width: auto !important;
    margin: 0 !important;
}

.table-actions .btn,
.table-actions button {
    width: auto !important;
    white-space: nowrap;
}

.inline-form {
    display: inline-flex !important;
    margin: 0 !important;
}

.table-link {
    color: var(--primary);
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.table-link:hover {
    color: var(--primary-dark);
}

/* USTAWIENIA */

.settings-summary {
    grid-template-columns: 1fr;
}

.summary-row {
    display: grid;
    gap: 6px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #f8fafc;
}

.summary-row span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.summary-row strong {
    text-align: left;
    font-size: 18px;
    line-height: 1.4;
}

.logo-preview-box {
    max-width: 240px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #f8fafc;
}

.logo-preview-box img {
    max-width: 200px;
    width: 100%;
    height: auto;
    display: block;
}

.summary-logo {
    max-width: 160px;
    max-height: 80px;
    width: auto;
    height: auto;
    display: block;
}

.logo-delete-form {
    margin-top: 14px;
}


/* STOPKA */

.site-footer {
    margin: 0 0 0 280px;
    padding: 18px 32px 26px;
    border-top: 1px solid var(--border);
    background: rgba(255, 255, 255, .72);
    color: #64748b;
    font-size: 13px;
    text-align: center;
    line-height: 1.55;
}

.site-footer-main {
    font-weight: 800;
    color: #334155;
}

.site-footer-meta {
    margin-top: 3px;
}

.site-footer a {
    color: var(--primary);
    font-weight: 850;
    text-decoration: none;
}

.site-footer a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
    text-underline-offset: 3px;
}


.auth-page .site-footer,
.auth-site-footer {
    width: 100%;
    max-width: 460px;
    margin: 0;
    padding: 0 4px;
    border-top: 0;
    background: transparent;
    box-shadow: none;
}

.auth-page .site-footer-main {
    color: #475569;
}

.auth-page .site-footer-meta {
    color: #64748b;
}

/* POMOCNICZE */

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

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* RESPONSYWNOŚĆ — LAPTOP / TABLET */

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

/* RESPONSYWNOŚĆ — TELEFON */

@media (max-width: 760px) {
    .app-layout {
        display: block;
        min-height: auto;
    }

    .sidebar {
        display: none;
    }

    .app-layout > .main {
        grid-column: auto;
        min-height: 0;
    }

    .site-footer {
        margin-left: 0;
        padding: 16px 20px 24px;
    }

    .mobile-sidebar {
        display: block;
        position: sticky;
        top: 0;
        z-index: 9999;
        background: #0f172a;
        color: #fff;
        padding: 12px;
        box-shadow: 0 12px 30px rgba(15, 23, 42, 0.18);
    }

    .mobile-sidebar-brand {
        display: flex;
        align-items: center;
        gap: 12px;
        min-width: 0;
        margin-bottom: 10px;
    }

    .mobile-sidebar-title {
        min-width: 0;
    }

    .mobile-sidebar-title strong {
        display: block;
        font-size: 15px;
        line-height: 1.2;
        overflow-wrap: anywhere;
    }

    .mobile-sidebar-title span {
        display: block;
        color: #94a3b8;
        font-size: 12px;
        margin-top: 2px;
    }

    .mobile-sidebar-dropdown {
        position: relative;
        max-height: calc(100dvh - 24px);
    }

    .mobile-sidebar-dropdown summary {
        list-style: none;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        width: 100%;
        padding: 12px 14px;
        border-radius: 14px;
        background: rgba(255, 255, 255, 0.1);
        color: #fff;
        font-weight: 800;
        cursor: pointer;
        user-select: none;
    }

    .mobile-sidebar-dropdown summary::-webkit-details-marker {
        display: none;
    }

    .mobile-sidebar-arrow {
        transition: transform 0.2s ease;
    }

    .mobile-sidebar-dropdown[open] .mobile-sidebar-arrow {
        transform: rotate(180deg);
    }

    .mobile-sidebar-nav {
        display: grid;
        gap: 6px;
        margin-top: 8px;
        padding: 8px;
        padding-bottom: max(16px, env(safe-area-inset-bottom));
        border-radius: 16px;
        background: #111c33;
        max-height: calc(100dvh - 168px);
        overflow-y: auto;
        overflow-x: hidden;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        scrollbar-gutter: stable;
    }

    .mobile-sidebar-nav a {
        display: block;
        padding: 12px 14px;
        border-radius: 12px;
        color: #cbd5e1;
        font-weight: 700;
    }

    .mobile-sidebar-nav a.active,
    .mobile-sidebar-nav a:hover {
        background: rgba(255, 255, 255, 0.12);
        color: #fff;
    }

    .main {
        padding: 20px;
        padding-bottom: 40px;
    }

    .topbar {
        align-items: flex-start;
    }

    .topbar h1 {
        font-size: 25px;
    }

    .cards-grid,
    .form-grid,
    .form-grid-inner {
        grid-template-columns: 1fr;
    }

    .section-header,
    .summary-row {
        display: grid;
    }

    .summary-row strong {
        text-align: left;
    }

    .auth-card {
        padding: 24px;
    }

    .mobile-nav {
        display: none !important;
    }
}

@media (max-width: 520px) {
    .table-actions {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    .table-actions > a,
    .table-actions > form,
    .table-actions .btn,
    .table-actions button {
        width: 100% !important;
    }
}

/* USTAWIENIA — AKORDEON I RESPONSYWNE TABELE */

/* Ważne: globalna reguła .card strong powiększa tekst w kartach.
 *  W tabelach nie chcemy tego efektu, dlatego resetujemy strong w tabelach. */

.data-table td strong {
    display: inline;
    font-size: inherit;
    margin-bottom: 0;
}

.settings-accordion-header {
    align-items: center;
}

.settings-accordion-header > div:first-child {
    min-width: 0;
}

.settings-accordion-toggle {
    min-width: 92px;
}

.settings-accordion-section.is-open .settings-toggle-open,
.settings-accordion-section:not(.is-open) .settings-toggle-close {
    display: none;
}

.settings-accordion-content[hidden] {
    display: none !important;
}

.settings-accordion-content {
    padding-top: 4px;
}

.settings-section-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    margin: 0 0 16px;
}

.settings-form-anchor {
    position: relative;
    top: -18px;
    height: 1px;
}

.settings-edit-panel {
    margin: 0 0 18px;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #f8fafc;
}

.settings-edit-panel h3 {
    margin: 0 0 16px;
    font-size: 18px;
}

@media (max-width: 760px) {
    .settings-accordion-header {
        display: grid;
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .settings-accordion-header .btn,
    .settings-section-actions .btn {
        width: 100%;
    }

    .settings-section-actions {
        display: grid;
        grid-template-columns: 1fr;
        margin-bottom: 14px;
    }

    .settings-edit-panel {
        padding: 14px;
        margin-left: -2px;
        margin-right: -2px;
    }

    .settings-responsive-table {
        min-width: 0;
        border-collapse: separate;
        border-spacing: 0 12px;
    }

    .settings-responsive-table thead {
        display: none;
    }

    .settings-responsive-table,
    .settings-responsive-table tbody,
    .settings-responsive-table tr,
    .settings-responsive-table td {
        display: block;
        width: 100%;
    }

    .settings-responsive-table tr {
        padding: 12px;
        border: 1px solid var(--border);
        border-radius: 16px;
        background: #fff;
    }

    .settings-responsive-table td {
        display: grid;
        grid-template-columns: minmax(105px, 38%) 1fr;
        gap: 10px;
        padding: 9px 0;
        border-bottom: 1px solid var(--border);
    }

    .settings-responsive-table td:last-child {
        border-bottom: 0;
    }

    .settings-responsive-table td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 12px;
        font-weight: 800;
    }

    .settings-responsive-table td[colspan]::before {
        content: none;
    }

    .settings-responsive-table td[colspan] {
        display: block;
    }

    .settings-responsive-table .table-actions {
        display: grid !important;
        grid-template-columns: 1fr;
        gap: 8px !important;
    }

    .settings-responsive-table .table-actions > a,
    .settings-responsive-table .table-actions > form,
    .settings-responsive-table .table-actions .btn,
    .settings-responsive-table .table-actions button {
        width: 100% !important;
    }
}

@media (max-width: 420px) {
    .settings-responsive-table td {
        grid-template-columns: 1fr;
        gap: 4px;
    }
}

/* GÓRNY PASEK UŻYTKOWNIKA */

.app-user-header {
    min-height: var(--app-header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 24px;
    background: linear-gradient(135deg, var(--header-bg) 0%, var(--header-bg-soft) 100%);
    color: var(--header-text);
    border-bottom: 1px solid var(--header-border);
    position: sticky;
    top: 0;
    z-index: 10000;
    box-shadow: 0 12px 34px rgba(15, 23, 42, 0.18);
}

.app-user-header-title {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.app-user-header-title strong {
    font-size: 16px;
    line-height: 1.2;
    color: var(--header-text);
    overflow-wrap: anywhere;
}

.app-user-header-title span {
    color: var(--header-muted);
    font-size: 12px;
    font-weight: 700;
}

.app-user-area {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    min-width: 0;
}

.app-user-summary {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    padding: 6px 10px;
    border: 1px solid var(--header-border);
    border-radius: 999px;
    background: var(--header-control-bg);
    color: var(--header-text);
    backdrop-filter: blur(10px);
}

.app-user-avatar {
    width: 34px;
    height: 34px;
    min-width: 34px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: #ffffff;
    color: var(--header-bg-soft);
    font-weight: 900;
    font-size: 14px;
}

.app-user-text {
    display: grid;
    gap: 1px;
    min-width: 0;
}

.app-user-text strong {
    font-size: 14px;
    line-height: 1.2;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--header-text);
}

.app-user-text small {
    color: var(--header-muted);
    font-size: 12px;
    font-weight: 700;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-user-menu {
    position: relative;
}

.app-user-menu summary {
    list-style: none;
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border: 1px solid var(--header-border);
    border-radius: 14px;
    background: var(--header-control-bg);
    color: var(--header-text);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    user-select: none;
    backdrop-filter: blur(10px);
}

.app-user-menu summary::-webkit-details-marker {
    display: none;
}

.app-user-menu summary:hover,
.app-user-menu[open] summary {
    background: var(--header-control-hover);
    border-color: rgba(255, 255, 255, 0.28);
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.08);
}

.app-user-menu-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: min(280px, calc(100vw - 24px));
    display: grid;
    gap: 4px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #fff;
    color: var(--text);
    box-shadow: var(--shadow);
    z-index: 10001;
}

.app-user-menu-head {
    display: grid;
    gap: 3px;
    padding: 10px 10px 12px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
}

.app-user-menu-head strong {
    font-size: 14px;
    line-height: 1.25;
    color: var(--text);
}

.app-user-menu-head span,
.app-user-menu-head small {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.app-user-menu-dropdown a {
    display: block;
    padding: 10px 11px;
    border-radius: 11px;
    color: var(--text);
    font-size: 14px;
    font-weight: 700;
}

.app-user-menu-dropdown a:hover {
    background: #eff6ff;
    color: var(--primary-dark);
}

.app-logout-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 10px 14px;
    border-radius: 14px;
    background: #dc2626;
    color: #fff;
    font-size: 14px;
    font-weight: 800;
    white-space: nowrap;
    box-shadow: 0 8px 18px rgba(220, 38, 38, 0.22);
}

.app-logout-btn:hover {
    background: #b91c1c;
}

@media (max-width: 760px) {
    .app-user-header {
        align-items: stretch;
        display: grid;
        grid-template-columns: 1fr;
        gap: 10px;
        padding: 10px 12px;
        position: static;
        border-bottom: 0;
        box-shadow: none;
    }

    .app-user-area {
        justify-content: space-between;
        width: 100%;
    }

    .app-user-summary {
        flex: 1;
        min-width: 0;
    }

    .app-user-text strong,
    .app-user-text small {
        max-width: none;
    }

    .app-logout-btn {
        padding-left: 12px;
        padding-right: 12px;
    }
}

@media (max-width: 420px) {
    .app-user-text small {
        display: none;
    }

    .app-user-header-title span {
        display: none;
    }
}

/* SPRAWDZANIE OBECNOŚCI NA ZEBRANIU */

.attendance-page {
    display: grid;
    gap: 18px;
}

.attendance-topbar {
    margin-bottom: 0;
}

.attendance-topbar p {
    margin: 5px 0 0;
    color: var(--muted);
}

.attendance-topbar p strong {
    font-size: inherit;
    margin: 0;
}

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

.attendance-self-card {
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 16px;
    padding: 18px 20px;
    border-left: 5px solid var(--primary);
}

.attendance-self-card.is-present {
    border-left-color: var(--success-text);
    background: #f0fdf4;
}

.attendance-self-copy strong {
    display: block;
    margin: 0 0 4px;
    font-size: 17px;
}

.attendance-self-copy small {
    display: block;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
}

.attendance-self-button:disabled {
    background: #94a3b8;
    cursor: default;
}

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

.attendance-stat-card {
    min-height: 0;
    padding: 14px 16px;
}

.attendance-stat-card span {
    display: block;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.attendance-stat-card strong {
    display: block;
    margin: 4px 0 0;
    font-size: 24px;
    line-height: 1.15;
}

.attendance-stat-card.quorum-ok {
    background: var(--success-bg);
    color: var(--success-text);
}

.attendance-stat-card.quorum-no {
    background: #fff7ed;
    color: #9a3412;
}

.attendance-workspace {
    min-height: 0;
    padding: 20px;
}

.attendance-workspace-header {
    align-items: center;
    margin-bottom: 16px;
}

.attendance-workspace-header h2 {
    margin: 0 0 4px;
    font-size: 20px;
}

.attendance-workspace-header p {
    margin: 0;
}

.attendance-mode-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.attendance-mode-tab {
    min-width: 120px;
}

.attendance-mode-tab.is-active {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
}

.attendance-panel {
    display: grid;
    gap: 12px;
}

.attendance-panel[hidden] {
    display: none !important;
}

.attendance-toolbar {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) auto;
    gap: 12px;
    align-items: center;
}

.attendance-search-field {
    gap: 0;
}

.attendance-counter {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    white-space: nowrap;
}

.attendance-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 8px;
    max-height: 65vh;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 2px 4px 2px 2px;
    overscroll-behavior: contain;
}

.attendance-person {
    min-width: 0;
    min-height: 44px;
    display: grid;
    grid-template-columns: 10px minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
}

.attendance-person.is-present {
    border-color: #86efac;
    background: #f0fdf4;
}

.attendance-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #dc2626;
}

.attendance-person.is-present .attendance-dot {
    background: #16a34a;
}

.attendance-name {
    min-width: 0;
}

.attendance-name strong {
    display: block;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    line-height: 1.25;
}

.attendance-name small {
    display: block;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.2;
}

.attendance-actions {
    display: flex;
    gap: 4px;
}

.attendance-action {
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: #fff;
    color: var(--text);
    font: inherit;
    font-size: 15px;
    font-weight: 900;
    cursor: pointer;
}

.attendance-action.present {
    color: var(--success-text);
}

.attendance-action.absent {
    color: var(--danger-text);
}

.attendance-action:hover:not(:disabled) {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(49, 87, 213, 0.10);
}

.attendance-action:disabled {
    cursor: default;
    opacity: 0.38;
}

.attendance-person.is-present .attendance-action.present,
.attendance-person.is-absent .attendance-action.absent {
    opacity: 1;
}

.attendance-person.is-present .attendance-action.present {
    border-color: #86efac;
    background: var(--success-bg);
}

.attendance-person.is-absent .attendance-action.absent {
    border-color: #fecaca;
    background: var(--danger-bg);
}

.attendance-qr-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.6fr);
    gap: 14px;
}

.attendance-subcard {
    min-width: 0;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #f8fafc;
}

.attendance-camera {
    display: block;
    width: 100%;
    min-height: 260px;
    max-height: 62vh;
    border-radius: 14px;
    background: #0f172a;
    object-fit: cover;
}

.attendance-camera-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.attendance-qr-status {
    margin-top: 12px;
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    font-size: 13px;
    line-height: 1.4;
}

.attendance-qr-status.is-success {
    border-color: #86efac;
    background: var(--success-bg);
    color: var(--success-text);
}

.attendance-qr-status.is-error {
    border-color: #fecaca;
    background: var(--danger-bg);
    color: var(--danger-text);
}

.attendance-manual-code {
    display: grid;
    gap: 10px;
}

.attendance-manual-code .form-field > span {
    font-size: 14px;
    font-weight: 800;
}

.attendance-scans {
    display: grid;
    gap: 6px;
    max-height: 320px;
    margin-top: 14px;
    overflow-y: auto;
}

.attendance-scan {
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: #fff;
    font-size: 12px;
    line-height: 1.35;
}

.attendance-scan strong {
    display: block;
    margin: 0 0 2px;
    font-size: 12px;
}

.attendance-empty {
    padding: 22px;
    border: 1px dashed #cbd5e1;
    border-radius: 14px;
    background: #f8fafc;
    color: var(--muted);
    text-align: center;
    font-size: 14px;
    line-height: 1.5;
}

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

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

    .attendance-qr-grid {
        grid-template-columns: 1fr;
    }

    .attendance-list {
        max-height: none;
    }
}

@media (max-width: 760px) {
    .attendance-topbar {
        display: grid;
        grid-template-columns: 1fr;
    }

    .attendance-topbar-actions,
    .attendance-topbar-actions .btn {
        width: 100%;
    }

    .attendance-self-card {
        grid-template-columns: 1fr;
        padding: 16px;
    }

    .attendance-self-button {
        width: 100%;
    }

    .attendance-workspace {
        padding: 16px;
    }

    .attendance-workspace-header {
        display: grid;
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .attendance-mode-tabs {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: 100%;
    }

    .attendance-mode-tab {
        min-width: 0;
        width: 100%;
    }

    .attendance-toolbar {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .attendance-counter {
        white-space: normal;
    }
}

@media (max-width: 520px) {
    .attendance-stats {
        grid-template-columns: 1fr 1fr;
    }

    .attendance-list {
        grid-template-columns: 1fr;
    }

    .attendance-person {
        grid-template-columns: 9px minmax(0, 1fr) auto;
    }

    .attendance-camera-actions .btn {
        width: 100%;
    }
}

@media (max-width: 380px) {
    .attendance-stats {
        grid-template-columns: 1fr;
    }
}
