:root {
    --font-sans: 'Inter', sans-serif;
}

body {
    font-family: var(--font-sans);
    background-color: var(--app-bg);
    color: var(--text-primary);
    min-width: 0;
}

main,
.view-section,
#view-pos > div,
#pos-product-grid { min-width: 0; }

#toast-container {
    max-width: min(26rem, calc(100vw - 2rem));
}

.sidebar-tooltip { display: none; }

@media (max-width: 1023px) {
    #sidebar > .sidebar-toggle { right: 0.75rem !important; top: 1.5rem; }

    #view-pos {
        overflow-y: auto !important;
        overflow-x: hidden;
    }

    #view-pos > div:first-child {
        flex: 0 0 auto !important;
        height: auto !important;
        min-height: 0 !important;
        overflow: visible !important;
        border-right: 0 !important;
    }

    #view-pos > div:first-child > div:nth-child(2) {
        flex: 0 0 auto !important;
        min-height: 16rem;
        max-height: 48vh;
        overflow-y: auto !important;
        overflow-x: hidden;
    }

    #view-pos > div:last-child {
        flex: 0 0 auto !important;
        width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
        overflow: visible !important;
    }

    #view-pos #pos-product-grid { gap: 0.75rem; }
    #view-pos #pos-cart-list { max-height: 16rem; min-height: 5rem; }
    #view-pos .grid-cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }

    #view-laporan-penjualan .overflow-y-auto,
    #view-laporan-produk .overflow-y-auto { overflow-x: auto !important; }
    #view-laporan-penjualan table { min-width: 44rem; }
    #view-laporan-produk table { min-width: 48rem; }
    #view-laporan-sesi table { min-width: 60rem; }
    #view-pengguna table { min-width: 42rem; }

    #view-laporan-penjualan .min-w-44,
    #view-laporan-produk .min-w-44,
    #view-laporan-sesi .min-w-44 { min-width: 0 !important; width: 100%; }

    #view-laporan-penjualan .flex.items-center.gap-2,
    #view-laporan-produk .flex.items-center.gap-2 { align-items: flex-end; flex-wrap: wrap; width: 100%; }
    #view-laporan-penjualan .flex.items-center.gap-2 > div,
    #view-laporan-produk .flex.items-center.gap-2 > div { flex: 1 1 8rem; min-width: 0; }
    #view-laporan-penjualan .flex.items-center.gap-2 input,
    #view-laporan-produk .flex.items-center.gap-2 input { width: 100%; }
}

@media (max-width: 639px) {
    #sidebar { width: min(18rem, 88vw) !important; }
    #toast-container { left: 1rem; right: 1rem; bottom: 1rem; max-width: none; }
    #toast-container > div { width: 100%; max-width: none; }

    header { min-height: 4.25rem; }
    #view-pos > div:first-child > div:first-child { padding: 1rem; gap: 1rem; }
    #view-pos > div:first-child > div:first-child > div:first-child { gap: 0.75rem; }
    #view-pos > div:first-child > div:first-child input { height: 2.75rem; }
    #view-pos > div:first-child > div:first-child button[title*="kamera"] { width: 2.75rem; height: 2.75rem; }

    .view-section { padding-left: 1rem !important; padding-right: 1rem !important; }
    .view-section > .bg-white,
    .view-section > div > .bg-white { border-radius: 1rem; }

    #view-laporan-penjualan > div:first-child,
    #view-laporan-produk > div:first-child { margin-bottom: 1rem !important; }

    #view-laporan-penjualan .report-summary-grid,
    #view-laporan-produk .report-summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 0.5rem !important;
    }

    #view-laporan-penjualan .report-summary-grid > div,
    #view-laporan-produk .report-summary-grid > div {
        min-width: 0;
        padding: 0.75rem !important;
    }

    #view-laporan-penjualan .report-summary-grid p:first-child,
    #view-laporan-produk .report-summary-grid p:first-child {
        font-size: 0.625rem;
        line-height: 1rem;
        min-height: 2rem;
    }

    #view-laporan-penjualan .report-summary-grid p:last-child,
    #view-laporan-produk .report-summary-grid p:last-child {
        font-size: 1.25rem;
        line-height: 1.5rem;
        margin-top: 0.25rem !important;
        overflow-wrap: anywhere;
    }

    #view-laporan-penjualan .report-filter,
    #view-laporan-produk .report-filter { gap: 0.5rem !important; }

    #view-laporan-penjualan .report-filter > div:first-child,
    #view-laporan-produk .report-filter > div:first-child {
        width: 100%;
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
        gap: 0.5rem;
        align-items: end;
    }

    #view-laporan-penjualan .report-filter > div:first-child > div,
    #view-laporan-produk .report-filter > div:first-child > div,
    #view-laporan-penjualan .report-filter > div:not(:first-child),
    #view-laporan-produk .report-filter > div:not(:first-child) {
        min-width: 0;
        width: 100%;
    }

    #view-laporan-penjualan .report-filter input,
    #view-laporan-produk .report-filter input,
    #view-laporan-penjualan .report-filter select,
    #view-laporan-produk .report-filter select {
        width: 100%;
        min-width: 0 !important;
    }

    #view-laporan-penjualan .report-filter button,
    #view-laporan-produk .report-filter button { width: 100%; }

    #view-laporan-penjualan .report-table-container,
    #view-laporan-produk .report-table-container {
        min-height: 20rem;
        overflow-x: auto !important;
    }
    #modal-product > div,
    #modal-user > div,
    #modal-change-password > div,
    #modal-receipt > div,
    #modal-camera-scanner > div,
    #modal-auth-override > div { max-height: calc(100dvh - 2rem); }
}

html[data-theme="dark"] .bg-white { background-color: var(--surface) !important; }
html[data-theme="dark"] .bg-gray-50 { background-color: var(--surface-muted) !important; }
html[data-theme="dark"] .bg-gray-100 { background-color: var(--surface-muted) !important; }
html[data-theme="dark"] .text-gray-900 { color: var(--text-primary) !important; }
html[data-theme="dark"] .text-gray-800 { color: var(--text-primary) !important; }
html[data-theme="dark"] .text-gray-700,
html[data-theme="dark"] .text-gray-600 { color: var(--text-secondary) !important; }
html[data-theme="dark"] .text-gray-500,
html[data-theme="dark"] .text-gray-400 { color: var(--text-muted) !important; }
html[data-theme="dark"] .border-gray-100,
html[data-theme="dark"] .border-gray-200 { border-color: var(--border-strong) !important; }
html[data-theme="dark"] .bg-red-50 { background-color: var(--surface-soft) !important; }
html[data-theme="dark"] input,
html[data-theme="dark"] textarea,
html[data-theme="dark"] select { color: var(--text-primary); }
html[data-theme="dark"] .shadow-sm,
html[data-theme="dark"] .shadow-2xl { box-shadow: 0 10px 30px var(--shadow-color) !important; }

/* Global theme shell: sidebar and application content use the same theme tokens. */
#sidebar {
    background-color: var(--sidebar-bg) !important;
    color: var(--sidebar-text) !important;
}

#sidebar .sidebar-header {
    border-color: var(--sidebar-border) !important;
}

#sidebar .sidebar-header > div:first-child {
    background-color: var(--sidebar-surface) !important;
    color: var(--sidebar-text-strong) !important;
}

#sidebar #sidebar-brand-title,
#sidebar .sidebar-header .text-white {
    color: var(--sidebar-text-strong) !important;
}

#sidebar .nav-btn {
    color: var(--sidebar-text) !important;
}

#sidebar .nav-btn:hover {
    color: var(--sidebar-text-strong) !important;
    background-color: var(--sidebar-hover) !important;
}

#sidebar .nav-btn.bg-gray-800,
#sidebar .nav-btn.text-red-500 {
    background-color: var(--sidebar-active) !important;
    color: var(--sidebar-active-text) !important;
}

#sidebar .sidebar-submenu {
    border-color: var(--sidebar-border) !important;
}

#sidebar #sidebar-user-panel {
    border-color: var(--sidebar-border) !important;
}

#sidebar #sidebar-user-avatar {
    background-color: var(--sidebar-avatar-bg) !important;
    color: var(--sidebar-text-strong) !important;
}

#sidebar #sidebar-user-fullname {
    color: var(--sidebar-text-strong) !important;
}

#sidebar .sidebar-user-summary p:last-child {
    color: var(--sidebar-muted) !important;
}

#sidebar .sidebar-lock {
    color: var(--sidebar-text) !important;
}

#sidebar .sidebar-lock:hover {
    color: var(--sidebar-text-strong) !important;
    background-color: var(--sidebar-hover) !important;
}

#sidebar .sidebar-tooltip {
    background-color: var(--surface) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-strong) !important;
}

#sidebar-overlay {
    background-color: var(--sidebar-overlay) !important;
}

main {
    background-color: var(--app-bg) !important;
    color: var(--text-primary);
}

main > header {
    background-color: var(--surface) !important;
    border-color: var(--border-strong) !important;
}

html[data-theme="dark"] .bg-slate-50,
html[data-theme="dark"] .bg-slate-100 {
    background-color: var(--surface-muted) !important;
}

html[data-theme="dark"] .border-slate-200,
html[data-theme="dark"] .border-slate-300 {
    border-color: var(--border-strong) !important;
}
/* Login overlay visibility is controlled by the validated session flow. */
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; }

@media (min-width: 640px) {
    #sidebar { transform: translateX(0) !important; }
    #sidebar-overlay { display: none !important; }
    .sidebar-collapsed { width: 5rem !important; }
    .sidebar-collapsed .sidebar-text { display: none !important; }
    .sidebar-collapsed .nav-btn { justify-content: center !important; padding-left: 0 !important; padding-right: 0 !important; }
    .sidebar-collapsed .nav-btn svg { margin-left: 0 !important; margin-right: 0 !important; }
    .sidebar-collapsed .sidebar-header { justify-content: center !important; padding-left: 0 !important; padding-right: 0 !important; }
    .sidebar-collapsed .sidebar-user-panel { padding-left: 0.5rem !important; padding-right: 0.5rem !important; }
    .sidebar-collapsed .sidebar-user-summary { justify-content: center !important; }
    .sidebar-collapsed .sidebar-lock { justify-content: center !important; padding-left: 0 !important; padding-right: 0 !important; }
    .sidebar-collapsed .sidebar-logout { justify-content: center !important; padding-left: 0 !important; padding-right: 0 !important; }
    .sidebar-collapsed .report-label-container { display: none !important; }
    .sidebar-collapsed .report-divider { display: block !important; }
    .sidebar-collapsed .sidebar-submenu { margin-left: 0 !important; padding-left: 0 !important; border-left: 0 !important; }
    .sidebar-tooltip { display: none !important; }
    .sidebar-collapsed .sidebar-tooltip { display: block !important; opacity: 0; }
    .sidebar-collapsed .nav-btn:hover .sidebar-tooltip { opacity: 1; }
}

@keyframes slideInUp { from { transform: translateY(100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.toast-animate { animation: slideInUp 0.3s ease-out forwards; }

/* Persediaan uses a strong header band so document and ledger columns remain easy to scan. */
#view-inventory thead,
#view-inventory-management thead { background-color: #0f172a !important; color: #ffffff !important; }
#view-inventory thead th,
#view-inventory-management thead th { color: #ffffff !important; }

/* Inventory input forms open on demand in focused responsive dialogs. */
#inventory-stock-in-modal-body > #inventory-manual-card,
#inventory-stock-out-modal-body > #inventory-out-card { margin-bottom: 0; padding: 0; border: 0; box-shadow: none; }
#inventory-stock-in-modal-body > #inventory-manual-card > div:first-child,
#inventory-stock-out-modal-body > #inventory-out-card > div:first-child { display: none; }
.reset-data-card { max-width: 980px; }
.reset-data-select-all { padding: 1rem 1.25rem; border-bottom: 1px solid #e5e7eb; }
.reset-data-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .85rem; padding: 1.25rem; }
.reset-data-option { display: flex; gap: .75rem; align-items: flex-start; padding: 1rem; border: 1px solid #e5e7eb; border-radius: .85rem; background: #fff; cursor: pointer; transition: border-color .15s ease, background .15s ease; }
.reset-data-option:hover { border-color: #94a3b8; background: #f8fafc; }
.reset-data-option input { margin-top: .2rem; accent-color: #ef4444; }
.reset-data-option span { display: flex; flex-direction: column; gap: .25rem; }
.reset-data-option small { color: #64748b; line-height: 1.35; }
.reset-data-summary { margin: 0 1.25rem; padding: .9rem 1rem; border-radius: .75rem; background: #fff7ed; color: #9a3412; }
.reset-data-summary strong { display: block; margin-top: .25rem; color: #7c2d12; }
.reset-data-actions { display: flex; justify-content: flex-end; padding: 1.25rem; }
.reset-data-auth-card { width: min(32rem, calc(100vw - 2rem)); }
.reset-data-confirmation { margin-top: 1rem; padding: .75rem; border-radius: .65rem; background: #fef2f2; color: #991b1b; }
.reset-data-confirmation strong { display: block; margin-top: .25rem; }
@media (max-width: 700px) {
    .reset-data-grid { grid-template-columns: 1fr; padding: 1rem; }
    .reset-data-actions { justify-content: stretch; }
    .reset-data-actions .btn { width: 100%; }
}
/* Reset Data follows the same full-page layout as the other system views. */
#view-reset-data.view-section:not(.hidden) {
    display: flex !important;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    padding: 1rem 2rem 2rem;
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--app-bg);
}
#view-reset-data .page-header {
    display: block !important;
    width: 100%;
    margin: 0 0 1.25rem;
}
#view-reset-data .page-header h1 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.75rem;
    line-height: 2.25rem;
    font-weight: 700;
}
#view-reset-data .page-header p {
    margin: .35rem 0 0;
    color: var(--text-secondary);
    font-size: .95rem;
}
#view-reset-data .reset-data-card {
    display: block !important;
    width: 100%;
    max-width: none !important;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 1rem;
    box-shadow: 0 4px 16px var(--shadow-color);
}
#view-reset-data .reset-data-card .card-header {
    display: block !important;
    width: 100%;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
}
#view-reset-data .reset-data-card .card-header h2 { display: none !important; }
#view-reset-data .reset-data-card .card-header p {
    margin: 0;
    color: var(--text-secondary);
    font-size: .9rem;
}
#view-reset-data .reset-data-select-all { padding: 1rem 1.5rem; background: var(--surface-muted); }
#view-reset-data .reset-data-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 1.5rem;
    gap: 1rem;
}
#view-reset-data .reset-data-option { min-width: 0; background: var(--surface); }
#view-reset-data .reset-data-summary { margin: 0 1.5rem; }
#view-reset-data .reset-data-actions {
    justify-content: flex-end;
    padding: 1.5rem;
    border-top: 1px solid var(--border);
}
#view-reset-data .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.75rem;
    padding: .7rem 1.1rem;
    border: 0;
    border-radius: .7rem;
    font-weight: 700;
    cursor: pointer;
}
#view-reset-data .btn-danger {
    color: #fff;
    background: #ef4444;
}
#view-reset-data .btn-danger:hover { background: #dc2626; }
#view-reset-data .btn-secondary {
    color: var(--text-primary);
    background: var(--surface-muted);
}
#reset-data-auth-modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgb(15 23 42 / .6);
}
#reset-data-auth-modal:not(.hidden) { display: flex; }
#reset-data-auth-modal .reset-data-auth-card {
    width: min(32rem, calc(100vw - 2rem));
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    padding: 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 1rem;
    box-shadow: 0 1rem 3rem rgb(15 23 42 / .25);
}
#reset-data-auth-modal .modal-header,
#reset-data-auth-modal .modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
}
#reset-data-auth-modal .modal-header { padding-bottom: 1rem; border-bottom: 1px solid var(--border); }
#reset-data-auth-modal .modal-body { padding: 1rem 0; }
#reset-data-auth-modal .modal-body > p { margin: 0 0 1rem; color: var(--text-secondary); }
#reset-data-auth-modal .form-group { display: flex; flex-direction: column; gap: .35rem; margin-top: .85rem; }
#reset-data-auth-modal .form-group label { color: var(--text-secondary); font-size: .8rem; font-weight: 700; }
#reset-data-auth-modal .form-group input {
    width: 100%;
    padding: .7rem .8rem;
    color: var(--text-primary);
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: .65rem;
    outline: none;
}
#reset-data-auth-modal .modal-close {
    width: 2rem;
    height: 2rem;
    border: 0;
    border-radius: 999px;
    color: var(--text-secondary);
    background: var(--surface-muted);
    cursor: pointer;
}
#reset-data-auth-modal .modal-footer { justify-content: flex-end; }
@media (max-width: 700px) {
    #view-reset-data.view-section:not(.hidden) { padding: 1rem; }
    #view-reset-data .reset-data-grid { grid-template-columns: 1fr; padding: 1rem; }
    #view-reset-data .reset-data-actions { padding: 1rem; }
    #view-reset-data .reset-data-actions .btn { width: 100%; }
}
#view-reset-data.view-section.hidden { display: none !important; }

/* POS product catalog adapts to available width while keeping two columns on mobile. */
.pos-product-grid-responsive {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
    gap: 1.5rem;
    width: 100%;
    min-width: 0;
}
.pos-product-grid-responsive > * { min-width: 0; }
@media (max-width: 639px) {
    .pos-product-grid-responsive {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: .75rem;
    }
    .pos-product-grid-responsive > * { padding: .75rem !important; border-radius: .9rem !important; }
    .pos-product-grid-responsive > * > div:first-child { margin-bottom: .65rem !important; border-radius: .7rem !important; }
    .pos-product-grid-responsive h3 { font-size: .78rem; line-height: 1.1rem; overflow-wrap: anywhere; }
    .pos-product-grid-responsive p { font-size: .9rem; }
}

/* Attendance map markers rendered above the OpenFreeMap road layer. */
.attendance-map-marker {
    position: relative;
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid #fff;
    border-radius: 999px;
    box-shadow: 0 3px 10px rgba(15, 23, 42, .35);
}
.attendance-map-marker--office { background: #2563eb; }
.attendance-map-marker--device { background: #ef4444; }
.attendance-map-marker--device::after {
    position: absolute;
    inset: -.35rem;
    content: '';
    border: 2px solid rgba(239, 68, 68, .35);
    border-radius: 999px;
}
.attendance-map-marker__label {
    position: absolute;
    top: 1.45rem;
    left: 50%;
    padding: .2rem .45rem;
    color: #1e3a8a;
    font-size: .65rem;
    font-weight: 700;
    line-height: 1rem;
    white-space: nowrap;
    background: rgba(255, 255, 255, .95);
    border-radius: .4rem;
    box-shadow: 0 2px 7px rgba(15, 23, 42, .2);
    transform: translateX(-50%);
}
.attendance-map-marker--device .attendance-map-marker__label { color: #b91c1c; }
#attendance-location-map .maplibregl-ctrl-attrib { font-size: 9px; }

/* Employee self-service keeps the primary attendance action visible without scrolling. */
#view-attendance.employee-attendance-mode > .mb-6 { margin-bottom: 1rem; }
#view-attendance.employee-attendance-mode > .mb-6 p { display: none; }
#view-attendance.employee-attendance-mode > .mb-6 h2 { font-size: 1.5rem; }
#view-attendance.employee-attendance-mode .attendance-selfie-frame {
    width: min(100%, 25rem);
    max-height: 16rem;
    aspect-ratio: 4 / 3;
    margin-inline: auto;
}
#view-attendance.employee-attendance-mode label:has(#attendance-event-type) {
    display: none;
}
#view-attendance.employee-attendance-mode [data-attendance-shared-only].hidden + label[data-attendance-shared-only] { display: none; }
#view-attendance.employee-attendance-mode .employee-request-panel #attendance-request-form.hidden { display: none; }
#view-attendance.employee-attendance-mode .employee-request-panel > div:last-child { padding-top: .75rem; }
@media (min-width: 1280px) {
    #view-attendance.employee-attendance-mode > .grid.grid-cols-1.xl\:grid-cols-\[minmax\(0\,1\.15fr\)_minmax\(320px\,\.85fr\)\] {
        align-items: start;
    }
}
