@import url('https://fonts.googleapis.com/css2?family=Sora:wght@400;600;700;800&family=Source+Sans+3:wght@400;500;600;700&display=swap');

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --accent: #0ea5e9;
    --surface: #ffffff;
    --surface-soft: #f4f9ff;
    --background: #edf3f9;
    --text-main: #0f172a;
    --text-muted: #475569;
    --border: #d7e3ee;
    --shadow: 0 14px 34px -24px rgb(15 23 42 / 0.55);
    --radius: 14px;
}

:root[data-theme="dark"] {
    --primary: #60a5fa;
    --primary-hover: #3b82f6;
    --accent: #38bdf8;
    --surface: #111b2e;
    --surface-soft: #0f172a;
    --background: #070d18;
    --text-main: #e2e8f0;
    --text-muted: #9fb0c8;
    --border: #23324a;
    --shadow: 0 16px 30px -22px rgb(2 8 22 / 0.86);
}

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

body {
    min-height: 100vh;
    font-family: 'Source Sans 3', sans-serif;
    color: var(--text-main);
    line-height: 1.5;
    background:
        radial-gradient(circle at 10% 14%, rgb(14 165 233 / 0.16), transparent 25%),
        radial-gradient(circle at 88% 16%, rgb(37 99 235 / 0.14), transparent 28%),
        linear-gradient(180deg, #f8fbff 0%, var(--background) 55%, #e8eff7 100%);
}

:root[data-theme="dark"] body {
    background:
        radial-gradient(circle at 12% 12%, rgb(59 130 246 / 0.16), transparent 28%),
        radial-gradient(circle at 88% 16%, rgb(56 189 248 / 0.13), transparent 30%),
        linear-gradient(180deg, #0a1324 0%, var(--background) 58%, #08101c 100%);
}

a {
    color: inherit;
}

header {
    background: linear-gradient(125deg, #1e3a8a 0%, #2563eb 45%, #0ea5e9 100%);
    color: #fff;
    padding: 30px 20px;
    box-shadow: 0 12px 26px -16px rgb(2 28 30 / 0.58);
    margin-bottom: 30px;
    position: relative;
    overflow: hidden;
}

header::after {
    content: '';
    position: absolute;
    right: -24px;
    top: -38px;
    width: 260px;
    height: 150px;
    border-radius: 999px;
    background: rgb(255 255 255 / 0.14);
    transform: rotate(-12deg);
}

.brand {
    display: flex;
    align-items: center;
    gap: 16px;
    position: relative;
    z-index: 1;
}

.brand-logo {
    width: 54px;
    height: 54px;
    border-radius: 16px;
    background: linear-gradient(135deg, #f8fafc 0%, #dbeafe 100%);
    display: grid;
    place-items: center;
    box-shadow: inset 0 0 0 2px rgb(255 255 255 / 0.55);
    position: relative;
}

.brand-logo::before {
    content: '';
    width: 24px;
    height: 24px;
    border: 3px solid #2563eb;
    border-radius: 999px;
    display: block;
}

.brand-logo::after {
    content: '';
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: #0ea5e9;
    right: 12px;
    top: 12px;
    box-shadow: -16px 16px 0 #60a5fa;
}

header h1 {
    font-family: 'Sora', sans-serif;
    font-size: 1.95rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    margin-bottom: 4px;
}

header p {
    font-size: 1rem;
    opacity: 0.94;
}

.container {
    max-width: 1120px;
    margin: 0 auto;
    padding: 0 24px 60px;
}

.main-content {
    animation: fadeInUp 0.28s ease;
}

h1,
h2,
h3 {
    font-family: 'Sora', sans-serif;
    color: var(--text-main);
    letter-spacing: -0.02em;
    margin-bottom: 1rem;
}

.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 28px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin-bottom: 24px;
}

.card-sm {
    max-width: 560px;
    margin-left: auto;
    margin-right: auto;
}

.card-md {
    max-width: 720px;
    margin-left: auto;
    margin-right: auto;
}

.card-soft {
    background: linear-gradient(140deg, #f9fcff 0%, #eff6ff 54%, #ecf7ff 100%);
    border-color: #cfdfed;
}

.compact-card {
    padding: 20px;
}

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

.panel-title {
    margin: 0;
    font-size: 1.38rem;
}

.panel-subtitle {
    margin-bottom: 10px;
    color: var(--text-muted);
    font-weight: 600;
}

.form-group {
    margin-bottom: 18px;
}

label {
    display: block;
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 8px;
}

.form-control {
    width: 100%;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #fff;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgb(2 132 199 / 0.14);
}

.inline-form {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.inline-form .form-control {
    flex: 1;
    min-width: 220px;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.form-actions .btn {
    flex: 1;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 11px 20px;
    border-radius: 10px;
    border: 1px solid transparent;
    background: var(--primary);
    color: #fff;
    font-size: 0.94rem;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.18s, background-color 0.18s, border-color 0.18s, color 0.18s;
}

.btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    pointer-events: none;
}

.btn:focus-visible {
    outline: 3px solid rgb(2 132 199 / 0.25);
    outline-offset: 2px;
}

.btn-sm {
    padding: 8px 12px;
    font-size: 0.82rem;
    border-radius: 8px;
}

.btn-block {
    width: 100%;
}

.btn-outline {
    background: #fff;
    color: #0d4d70;
    border-color: #adc4d8;
}

.btn-outline:hover {
    background: #eff6fb;
    color: #0f3f5d;
}

.theme-toggle {
    min-width: 118px;
}

.btn-danger {
    background: #fff1f2;
    color: #be123c;
    border-color: #fecdd3;
}

.btn-danger:hover {
    background: #e11d48;
    color: #fff;
    border-color: #e11d48;
}

.btn-success {
    background: #e0f2fe;
    color: #075985;
    border-color: #7dd3fc;
}

.btn-success:hover {
    background: #0369a1;
    color: #fff;
    border-color: #0369a1;
}

.table-container {
    overflow-x: auto;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin: 16px 0;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th {
    background: #f1f7fd;
    padding: 14px 16px;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

td {
    padding: 13px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 0.95rem;
}

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

tr:hover td {
    background-color: #f8fbff;
}

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

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 18px;
    margin-top: 22px;
}

.dashboard-grid {
    margin-bottom: 40px;
}

.dashboard-grid--admin {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 18px;
}

.dashboard-grid--admin .stat-card {
    flex: 1 1 240px;
    max-width: 265px;
}

.stat-card {
    padding: 28px;
    text-align: center;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-decoration: none;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid var(--border);
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 16px 30px -20px rgb(15 23 42 / 0.58);
}

.stat-card .icon {
    font-size: 2.35rem;
    margin-bottom: 14px;
    display: block;
}

.stat-card h3 {
    margin-bottom: 6px;
    font-size: 1.25rem;
}

.stat-card p {
    color: var(--text-muted);
    font-size: 0.93rem;
}

.stat-card--featured {
    background: linear-gradient(140deg, #fcfeff 0%, #edf8ff 58%, #ecfff7 100%);
    border-color: #bad8e9;
}

.user-strip {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    background: #fff;
    padding: 14px 22px;
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    gap: 14px;
}

.user-strip-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.user-strip-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: linear-gradient(140deg, #1d4ed8 0%, #0ea5e9 100%);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.15rem;
}

.user-name {
    font-weight: 700;
    color: var(--text-main);
}

.user-role {
    font-size: 0.85rem;
    color: var(--text-muted);
}

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

.card-grid .card,
.query-grid .card {
    margin: 0;
}

.query-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 14px;
    margin-top: 14px;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    background: #dbeafe;
    color: #1e3a8a;
    border: 1px solid #93c5fd;
}

.status-pill--pending {
    background: #fff7ed;
    color: #9a3412;
    border-color: #fdba74;
}

.status-pill--present {
    background: #dcfce7;
    color: #166534;
    border-color: #86efac;
}

.status-pill--absent {
    background: #fee2e2;
    color: #991b1b;
    border-color: #fca5a5;
}

.status-pill--late {
    background: #fff7ed;
    color: #ea580c;
    border-color: #fdba74;
}

.status-pill--license {
    background: #dbeafe;
    color: #1d4ed8;
    border-color: #93c5fd;
}

.report-pdf {
    background: #dc2626;
    border-color: #b91c1c;
    color: #fff;
}

.report-excel {
    background: #16a34a;
    border-color: #15803d;
    color: #fff;
}

.status-pill strong {
    margin-left: 5px;
}

.code-pill,
code {
    display: inline-block;
    background: #eff6ff;
    color: #1e3a8a;
    border: 1px solid #c7d2fe;
    border-radius: 6px;
    font-size: 0.84rem;
    padding: 2px 8px;
    font-family: 'Consolas', 'Courier New', monospace;
}

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

.empty-state-icon {
    font-size: 2.8rem;
    display: block;
    margin-bottom: 10px;
}

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

.qr-image-wrap {
    margin-top: 12px;
    display: flex;
    justify-content: center;
}

.qr-image {
    width: 300px;
    max-width: 100%;
    border-radius: 12px;
    border: 1px solid #cbd5e1;
    background: #fff;
    padding: 8px;
}

.qr-scanner-wrap {
    margin-top: 14px;
    display: grid;
    gap: 10px;
}

.qr-reader {
    width: 100%;
    max-width: 380px;
    border-radius: 12px;
    border: 1px solid #cbd5e1;
    background: #fff;
    overflow: hidden;
}

.alert {
    padding: 12px 15px;
    border-radius: 10px;
    margin-bottom: 14px;
    font-weight: 600;
}

.alert-success {
    background-color: #dbeafe;
    color: #1e3a8a;
    border-left: 4px solid #3b82f6;
}

.alert-danger {
    background-color: #fee2e2;
    color: #991b1b;
    border-left: 4px solid #ef4444;
}

.toast-stack {
    position: fixed;
    top: 16px;
    right: 18px;
    z-index: 9999;
    width: min(360px, calc(100vw - 24px));
    display: grid;
    gap: 10px;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 11px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #0f172a;
    box-shadow: 0 14px 26px -18px rgb(15 23 42 / 0.7);
    animation: toastIn 0.22s ease;
}

.toast-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: #64748b;
}

.toast-text {
    font-size: 0.9rem;
    line-height: 1.35;
    font-weight: 600;
}

.toast-close {
    border: 0;
    background: transparent;
    color: #475569;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 700;
    width: 24px;
    height: 24px;
    border-radius: 6px;
}

.toast-close:hover {
    background: #f1f5f9;
}

.toast--success {
    border-color: #86efac;
    background: #f0fdf4;
}

.toast--success .toast-dot {
    background: #16a34a;
}

.toast--danger {
    border-color: #fca5a5;
    background: #fef2f2;
}

.toast--danger .toast-dot {
    background: #dc2626;
}

.toast--warning {
    border-color: #fdba74;
    background: #fff7ed;
}

.toast--warning .toast-dot {
    background: #ea580c;
}

.toast--info {
    border-color: #93c5fd;
    background: #eff6ff;
}

.toast--info .toast-dot {
    background: #2563eb;
}

.toast-hide {
    animation: toastOut 0.2s ease forwards;
}

body.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
}

.login-wrap {
    width: 100%;
    max-width: 430px;
}

.login-card {
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 22px 45px -28px rgb(15 23 42 / 0.75);
    padding: 2rem 1.8rem 1.5rem;
    border: 1px solid #d9e6f1;
}

.login-top-actions {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 6px;
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: center;
    margin-bottom: 0.5rem;
}

.login-logo {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, #f8fafc 0%, #dbeafe 100%);
    position: relative;
    box-shadow: inset 0 0 0 2px rgb(255 255 255 / 0.55);
}

.login-logo::before {
    content: '';
    width: 19px;
    height: 19px;
    border: 3px solid #2563eb;
    border-radius: 999px;
    position: absolute;
    left: 8px;
    top: 8px;
}

.login-logo::after {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: #0ea5e9;
    right: 8px;
    top: 8px;
    box-shadow: -12px 12px 0 #60a5fa;
}

.login-brand-text {
    font-family: 'Sora', sans-serif;
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.03em;
}

.login-subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 0.95rem;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 0.95rem;
    margin-top: 0.8rem;
}

.login-form .input-group {
    display: flex;
    flex-direction: column;
}

.login-note {
    margin-top: 0.9rem;
    font-size: 0.84rem;
    color: #64748b;
    text-align: center;
}

.login-icon {
    margin-right: 0.35rem;
}

:root[data-theme="dark"] .card,
:root[data-theme="dark"] .stat-card,
:root[data-theme="dark"] .user-strip,
:root[data-theme="dark"] .table-container,
:root[data-theme="dark"] .login-card {
    background: var(--surface);
    border-color: var(--border);
}

:root[data-theme="dark"] .card-soft,
:root[data-theme="dark"] .stat-card--featured {
    background: linear-gradient(145deg, #111e34 0%, #13243d 60%, #173452 100%);
    border-color: #2f4767;
}

:root[data-theme="dark"] .form-control {
    background: var(--surface-soft);
    border-color: var(--border);
    color: var(--text-main);
}

:root[data-theme="dark"] .form-control::placeholder {
    color: #7d8fa8;
}

:root[data-theme="dark"] th {
    background: #142238;
    border-bottom-color: var(--border);
}

:root[data-theme="dark"] td {
    border-bottom-color: var(--border);
}

:root[data-theme="dark"] tr:hover td {
    background-color: #17263d;
}

:root[data-theme="dark"] .btn-outline {
    background: #17243a;
    color: #dbeafe;
    border-color: #355074;
}

:root[data-theme="dark"] .btn-outline:hover {
    background: #22334d;
    color: #f8fbff;
}

:root[data-theme="dark"] .btn-danger {
    background: #3b1320;
    color: #fecdd3;
    border-color: #7f1d1d;
}

:root[data-theme="dark"] .btn-danger:hover {
    background: #be123c;
    border-color: #be123c;
}

:root[data-theme="dark"] .btn-success {
    background: #10263c;
    color: #bae6fd;
    border-color: #1f4b74;
}

:root[data-theme="dark"] .btn-success:hover {
    background: #0369a1;
    border-color: #0369a1;
}

:root[data-theme="dark"] .code-pill,
:root[data-theme="dark"] code {
    background: #192843;
    color: #bfdbfe;
    border-color: #31547c;
}

:root[data-theme="dark"] .status-pill--pending {
    background: #3b240f;
    color: #fdba74;
    border-color: #7c4a1f;
}

:root[data-theme="dark"] .status-pill--late {
    background: #3b240f;
    color: #fb923c;
    border-color: #9a3412;
}

:root[data-theme="dark"] .status-pill--present {
    background: #103022;
    color: #86efac;
    border-color: #1e5a3f;
}

:root[data-theme="dark"] .status-pill--absent {
    background: #3b171a;
    color: #fecaca;
    border-color: #7f1d1d;
}

:root[data-theme="dark"] .status-pill--license {
    background: #10263a;
    color: #bae6fd;
    border-color: #1f4b74;
}

:root[data-theme="dark"] .alert-success {
    background: #10263a;
    color: #bae6fd;
    border-left-color: #38bdf8;
}

:root[data-theme="dark"] .alert-danger {
    background: #3b171a;
    color: #fecaca;
    border-left-color: #ef4444;
}

:root[data-theme="dark"] .toast {
    background: #111b2e;
    color: #dbe7f6;
    border-color: #2d4361;
}

:root[data-theme="dark"] .toast-close {
    color: #9fb0c8;
}

:root[data-theme="dark"] .toast-close:hover {
    background: #1c2c45;
}

:root[data-theme="dark"] .toast--success {
    background: #102b1f;
    border-color: #1e5a3f;
}

:root[data-theme="dark"] .toast--danger {
    background: #3b171a;
    border-color: #7f1d1d;
}

:root[data-theme="dark"] .toast--warning {
    background: #3b240f;
    border-color: #7c4a1f;
}

:root[data-theme="dark"] .toast--info {
    background: #10263a;
    border-color: #1f4b74;
}

:root[data-theme="dark"] .qr-image,
:root[data-theme="dark"] .qr-reader {
    background: #fff;
    border-color: #334155;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(-8px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }

    to {
        opacity: 0;
        transform: translateY(-6px) scale(0.98);
    }
}

@media (max-width: 900px) {
    .container {
        padding: 0 16px 42px;
    }

    .card {
        padding: 22px;
    }
}

@media (max-width: 700px) {
    header {
        padding: 22px 16px;
    }

    header h1 {
        font-size: 1.45rem;
    }

    header p {
        font-size: 0.9rem;
    }

    .brand {
        gap: 12px;
    }

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

    .dashboard-grid--admin {
        display: grid;
        grid-template-columns: 1fr;
    }

    .dashboard-grid--admin .stat-card {
        max-width: 100%;
    }

    .user-strip {
        flex-direction: column;
        align-items: stretch;
    }

    .user-strip .btn {
        width: 100%;
    }

    .user-strip-actions {
        width: 100%;
        flex-direction: column;
    }

    .user-strip-actions .btn {
        width: 100%;
    }

    .form-actions {
        flex-direction: column;
    }

    .actions-cell {
        white-space: normal;
    }
}
