:root {
    --kp-primary: #4F46E5;
    --kp-primary-dark: #4338CA;
    --kp-primary-light: #EEF2FF;
    --kp-ink: #0F172A;
    --kp-body: #334155;
    --kp-muted: #64748B;
    --kp-border: #E5E7EB;
    --kp-bg: #F7F7F8;
    --kp-surface: #FFFFFF;
    --kp-success: #16A34A;
    --kp-success-bg: #DCFCE7;
    --kp-danger: #DC2626;
    --kp-danger-bg: #FEE2E2;
    --kp-warning: #B45309;
    --kp-warning-bg: #FEF3C7;
    --kp-info: #0369A1;
    --kp-info-bg: #E0F2FE;
    --kp-secondary-bg: #F1F1F3;
    --kp-radius-lg: 14px;
    --kp-radius: 10px;
    --kp-radius-sm: 8px;
    /* Square-style flat surfaces: separation comes from a 1px border, not a
       floating shadow. Shadow is reserved for things that actually lift off
       the page (dropdowns, hover states), not resting cards. */
    --kp-shadow: 0 8px 24px -12px rgba(15,23,42,.18);
    --kp-shadow-sm: 0 1px 2px rgba(15,23,42,.04);
}

* { box-sizing: border-box; }

body {
    background-color: var(--kp-bg);
    color: var(--kp-body);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: .925rem;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6, .brand, .fw-display {
    font-family: 'Plus Jakarta Sans', 'Inter', sans-serif;
    color: var(--kp-ink);
    font-weight: 800;
    letter-spacing: -.02em;
}

a { color: var(--kp-primary); text-decoration: none; }
a:hover { color: var(--kp-primary-dark); }

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

.sidebar {
    width: 254px;
    min-height: 100vh;
    background: var(--kp-ink);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: 1.5rem 1.25rem 1.25rem;
    color: #fff;
}
.sidebar-brand .mark {
    width: 32px; height: 32px; border-radius: 9px;
    background: var(--kp-primary);
    display: flex; align-items: center; justify-content: center;
    font-family: 'Plus Jakarta Sans', sans-serif; font-weight: 800; font-size: 1rem;
}
.sidebar-brand .brand-mark-image {
    width: 32px; height: 32px; border-radius: 9px;
    object-fit: cover; background: #fff; flex: 0 0 32px;
}
.brand-mark-image { max-width: 100%; display: block; }
.sidebar-brand .word { font-family: 'Plus Jakarta Sans', sans-serif; font-weight: 800; font-size: 1.15rem; letter-spacing: -.02em; }
.sidebar-brand .staff-tag {
    font-size: .62rem; font-weight: 700; letter-spacing: .08em;
    background: rgba(255,255,255,.1); color: rgba(255,255,255,.7);
    border-radius: 999px; padding: .15rem .5rem; margin-left: .1rem;
}

.sidebar-nav { padding: .5rem .9rem 1rem; flex-grow: 1; }
.sidebar-section {
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: rgba(255,255,255,.35);
    margin: 1.15rem .6rem .4rem;
}
.sidebar-nav .nav-link {
    color: rgba(255,255,255,.72);
    border-radius: var(--kp-radius-sm);
    padding: .55rem .65rem;
    font-size: .865rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: .65rem;
    transition: background .15s ease, color .15s ease;
    margin-bottom: 1px;
}
.sidebar-nav .nav-link i { font-size: .95rem; width: 18px; text-align: center; opacity: .9; }
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-nav .nav-link.active { background: var(--kp-primary); color: #fff; }

.sidebar-foot { padding: 1rem 1.25rem 1.25rem; border-top: 1px solid rgba(255,255,255,.08); }
.plan-chip {
    display: inline-flex; align-items: center; gap: .4rem;
    background: rgba(255,255,255,.08); color: rgba(255,255,255,.85);
    border-radius: 999px; padding: .3rem .7rem; font-size: .72rem; font-weight: 600;
}
.sidebar-credit { margin-top: .6rem; font-size: .68rem; color: rgba(255,255,255,.35); }
.sidebar-credit a { color: rgba(255,255,255,.55); text-decoration: underline; text-decoration-color: rgba(255,255,255,.25); }
.sidebar-credit a:hover { color: #fff; }

/* ---------- Topbar ---------- */
.topbar {
    background: var(--kp-surface);
    border-bottom: 1px solid var(--kp-border);
    padding: .9rem 2rem;
    position: sticky; top: 0; z-index: 20;
}
.topbar .biz-name { font-weight: 700; color: var(--kp-ink); font-size: .95rem; }
.topbar .loc-pill {
    background: var(--kp-secondary-bg); border: none; color: var(--kp-muted);
    font-size: .78rem; font-weight: 600; border-radius: 999px; padding: .2rem .65rem;
}
.avatar-circle {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--kp-primary-light); color: var(--kp-primary);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .8rem; flex-shrink: 0;
}

main.content { padding: 2rem; max-width: 1400px; }

/* ---------- Page header ---------- */
.page-header { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: .75rem; margin-bottom: 1.75rem; }
.page-header h4, .page-header h1 { margin-bottom: .15rem; font-size: 1.5rem; }
.page-header .eyebrow { color: var(--kp-muted); font-size: .84rem; font-weight: 600; }

/* ---------- Cards ---------- */
/* Flat, bordered, no resting shadow — the Square pattern. */
.card {
    border: 1px solid var(--kp-border);
    border-radius: var(--kp-radius-lg);
    box-shadow: none;
}
.card-stat {
    border: 1px solid var(--kp-border);
    border-radius: var(--kp-radius-lg);
    box-shadow: none;
    background: var(--kp-surface);
    transition: border-color .15s ease;
}
.card-body { padding: 1.5rem; }

.stat-icon {
    width: 42px; height: 42px; border-radius: var(--kp-radius-sm);
    display: flex; align-items: center; justify-content: center;
    background: var(--kp-primary-light); color: var(--kp-primary); font-size: 1.1rem;
}

/* ---------- Buttons ---------- */
.btn { border-radius: var(--kp-radius-sm); font-weight: 700; font-size: .875rem; padding: .5rem 1rem; }
.btn-primary { background: var(--kp-primary); border-color: var(--kp-primary); }
.btn-primary:hover, .btn-primary:focus { background: var(--kp-primary-dark); border-color: var(--kp-primary-dark); }
.btn-outline-primary { color: var(--kp-primary); border-color: var(--kp-primary); }
.btn-outline-primary:hover { background: var(--kp-primary); border-color: var(--kp-primary); }
.btn-sm { border-radius: var(--kp-radius-sm); padding: .3rem .65rem; }
.btn-lg { border-radius: var(--kp-radius); padding: .75rem 1.25rem; font-size: .95rem; }

/* ---------- Forms ---------- */
.form-control, .form-select {
    border-radius: var(--kp-radius-sm);
    border-color: var(--kp-border);
    font-size: .875rem;
    padding: .55rem .75rem;
}
.form-control:focus, .form-select:focus {
    border-color: var(--kp-primary);
    box-shadow: 0 0 0 3px var(--kp-primary-light);
}
.form-label { font-weight: 700; font-size: .82rem; color: var(--kp-ink); }
.form-text { color: var(--kp-muted); font-size: .78rem; }

/* ---------- Tables ---------- */
.table { font-size: .875rem; margin-bottom: 0; }
.table thead th {
    text-transform: uppercase; font-size: .68rem; letter-spacing: .06em;
    color: var(--kp-muted); font-weight: 700; border-bottom: 1px solid var(--kp-border);
    background: transparent; padding: .75rem .75rem;
}
.table tbody td { padding: .9rem .75rem; vertical-align: middle; border-bottom: 1px solid var(--kp-border); color: var(--kp-body); }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--kp-bg); }

/* ---------- Badges (soft pills) ---------- */
.badge { font-weight: 700; font-size: .72rem; border-radius: 999px; padding: .35em .7em; }
.badge.bg-success { background: var(--kp-success-bg) !important; color: var(--kp-success) !important; }
.badge.bg-danger { background: var(--kp-danger-bg) !important; color: var(--kp-danger) !important; }
.badge.bg-warning { background: var(--kp-warning-bg) !important; color: var(--kp-warning) !important; }
.badge.bg-info { background: var(--kp-info-bg) !important; color: var(--kp-info) !important; }
.badge.bg-primary { background: var(--kp-primary-light) !important; color: var(--kp-primary) !important; }
.badge.bg-secondary { background: var(--kp-secondary-bg) !important; color: var(--kp-muted) !important; }

/* ---------- Alerts ---------- */
.alert { border: none; border-radius: var(--kp-radius); font-size: .875rem; }
.alert-success { background: var(--kp-success-bg); color: #14532D; }
.alert-danger { background: var(--kp-danger-bg); color: #7F1D1D; }
.alert-warning { background: var(--kp-warning-bg); color: #78350F; }
.alert-info { background: var(--kp-info-bg); color: #0C4A6E; }

/* ---------- Misc ---------- */
.list-group-item { border-color: var(--kp-border); }
code { background: var(--kp-secondary-bg); color: var(--kp-primary-dark); padding: .15em .45em; border-radius: 6px; font-size: .82em; }

.product-avatar {
    width: 38px; height: 38px; border-radius: 9px;
    background: var(--kp-primary-light); color: var(--kp-primary);
    display: flex; align-items: center; justify-content: center;
    font-family: 'Plus Jakarta Sans', sans-serif; font-weight: 700;
    overflow: hidden; flex-shrink: 0;
}
.product-avatar img { width: 100%; height: 100%; object-fit: cover; }

.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--kp-muted); }
.empty-state i { font-size: 1.8rem; opacity: .5; display: block; margin-bottom: .5rem; }

/* Mobile sidebar behaviour lives in the "Mobile / small screens" section at the end of this file. */

/* ---------- Auth pages (login/register/password reset) ---------- */
.auth-shell { min-height: 100vh; }
.auth-brand-panel {
    width: 46%; min-width: 380px; padding: 3rem;
    background: var(--kp-ink);
}
.auth-brand-panel .mark {
    width: 32px; height: 32px; border-radius: 9px;
    background: var(--kp-primary);
    display: flex; align-items: center; justify-content: center;
    font-family: 'Plus Jakarta Sans', sans-serif; font-weight: 800; color: #fff;
}
.auth-brand-panel .brand-mark-image {
    width: 64px; height: 48px; object-fit: contain; object-position: left center;
    background: #fff; border-radius: 10px; margin-bottom: .75rem;
}
.auth-brand-panel .word { color: #fff; font-family: 'Plus Jakarta Sans', sans-serif; font-weight: 800; font-size: 1.1rem; }
.auth-brand-panel a { color: rgba(255,255,255,.75); text-decoration: underline; text-decoration-color: rgba(255,255,255,.3); }
.auth-brand-panel a:hover { color: #fff; }
.auth-form-panel { flex-grow: 1; padding: 2rem; background: var(--kp-surface); }

/* ============================================================
   Point of Sale — Square-style checkout: big touch-friendly item
   tiles, a live running ticket, and a single unmissable charge
   button with the amount printed right on it.
   ============================================================ */

.pos-search .input-group-text, .pos-search .form-control {
    border-color: var(--kp-border);
    padding-top: .65rem; padding-bottom: .65rem;
}

.product-tile {
    cursor: pointer;
    position: relative;
    border: 1px solid var(--kp-border);
    border-radius: var(--kp-radius);
    background: var(--kp-surface);
    padding: 0;
    overflow: hidden;
    transition: border-color .12s ease, background .12s ease;
    display: flex;
    flex-direction: column;
    height: 100%;
}
.product-tile:hover { border-color: var(--kp-primary); }
.product-tile:active { background: var(--kp-primary-light); }
.product-tile.in-cart { border-color: var(--kp-primary); border-width: 2px; }

.product-tile-media {
    aspect-ratio: 1.15 / 1;
    background: var(--kp-secondary-bg);
    display: flex; align-items: center; justify-content: center;
    color: var(--kp-primary);
    font-family: 'Plus Jakarta Sans', sans-serif; font-weight: 800; font-size: 1.6rem;
    overflow: hidden;
}
.product-tile-media img { width: 100%; height: 100%; object-fit: cover; }

.product-tile-info { padding: .65rem .75rem .8rem; }
.product-tile-name {
    font-weight: 600; font-size: .84rem; line-height: 1.25;
    color: var(--kp-ink);
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
    min-height: 2.1em;
}
.product-tile-price { font-weight: 800; font-size: .95rem; color: var(--kp-ink); margin-top: .35rem; }

.tile-qty-badge {
    position: absolute; top: .5rem; right: .5rem;
    min-width: 22px; height: 22px; padding: 0 .35rem;
    background: var(--kp-primary); color: #fff;
    border-radius: 999px; font-size: .74rem; font-weight: 800;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 6px rgba(79,70,229,.4);
}

/* ---------- Cart / ticket panel ---------- */
.pos-cart-panel { position: sticky; top: 90px; display: flex; flex-direction: column; }
.pos-cart-panel .card-body { padding: 1.25rem; }

.cart-row { padding: .75rem 0; border-bottom: 1px solid var(--kp-border); display: flex; align-items: center; gap: .6rem; }
.cart-row:last-child { border-bottom: none; }
.cart-row-name { font-weight: 700; font-size: .86rem; color: var(--kp-ink); }
.cart-row-price { color: var(--kp-muted); font-size: .74rem; }
.cart-row-subtotal { font-weight: 800; font-size: .92rem; color: var(--kp-ink); }

.qty-stepper {
    display: flex; align-items: center; gap: 0;
    border: 1px solid var(--kp-border); border-radius: 999px; overflow: hidden; flex-shrink: 0;
}
.qty-btn {
    width: 28px; height: 28px; border: none; background: var(--kp-secondary-bg);
    color: var(--kp-ink); font-weight: 800; font-size: .95rem; line-height: 1;
    display: flex; align-items: center; justify-content: center; cursor: pointer;
    transition: background .12s ease, color .12s ease;
}
.qty-btn:hover { background: var(--kp-primary); color: #fff; }
.qty-value-input {
    width: 34px; border: none; background: transparent; text-align: center;
    font-weight: 800; font-size: .82rem; color: var(--kp-ink); padding: 0; height: 28px;
    -moz-appearance: textfield;
}
.qty-value-input::-webkit-outer-spin-button, .qty-value-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.qty-value-input:focus { outline: none; background: var(--kp-primary-light); border-radius: 4px; }

.remove-icon-btn {
    width: 26px; height: 26px; border: none; background: transparent; color: var(--kp-muted);
    display: flex; align-items: center; justify-content: center; border-radius: 999px; cursor: pointer;
    transition: background .12s ease, color .12s ease; flex-shrink: 0;
}
.remove-icon-btn:hover { background: var(--kp-danger-bg); color: var(--kp-danger); }

.cart-total-row {
    display: flex; justify-content: space-between; align-items: baseline;
    padding: 1rem 0; border-top: 2px solid var(--kp-ink);
}
.cart-total-label { font-weight: 700; color: var(--kp-muted); font-size: .85rem; }
.cart-total-amount { font-weight: 800; font-size: 1.9rem; color: var(--kp-ink); letter-spacing: -.02em; }

.charge-btn {
    width: 100%; border: none; border-radius: var(--kp-radius);
    background: var(--kp-success); color: #fff;
    font-weight: 800; font-size: 1.05rem; padding: .9rem 1rem;
    display: flex; align-items: center; justify-content: center; gap: .5rem;
    transition: background .12s ease;
}
.charge-btn:hover { background: #15803D; color: #fff; }
.charge-btn:disabled { background: var(--kp-secondary-bg); color: var(--kp-muted); cursor: not-allowed; }

.pos-more-options summary {
    cursor: pointer; font-size: .8rem; font-weight: 700; color: var(--kp-muted);
    padding: .5rem 0; list-style: none;
}
.pos-more-options summary::-webkit-details-marker { display: none; }
.pos-more-options summary::before { content: '⚙ '; }

/* ============================================================
   Mobile / small screens
   Breakpoints follow Bootstrap: lg = 992px (sidebar becomes a drawer),
   md = 768px (tables shed low-priority columns), sm = 576px (phones).
   ============================================================ */

/* Hamburger + drawer backdrop: hidden on desktop. */
.menu-toggle {
    display: none;
    align-items: center; justify-content: center;
    width: 40px; height: 40px; flex-shrink: 0;
    border: 1px solid var(--kp-border); border-radius: var(--kp-radius-sm);
    background: var(--kp-surface); color: var(--kp-ink); font-size: 1.25rem; padding: 0;
}
.menu-toggle:hover { background: var(--kp-bg); }
.sidebar-backdrop { display: none; }

/* Marketplace category chips: the phone stand-in for the category sidebar. */
.category-chips {
    display: flex; gap: .5rem; overflow-x: auto; white-space: nowrap;
    padding: 0 0 .5rem; margin: 0 -.25rem 1rem; scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
}
.category-chips::-webkit-scrollbar { display: none; }
.category-chip {
    flex: 0 0 auto; scroll-snap-align: start;
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .45rem .85rem; border-radius: 999px; font-size: .84rem; font-weight: 600;
    background: var(--kp-surface); color: var(--kp-ink); border: 1px solid var(--kp-border); text-decoration: none;
}
.category-chip .count { color: var(--kp-muted); font-weight: 500; font-size: .76rem; }
.category-chip.active { background: var(--kp-primary); border-color: var(--kp-primary); color: #fff; }
.category-chip.active .count { color: rgba(255,255,255,.8); }

/* Marketplace brand: a touch smaller on phones so the brand, sign-in and cart share one row even at 320px. */
.store-brand { font-size: 1.05rem; }
.brand-wordmark-image {
    display: block; width: 142px; height: 30px; max-width: 42vw;
    object-fit: contain; object-position: left center; vertical-align: middle;
}
.whatsapp-fab {
    position: fixed; right: 1.5rem; bottom: 1.5rem; z-index: 1030;
    width: 56px; height: 56px; border-radius: 50%;
    background: #25D366; color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.6rem; box-shadow: 0 8px 20px rgba(37,211,102,.45);
    transition: transform .15s ease;
}
.pwa-install-button {
    position: fixed; right: 6.25rem; bottom: 1.5rem; z-index: 1030;
    border: 0; border-radius: 999px; padding: .7rem 1.05rem;
    background: var(--kp-primary); color: #fff; font-weight: 700;
    box-shadow: 0 8px 20px rgba(79,70,229,.3); white-space: nowrap;
    transition: transform .15s ease, box-shadow .15s ease;
}
.pwa-install-button:hover { color: #fff; transform: translateY(-2px); box-shadow: 0 10px 24px rgba(79,70,229,.4); }
.whatsapp-fab:hover { color: #fff; transform: scale(1.08); }
.whatsapp-fab i { position: relative; z-index: 1; }
.whatsapp-fab-ping {
    position: absolute; inset: 0; border-radius: 50%;
    background: #25D366; opacity: .55; pointer-events: none;
    animation: whatsapp-fab-pulse 2.2s ease-out infinite;
}
@keyframes whatsapp-fab-pulse {
    0% { transform: scale(1); opacity: .55; }
    100% { transform: scale(1.7); opacity: 0; }
}
@media (max-width: 575.98px) {
    .whatsapp-fab { right: 1rem !important; bottom: 1rem !important; width: 52px; height: 52px; }
    .pwa-install-button { right: 4.75rem !important; bottom: 1rem !important; padding: .65rem .85rem; }
}
@media (prefers-reduced-motion: reduce) {
    .whatsapp-fab-ping { animation: none; display: none; }
}
@media (min-width: 576px) { .store-brand { font-size: 1.25rem; } }
/* Hides secondary controls on the narrowest phones (360px and below), where the long brand name leaves no room. */
@media (max-width: 369.98px) { .hide-xxs { display: none !important; } }

/* POS "view sale" bar: phones only. */
.pos-mobile-bar { display: none; }

/* The landing hero sits on a dark panel; the global heading colour would make it unreadable. */
.landing-hero h1, .landing-hero h2, .landing-hero h3 { color: #fff; }

@media (max-width: 991.98px) {
    .sidebar {
        position: fixed; top: 0; left: -290px; width: 272px; height: 100vh; height: 100dvh;
        z-index: 1045; visibility: hidden;
        transition: left .22s ease, visibility 0s linear .22s;
    }
    .sidebar.open { left: 0; visibility: visible; transition: left .22s ease, visibility 0s; box-shadow: 8px 0 32px rgba(15,23,42,.35); }
    .sidebar-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 1040; }
    body.menu-open { overflow: hidden; }
    .menu-toggle { display: inline-flex; }

    .topbar { padding: .6rem 1rem; }
    .topbar .biz-name { max-width: 38vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .topbar .loc-pill { white-space: nowrap; max-width: 34vw; overflow: hidden; text-overflow: ellipsis; }
    main.content { padding: 1rem; }

    .page-header { margin-bottom: 1.1rem; }
    .page-header h4, .page-header h1 { font-size: 1.25rem; }
    .page-header > .btn { flex: 1 1 100%; }

    /* Sticky-on-desktop ticket panel just scrolls with the page here. */
    .pos-cart-panel { position: static; scroll-margin-top: 70px; }
    .pos-mobile-bar {
        display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
        align-items: center; justify-content: space-between; gap: .75rem;
        padding: .7rem 1rem calc(.7rem + env(safe-area-inset-bottom));
        background: var(--kp-ink); color: #fff; text-decoration: none; font-weight: 700;
    }
    .pos-mobile-bar:hover { color: #fff; }
    .pos-mobile-bar.is-empty { display: none; }
    .pos-mobile-spacer { height: 4.5rem; }
}

@media (max-width: 767.98px) {
    /* Tables keep scrolling sideways on a phone; shadows at the edges show there is more. */
    .table-responsive {
        background:
            linear-gradient(to right, #fff 30%, rgba(255,255,255,0)),
            linear-gradient(to right, rgba(255,255,255,0), #fff 70%) 100% 0,
            radial-gradient(farthest-side at 0 50%, rgba(15,23,42,.18), rgba(15,23,42,0)),
            radial-gradient(farthest-side at 100% 50%, rgba(15,23,42,.18), rgba(15,23,42,0)) 100% 0;
        background-repeat: no-repeat;
        background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
        background-attachment: local, local, scroll, scroll;
    }
    .table thead th, .table tbody td { padding: .6rem .5rem; }
    .card.p-4, .card-stat.p-4 { padding: 1.1rem !important; }
}

@media (max-width: 575.98px) {
    /* 16px inputs stop iOS from zooming the page when a field is focused. */
    .form-control, .form-select, .form-control-sm, .form-select-sm { font-size: 16px; }
    /* Bigger tap targets. */
    .btn-sm { padding: .45rem .8rem; }
    .qty-btn { width: 36px; height: 36px; }
    .avatar-circle { width: 36px; height: 36px; }
    .alert { font-size: .84rem; }
}
