:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-soft: #eef3f8;
    --text: #172033;
    --muted: #697386;
    --line: #dbe3ee;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #16a34a;
    --danger: #dc2626;
    --sidebar: #172033;
}

* {
    box-sizing: border-box;
}

body {
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
}

a {
    text-decoration: none;
}

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

.app-sidebar {
    width: 270px;
    position: sticky;
    top: 0;
    height: 100vh;
    background: var(--sidebar);
    color: #fff;
    padding: 18px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-weight: 700;
    min-height: 44px;
}

.brand:hover {
    color: #fff;
}

.brand-mark,
.login-mark {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: #2dd4bf;
    color: #102027;
    font-size: 1.35rem;
}

.sidebar-nav {
    display: grid;
    gap: 6px;
    margin-top: 24px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #d8e0ea;
    padding: 10px 12px;
    border-radius: 8px;
}

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

.mobile-nav {
    margin-top: 0;
}

.mobile-nav a {
    color: var(--text);
}

.mobile-nav a:hover,
.mobile-nav a.active {
    background: var(--surface-soft);
    color: var(--text);
}

.sidebar-profile {
    margin-top: auto;
    border-top: 1px solid rgba(255, 255, 255, .13);
    padding-top: 16px;
}

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

.topbar {
    min-height: 78px;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 24px;
    background: rgba(255, 255, 255, .95);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 20;
}

.topbar h1 {
    font-size: 1.25rem;
    margin: 0;
    font-weight: 700;
}

.content {
    padding: 24px;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
    box-shadow: 0 8px 24px rgba(23, 32, 51, .05);
}

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

.panel-header h2 {
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
}

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

.stat-card {
    position: relative;
    min-height: 112px;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}

.stat-card span {
    display: block;
    color: var(--muted);
    margin-bottom: 10px;
}

.stat-card strong {
    font-size: clamp(1.35rem, 2vw, 1.85rem);
}

.stat-card i {
    position: absolute;
    right: 14px;
    bottom: 10px;
    font-size: 2rem;
    color: rgba(37, 99, 235, .18);
}

.filter-bar,
.page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.filter-bar .form-control,
.filter-bar .form-select {
    width: auto;
    min-width: 150px;
}

.page-actions {
    justify-content: space-between;
    margin-bottom: 14px;
}

.action-row {
    display: inline-flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
}

.icon-btn {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
}

.status-list {
    display: grid;
    gap: 10px;
}

.status-list > div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}

.status-list > div:last-child {
    border-bottom: 0;
}

.status-list span {
    color: var(--muted);
}

.camera-box {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    background: #101828;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--line);
}

.camera-box video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.camera-placeholder {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 10px;
    color: #e5edf5;
    text-align: center;
    padding: 16px;
}

.camera-placeholder i {
    font-size: 2.5rem;
}

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

.qr-layout {
    display: grid;
    grid-template-columns: minmax(260px, 360px) 1fr;
    gap: 24px;
    align-items: start;
}

.qr-box {
    width: 100%;
    max-width: 360px;
    min-height: 360px;
    display: grid;
    place-items: center;
    align-content: center;
    border: 1px dashed var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 16px;
    overflow: hidden;
    contain: layout paint;
}

.qr-box #qrCode {
    width: 280px;
    height: 280px;
    display: grid;
    place-items: center;
    overflow: hidden;
}

.qr-box #qrCode img,
.qr-box #qrCode canvas {
    width: 280px !important;
    height: 280px !important;
    display: block;
    max-width: none;
    max-height: none;
}

.qr-fallback {
    word-break: break-all;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    width: 100%;
    min-height: 280px;
    display: grid;
    place-items: center;
    text-align: center;
    font-size: .9rem;
    line-height: 1.4;
}

.qr-panel .qr-info .status-list {
    min-height: 200px;
}

.qr-panel .qr-meta {
    display: grid;
    gap: 10px;
    min-height: 200px;
}

.qr-panel .qr-meta-row {
    display: grid;
    grid-template-columns: 150px minmax(0, 1fr);
    gap: 12px;
    align-items: start;
    min-height: 28px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}

.qr-panel .qr-meta-row:last-child {
    border-bottom: 0;
}

.qr-panel .qr-meta-label {
    color: var(--muted);
    line-height: 1.35;
}

.qr-panel .qr-meta-value {
    min-width: 0;
    line-height: 1.35;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.qr-panel .qr-meta-break {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.qr-panel .qr-info .status-list > div {
    min-height: 28px;
    align-items: center;
}

.qr-panel .qr-info strong,
.qr-panel .qr-info .form-control,
.qr-panel .qr-info .badge {
    font-size: .9rem;
    line-height: 1.35;
}

.qr-panel .qr-info strong {
    min-height: 1.35em;
    display: inline-flex;
    align-items: center;
}

.qr-panel .qr-token-text {
    min-height: 84px;
    resize: none;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

@media (max-width: 767.98px) {
    .qr-panel .qr-meta-row {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .qr-panel .qr-meta-label {
        font-weight: 600;
    }
}

.auth-body {
    min-height: 100vh;
    background: #edf2f7;
}

.auth-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.auth-panel {
    width: min(100%, 430px);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 28px;
    box-shadow: 0 24px 80px rgba(23, 32, 51, .12);
}

.login-mark {
    width: 56px;
    height: 56px;
    font-size: 1.7rem;
}

.login-help {
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    color: var(--muted);
    font-size: .9rem;
}

.settings-form hr {
    border-color: var(--line);
    margin: 24px 0;
}

.form-footer {
    margin-top: 20px;
    display: flex;
    justify-content: flex-end;
}

.table th {
    white-space: nowrap;
    color: #334155;
}

.report-table {
    min-width: 1600px;
}

.report-coord-cell {
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.selfie-thumb-btn {
    border: 0;
    background: transparent;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.selfie-thumb {
    width: 54px;
    height: 54px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--line);
    display: block;
}

.report-print-header {
    border-bottom: 1px solid var(--line);
    padding-bottom: 12px;
}

.report-print-header h2 {
    font-weight: 700;
}

.report-panel {
    overflow: hidden;
}

.btn {
    border-radius: 8px;
}

@media (max-width: 991.98px) {
    .topbar {
        padding: 12px 16px;
    }

    .content {
        padding: 16px;
    }

    .page-actions {
        align-items: stretch;
    }

    .filter-bar,
    .page-actions,
    .filter-bar .form-control,
    .filter-bar .form-select {
        width: 100%;
    }

    .filter-bar .btn,
    .page-actions > .btn {
        width: 100%;
    }

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

    .report-table {
        min-width: 1400px;
    }
}

@media (max-width: 575.98px) {
    body {
        font-size: 14px;
    }

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

    .topbar h1 {
        font-size: 1.05rem;
    }

    .content {
        padding: 12px;
    }

    .panel,
    .auth-panel {
        padding: 14px;
    }

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

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

    .selfie-thumb {
        width: 48px;
        height: 48px;
    }
}

@media print {
    body {
        background: #fff;
        font-size: 11px;
    }

    .app-sidebar,
    .topbar,
    .filter-bar,
    .page-actions,
    .btn,
    .alert,
    .offcanvas,
    .modal,
    .report-print-header .small {
        display: none !important;
    }

    .app-shell,
    .app-main,
    .content {
        display: block;
        padding: 0;
        margin: 0;
    }

    .panel {
        box-shadow: none;
        border: 0;
        padding: 0;
    }

    .report-table {
        min-width: 0;
        font-size: 10px;
    }

    .selfie-thumb {
        width: 60px;
        height: 60px;
    }

    .report-coord-cell {
        white-space: normal !important;
    }

    .report-panel {
        box-shadow: none;
        border: 0;
    }

    .report-print-header {
        display: block !important;
    }
}
