:root {
    --bg: #f4f7fb;
    --surface: #ffffff;
    --sidebar: #0f172a;
    --sidebar-hover: #1e293b;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --primary: #0d9488;
    --primary-dark: #0f766e;
    --primary-soft: #ccfbf1;
    --danger: #dc2626;
    --danger-soft: #fee2e2;
    --warning: #d97706;
    --warning-soft: #fef3c7;
    --success: #059669;
    --qc-completed: #059669;
    --qc-completed-soft: #dcfce7;
    --qc-completed-text: #166534;
    --qc-seller: #2563eb;
    --qc-seller-soft: #dbeafe;
    --qc-seller-text: #1e40af;
    --qc-scan: #d97706;
    --qc-scan-soft: #fef3c7;
    --qc-scan-text: #b45309;
    --qc-secure: #0891b2;
    --qc-secure-soft: #cffafe;
    --qc-secure-text: #0e7490;
    --qc-invalid: #dc2626;
    --qc-invalid-soft: #fee2e2;
    --qc-invalid-text: #b91c1c;
    --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
    --radius: 14px;
    --radius-sm: 10px;
    --sidebar-width: 270px;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: "Plus Jakarta Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.55;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

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

/* Login */
.login-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
}

.login-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px 32px;
    background: var(--surface);
}

.login-card {
    width: min(420px, 100%);
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 32px;
}

.login-brand img {
    width: 52px;
    height: 52px;
    object-fit: contain;
    border-radius: 12px;
}

.login-brand strong {
    display: block;
    font-size: 1.15rem;
}

.login-brand span {
    color: var(--muted);
    font-size: 0.9rem;
}

.login-card h1 {
    margin: 0 0 8px;
    font-size: 2rem;
    letter-spacing: -0.03em;
}

.login-card .subtitle {
    margin: 0 0 28px;
    color: var(--muted);
}

.field {
    margin-bottom: 18px;
}

.field label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    font-weight: 600;
}

.field input {
    width: 100%;
    padding: 13px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font: inherit;
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.field input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(13, 148, 136, 0.12);
}

.captcha-row {
    display: grid;
    grid-template-columns: 130px 1fr;
    gap: 12px;
    align-items: center;
}

.captcha-row img {
    width: 100%;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    cursor: pointer;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    border-radius: var(--radius-sm);
    padding: 13px 18px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s, background 0.2s, box-shadow 0.2s;
}

.btn-primary {
    width: 100%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    box-shadow: 0 12px 24px rgba(13, 148, 136, 0.25);
}

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

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

.btn:disabled,
.btn.is-busy {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    pointer-events: none;
}

.alert {
    margin-top: 16px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.92rem;
    display: none;
}

.alert.error {
    display: block;
    background: var(--danger-soft);
    color: var(--danger);
}

.login-hero {
    position: relative;
    overflow: hidden;
    background: linear-gradient(145deg, #042f2e 0%, #0f766e 45%, #134e4a 100%);
    color: #fff;
    padding: 48px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.login-hero::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 20% 20%, rgba(255,255,255,0.12), transparent 35%),
        radial-gradient(circle at 80% 0%, rgba(255,255,255,0.08), transparent 30%);
}

.login-hero-content {
    position: relative;
    z-index: 1;
    max-width: 420px;
}

.login-hero h2 {
    margin: 0 0 12px;
    font-size: 2.2rem;
    line-height: 1.15;
    letter-spacing: -0.03em;
}

.login-hero p {
    margin: 0;
    color: rgba(255,255,255,0.82);
    font-size: 1.05rem;
}

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

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar);
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
    transition: transform 0.25s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.brand-logo {
    width: 42px;
    height: 42px;
    object-fit: contain;
    border-radius: 10px;
    background: #fff;
    padding: 4px;
}

.sidebar-brand strong {
    display: block;
    color: #fff;
}

.sidebar-brand span {
    font-size: 0.82rem;
    color: #94a3b8;
}

.sidebar-nav {
    padding: 18px 12px;
    flex: 1;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 12px;
    color: #cbd5e1;
    margin-bottom: 6px;
    transition: background 0.2s, color 0.2s;
}

.nav-link svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.nav-link:hover,
.nav-link.active {
    background: var(--sidebar-hover);
    color: #fff;
}

.nav-link.active {
    background: linear-gradient(90deg, rgba(13,148,136,0.25), rgba(13,148,136,0.05));
    box-shadow: inset 3px 0 0 var(--primary);
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.avatar,
.avatar-img {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    object-fit: cover;
    flex-shrink: 0;
}

.avatar {
    background: var(--primary);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 700;
}

.punch-select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
}

.user-chip strong {
    display: block;
    color: #fff;
    font-size: 0.95rem;
}

.user-chip span {
    color: #94a3b8;
    font-size: 0.82rem;
}

.logout-btn {
    display: block;
    text-align: center;
    padding: 10px;
    border-radius: 10px;
    background: rgba(255,255,255,0.06);
    color: #e2e8f0;
    font-size: 0.9rem;
}

.logout-btn:hover {
    background: rgba(255,255,255,0.1);
}

.main-area {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    width: calc(100% - var(--sidebar-width));
    display: flex;
    flex-direction: column;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 28px;
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.menu-toggle {
    display: none;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 10px;
    width: 42px;
    height: 42px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

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

.topbar-title h1 {
    margin: 0;
    font-size: 1.35rem;
    letter-spacing: -0.02em;
}

.topbar-title p {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: 0.88rem;
}

.topbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}


.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-size: 0.85rem;
    font-weight: 600;
}

.status-pill.online::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
}

.page-content {
    padding: 24px 28px 32px;
    flex: 1;
}

.app-footer {
    padding: 16px 28px 24px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: var(--muted);
    font-size: 0.85rem;
}

.version-tag {
    padding: 4px 10px;
    border-radius: 999px;
    background: #e2e8f0;
    color: #475569;
    font-weight: 600;
}

/* Dashboard */
.dashboard-section {
    margin-bottom: 22px;
}

.dashboard-charts-body {
    padding: 20px;
}

.dashboard-chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 18px;
    margin-bottom: 18px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #f8fafc;
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--text);
}

.dashboard-chart-legend span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.dashboard-chart-legend i {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    display: inline-block;
}

.qc-swatch-completed { background: var(--qc-completed); }
.qc-swatch-seller { background: var(--qc-seller); }
.qc-swatch-scan { background: var(--qc-scan); }
.qc-swatch-secure { background: var(--qc-secure); }
.qc-swatch-invalid { background: var(--qc-invalid); }

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

.location-chart-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    flex-direction: column;
    min-height: 420px;
}

.location-chart-card-head h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.3;
}

.location-chart-card-head p {
    margin: 8px 0 0;
    display: flex;
    justify-content: space-between;
    gap: 10px;
    color: var(--muted);
    font-size: 0.84rem;
    font-weight: 600;
}

.location-chart-wrap {
    position: relative;
    min-height: 220px;
    margin-top: 14px;
}

.location-audit-section {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px dashed var(--border);
}

.location-audit-section h4 {
    margin: 0 0 12px;
    font-size: 0.92rem;
    font-weight: 700;
    color: #5b21b6;
}

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

.location-audit-stat {
    background: #f5f3ff;
    border: 1px solid #ddd6fe;
    border-radius: var(--radius-sm);
    padding: 10px 12px;
}

.location-audit-stat span {
    display: block;
    color: #6d28d9;
    font-size: 0.76rem;
    font-weight: 600;
    line-height: 1.35;
}

.location-audit-stat strong {
    display: block;
    margin-top: 6px;
    font-size: 1.15rem;
    color: #4c1d95;
}

.stat-card.stat-audit {
    border-top: 4px solid #7c3aed;
}

@media (max-width: 1100px) {
    .location-charts-grid {
        grid-template-columns: 1fr;
    }
}

.section-heading {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 12px;
    margin-bottom: 16px;
}

.section-heading h2 {
    margin: 0;
    font-size: 1.2rem;
    letter-spacing: -0.02em;
}

.section-heading p {
    margin: 0;
    color: var(--muted);
    font-size: 0.92rem;
}

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

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

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.stat-card .label {
    color: var(--muted);
    font-size: 0.88rem;
    margin-bottom: 8px;
}

.stat-card .value {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.stat-card .meta {
    margin-top: 8px;
    font-size: 0.85rem;
    color: var(--muted);
}

.stat-card.accent {
    background: linear-gradient(135deg, #0f766e, #115e59);
    color: #fff;
    border: none;
}

.stat-card.accent .label,
.stat-card.accent .meta {
    color: rgba(255,255,255,0.78);
}

.stat-card.stat-completed { border-top: 4px solid var(--qc-completed); }
.stat-card.stat-seller { border-top: 4px solid var(--qc-seller); }
.stat-card.stat-scan { border-top: 4px solid var(--qc-scan); }
.stat-card.stat-secure { border-top: 4px solid var(--qc-secure); }
.stat-card.stat-invalid { border-top: 4px solid var(--qc-invalid); }

.panel-full {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.panel-grid-single {
    grid-template-columns: 2fr 1fr;
}

.panel-wide {
    min-width: 0;
}

.panel-body-flush {
    padding: 0;
}

.table-wrap-flat {
    border: none;
    border-radius: 0;
    box-shadow: none;
}

.location-table tfoot .totals-row {
    background: #f8fafc;
}

.location-table tfoot td {
    border-top: 2px solid var(--border);
}

.badge.seller { background: var(--qc-seller-soft); color: var(--qc-seller-text); }
.badge.audit-pending { background: #f3f4f6; color: #4b5563; }

.location-table .cell-stat {
    display: inline-block;
    line-height: 1.35;
    text-align: center;
}

.location-table .cell-pct {
    display: inline-block;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 600;
}

.location-table td {
    vertical-align: middle;
}

.panel-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 18px;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.panel-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header h2 {
    margin: 0;
    font-size: 1.05rem;
}

.panel-body {
    padding: 20px;
}

.activity-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.activity-list li {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.activity-list li:last-child {
    border-bottom: none;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.badge.qc { background: var(--qc-completed-soft); color: var(--qc-completed-text); }
.badge.scan { background: var(--qc-scan-soft); color: var(--qc-scan-text); }
.badge.secure { background: var(--qc-secure-soft); color: var(--qc-secure-text); }
.badge.invalid { background: var(--qc-invalid-soft); color: var(--qc-invalid-text); }

.quick-links {
    display: grid;
    gap: 10px;
}

.quick-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #f8fafc;
    transition: background 0.2s, border-color 0.2s;
}

.quick-link:hover {
    background: var(--primary-soft);
    border-color: #99f6e4;
}

/* Manage data */
.filters-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 18px;
    align-items: end;
}

.filters-bar .field {
    margin: 0;
    min-width: 160px;
}

.filters-bar select,
.filters-bar input {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font: inherit;
    background: #fff;
}

.table-wrap {
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

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

.data-table th,
.data-table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 0.92rem;
}

.data-table th {
    position: sticky;
    top: 0;
    background: #f8fafc;
    color: #475569;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.data-table tbody tr:hover {
    background: #f8fafc;
}

.panel-subtitle {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.audit-panel {
    margin-top: 28px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.audit-panel h3 {
    margin: 0 0 18px;
    font-size: 1.1rem;
}

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

.audit-form .form-control,
.filters-bar select,
.filters-bar input {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font: inherit;
    background: #fff;
}

.audit-submit {
    min-width: 180px;
}

.audit-readonly-item {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
}

.audit-readonly-item p {
    margin: 8px 0 0;
    color: var(--text);
}

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

.audit-alert.success {
    background: #dcfce7;
    color: #166534;
}

.audit-alert.info {
    background: #eff6ff;
    color: #1d4ed8;
}

.audit-icon {
    display: inline-flex;
    width: 18px;
    height: 18px;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    vertical-align: middle;
}

.audit-icon.verified { background: #dcfce7; color: #166534; }
.audit-icon.rejected { background: #fee2e2; color: #b91c1c; }
.audit-icon.pending { background: #dbeafe; color: #1d4ed8; }

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

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

.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.pagination .pages {
    display: flex;
    gap: 6px;
}

.page-btn {
    min-width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    color: inherit;
}

.page-btn.active,
.page-btn:hover {
    border-color: var(--primary);
    color: var(--primary-dark);
    background: var(--primary-soft);
}

.manage-data-page .field-grow {
    flex: 1;
    min-width: 220px;
}

.filters-panel {
    margin-bottom: 18px;
}

.filters-panel .filters-bar {
    margin-bottom: 12px;
}

.filters-bar-end {
    margin-left: auto;
    align-self: end;
}

.attendance-downloads {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.attendance-heading {
    margin: 0 0 14px;
}

.attendance-heading p {
    margin: 0;
    display: flex;
    gap: 18px;
    color: var(--muted);
    font-size: 0.92rem;
}

.attendance-heading strong {
    color: var(--text);
}

.manage-data-download {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.manage-data-download img {
    display: block;
}

.manage-data-table th,
.manage-data-table td {
    vertical-align: middle;
}

.status-cell,
.action-cell,
.audit-cell {
    text-align: center;
}

.scan-value-cell {
    text-align: left;
    min-width: 180px;
}

.scan-value-wrap {
    display: grid;
    gap: 8px;
}

.tracking-inline-result {
    display: none;
    margin-top: 2px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    line-height: 1.45;
    text-align: left;
}

.tracking-inline-result:not(:empty) {
    display: block;
}

.tracking-inline-headline {
    font-weight: 700;
}

.tracking-inline-stats {
    margin-top: 4px;
    color: var(--muted);
}

.tracking-inline-line {
    margin-top: 4px;
    font-family: Consolas, monospace;
    font-size: 0.76rem;
}

.tracking-inline-match,
.tracking-inline-line-match {
    background: #ecfdf5;
    border: 1px solid #bbf7d0;
    color: #166534;
}

.tracking-inline-partial,
.tracking-inline-line-partial {
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #b45309;
}

.tracking-inline-mismatch,
.tracking-inline-line-mismatch,
.tracking-inline-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
}

.tracking-inline-missing,
.tracking-inline-line-missing,
.tracking-inline-loading {
    background: #f8fafc;
    border: 1px solid var(--border);
    color: #475569;
}

.action-cell-buttons {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.action-btn-secondary {
    background: #fff;
    color: var(--text);
    border: 1px solid var(--border);
    box-shadow: none;
}

.action-btn-secondary:hover {
    background: #f8fafc;
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.08);
}

.action-btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
}

.status-pill-lg {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 128px;
    min-height: 42px;
    padding: 10px 18px;
    border-radius: 999px;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    line-height: 1.2;
    text-align: center;
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.04);
}

.status-pill-lg.qc { background: var(--qc-completed-soft); color: var(--qc-completed-text); }
.status-pill-lg.seller { background: var(--qc-seller-soft); color: var(--qc-seller-text); }
.status-pill-lg.scan { background: var(--qc-scan-soft); color: var(--qc-scan-text); }
.status-pill-lg.secure { background: var(--qc-secure-soft); color: var(--qc-secure-text); }
.status-pill-lg.invalid { background: var(--qc-invalid-soft); color: var(--qc-invalid-text); }

.action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 108px;
    min-height: 42px;
    padding: 10px 16px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    font-weight: 700;
    font-size: 0.92rem;
    box-shadow: 0 8px 18px rgba(13, 148, 136, 0.22);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.action-btn-icon {
    min-width: 42px;
    width: 42px;
    height: 42px;
    padding: 0;
    gap: 0;
}

.action-btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.action-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 24px rgba(13, 148, 136, 0.28);
}

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

.audit-yes { color: var(--success); font-weight: 700; }
.audit-no { color: var(--danger); font-weight: 700; }
.audit-pending { color: var(--muted); font-weight: 700; }

#manageDataTable.is-loading,
#attendanceTable.is-loading {
    opacity: 0.55;
    pointer-events: none;
}

.page-image-loader {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9997;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    background: rgba(248, 250, 252, 0.94);
    color: var(--text);
    font-size: 0.95rem;
    font-weight: 600;
}

.page-image-loader.is-active {
    display: flex;
}

.page-image-loader img,
.gallery-loader-img,
.image-card-loader img {
    width: 64px;
    height: 64px;
    object-fit: contain;
}

.image-card-loader {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 3;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.55);
}

.image-card.is-opening .image-card-loader {
    display: flex;
}

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

.gallery-hint {
    margin: 0 0 16px;
    color: var(--muted);
    font-size: 0.92rem;
}

.image-card {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    background: #f8fafc;
    cursor: zoom-in;
    text-align: left;
    text-decoration: none;
    color: inherit;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.image-card:hover,
.image-card:focus-visible {
    transform: translateY(-2px);
    border-color: #93c5fd;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
    outline: none;
}

.image-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
    background: #f8fafc;
    pointer-events: none;
}

.image-card-zoom {
    position: absolute;
    right: 12px;
    bottom: 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.78);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 600;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.image-card-zoom svg {
    width: 14px;
    height: 14px;
}

.image-card:hover .image-card-zoom,
.image-card:focus-visible .image-card-zoom {
    opacity: 1;
}

body.gallery-open {
    overflow: hidden;
}

.gallery-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
}

.gallery-lightbox.is-open {
    display: block;
}

.gallery-lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.88);
}

.gallery-lightbox-dialog {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 56px 72px 40px;
    box-sizing: border-box;
}

.gallery-stage {
    position: relative;
    margin: 0;
    max-width: min(1600px, 96vw);
    max-height: 100%;
    min-height: 240px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.gallery-loader {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    min-width: 220px;
    min-height: 220px;
    color: #e2e8f0;
    font-size: 0.92rem;
    font-weight: 600;
}

.gallery-lightbox.is-loading .gallery-loader {
    display: flex;
}

.gallery-image.is-hidden {
    visibility: hidden;
    opacity: 0;
}

.gallery-image:not(.is-hidden) {
    visibility: visible;
    opacity: 1;
    transition: opacity 0.2s ease;
}

.gallery-image {
    display: block;
    max-width: min(96vw, 1600px);
    max-height: calc(100vh - 96px);
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    background: #0f172a;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
    cursor: zoom-out;
}

.gallery-caption {
    color: #e2e8f0;
    font-size: 0.92rem;
    font-weight: 600;
}

.gallery-close,
.gallery-nav {
    position: absolute;
    border: 0;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    cursor: pointer;
    transition: background 0.15s ease, opacity 0.15s ease;
}

.gallery-close:hover,
.gallery-nav:hover:not(:disabled),
.gallery-close:focus-visible,
.gallery-nav:focus-visible:not(:disabled) {
    background: rgba(255, 255, 255, 0.22);
    outline: none;
}

.gallery-close {
    top: 18px;
    right: 18px;
    width: 44px;
    height: 44px;
    border-radius: 999px;
    font-size: 1.8rem;
    line-height: 1;
}

.gallery-nav {
    top: 50%;
    transform: translateY(-50%);
    width: 52px;
    height: 52px;
    border-radius: 999px;
    font-size: 2rem;
    line-height: 1;
}

.gallery-nav:disabled {
    opacity: 0.35;
    cursor: default;
}

.gallery-prev {
    left: 18px;
}

.gallery-next {
    right: 18px;
}

@media (max-width: 768px) {
    .gallery-lightbox-dialog {
        padding: 64px 16px 32px;
    }

    .gallery-nav {
        width: 42px;
        height: 42px;
        font-size: 1.6rem;
    }

    .gallery-prev {
        left: 8px;
    }

    .gallery-next {
        right: 8px;
    }
}

.placeholder-panel {
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 48px 24px;
    text-align: center;
    color: var(--muted);
}

.placeholder-panel h2 {
    margin: 0 0 8px;
    color: var(--text);
}

/* 404 */
.error-page {
    min-height: 60vh;
    display: grid;
    place-items: center;
    text-align: center;
}

.error-page h1 {
    font-size: 4rem;
    margin: 0;
    color: var(--primary);
}

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

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

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

    .panel-grid,
    .panel-grid-single {
        grid-template-columns: 1fr;
    }
}

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

    .login-hero {
        display: none;
    }

    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-area {
        margin-left: 0;
        width: 100%;
    }

    .menu-toggle {
        display: inline-flex;
    }
}

.btn-sm {
    padding: 8px 12px;
    font-size: 0.84rem;
}

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

.tracking-match-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}

.tracking-summary-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
}

.tracking-summary-card span {
    display: block;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 600;
}

.tracking-summary-card strong {
    display: block;
    margin-top: 6px;
    font-size: 1.35rem;
}

.tracking-summary-match strong { color: #059669; }
.tracking-summary-partial strong { color: #d97706; }
.tracking-summary-mismatch strong { color: #dc2626; }
.tracking-summary-missing strong { color: #64748b; }

.tracking-match-hint {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
}

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

.tracking-match-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.tracking-match-card-media {
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
}

.tracking-match-card-media img {
    display: block;
    width: 100%;
    height: 220px;
    object-fit: contain;
    background: #f8fafc;
}

.tracking-match-card-body {
    padding: 14px;
    display: grid;
    gap: 12px;
}

.tracking-match-meta {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 600;
}

.tracking-match-fields {
    margin: 0;
    display: grid;
    gap: 8px;
}

.tracking-match-fields div {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 8px;
    align-items: start;
}

.tracking-match-fields dt {
    margin: 0;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 600;
}

.tracking-match-fields dd {
    margin: 0;
    font-size: 0.9rem;
    word-break: break-all;
}

.tracking-match-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tracking-status {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
}

.tracking-status-match {
    background: #dcfce7;
    color: #15803d;
}

.tracking-status-partial {
    background: #fef3c7;
    color: #b45309;
}

.tracking-status-mismatch {
    background: #fee2e2;
    color: #b91c1c;
}

.tracking-status-missing {
    background: #f3f4f6;
    color: #4b5563;
}

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

    .page-content,
    .topbar,
    .app-footer {
        padding-left: 16px;
        padding-right: 16px;
    }

    .filters-bar .field {
        width: 100%;
    }
}
