:root {
    --m-primary: #2c3e50;
    --m-accent: #e67e22;
    --m-bg: #f4f6f8;
    --m-card: #ffffff;
    --m-text: #1e293b;
    --m-muted: #64748b;
    --m-border: #e2e8f0;
    --m-success: #059669;
    --m-danger: #dc2626;
    --m-nav-h: 64px;
    --m-safe-b: env(safe-area-inset-bottom, 0px);
}

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

body.m-app {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--m-bg);
    color: var(--m-text);
    min-height: 100vh;
    padding-bottom: calc(var(--m-nav-h) + var(--m-safe-b) + 12px);
}

.m-topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--m-primary);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 12px rgba(0,0,0,.15);
}

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

.m-topbar small {
    display: block;
    font-size: .7rem;
    opacity: .8;
    font-weight: 400;
}

.m-topbar .m-user {
    font-size: .75rem;
    text-align: right;
    opacity: .9;
}

.m-content {
    padding: 16px;
    max-width: 480px;
    margin: 0 auto;
}

.m-flash {
    margin: 12px 16px 0;
    padding: 12px 14px;
    border-radius: 10px;
    font-size: .9rem;
}

.m-flash.success { background: #d1fae5; color: #065f46; }
.m-flash.danger { background: #fee2e2; color: #991b1b; }

.m-stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.m-stat {
    background: var(--m-card);
    border-radius: 14px;
    padding: 14px;
    border: 1px solid var(--m-border);
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
}

.m-stat.wide { grid-column: span 2; }

.m-stat .label {
    font-size: .72rem;
    color: var(--m-muted);
    text-transform: uppercase;
    letter-spacing: .03em;
    margin-bottom: 4px;
}

.m-stat .value {
    font-size: 1.25rem;
    font-weight: 700;
}

.m-stat .value.green { color: var(--m-success); }
.m-stat .value.red { color: var(--m-danger); }
.m-stat .value.orange { color: var(--m-accent); }

.m-card {
    background: var(--m-card);
    border-radius: 14px;
    border: 1px solid var(--m-border);
    margin-bottom: 12px;
    overflow: hidden;
}

.m-card-head {
    padding: 12px 14px;
    font-weight: 600;
    font-size: .9rem;
    border-bottom: 1px solid var(--m-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.m-card-body { padding: 14px; }

.m-list-item {
    padding: 14px;
    border-bottom: 1px solid var(--m-border);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
}

.m-list-item:last-child { border-bottom: none; }

.m-list-item .title { font-weight: 600; font-size: .92rem; }
.m-list-item .meta { font-size: .78rem; color: var(--m-muted); margin-top: 2px; }
.m-list-item .amount { font-weight: 700; white-space: nowrap; }
.m-list-item .amount.green { color: var(--m-success); }
.m-list-item .amount.red { color: var(--m-danger); }

.m-fab {
    position: fixed;
    right: 20px;
    bottom: calc(var(--m-nav-h) + var(--m-safe-b) + 16px);
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--m-accent);
    color: #fff;
    border: none;
    font-size: 1.5rem;
    box-shadow: 0 4px 16px rgba(230,126,34,.45);
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    z-index: 90;
}

.m-btn {
    display: block;
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
}

.m-btn-primary { background: var(--m-primary); color: #fff; }
.m-btn-accent { background: var(--m-accent); color: #fff; }
.m-btn-outline { background: #fff; color: var(--m-primary); border: 1px solid var(--m-border); }

.m-form-group { margin-bottom: 14px; }
.m-form-group label {
    display: block;
    font-size: .8rem;
    font-weight: 600;
    color: var(--m-muted);
    margin-bottom: 6px;
}

.m-form-group input,
.m-form-group select,
.m-form-group textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--m-border);
    border-radius: 10px;
    font-size: 1rem;
    background: #fff;
}

.m-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.m-item-row {
    background: #f8fafc;
    border: 1px solid var(--m-border);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 10px;
}

.m-item-row .row-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.m-item-row .remove-btn {
    background: none;
    border: none;
    color: var(--m-danger);
    font-size: 1.2rem;
    padding: 4px;
}

.m-total-bar {
    background: var(--m-primary);
    color: #fff;
    padding: 14px 16px;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 16px 0;
    font-size: 1.1rem;
    font-weight: 700;
}

.m-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--m-nav-h) + var(--m-safe-b));
    padding-bottom: var(--m-safe-b);
    background: #fff;
    border-top: 1px solid var(--m-border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 200;
    box-shadow: 0 -2px 12px rgba(0,0,0,.06);
}

.m-nav a {
    flex: 1;
    text-align: center;
    text-decoration: none;
    color: var(--m-muted);
    font-size: .65rem;
    padding: 8px 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

.m-nav a i { font-size: 1.35rem; }
.m-nav a.active { color: var(--m-primary); font-weight: 600; }

.m-login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(160deg, var(--m-primary) 0%, #1a252f 100%);
}

.m-login-card {
    background: #fff;
    border-radius: 20px;
    padding: 28px 24px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
}

.m-login-card .logo-wrap {
    text-align: center;
    margin-bottom: 20px;
}

.m-login-card .logo-wrap img {
    max-height: 72px;
    margin-bottom: 10px;
}

.m-login-card h2 {
    text-align: center;
    font-size: 1.1rem;
    color: var(--m-primary);
    margin-bottom: 4px;
}

.m-login-card .sub {
    text-align: center;
    font-size: .8rem;
    color: var(--m-muted);
    margin-bottom: 24px;
}

.m-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: .7rem;
    font-weight: 600;
    background: #e2e8f0;
    color: var(--m-muted);
}

.m-badge.low { background: #fee2e2; color: #991b1b; }
.m-badge.ok { background: #d1fae5; color: #065f46; }

.m-empty {
    text-align: center;
    padding: 32px 16px;
    color: var(--m-muted);
}

.m-empty i { font-size: 2.5rem; display: block; margin-bottom: 8px; opacity: .4; }

.m-quick-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
}

.m-quick-btn {
    background: var(--m-card);
    border: 1px solid var(--m-border);
    border-radius: 14px;
    padding: 16px 12px;
    text-align: center;
    text-decoration: none;
    color: var(--m-text);
}

.m-quick-btn i {
    font-size: 1.6rem;
    color: var(--m-accent);
    display: block;
    margin-bottom: 6px;
}

.m-quick-btn span { font-size: .82rem; font-weight: 600; }

/* PDF download sheet */
.m-pdf-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

.m-pdf-trigger {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 14px;
    border: 1px solid #fecaca;
    border-radius: 12px;
    background: #fef2f2;
    color: #b91c1c;
    font-size: .85rem;
    font-weight: 600;
    cursor: pointer;
}

.m-pdf-trigger i { font-size: 1.1rem; }

.m-pdf-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .45);
    z-index: 200;
    opacity: 0;
    transition: opacity .25s ease;
}

.m-pdf-overlay.open { opacity: 1; }

.m-pdf-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 201;
    background: var(--m-card);
    border-radius: 20px 20px 0 0;
    max-height: 88vh;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform .28s ease;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.m-pdf-sheet.open { transform: translateY(0); }

.m-pdf-sheet-handle {
    width: 40px;
    height: 4px;
    background: #cbd5e1;
    border-radius: 4px;
    margin: 10px auto 0;
}

.m-pdf-sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px 8px;
    border-bottom: 1px solid var(--m-border);
}

.m-pdf-sheet-head h2 {
    font-size: 1rem;
    margin: 0;
    color: var(--m-primary);
}

.m-pdf-sheet-head h2 i { color: #dc2626; margin-right: 6px; }

.m-pdf-close {
    border: none;
    background: #f1f5f9;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 1.4rem;
    line-height: 1;
    color: var(--m-muted);
    cursor: pointer;
}

.m-pdf-sheet-body { padding: 16px; }

.m-pdf-sheet-foot {
    display: flex;
    gap: 10px;
    padding: 12px 16px 16px;
    border-top: 1px solid var(--m-border);
}

.m-pdf-sheet-foot .m-btn { flex: 1; }

.m-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.m-pdf-check {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 12px;
    border: 1px solid var(--m-border);
    border-radius: 12px;
    background: #f8fafc;
    margin-bottom: 12px;
    cursor: pointer;
}

.m-pdf-check input { margin-top: 3px; }

.m-pdf-check strong { display: block; font-size: .88rem; }

.m-pdf-check small { display: block; color: var(--m-muted); font-size: .75rem; margin-top: 2px; }

.m-btn-outline {
    background: transparent;
    border: 1px solid var(--m-border);
    color: var(--m-text);
}

.m-btn-danger {
    background: #dc2626;
    color: #fff;
    border: none;
}

body.m-pdf-open { overflow: hidden; }

/* Bill view */
.m-bill-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

.m-bill-actions .m-btn { flex: 1; }

.m-btn-whatsapp {
    background: #25d366;
    color: #fff;
    border: none;
}

.m-btn-whatsapp:disabled {
    opacity: .7;
}

.m-share-overlay {
    position: fixed;
    inset: 0;
    z-index: 300;
    background: rgba(15, 23, 42, .55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.m-share-overlay[hidden] { display: none !important; }

.m-share-overlay-box {
    background: #fff;
    border-radius: 16px;
    padding: 24px 28px;
    text-align: center;
    max-width: 280px;
}

.m-share-overlay-box p {
    margin: 14px 0 0;
    font-size: .9rem;
    color: var(--m-muted);
}

.m-share-spinner {
    width: 36px;
    height: 36px;
    margin: 0 auto;
    border: 3px solid #e2e8f0;
    border-top-color: #25d366;
    border-radius: 50%;
    animation: m-spin .8s linear infinite;
}

@keyframes m-spin {
    to { transform: rotate(360deg); }
}

.m-share-toast {
    position: fixed;
    left: 50%;
    bottom: calc(80px + env(safe-area-inset-bottom, 0));
    transform: translateX(-50%) translateY(20px);
    background: rgba(15, 23, 42, .92);
    color: #fff;
    padding: 12px 18px;
    border-radius: 12px;
    font-size: .85rem;
    z-index: 400;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease, transform .25s ease;
    max-width: 90vw;
    text-align: center;
}

.m-share-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

#billSnapshot {
    background: #fff;
}

.m-share-ask {
    position: fixed;
    inset: 0;
    z-index: 250;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.m-share-ask[hidden] { display: none !important; }

.m-share-ask-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, .45);
}

.m-share-ask-box {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 480px;
    background: #fff;
    border-radius: 20px 20px 0 0;
    padding: 20px 16px calc(16px + env(safe-area-inset-bottom, 0));
}

.m-share-ask-box h3 {
    margin: 0 0 8px;
    font-size: 1.05rem;
    color: var(--m-primary);
}

.m-share-ask-box p {
    margin: 0 0 10px;
    font-size: .9rem;
    color: var(--m-text);
}

.m-share-ask-note {
    font-size: .82rem !important;
    color: var(--m-muted) !important;
    background: #f8fafc;
    border-radius: 10px;
    padding: 10px 12px;
}

.m-share-ask-actions {
    display: flex;
    gap: 10px;
    margin-top: 14px;
}

.m-share-ask-actions .m-btn { flex: 1; }

body.m-share-open { overflow: hidden; }

.m-alert-warning {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    background: #fef3c7;
    border: 1px solid #fcd34d;
    color: #92400e;
    padding: 12px 14px;
    border-radius: 12px;
    margin-bottom: 16px;
    font-size: .85rem;
}

.m-alert-warning a { color: #b45309; font-weight: 600; }
.m-alert-warning a.wa { color: #16a34a; }

.m-offline-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 500;
    background: #b91c1c;
    color: #fff;
    text-align: center;
    padding: 6px 12px;
    font-size: .78rem;
}

.m-offline-bar[hidden] { display: none !important; }

.m-offline-badge {
    position: fixed;
    bottom: calc(70px + env(safe-area-inset-bottom, 0));
    left: 50%;
    transform: translateX(-50%);
    background: #1e40af;
    color: #fff;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: .75rem;
    z-index: 150;
}

.m-offline-badge[hidden] { display: none !important; }

.m-offline-sync-card {
    border: 1px solid #bfdbfe;
    background: #eff6ff;
}

.m-offline-sync-card .m-easy-save {
    width: 100%;
}

.m-scan-result {
    padding: 10px 12px;
    border-radius: 10px;
    font-size: .85rem;
    margin-bottom: 12px;
}

.m-scan-result.ok { background: #d1fae5; color: #065f46; }
.m-scan-result.err { background: #fee2e2; color: #991b1b; }

.m-meta-text { font-size: .8rem; color: var(--m-muted); margin: 0; }

.m-bill-expenses {
    border-top: 2px dashed #fecaca;
    margin-top: 4px;
    background: #fffafb;
}

.m-bill-expenses-head {
    padding: 14px 16px 10px;
    font-weight: 700;
    font-size: .9rem;
    color: #b91c1c;
}

.m-bill-expenses-head i { margin-right: 6px; }

.m-bill-expense-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    border-top: 1px solid #fee2e2;
}

.m-bill-expense-row .title {
    font-size: .88rem;
    font-weight: 600;
}

.m-bill-expense-row .meta {
    font-size: .75rem;
    color: var(--m-muted);
    margin-top: 2px;
}

.m-bill-expense-row .amount.red {
    color: #dc2626;
    font-weight: 700;
    white-space: nowrap;
}

.m-bill-expense-total,
.m-bill-expense-net {
    display: flex;
    justify-content: space-between;
    padding: 12px 16px;
    font-weight: 700;
    font-size: .9rem;
    border-top: 1px solid #fecaca;
}

.m-bill-expense-net {
    background: #f0fdf4;
    border-top: 2px solid #bbf7d0;
}

.m-bill-expense-net .red { color: #dc2626; }
.m-bill-expense-net .green { color: #16a34a; }

.m-bill-expense-empty {
    padding: 14px 16px;
    color: var(--m-muted);
    font-size: .85rem;
}

.m-bill-card { overflow: hidden; }

.m-bill-head {
    text-align: center;
    padding: 20px 16px 16px;
    border-bottom: 1px solid var(--m-border);
    background: linear-gradient(180deg, #f8fafc 0%, #fff 100%);
}

.m-bill-logo {
    max-height: 56px;
    margin-bottom: 8px;
}

.m-bill-head h2 {
    font-size: 1rem;
    margin: 0 0 4px;
    color: var(--m-primary);
}

.m-bill-head p {
    margin: 0;
    font-size: .8rem;
    color: var(--m-muted);
}

.m-bill-badge {
    display: inline-block;
    margin-top: 10px;
    padding: 4px 12px;
    border-radius: 20px;
    background: var(--m-accent);
    color: #fff;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .04em;
}

.m-bill-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid var(--m-border);
}

.m-bill-meta span {
    display: block;
    font-size: .72rem;
    color: var(--m-muted);
    text-transform: uppercase;
    letter-spacing: .03em;
}

.m-bill-meta strong {
    display: block;
    font-size: .88rem;
    margin-top: 2px;
}

.m-bill-items .m-list-item { border-bottom: 1px solid var(--m-border); }

.m-bill-notes {
    padding: 14px 16px;
    border-top: 1px solid var(--m-border);
    font-size: .88rem;
}

.m-bill-notes p {
    margin: 6px 0 0;
    color: var(--m-muted);
}

@media print {
    .m-topbar, .m-nav, .m-bill-actions, .m-flash, .m-share-overlay { display: none !important; }
    .m-content { padding: 0 !important; }
    .m-bill-card { border: none; box-shadow: none; }
}

/* PWA Install */
.m-install-banner {
    margin: 12px 16px 0;
    background: linear-gradient(135deg, #2c3e50, #34495e);
    color: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(44, 62, 80, .25);
}

.m-install-banner-inner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
}

.m-install-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(230, 126, 34, .2);
    color: #f39c12;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.m-install-text {
    flex: 1;
    min-width: 0;
}

.m-install-text strong {
    display: block;
    font-size: .88rem;
    line-height: 1.3;
}

.m-install-text span {
    display: block;
    font-size: .72rem;
    opacity: .85;
    margin-top: 2px;
}

.m-install-btn {
    border: none;
    background: var(--m-accent);
    color: #fff;
    font-size: .78rem;
    font-weight: 600;
    padding: 8px 12px;
    border-radius: 8px;
    white-space: nowrap;
    flex-shrink: 0;
}

.m-install-dismiss {
    border: none;
    background: transparent;
    color: rgba(255,255,255,.7);
    font-size: 1.25rem;
    line-height: 1;
    padding: 0 4px;
    flex-shrink: 0;
}

.m-install-login-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding: 14px 16px;
    border: 2px dashed #e67e22;
    border-radius: 12px;
    background: #fff8f0;
    color: var(--m-text);
    text-align: left;
    cursor: pointer;
}

.m-install-login-btn > .bi-download {
    font-size: 1.4rem;
    color: var(--m-accent);
}

.m-install-login-btn span {
    flex: 1;
}

.m-install-login-btn strong {
    display: block;
    font-size: .9rem;
    color: var(--m-primary);
}

.m-install-login-btn small {
    display: block;
    font-size: .72rem;
    color: var(--m-muted);
    margin-top: 2px;
}

.m-install-login-btn > .bi-chevron-right {
    color: var(--m-muted);
}

.m-install-hint {
    font-size: .78rem;
    color: var(--m-muted);
    background: #f1f5f9;
    border-radius: 10px;
    padding: 10px 12px;
    margin: -8px 0 16px;
    line-height: 1.4;
}

.m-install-ios[hidden] {
    display: none !important;
}

.m-install-ios:not([hidden]) {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(15, 23, 42, .55);
    display: flex;
    align-items: flex-end;
    padding: 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}

body.pwa-modal-open {
    overflow: hidden;
}

.m-install-ios-inner {
    width: 100%;
    background: #fff;
    border-radius: 16px;
    padding: 20px;
}

.m-install-ios-inner strong {
    display: block;
    margin-bottom: 12px;
    font-size: 1rem;
}

.m-install-ios ol {
    margin: 0 0 16px 18px;
    font-size: .88rem;
    color: var(--m-text);
}

.m-install-ios li {
    margin-bottom: 8px;
}

.m-btn-block {
    width: 100%;
    justify-content: center;
}

/* POS Sale — easy mobile billing */
body.has-pos-footer {
    padding-bottom: calc(var(--m-nav-h) + var(--m-safe-b) + 88px);
}

.m-pos-page {
    max-width: 480px;
    margin: 0 auto;
}

.m-pos-stall-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fff;
    border: 1px solid var(--m-border);
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 12px;
}

.m-pos-stall-badge i {
    font-size: 1.3rem;
    color: var(--m-accent);
}

.m-pos-stall-badge span {
    font-weight: 700;
    font-size: 1rem;
}

.m-pos-stall-badge small {
    display: block;
    font-size: .72rem;
    color: var(--m-muted);
    font-weight: 400;
}

.m-pos-pay {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
}

.m-pay-pill {
    border: 2px solid var(--m-border);
    background: #fff;
    border-radius: 12px;
    padding: 12px 8px;
    font-size: .82rem;
    font-weight: 600;
    color: var(--m-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.m-pay-pill i {
    font-size: 1.1rem;
}

.m-pay-pill.active {
    border-color: var(--m-accent);
    background: #fff8f0;
    color: var(--m-accent);
}

.m-pos-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
}

.m-pos-tab {
    border: none;
    background: #e2e8f0;
    color: var(--m-text);
    border-radius: 10px;
    padding: 10px;
    font-size: .88rem;
    font-weight: 600;
}

.m-pos-tab.active {
    background: var(--m-primary);
    color: #fff;
}

.m-pos-search-wrap {
    position: relative;
    margin-bottom: 10px;
}

.m-pos-search-wrap i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--m-muted);
}

.m-pos-search-wrap input {
    width: 100%;
    padding: 12px 12px 12px 38px;
    border: 1px solid var(--m-border);
    border-radius: 10px;
    font-size: 1rem;
    background: #fff;
}

.m-pos-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 14px;
    max-height: 42vh;
    overflow-y: auto;
    padding-bottom: 4px;
}

.m-pos-item {
    border: 1px solid var(--m-border);
    background: #fff;
    border-radius: 12px;
    padding: 12px 10px;
    text-align: left;
    min-height: 88px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.m-pos-item .name {
    font-size: .85rem;
    font-weight: 700;
    line-height: 1.25;
    color: var(--m-text);
}

.m-pos-item .price {
    font-size: .95rem;
    font-weight: 700;
    color: var(--m-success);
}

.m-pos-item .stock {
    font-size: .68rem;
    color: var(--m-muted);
}

.m-pos-item:active {
    transform: scale(0.98);
    border-color: var(--m-accent);
}

.m-pos-item.out {
    opacity: .55;
}

.m-pos-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 24px 12px;
    color: var(--m-muted);
    font-size: .88rem;
}

.m-pos-quick-card {
    background: #fff;
    border: 1px solid var(--m-border);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 14px;
}

.m-pos-quick-card label {
    display: block;
    font-size: .8rem;
    font-weight: 600;
    color: var(--m-muted);
    margin-bottom: 6px;
}

.m-pos-quick-card input {
    width: 100%;
    padding: 14px;
    border: 1px solid var(--m-border);
    border-radius: 10px;
    font-size: 1.1rem;
}

.m-pos-cart {
    background: #fff;
    border: 1px solid var(--m-border);
    border-radius: 12px;
    overflow: hidden;
}

.m-pos-cart-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    background: #f8fafc;
    border-bottom: 1px solid var(--m-border);
    font-size: .9rem;
}

.m-pos-clear {
    border: none;
    background: none;
    color: var(--m-danger);
    font-size: .78rem;
    font-weight: 600;
}

.m-pos-cart-list {
    max-height: 200px;
    overflow-y: auto;
}

.m-pos-cart-empty {
    padding: 20px 14px;
    text-align: center;
    color: var(--m-muted);
    font-size: .85rem;
}

.m-pos-cart-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 8px;
    align-items: center;
    padding: 10px 12px;
    border-bottom: 1px solid var(--m-border);
}

.m-pos-cart-row:last-child {
    border-bottom: none;
}

.m-pos-cart-info .name {
    font-size: .88rem;
    font-weight: 600;
}

.m-pos-cart-info .meta {
    font-size: .72rem;
    color: var(--m-muted);
    margin-top: 2px;
}

.m-pos-cart-qty {
    display: flex;
    align-items: center;
    gap: 6px;
}

.m-pos-cart-qty .qty-btn {
    width: 30px;
    height: 30px;
    border: 1px solid var(--m-border);
    background: #fff;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 700;
    color: var(--m-primary);
}

.m-pos-cart-qty span {
    min-width: 24px;
    text-align: center;
    font-weight: 600;
    font-size: .9rem;
}

.m-pos-cart-amt {
    font-weight: 700;
    color: var(--m-success);
    font-size: .88rem;
    white-space: nowrap;
}

.m-pos-footer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(var(--m-nav-h) + var(--m-safe-b));
    z-index: 95;
    background: #fff;
    border-top: 1px solid var(--m-border);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 -4px 20px rgba(0,0,0,.08);
}

.m-pos-footer-total span {
    display: block;
    font-size: .72rem;
    color: var(--m-muted);
}

.m-pos-footer-total strong {
    font-size: 1.25rem;
    color: var(--m-success);
}

.m-pos-save-btn {
    flex: 1;
    border: none;
    background: var(--m-accent);
    color: #fff;
    border-radius: 12px;
    padding: 14px 16px;
    font-size: 1rem;
    font-weight: 700;
}

.m-pos-save-btn:disabled {
    opacity: .45;
}

.m-sales-hero-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 16px;
    margin-bottom: 16px;
    border: none;
    border-radius: 14px;
    background: linear-gradient(135deg, #e67e22, #f39c12);
    color: #fff;
    font-size: 1.05rem;
    font-weight: 700;
    text-decoration: none;
    box-shadow: 0 4px 16px rgba(230,126,34,.35);
}

.m-sales-hero-btn i {
    font-size: 1.3rem;
}

.m-expense-hero-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 16px;
    margin-bottom: 16px;
    border: none;
    border-radius: 14px;
    background: linear-gradient(135deg, #dc2626, #ef4444);
    color: #fff;
    font-size: 1.05rem;
    font-weight: 700;
    text-decoration: none;
    box-shadow: 0 4px 16px rgba(220, 38, 38, .3);
}

.m-expense-hero-btn i {
    font-size: 1.3rem;
}

.m-fab-expense {
    background: #dc2626;
    box-shadow: 0 4px 16px rgba(220, 38, 38, .4);
}

/* Expense quick add */
.m-expense-page .m-expense-amount-wrap {
    background: #fff;
    border: 2px solid var(--m-border);
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 14px;
    text-align: center;
}

.m-expense-amount-wrap label {
    display: block;
    font-size: .78rem;
    font-weight: 600;
    color: var(--m-muted);
    margin-bottom: 8px;
}

.m-expense-amount-wrap input {
    width: 100%;
    border: none;
    font-size: 2.2rem;
    font-weight: 700;
    text-align: center;
    color: var(--m-danger);
    outline: none;
    background: transparent;
}

.m-pos-section-label {
    font-size: .78rem;
    font-weight: 700;
    color: var(--m-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: 8px;
}

.m-expense-cats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 14px;
}

.m-expense-cat {
    border: 2px solid var(--m-border);
    background: #fff;
    border-radius: 12px;
    padding: 12px 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    font-size: .68rem;
    font-weight: 600;
    color: var(--m-muted);
    min-height: 72px;
}

.m-expense-cat i {
    font-size: 1.2rem;
    color: var(--m-primary);
}

.m-expense-cat.active {
    border-color: var(--m-danger);
    background: #fef2f2;
    color: var(--m-danger);
}

.m-expense-cat.active i {
    color: var(--m-danger);
}

.m-pos-pay-4 {
    grid-template-columns: repeat(2, 1fr);
}

.m-pos-pay-4 .m-pay-pill {
    padding: 10px 4px;
    font-size: .7rem;
}

.m-expense-footer .m-pos-footer-total strong {
    color: var(--m-danger);
}

.m-expense-save {
    background: #dc2626;
}

/* ——— Clean Easy UI (Sales / Expenses) ——— */
.m-easy-form {
    max-width: 480px;
    margin: 0 auto;
}

.m-easy-sheet {
    background: #fff;
    border-radius: 20px;
    padding: 20px;
    margin-bottom: 14px;
    box-shadow: 0 4px 24px rgba(15, 23, 42, .06);
    border: 1px solid rgba(226, 232, 240, .8);
}

.m-easy-stall {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 16px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--m-border);
}

.m-easy-stall i {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: #f1f5f9;
    color: var(--m-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.m-easy-stall strong {
    display: block;
    font-size: 1rem;
}

.m-easy-stall span {
    font-size: .75rem;
    color: var(--m-muted);
}

.m-easy-field {
    margin-bottom: 16px;
}

.m-easy-field label {
    display: block;
    font-size: .75rem;
    font-weight: 600;
    color: var(--m-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.m-easy-input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--m-border);
    border-radius: 12px;
    font-size: 1rem;
    background: #f8fafc;
}

.m-easy-input:focus {
    outline: none;
    border-color: var(--m-accent);
    background: #fff;
}

.m-easy-segment {
    display: flex;
    background: #f1f5f9;
    border-radius: 12px;
    padding: 4px;
    gap: 4px;
    margin-bottom: 20px;
}

.m-easy-segment button {
    flex: 1;
    border: none;
    background: transparent;
    padding: 12px 8px;
    border-radius: 10px;
    font-size: .88rem;
    font-weight: 600;
    color: var(--m-muted);
}

.m-easy-segment button.active {
    background: #fff;
    color: var(--m-primary);
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
}

.m-easy-sheet--expense .m-easy-segment button.active {
    color: var(--m-danger);
}

.m-easy-hero {
    text-align: center;
    margin-bottom: 16px;
}

.m-easy-hero label {
    display: block;
    font-size: .8rem;
    color: var(--m-muted);
    margin-bottom: 8px;
}

.m-easy-amount {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 0;
}

.m-easy-amount span {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--m-muted);
}

.m-easy-amount input {
    border: none;
    background: transparent;
    font-size: 2.75rem;
    font-weight: 700;
    width: 160px;
    text-align: left;
    color: var(--m-success);
    outline: none;
}

.m-easy-hero--expense .m-easy-amount input {
    color: var(--m-danger);
}

.m-easy-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.m-easy-chip {
    border: 1px solid var(--m-border);
    background: #f8fafc;
    border-radius: 999px;
    padding: 10px 16px;
    font-size: .82rem;
    font-weight: 600;
    color: var(--m-muted);
}

.m-easy-chip.active {
    background: #fef2f2;
    border-color: #fca5a5;
    color: var(--m-danger);
}

.m-easy-save {
    width: 100%;
    border: none;
    border-radius: 14px;
    padding: 16px;
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 4px;
}

.m-easy-save--sale {
    background: linear-gradient(135deg, #059669, #10b981);
    box-shadow: 0 4px 14px rgba(5, 150, 105, .35);
}

.m-easy-save--expense {
    background: linear-gradient(135deg, #dc2626, #ef4444);
    box-shadow: 0 4px 14px rgba(220, 38, 38, .3);
}

.m-easy-save:disabled {
    opacity: .45;
    box-shadow: none;
}

.m-easy-save--outline {
    background: #fff;
    color: var(--m-success);
    border: 2px solid var(--m-success);
    box-shadow: none;
    margin-top: 12px;
}

.m-easy-details {
    background: #fff;
    border-radius: 16px;
    border: 1px solid var(--m-border);
    margin-bottom: 12px;
    overflow: hidden;
}

.m-easy-details summary {
    padding: 14px 16px;
    font-size: .9rem;
    font-weight: 600;
    color: var(--m-primary);
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.m-easy-details summary::-webkit-details-marker {
    display: none;
}

.m-easy-details-body {
    padding: 0 16px 16px;
    border-top: 1px solid var(--m-border);
}

.m-easy-item-list {
    margin: 12px 0;
    max-height: 200px;
    overflow-y: auto;
}

.m-easy-item-row {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 0;
    border: none;
    border-bottom: 1px solid var(--m-border);
    background: transparent;
    text-align: left;
}

.m-easy-item-row .n {
    flex: 1;
    font-weight: 600;
    font-size: .9rem;
}

.m-easy-item-row .p {
    color: var(--m-success);
    font-weight: 700;
    font-size: .88rem;
}

.m-easy-item-row i {
    color: var(--m-accent);
    font-size: 1.2rem;
}

.m-easy-cart-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--m-border);
    font-size: .88rem;
}

.m-easy-cart-row small {
    display: block;
    color: var(--m-muted);
    font-size: .75rem;
}

.m-easy-cart-row .q button {
    width: 32px;
    height: 32px;
    border: 1px solid var(--m-border);
    border-radius: 8px;
    background: #fff;
    font-weight: 700;
    margin-left: 4px;
}

.m-easy-cart-total {
    text-align: right;
    font-size: .9rem;
    margin: 10px 0 0;
    color: var(--m-muted);
}

.m-easy-cart-total strong {
    color: var(--m-success);
    font-size: 1.1rem;
}

.m-easy-muted {
    text-align: center;
    color: var(--m-muted);
    font-size: .85rem;
    padding: 16px 0;
}

.m-easy-cancel {
    display: block;
    text-align: center;
    color: var(--m-muted);
    font-size: .88rem;
    text-decoration: none;
    padding: 12px;
}

/* List page action cards */
.m-action-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
    background: #fff;
    border-radius: 16px;
    margin-bottom: 16px;
    text-decoration: none;
    color: inherit;
    border: 1px solid var(--m-border);
    box-shadow: 0 2px 12px rgba(0,0,0,.04);
}

.m-action-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    color: #fff;
}

.m-action-card--sale .m-action-icon {
    background: linear-gradient(135deg, #059669, #10b981);
}

.m-action-card--expense .m-action-icon {
    background: linear-gradient(135deg, #dc2626, #f87171);
}

.m-action-card--bulk .m-action-icon {
    background: linear-gradient(135deg, #2563eb, #3b82f6);
}

.m-action-card--import .m-action-icon {
    background: linear-gradient(135deg, #059669, #34d399);
}

.m-action-text {
    flex: 1;
}

.m-action-text strong {
    display: block;
    font-size: 1rem;
}

.m-action-text span {
    font-size: .78rem;
    color: var(--m-muted);
}

.m-action-arrow {
    color: #cbd5e1;
    font-size: 1.1rem;
}

.m-date-bar {
    margin-bottom: 16px;
}

.m-date-bar form {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fff;
    border: 1px solid var(--m-border);
    border-radius: 12px;
    padding: 10px 14px;
}

.m-date-bar i {
    color: var(--m-muted);
}

.m-date-bar input {
    flex: 1;
    border: none;
    font-size: .95rem;
    background: transparent;
}

/* Product picker — sale bill */
.m-product-pick {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-height: 180px;
    overflow-y: auto;
}

.m-product-btn {
    border: 2px solid var(--m-border);
    background: #f8fafc;
    border-radius: 12px;
    padding: 10px 14px;
    text-align: left;
    min-width: calc(50% - 4px);
    flex: 1 1 calc(50% - 4px);
}

.m-product-btn-name {
    display: block;
    font-size: .85rem;
    font-weight: 700;
    color: var(--m-text);
    line-height: 1.25;
}

.m-product-btn-price {
    display: block;
    font-size: .75rem;
    color: var(--m-success);
    font-weight: 600;
    margin-top: 4px;
}

.m-product-btn.active {
    border-color: #10b981;
    background: #ecfdf5;
}

.m-product-btn.active .m-product-btn-name {
    color: #047857;
}

.m-qty-row {
    max-width: 140px;
}

.m-pick-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(15, 23, 42, .5);
    display: flex;
    align-items: flex-end;
    padding: 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}

.m-pick-modal[hidden] {
    display: none !important;
}

.m-pick-modal-box {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    background: #fff;
    border-radius: 20px 20px 16px 16px;
    padding: 20px;
    max-height: 70vh;
    overflow-y: auto;
}

.m-pick-modal-box strong {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.05rem;
    margin-bottom: 6px;
}

.m-pick-hint {
    font-size: .82rem;
    color: var(--m-muted);
    margin-bottom: 14px;
}

.m-stat-grid--3 { grid-template-columns: repeat(3, 1fr); }

/* Mobile Inventory */
.m-inv-page { display: flex; flex-direction: column; gap: 0; }

.m-inv-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}

.m-inv-stats .m-stat {
    padding: 10px 8px;
    min-width: 0;
    text-align: center;
}

.m-inv-stats .label {
    font-size: .62rem;
    line-height: 1.2;
    margin-bottom: 2px;
}

.m-inv-stats .value {
    font-size: clamp(.72rem, 3.2vw, .95rem);
    line-height: 1.25;
    word-break: break-word;
}

.m-inv-toolbar {
    padding: 12px;
    margin-bottom: 12px;
}

.m-inv-toolbar .m-inv-search {
    margin-bottom: 10px;
}

.m-inv-search {
    position: relative;
}

.m-inv-search i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--m-muted);
    pointer-events: none;
}

.m-inv-search input {
    width: 100%;
    padding: 12px 14px 12px 40px;
    border: 1px solid var(--m-border);
    border-radius: 12px;
    font-size: 1rem;
    background: #fff;
    -webkit-appearance: none;
    appearance: none;
}

.m-inv-filter-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.m-inv-filter-label {
    font-size: .78rem;
    font-weight: 600;
    color: var(--m-muted);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 4px;
}

.m-inv-select {
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid var(--m-border);
    border-radius: 10px;
    font-size: .92rem;
    background: #fff;
}

.m-inv-chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.m-inv-chips::-webkit-scrollbar { display: none; }

.m-inv-chip {
    flex-shrink: 0;
    border: 1px solid var(--m-border);
    background: #fff;
    color: var(--m-text);
    border-radius: 999px;
    padding: 7px 12px;
    font-size: .78rem;
    font-weight: 600;
    font-family: inherit;
    line-height: 1.2;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

.m-inv-chip.active { background: var(--m-primary); color: #fff; border-color: var(--m-primary); }
.m-inv-chip.warn.active { background: #dc2626; border-color: #dc2626; color: #fff; }

.m-inv-scan-btn {
    width: 100%;
    margin-bottom: 12px;
}

.m-inv-qr {
    margin-bottom: 12px;
    border-radius: 12px;
    overflow: hidden;
}

.m-inv-qr[hidden] { display: none !important; }

.m-inv-quick { margin-bottom: 12px; }
.m-inv-quick summary { cursor: pointer; list-style: none; }
.m-inv-quick summary::-webkit-details-marker { display: none; }
.m-inv-quick summary i { margin-right: 6px; }

.m-inv-list .m-card-head {
    gap: 8px;
}

.m-inv-count {
    font-size: .78rem;
    font-weight: 700;
    background: #eef2ff;
    color: #4338ca;
    padding: 2px 8px;
    border-radius: 999px;
}

.m-inv-item {
    padding: 12px 14px;
    border-bottom: 1px solid var(--m-border);
}

.m-inv-item:last-of-type { border-bottom: none; }
.m-inv-item.low { background: #fffafb; }

.m-inv-item-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    min-height: 22px;
}

.m-inv-cat {
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .02em;
    color: #6366f1;
    background: #eef2ff;
    padding: 3px 8px;
    border-radius: 999px;
    max-width: 70%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.m-inv-cat--empty { visibility: hidden; }

.m-inv-item-top .m-badge { margin-left: auto; flex-shrink: 0; }

.m-inv-item-main {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.m-inv-item .title {
    font-weight: 600;
    font-size: .95rem;
    line-height: 1.3;
    word-break: break-word;
}

.m-inv-item .meta {
    font-size: .78rem;
    color: var(--m-muted);
    margin-top: 3px;
    line-height: 1.35;
}

.m-inv-qty {
    text-align: right;
    white-space: nowrap;
    flex-shrink: 0;
}

.m-inv-qty strong {
    font-size: 1.05rem;
    color: var(--m-primary);
    display: block;
    line-height: 1.2;
}

.m-inv-qty small { color: var(--m-muted); font-size: .72rem; }

.m-inv-bar {
    height: 6px;
    background: #f1f5f9;
    border-radius: 999px;
    overflow: hidden;
    margin-top: 10px;
}

.m-inv-bar > span {
    display: block;
    height: 100%;
    min-width: 4px;
    background: linear-gradient(90deg, #22c55e, #16a34a);
    border-radius: 999px;
    transition: width .2s ease;
}

.m-inv-bar.low > span { background: linear-gradient(90deg, #f97316, #dc2626); }

.m-btn-block { width: 100%; }

@media (max-width: 360px) {
    .m-inv-stats {
        grid-template-columns: 1fr 1fr;
    }
    .m-inv-stats .m-stat:last-child {
        grid-column: 1 / -1;
    }
}
