:root {
    --primary: #e85d04;
    --primary-dark: #d00000;
    --primary-light: #fff3e6;
    --bg: #f8f6f3;
    --surface: #ffffff;
    --text: #1a1a1a;
    --text-muted: #6b6b6b;
    --border: #e8e4df;
    --success: #2d6a4f;
    --success-bg: #d8f3dc;
    --warning: #e85d04;
    --warning-bg: #fff3e6;
    --danger: #d00000;
    --danger-bg: #ffe5e5;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    --radius: 14px;
    --nav-height: 68px;
    --header-height: 72px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    -webkit-text-size-adjust: 100%;
    touch-action: manipulation;
}

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100dvh;
    overflow-x: hidden;
}

.app {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
}

/* HTTPS banner for mobile camera */
.https-banner {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #fff;
    padding: 14px 16px;
    margin: 0;
}

.https-banner-content {
    max-width: 480px;
    margin: 0 auto;
    font-size: 0.85rem;
    line-height: 1.5;
}

.https-banner strong {
    display: block;
    font-size: 0.95rem;
    margin-bottom: 6px;
}

.https-link {
    display: block;
    background: rgba(232, 93, 4, 0.2);
    border: 1.5px solid #e85d04;
    color: #ffb347;
    padding: 10px 12px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    word-break: break-all;
    margin: 8px 0;
    text-align: center;
}

.https-hint {
    font-size: 0.75rem;
    opacity: 0.85;
    margin-top: 6px;
}

.https-setup-link {
    display: inline-block;
    margin-top: 8px;
    color: #ffb347;
    font-size: 0.8rem;
}

/* Header */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 16px 20px;
    padding-top: max(16px, env(safe-area-inset-top));
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-icon {
    font-size: 2rem;
    line-height: 1;
}

.header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.header-sub {
    font-size: 0.8rem;
    opacity: 0.85;
    font-weight: 400;
}

/* Main */
.main {
    flex: 1;
    padding: 16px;
    padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px);
}

.panel {
    display: none;
}

.panel.active {
    display: block;
    animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Cards */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 16px;
}

.scanner-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.scanner-header p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}

/* Scanner */
.scanner-container {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    background: #111;
    width: 100%;
    height: clamp(160px, 32dvh, 240px);
    max-height: 240px;
    margin-bottom: 12px;
}

#reader {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.scan-video,
#reader video {
    display: block;
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    min-height: 0 !important;
    object-fit: cover !important;
    position: absolute;
    inset: 0;
}

#reader > div {
    border: none !important;
    box-shadow: none !important;
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    position: absolute !important;
    inset: 0 !important;
    overflow: hidden !important;
}

#reader canvas {
    max-width: 100% !important;
    max-height: 100% !important;
}

#reader img[alt="Info icon"] {
    display: none !important;
}

.scanner-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.scanner-overlay::before {
    content: '';
    width: 80%;
    height: 28%;
    max-height: 72px;
    border: 2px solid rgba(255, 255, 255, 0.8);
    border-radius: 8px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.25);
}

.scan-line {
    position: absolute;
    width: 80%;
    max-width: 280px;
    height: 2px;
    background: var(--primary);
    box-shadow: 0 0 8px var(--primary);
    animation: scanMove 2s ease-in-out infinite;
}

@keyframes scanMove {
    0%, 100% { transform: translateY(-36px); opacity: 0.5; }
    50% { transform: translateY(36px); opacity: 1; }
}

.scanner-container:not(.scanning) .scanner-overlay,
.scanner-container:not(.scanning) .scan-line {
    display: none;
}

.scanner-container:not(.scanning) {
    display: none;
}

.scanner-status {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 10px;
    min-height: 1.2em;
}

.divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 16px 0;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.manual-barcode {
    display: flex;
    gap: 8px;
}

.section-title {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 14px;
}

.add-product-card {
    margin-bottom: 16px;
}

.search-group {
    position: relative;
}

.suggestions {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 4px);
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow);
    max-height: 220px;
    overflow-y: auto;
    z-index: 50;
}

.suggestion-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    padding: 12px 14px;
    border: none;
    border-bottom: 1px solid var(--border);
    background: none;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:active {
    background: var(--primary-light);
}

.suggestion-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.suggestion-price {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.suggestion-empty {
    padding: 14px;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-align: center;
}

.stock-details {
    background: var(--bg);
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 12px;
}

.stock-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.stock-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}

.stock-value {
    font-size: 1.25rem;
    font-weight: 700;
}

.price-value {
    color: var(--primary);
}

#stock-barcode {
    font-size: 0.95rem;
    word-break: break-all;
    letter-spacing: 0.02em;
}

.scan-hint,
.modal-note {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

/* Forms */
.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.input {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: 1rem;
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
    transition: border-color 0.2s, box-shadow 0.2s;
    -webkit-appearance: none;
}

.input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(232, 93, 4, 0.15);
}

.input[readonly] {
    background: var(--bg);
    color: var(--text-muted);
}

.form-actions {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 13px 20px;
    border: none;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: transform 0.15s, opacity 0.15s, background 0.15s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.btn:active {
    transform: scale(0.97);
}

.btn-block {
    width: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
}

.btn-secondary {
    background: var(--text);
    color: white;
}

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--primary);
    color: var(--primary);
    padding: 12px 16px;
    white-space: nowrap;
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
}

.btn-danger {
    background: var(--danger-bg);
    color: var(--danger);
}

.btn-sm {
    padding: 8px 14px;
    font-size: 0.85rem;
}

.hidden {
    display: none !important;
}

/* Result card */
.result-header {
    margin-bottom: 16px;
}

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.badge-found {
    background: var(--success-bg);
    color: var(--success);
}

.badge-new {
    background: var(--warning-bg);
    color: var(--warning);
}

#result-title {
    font-size: 1rem;
    font-weight: 600;
}

/* Search */
.search-bar {
    position: relative;
    margin-bottom: 16px;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1rem;
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 13px 14px 13px 42px;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    font-size: 1rem;
    font-family: inherit;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
}

/* Stats */
.stats-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.stat {
    background: var(--surface);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-value {
    display: block;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.2;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Product list */
.products-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.product-item {
    background: var(--surface);
    border-radius: 12px;
    padding: 14px 16px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    transition: transform 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.product-item:active {
    transform: scale(0.98);
}

.product-item.low-stock {
    border-left: 4px solid var(--warning);
}

.product-item.out-of-stock {
    border-left: 4px solid var(--danger);
    opacity: 0.85;
}

.product-info {
    flex: 1;
    min-width: 0;
}

.product-name {
    font-weight: 600;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.product-price {
    font-weight: 700;
    font-size: 1rem;
    color: var(--primary);
    white-space: nowrap;
}

.product-qty {
    text-align: center;
    min-width: 44px;
}

.qty-number {
    display: block;
    font-weight: 700;
    font-size: 1.1rem;
}

.qty-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.product-actions {
    display: flex;
    gap: 6px;
}

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: 12px;
}

.empty-state h3 {
    font-size: 1rem;
    color: var(--text);
    margin-bottom: 6px;
}

.loading {
    text-align: center;
    padding: 32px;
    color: var(--text-muted);
}

/* Bottom nav */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    height: calc(var(--nav-height) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex;
    z-index: 200;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.06);
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--text-muted);
    font-family: inherit;
    padding: 8px;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.2s;
}

.nav-item.active {
    color: var(--primary);
}

.nav-icon {
    font-size: 1.4rem;
    line-height: 1;
}

.nav-label {
    font-size: 0.7rem;
    font-weight: 600;
}

/* Toast */
.toast {
    position: fixed;
    bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px);
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--text);
    color: white;
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 500;
    z-index: 300;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    max-width: calc(100% - 32px);
    text-align: center;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--danger);
}

/* Modal for edit from list */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 400;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.modal {
    background: var(--surface);
    border-radius: 20px 20px 0 0;
    width: 100%;
    max-width: 480px;
    max-height: 85dvh;
    overflow-y: auto;
    padding: 24px 20px;
    padding-bottom: calc(24px + var(--safe-bottom));
    animation: slideUp 0.3s ease;
}

.confirm-backdrop {
    align-items: center;
    z-index: 500;
}

.confirm-modal {
    border-radius: 16px;
    max-width: 360px;
    width: calc(100% - 32px);
    max-height: none;
    animation: fadeIn 0.2s ease;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-handle {
    width: 40px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 0 auto 20px;
}

.modal h3 {
    font-size: 1.1rem;
    margin-bottom: 16px;
}

.modal-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.modal-actions .btn {
    flex: 1;
}

.scanner-card {
    padding: 16px;
}

.scanner-header p {
    margin-bottom: 12px;
}

@media (max-width: 480px) {
    .main {
        padding: 12px;
        padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 12px);
    }

    .card {
        padding: 14px;
        margin-bottom: 12px;
    }

    .scanner-container {
        height: clamp(150px, 28dvh, 200px);
        max-height: 200px;
    }

    .scanner-header h2 {
        font-size: 1rem;
    }

    .scanner-header p {
        font-size: 0.8rem;
        margin-bottom: 10px;
    }

    .btn {
        padding: 11px 16px;
        font-size: 0.9rem;
    }
}

/* Landing page */
.landing-body {
    background: linear-gradient(160deg, #fff3e6 0%, #f8f6f3 50%, #e8f5e9 100%);
    min-height: 100dvh;
}

.landing {
    max-width: 480px;
    margin: 0 auto;
    padding: 24px 20px;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.landing-header {
    text-align: center;
    padding: 32px 0 28px;
}

.landing-icon {
    font-size: 3.5rem;
    display: block;
    margin-bottom: 12px;
}

.landing-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 6px;
}

.landing-header p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.menu-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    flex: 1;
    align-content: start;
}

.menu-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 28px 16px;
    border: none;
    border-radius: 16px;
    cursor: pointer;
    font-family: inherit;
    min-height: 160px;
    box-shadow: var(--shadow);
    transition: transform 0.15s;
}

.menu-card:active {
    transform: scale(0.97);
}

.menu-sales {
    background: linear-gradient(145deg, #2d6a4f, #1b4332);
    color: white;
}

.menu-inventory {
    background: linear-gradient(145deg, var(--primary), var(--primary-dark));
    color: white;
}

.menu-card-icon {
    font-size: 2.5rem;
}

.menu-card-title {
    font-size: 1.1rem;
    font-weight: 700;
}

.menu-card-desc {
    font-size: 0.75rem;
    opacity: 0.9;
    text-align: center;
}

.landing-foot {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 24px;
    padding-bottom: env(safe-area-inset-bottom);
}

.landing-foot code {
    background: rgba(0,0,0,0.06);
    padding: 2px 6px;
    border-radius: 4px;
}

.password-backdrop {
    align-items: center;
    padding: 16px;
}

.password-modal {
    margin: 0;
    border-radius: 16px;
    max-width: 400px;
    width: 100%;
    animation: none;
}

.input-password {
    font-size: 16px;
    min-height: 48px;
}

.password-modal .modal-actions .btn-primary {
    min-height: 48px;
    font-size: 1rem;
}

.modal-backdrop.hidden {
    display: none !important;
}

.header-row {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.header-back {
    color: white;
    text-decoration: none;
    font-size: 1.4rem;
    font-weight: 700;
    padding: 4px 8px;
    line-height: 1;
}

.header-sales {
    background: linear-gradient(135deg, #2d6a4f 0%, #1b4332 100%);
}

.cart-badge {
    margin-left: auto;
    background: rgba(255,255,255,0.25);
    color: white;
    font-weight: 700;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
}

/* Sales cart */
.cart-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 14px;
    max-height: 40vh;
    overflow-y: auto;
}

.cart-empty {
    padding: 24px !important;
}

.cart-item {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    gap: 8px;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.cart-item:last-child {
    border-bottom: none;
}

.cart-item-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.cart-item-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.cart-qty-controls {
    display: flex;
    align-items: center;
    gap: 6px;
}

.qty-btn {
    width: 32px;
    height: 32px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
}

.qty-display {
    min-width: 24px;
    text-align: center;
    font-weight: 700;
}

.cart-item-sub {
    font-weight: 700;
    color: var(--primary);
    font-size: 0.9rem;
    white-space: nowrap;
}

.cart-remove {
    border: none;
    background: var(--danger-bg);
    color: var(--danger);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    line-height: 1;
}

.cart-total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.1rem;
    font-weight: 600;
    padding: 12px 0;
    border-top: 2px solid var(--border);
    margin-bottom: 12px;
}

.cart-total {
    font-size: 1.35rem;
    color: var(--primary);
}

.payment-btns {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
}

.payment-btn {
    padding: 16px;
    font-size: 1.05rem;
}

.utang-btn {
    background: #1b4332;
}

.gcash-qr {
    width: 100%;
    max-width: 320px;
    border-radius: 12px;
    border: 1px solid var(--border);
    margin: 8px auto 12px;
    display: block;
}

.selected-customer {
    background: var(--warning-bg);
    padding: 10px 12px;
    border-radius: 8px;
    font-weight: 600;
    margin-bottom: 12px;
}

.receipt-modal {
    text-align: center;
}

.receipt-question {
    font-weight: 600;
    margin: 12px 0 4px;
}

.receipt-icon {
    font-size: 3rem;
    margin-bottom: 8px;
}

.receipt-items {
    list-style: none;
    text-align: left;
    margin: 16px 0;
    font-size: 0.9rem;
    max-height: 200px;
    overflow-y: auto;
}

.receipt-items li {
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}

.receipt-total {
    font-size: 1.2rem;
    margin-bottom: 16px;
}

#btn-print-receipt {
    margin-bottom: 10px;
}

.recent-sales {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sale-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.sale-row-title {
    font-weight: 600;
    font-size: 0.9rem;
}

.sale-row-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.sale-row-total {
    font-weight: 700;
    color: var(--primary);
}

.empty-hint {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 12px;
}

.compact-scanner .scanner-container {
    margin-top: 10px;
}

/* Sales scanner: always show camera box when wrap is open */
#sales-scanner-wrap:not(.hidden) .scanner-container {
    display: block !important;
}

.compact-scanner #reader video,
.compact-scanner .scan-video {
    position: relative !important;
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 160px;
    object-fit: cover !important;
}

.compact-scanner #reader {
    min-height: 160px;
    background: #000;
}

.product-search-results {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 280px;
    overflow-y: auto;
    margin: 12px 0 16px;
}

.product-result-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg);
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    transition: border-color 0.15s;
}

.product-result-item:active:not(:disabled) {
    border-color: var(--primary);
    background: var(--primary-light);
}

.product-result-item.out-of-stock {
    opacity: 0.55;
    cursor: not-allowed;
}

.product-result-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.product-result-meta {
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin-top: 4px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.compact-scanner .scan-hint {
    margin-top: 8px;
    margin-bottom: 0;
    text-align: center;
}

.compact-scanner #btn-search-product {
    margin-top: 8px;
}

.compact-scanner .manual-barcode {
    margin-top: 10px;
}

/* Sales filter tabs */
.filter-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.period-tabs {
    margin-bottom: 10px;
}

.payment-tabs {
    margin-top: 16px;
}

.period-tab {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

.period-tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.sales-summary {
    padding: 16px;
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--bg) 100%);
    border: 1px solid var(--border);
    border-radius: 12px;
    text-align: center;
    margin-bottom: 4px;
}

.sales-summary-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.sales-summary-total {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 10px;
    line-height: 1.1;
}

.sales-summary-breakdown {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px 16px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.sales-summary-breakdown strong {
    color: var(--text);
    font-weight: 700;
}

.filter-tab {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

.filter-tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.section-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: -4px 0 12px;
}

.sale-row.clickable {
    cursor: pointer;
    border-radius: 8px;
    padding: 10px 8px;
    margin: 0 -8px;
    transition: background 0.15s;
}

.sale-row.clickable:active {
    background: var(--bg);
}

/* Debt list */
.debt-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.debt-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    background: var(--bg);
    transition: border-color 0.15s;
}

.debt-row-main {
    flex: 1;
    min-width: 0;
}

.debt-row-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.debt-invoice-btn {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    font-size: 1rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
}

.debt-invoice-btn:active {
    border-color: var(--primary);
    background: var(--primary-light);
}

.debt-row:active {
    border-color: var(--primary);
}

.debt-row-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.debt-row-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.debt-row-balance {
    font-weight: 700;
    font-size: 1rem;
    color: #c1121f;
}

.debt-modal {
    max-height: 90vh;
    overflow-y: auto;
}

.debt-summary {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    margin: 12px 0 16px;
    text-align: center;
}

.debt-summary div {
    padding: 10px 6px;
    background: var(--bg);
    border-radius: 8px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.debt-summary strong {
    display: block;
    font-size: 0.95rem;
    color: var(--text);
    margin-top: 4px;
}

.debt-summary .debt-balance strong {
    color: #c1121f;
}

.sub-title {
    font-size: 0.85rem;
    font-weight: 600;
    margin: 12px 0 8px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.debt-entries {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 8px;
}

.debt-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    background: var(--bg);
    border-radius: 8px;
    font-size: 0.85rem;
}

.debt-entry-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.debt-sale-entry {
    cursor: pointer;
}

.debt-sale-entry:active {
    background: var(--primary-light);
}

.debt-entry-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.debt-entry-amount {
    font-weight: 600;
}

.debt-entry.payment .debt-entry-amount {
    color: var(--primary);
}

.pay-debt-form {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.pay-debt-form #btn-record-payment {
    margin-top: 4px;
}

#btn-debt-invoice {
    margin-top: 20px;
    margin-bottom: 16px;
}

#btn-close-debt-detail {
    margin-top: 4px;
}

.main-sales {
    padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px);
}

/* Tablet / larger screens */
@media (min-width: 481px) {
    .app {
        border-left: 1px solid var(--border);
        border-right: 1px solid var(--border);
        box-shadow: 0 0 40px rgba(0, 0, 0, 0.06);
    }
}
