/* Thaitec POS - light, flat interface theme.
 *
 * Surfaces are white on a soft neutral canvas, separated by hairlines rather
 * than shadows. Orange is the only chromatic accent and is spent sparingly:
 * the active nav item, primary actions, focus rings. Everything else is
 * greyscale so the accent still means something.
 */

:root {
    /* Brand orange - unchanged, used flat rather than as a gradient */
    --accent: #f97316;
    --accent-light: #fb923c;
    --accent-dark: #ea580c;
    --accent-soft: #fff3ea;
    --accent-softer: #fffaf6;
    /* Text-on-tint orange. #ea580c only reaches 3.26:1 on --accent-soft, which
     * fails AA for 14px labels; this clears 4.5:1. */
    --accent-ink: #b23c05;
    /* Fill for buttons that carry white text. The bright brand orange gives
     * white only 2.8:1; this reaches 4.9:1 while still reading as the brand.
     * --accent itself stays bright for non-text uses: icons, the active nav
     * indicator, focus rings, chart marks. */
    --accent-btn: #c2410c;
    --accent-btn-hover: #9a3412;

    /* Surfaces */
    --surface: #ffffff;
    --canvas: #f7f7f8;
    --raised: #fafafa;

    /* Hairlines */
    --line: #ebebed;
    --line-strong: #dcdce0;

    /* Ink */
    --ink: #18181b;
    --ink-2: #52525b;
    /* #71717a clears 4.5:1 on pure white but only 4.48:1 on --raised, which is
     * where table headers and footers sit. This clears both. */
    --ink-3: #6b6b74;
    /* Sidebar section labels. Lighter greys look closer to the reference but
     * #a1a1aa only reaches 2.56:1 on white. */
    --eyebrow: #71717a;

    /* Status */
    --success: #16a34a;
    --success-light: #22c55e;
    --success-dark: #15803d;
    --warn: #d97706;
    --danger: #dc2626;
    --info: #2563eb;

    /* Kept for markup that still references the old navy. It now reads as
     * near-black ink rather than blue, so .text-primary stays legible. */
    --primary: #26262b;
    --primary-light: #3f3f46;
    --primary-dark: #18181b;

    --radius: 12px;
    --radius-sm: 9px;

    --sidebar-width: 260px;
    --tblr-primary: #f97316;
    --tblr-primary-rgb: 249, 115, 22;
    --font-size-base: 0.95rem;
    --font-size-sm: 0.85rem;
    --font-size-xs: 0.8rem;
}

body {
    background: var(--canvas);
    color: var(--ink);
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: "cv02", "cv03", "cv04", "tnum";
}

/* Figures line up in columns when they sit in tables and stat tiles. */
.table td, .table th, .stat-card .h2, .h2, .h1 { font-variant-numeric: tabular-nums; }

.page-title {
    font-weight: 650;
    letter-spacing: -0.02em;
    color: var(--ink);
}

/* ========== SIDEBAR ========== */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    background: var(--surface);
    border-right: 1px solid var(--line);
    z-index: 1050;
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.5rem 0.65rem 2.5rem;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Quiet scrollbar - the nav is long, so the track shouldn't compete. */
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: #e4e4e7; border-radius: 999px; }
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: var(--line-strong); }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }

.nav-section {
    margin-top: 0.85rem;
    padding: 0 0.85rem 0.35rem;
}

.nav-section:first-child {
    margin-top: 0.35rem;
}

.nav-section-header {
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--eyebrow);
    display: block;
    user-select: none;
    -webkit-user-select: none;
}

/* The section labels already group the nav; a rule between them as well is
 * one accessory too many. */
.nav-section-divider {
    height: 0;
    margin: 0.35rem 0;
}

.sidebar-brand {
    padding: 1rem 1rem 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    text-align: left;
    background: var(--surface);
    color: var(--ink);
    border-bottom: 1px solid var(--line);
    position: relative;
    flex-shrink: 0;
}

.sidebar-logo {
    max-width: 56px;
    height: auto;
    max-height: 46px;
    object-fit: contain;
    border-radius: 16px;
}

.sidebar-brand i { font-size: 1.6rem; color: var(--accent); }
.sidebar-brand img { flex-shrink: 0; }
.sidebar-brand h5 { font-weight: 650; margin: 0; font-size: 0.9rem; line-height: 1.25; letter-spacing: -0.015em; color: var(--ink); }
.sidebar-brand small { font-size: 0.68rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-3); display: block; margin-top: 0.1rem; }

.login-logo-img {
    max-width: 80px;
    height: auto;
    max-height: 70px;
    object-fit: contain;
    border-radius: 16px;
}

.nav-item {
    margin-bottom: 0.1rem;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.7rem;
    color: var(--ink-2);
    border-radius: var(--radius-sm);
    transition: background 0.12s ease, color 0.12s ease;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    position: relative;
}

.nav-link i {
    width: 20px;
    margin-right: 0.65rem;
    font-size: 1.05rem;
    text-align: center;
    flex-shrink: 0;
    color: var(--ink-3);
    transition: color 0.12s ease;
}

.nav-link:hover {
    background: #f4f4f5;
    color: var(--ink);
}
.nav-link:hover i { color: var(--ink-2); }

/* The one place orange is allowed to fill a surface. */
.nav-link.active {
    background: var(--accent-soft);
    color: var(--accent-ink);
    font-weight: 600;
}
.nav-link.active i { color: var(--accent); }

.nav-link.active::before {
    content: '';
    position: absolute;
    left: -0.65rem;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 18px;
    border-radius: 0 3px 3px 0;
    background: var(--accent);
}

.nav-link .badge {
    margin-left: auto;
    font-size: 0.6rem;
    font-weight: 600;
    padding: 0.15em 0.5em;
    border-radius: 999px;
    letter-spacing: 0.3px;
}

.sidebar-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--line);
    flex-shrink: 0;
    font-size: 0.7rem;
    color: var(--ink-3);
    text-align: center;
}

/* Sidebar Close Button */
.sidebar-close {
    display: none;
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: #f4f4f5;
    border: none;
    color: var(--ink-2);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    z-index: 10;
    align-items: center;
    justify-content: center;
}

.sidebar-close:hover { background: #e9e9ec; color: var(--ink); }

/* Sidebar Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1040;
}

.sidebar-overlay.show { display: block; }

/* ========== MAIN CONTENT ========== */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    background: var(--canvas);
    transition: margin-left 0.3s ease;
    overflow-x: clip;
}
.page-body {
    padding: 0;
    margin: 0;
}

/* ========== NAVBAR ========== */
.navbar {
    border-bottom: 1px solid var(--line) !important;
    box-shadow: none !important;
    min-height: 58px;
    display: flex;
    align-items: stretch;
}
.navbar > .container-fluid {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    min-height: 58px;
}
.navbar .navbar-brand {
    font-weight: 650;
    letter-spacing: -0.015em;
    font-size: 0.98rem;
    color: var(--ink) !important;
}

.mobile-menu-toggle {
    display: none;
    background: #f4f4f5;
    border: none;
    color: var(--ink);
    width: 38px;
    height: 38px;
    border-radius: 10px;
    cursor: pointer;
    flex-shrink: 0;
}

.mobile-menu-toggle:hover { background: #e9e9ec; }
.mobile-menu-toggle i { font-size: 1.25rem; }

/* ========== STAT CARDS ========== */
/* Stat tiles are white cards, not filled blocks. The figure is the loudest
 * thing on them; the category shows as a thin colour bar down the left edge
 * and a tinted icon, so a row of tiles stays scannable instead of turning
 * into six competing blocks of colour. */
.stat-card {
    border-radius: var(--radius);
    padding: 1.1rem 1.25rem;
    position: relative;
    overflow: hidden;
    height: 100%;
    background: var(--surface);
    border: 1px solid var(--line) !important;
    box-shadow: none;
    color: var(--ink) !important;
}

.stat-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--line-strong);
}

.stat-card .h2 {
    font-size: 1.5rem;
    font-weight: 650;
    letter-spacing: -0.02em;
    color: var(--ink) !important;
    margin-bottom: 0.1rem;
}
.stat-card .small { font-size: 0.78rem; color: var(--ink-3) !important; }
.stat-card i { font-size: 1.35rem !important; }

/* These were white-on-gradient; on a white card they need dark ink. */
.stat-card .text-white-50 { color: var(--ink-3) !important; }
.stat-card .text-white-75 { color: var(--ink-2) !important; }
.stat-card .text-muted    { color: var(--ink-3) !important; }

.stat-card .avatar,
.stat-card .stat-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-card.primary::before   { background: var(--ink-2); }
.stat-card.success::before   { background: var(--success); }
.stat-card.warning::before   { background: var(--accent); }
.stat-card.info::before      { background: var(--info); }
.stat-card.secondary::before { background: #a1a1aa; }
.stat-card.danger::before    { background: var(--danger); }

.stat-card.primary   i { color: var(--ink-2) !important; }
.stat-card.success   i { color: var(--success) !important; }
.stat-card.warning   i { color: var(--accent) !important; }
.stat-card.info      i { color: var(--info) !important; }
.stat-card.secondary i { color: #71717a !important; }
.stat-card.danger    i { color: var(--danger) !important; }

.stat-card.primary   .avatar { background: #f4f4f5 !important; }
.stat-card.success   .avatar { background: #ecfdf3 !important; }
.stat-card.warning   .avatar { background: var(--accent-soft) !important; }
.stat-card.info      .avatar { background: #eff6ff !important; }
.stat-card.secondary .avatar { background: #f4f4f5 !important; }
.stat-card.danger    .avatar { background: #fef2f2 !important; }

/* ========== POS LAYOUT ========== */
.pos-container { display: flex; height: calc(100vh - 60px); }
.products-section { flex: 1; overflow-y: auto; padding: 1rem; background: var(--raised); }
.cart-section { width: 380px; background: white; border-left: 1px solid var(--line); display: flex; flex-direction: column; }

.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 0.75rem; }

.product-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 0.85rem;
    text-align: center;
    cursor: pointer;
    border: 1px solid var(--line);
    transition: border-color 0.12s ease, background 0.12s ease;
    box-shadow: none;
}

.product-card:hover {
    border-color: var(--accent);
    background: var(--accent-softer);
}

.product-card .icon {
    font-size: 1.75rem;
    color: var(--primary);
    margin-bottom: 0.4rem;
    width: 64px;
    height: 64px;
    margin-left: auto;
    margin-right: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 14px;
    background: var(--raised);
}
.product-card .icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 14px;
}
.product-card .fw-medium { font-size: 0.85rem; line-height: 1.3; }
.product-card .text-muted { font-size: 0.78rem; }
/* The price is the number a cashier scans for, so it gets ink rather than the
 * accent - bright orange on white is only 2.8:1, and a grid of 60 orange
 * prices has no hierarchy anyway. */
.product-card .text-primary { color: var(--ink) !important; font-weight: 650; }

.cart-header {
    padding: 1rem 1.15rem;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    color: var(--ink);
    display: flex;
    align-items: center;
}
.cart-header h4 { font-weight: 650; letter-spacing: -0.015em; color: var(--ink); }
.cart-header i { color: var(--accent); }

.cart-header h4 {
    display: flex;
    align-items: center;
    font-size: 1rem;
}

.cart-items { flex: 1; overflow-y: auto; }
.cart-item { padding: 0.8rem 1rem; border-bottom: 1px solid var(--line); transition: background 0.15s ease; }
.cart-item:hover { background: var(--raised); }
.cart-footer { padding: 1rem; background: var(--raised); border-top: 1px solid var(--line); }

/* ========== LOGIN ========== */
.login-wrapper {
    min-height: 100vh;
    background: var(--canvas);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.login-card {
    background: rgba(255, 255, 255, 0.98);
    border-radius: 24px;
    box-shadow: 0 12px 48px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.04);
    border: 1px solid var(--line);
    width: 100%;
    max-width: 400px;
    padding: 2.25rem 2rem;
    backdrop-filter: blur(10px);
}
.login-card .form-control {
    height: 46px;
    font-size: 0.95rem;
    border-radius: 12px;
}
.login-card .form-control:focus {
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 4px rgba(249, 115, 22, 0.1) !important;
}
.login-card .btn-primary {
    border-radius: 12px;
    transition: transform 0.08s ease, box-shadow 0.15s ease;
}
.login-card .btn-primary:active {
    transform: scale(0.98);
}

.login-logo {
    width: 64px;
    height: 64px;
    background: var(--accent);
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.25rem;
    box-shadow: 0 8px 24px rgba(249, 115, 22, 0.25);
}

.login-logo i { font-size: 1.75rem; color: white; }


/* ========== CARDS & TABLES ========== */
.card {
    margin-bottom: 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    box-shadow: none;
    background: var(--surface);
}
.card-header {
    padding: 0.9rem 1.15rem;
    background: transparent;
    border-bottom: 1px solid var(--line);
    border-radius: var(--radius) var(--radius) 0 0;
    min-height: 0;
}
.card-title {
    font-size: 0.9rem;
    font-weight: 650;
    letter-spacing: -0.01em;
    color: var(--ink);
    margin: 0;
}
.card-body { padding: 1.15rem; }
.card-footer { background: transparent; border-top: 1px solid var(--line); padding: 0.85rem 1.15rem; }

.table-responsive { -webkit-overflow-scrolling: touch; }
.table { color: var(--ink); margin-bottom: 0; }
.table th {
    padding: 0.6rem 0.9rem;
    vertical-align: middle;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-3);
    background: transparent;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.table td {
    padding: 0.75rem 0.9rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--line);
    font-size: 0.875rem;
}
.table tbody tr:last-child td { border-bottom: none; }
.table-hover tbody tr:hover td { background: var(--raised); }
.table tfoot th, .table tfoot td {
    border-top: 1px solid var(--line);
    background: var(--raised);
    text-transform: none;
    font-size: 0.875rem;
    color: var(--ink);
}

/* ========== BUTTONS ========== */
.btn {
    border-radius: var(--radius-sm);
    font-weight: 550;
    font-size: 0.875rem;
    padding: 0.45rem 0.9rem;
    transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
    box-shadow: none !important;
}

/* Primary action is orange and flat. There is only one on a screen. */
.btn-primary {
    background: var(--accent-btn) !important;
    border-color: var(--accent-btn) !important;
    color: #fff !important;
}
.btn-primary:hover, .btn-primary:focus {
    background: var(--accent-btn-hover) !important;
    border-color: var(--accent-btn-hover) !important;
}

/* White on #16a34a is 3.3:1; the darker green clears AA. */
.btn-success {
    background: var(--success-dark) !important;
    border-color: var(--success-dark) !important;
    color: #fff !important;
}
.btn-success:hover { background: #14532d !important; border-color: #14532d !important; }

.btn-info { background: #1d4ed8 !important; border-color: #1d4ed8 !important; color: #fff !important; }
.btn-info:hover { background: #1e40af !important; border-color: #1e40af !important; }
.btn-danger { background: #b91c1c !important; border-color: #b91c1c !important; color: #fff !important; }
.btn-danger:hover { background: #991b1b !important; border-color: #991b1b !important; }

/* Solid Tabler badges put white on mid-tone hues (2.1-3.3:1). Darken the fills.
 * Both the hue names (bg-green) and the semantic names (bg-success) are used
 * across this codebase, so both need covering. */
.badge.bg-success, .avatar.bg-success { background-color: var(--success-dark) !important; color: #fff !important; }
.badge.bg-danger,  .avatar.bg-danger  { background-color: #b91c1c !important; color: #fff !important; }
.badge.bg-warning, .avatar.bg-warning { background-color: #b45309 !important; color: #fff !important; }
.badge.bg-info,    .avatar.bg-info    { background-color: #1d4ed8 !important; color: #fff !important; }
.badge.bg-cyan,    .avatar.bg-cyan    { background-color: #0e7490 !important; color: #fff !important; }
.badge.bg-teal,    .avatar.bg-teal    { background-color: #0f766e !important; color: #fff !important; }
.badge.bg-pink,    .avatar.bg-pink    { background-color: #be185d !important; color: #fff !important; }

/* Bootstrap 5.3 "-subtle" pairs, and the -lt variants Tabler generates from a
 * 10% tint of the hue - the latter put a colour on its own tint, which lands at
 * 1:1 and is literally invisible (seen on .bg-cyan-lt in salespersons.php). */
.bg-success-subtle { background-color: #ecfdf3 !important; color: var(--success-dark) !important; }
.bg-danger-subtle  { background-color: #fef2f2 !important; color: #b91c1c !important; }
.bg-warning-subtle { background-color: #fffaeb !important; color: #b45309 !important; }
.bg-info-subtle    { background-color: #eff6ff !important; color: #1d4ed8 !important; }
.bg-cyan-lt,   .avatar.bg-cyan-lt   { background: #ecfeff !important; color: #0e7490 !important; }
.bg-teal-lt,   .avatar.bg-teal-lt   { background: #f0fdfa !important; color: #0f766e !important; }
.bg-pink-lt,   .avatar.bg-pink-lt   { background: #fdf2f8 !important; color: #be185d !important; }
.bg-indigo-lt, .avatar.bg-indigo-lt { background: #eef2ff !important; color: #4338ca !important; }
.bg-lime-lt,   .avatar.bg-lime-lt   { background: #f7fee7 !important; color: #4d7c0f !important; }
.bg-azure-lt,  .avatar.bg-azure-lt  { background: #eff6ff !important; color: #1d4ed8 !important; }
.bg-dark-lt,   .avatar.bg-dark-lt   { background: #f4f4f5 !important; color: var(--ink) !important; }

/* Alert headings inherit a mid-tone hue that fails on the alert's own tint. */
.alert-title { color: inherit !important; font-weight: 650; }

.badge.bg-green, .avatar.bg-green   { background-color: var(--success-dark) !important; color: #fff !important; }
.badge.bg-yellow, .avatar.bg-yellow { background-color: #b45309 !important; color: #fff !important; }
.badge.bg-red, .avatar.bg-red       { background-color: #b91c1c !important; color: #fff !important; }
.badge.bg-blue, .avatar.bg-blue     { background-color: #1d4ed8 !important; color: #fff !important; }
.badge.bg-purple, .avatar.bg-purple { background-color: #6d28d9 !important; color: #fff !important; }

/* Stat tiles are white now, so white text inside them would vanish. */
.stat-card .text-white, .stat-card .h2.text-white { color: var(--ink) !important; }

.btn-warning, .btn-orange {
    background: var(--accent-btn) !important;
    border-color: var(--accent-btn) !important;
    color: #fff !important;
}

.btn-secondary {
    background: var(--surface) !important;
    border-color: var(--line-strong) !important;
    color: var(--ink-2) !important;
}
.btn-secondary:hover { background: #f4f4f5 !important; color: var(--ink) !important; }

.btn-outline-primary {
    color: var(--ink-2) !important;
    border-color: var(--line-strong) !important;
    background: var(--surface) !important;
}
.btn-outline-primary:hover {
    background: #f4f4f5 !important;
    color: var(--ink) !important;
    border-color: var(--line-strong) !important;
}

.btn-outline-secondary { color: var(--ink-2) !important; border-color: var(--line-strong) !important; }
.btn-outline-secondary:hover { background: #f4f4f5 !important; color: var(--ink) !important; }

.btn-light { background: #f4f4f5 !important; border-color: transparent !important; color: var(--ink-2) !important; }

/* ========== BADGES ========== */
.badge {
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.7rem;
    letter-spacing: 0.01em;
    padding: 0.25em 0.55em;
}
.bg-primary { background-color: var(--ink) !important; }
.bg-orange, .bg-warning { background-color: var(--accent) !important; }
.bg-green, .bg-success { background-color: var(--success) !important; }
.text-primary { color: var(--ink) !important; }
/* Tabler's semantic text hues are tuned for large display type and land
 * between 2.5:1 and 3.5:1 on white. These are the darkened equivalents. */
.text-orange, .text-warning { color: var(--accent-ink) !important; }
.text-success { color: var(--success-dark) !important; }
.text-danger  { color: #b91c1c !important; }
.text-info    { color: #1d4ed8 !important; }
.text-yellow  { color: #b45309 !important; }
.text-muted   { color: var(--ink-3) !important; }
/* Tabler/Bootstrap hue utilities that bypass the semantic names above. */
.text-green   { color: var(--success-dark) !important; }
.text-red     { color: #b91c1c !important; }
.text-blue    { color: #1d4ed8 !important; }
.text-cyan    { color: #0e7490 !important; }
.text-purple  { color: #6d28d9 !important; }
.text-teal    { color: #0f766e !important; }
.text-pink    { color: #be185d !important; }

/* Soft badge variants - tinted, not filled */
.bg-green-lt   { background: #ecfdf3 !important; color: var(--success-dark) !important; }
.bg-yellow-lt  { background: #fffaeb !important; color: #b45309 !important; }
.bg-red-lt     { background: #fef2f2 !important; color: #b91c1c !important; }
.bg-blue-lt    { background: #eff6ff !important; color: #1d4ed8 !important; }
.bg-purple-lt  { background: #f5f3ff !important; color: #6d28d9 !important; }
.bg-orange-lt  { background: var(--accent-soft) !important; color: var(--accent-dark) !important; }
.bg-secondary-lt { background: #f4f4f5 !important; color: var(--ink-2) !important; }
.bg-primary-lt { background: #f4f4f5 !important; color: var(--ink) !important; }
.bg-info-lt    { background: #eff6ff !important; color: #1d4ed8 !important; }
/* Tabler's own -lt variants pair a tint with a mid-tone hue that lands near
 * 1:1 once the tint is applied. These are used on cards too, where children
 * inherit the colour, so the whole tile has to be legible. */
.bg-success-lt { background: #ecfdf3 !important; color: var(--success-dark) !important; }
.bg-danger-lt  { background: #fef2f2 !important; color: #b91c1c !important; }
.bg-warning-lt { background: #fffaeb !important; color: #b45309 !important; }
.bg-success-lt .text-muted, .bg-danger-lt .text-muted,
.bg-warning-lt .text-muted, .bg-info-lt .text-muted { color: inherit !important; opacity: 0.75; }

.btn-outline-info { color: #1d4ed8 !important; border-color: #b3ccf5 !important; }
.btn-outline-info:hover { background: #eff6ff !important; color: #1d4ed8 !important; }

/* ========== ALERTS ========== */
.alert {
    padding: 0.7rem 1rem;
    font-size: 0.86rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
}
.alert-success { background: #ecfdf3; border-color: #d1fadf; color: #05603a; }
.alert-danger  { background: #fef3f2; border-color: #fecdca; color: #b42318; }
.alert-warning { background: #fffaeb; border-color: #fedf89; color: #b54708; }
.alert-info    { background: #eff8ff; border-color: #b2ddff; color: #175cd3; }
.alert .btn-sm { white-space: nowrap; }

/* ========== FORMS ========== */
.form-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--ink-2);
    margin-bottom: 0.4rem;
    letter-spacing: 0.01em;
}
.form-label .text-danger,
.form-label .text-danger-star {
    color: var(--accent-dark) !important;
    margin-left: 2px;
}
.form-control, .form-select {
    border-radius: var(--radius-sm);
    border-color: var(--line-strong);
    font-size: 0.875rem;
    padding: 0.55rem 0.8rem;
    color: var(--ink);
    background-color: var(--surface);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
    line-height: 1.5;
}
.form-control:hover, .form-select:hover {
    border-color: #c4c4ca;
}
.form-control::placeholder { color: #b4b4bb; font-weight: 400; }
.form-control:focus, .form-select:focus {
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.12) !important;
    background-color: var(--surface) !important;
}
.form-control:disabled, .form-select:disabled {
    background: var(--raised) !important;
    color: var(--ink-3) !important;
    cursor: not-allowed;
}
.form-control:read-only {
    background: var(--raised) !important;
}
textarea.form-control {
    min-height: 70px;
    resize: vertical;
    line-height: 1.55;
}
.form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b6b74' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.7rem center;
    background-size: 16px;
    padding-right: 2.2rem;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}
.form-select:focus {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23f97316' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}
.form-text {
    font-size: 0.76rem;
    color: var(--ink-3);
    margin-top: 0.3rem;
    line-height: 1.4;
}
.input-group-text {
    background: var(--raised);
    border-color: var(--line-strong);
    color: var(--ink-3);
    font-size: 0.83rem;
    border-radius: var(--radius-sm);
    transition: border-color 0.15s ease;
}
.input-group:focus-within .input-group-text {
    border-color: var(--accent);
}
.input-group .form-control:first-child,
.input-group .form-select:first-child {
    border-top-left-radius: var(--radius-sm);
    border-bottom-left-radius: var(--radius-sm);
}
.input-group .form-control:last-child,
.input-group .form-select:last-child {
    border-top-right-radius: var(--radius-sm);
    border-bottom-right-radius: var(--radius-sm);
}
.form-check-input {
    border-color: var(--line-strong);
    cursor: pointer;
}
.form-check-input:checked {
    background-color: var(--accent-btn);
    border-color: var(--accent-btn);
}
.form-check-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.12);
}
.form-check-label {
    font-size: 0.85rem;
    color: var(--ink-2);
    cursor: pointer;
}
.form-control.is-invalid, .form-select.is-invalid {
    border-color: var(--danger) !important;
}
.form-control.is-invalid:focus, .form-select.is-invalid:focus {
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12) !important;
}
.invalid-feedback {
    font-size: 0.76rem;
    color: var(--danger);
}
.form-control.is-valid, .form-select.is-valid {
    border-color: var(--success) !important;
}
.form-control.is-valid:focus, .form-select.is-valid:focus {
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.12) !important;
}

/* Login form input-icon polish */
.input-icon { position: relative; }
.input-icon .form-control { padding-left: 2.5rem; }
.input-icon-addon {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    left: 0.75rem;
    color: var(--ink-3);
    font-size: 1rem;
    pointer-events: none;
    z-index: 2;
}
.input-icon .form-control:focus + .input-icon-addon,
.input-icon:focus-within .input-icon-addon {
    color: var(--accent);
}

/* Modal form spacing */
.modal-body .mb-3 { margin-bottom: 1.1rem !important; }
.modal-body .mb-3:last-child { margin-bottom: 0 !important; }
.modal-body .form-label { font-size: 0.82rem; }

/* Search box consistency */
.search-box .form-control {
    padding-left: 2.5rem;
    height: 42px;
    border-radius: 10px;
}

/* ========== MODALS ========== */
.modal-content { border-radius: var(--radius); border: 1px solid var(--line); box-shadow: 0 12px 40px rgba(0,0,0,0.10); }
.modal-header { border-bottom: 1px solid var(--line); padding: 1rem 1.15rem; }
.modal-title { font-size: 0.98rem; font-weight: 650; letter-spacing: -0.015em; }
.modal-body { padding: 1.15rem; }
.modal-footer { border-top: 1px solid var(--line); padding: 0.85rem 1.15rem; }

/* ========== PAGINATION ========== */
.page-link { color: var(--ink-2); border-color: var(--line); font-size: 0.83rem; }
.page-link:hover { background: #f4f4f5; color: var(--ink); }
.page-item.active .page-link { background: var(--accent-btn); border-color: var(--accent-btn); color: #fff; }

/* ========== DROPDOWNS ========== */
.dropdown-menu { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 28px rgba(0,0,0,0.09); font-size: 0.875rem; padding: 0.3rem; }
.dropdown-item { border-radius: 7px; padding: 0.45rem 0.6rem; color: var(--ink-2); }
.dropdown-item:hover { background: #f4f4f5; color: var(--ink); }

/* ========== RESPONSIVE - TABLET (992px) ========== */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
    }
    .sidebar.show { transform: translateX(0); box-shadow: 4px 0 30px rgba(0,0,0,0.3); }
    .sidebar-close {
        display: flex !important;
        align-items: center;
        justify-content: center;
    }
    .sidebar-nav {
        max-height: calc(100vh - 120px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 2rem;
    }
    .main-content { margin-left: 0; }
    .mobile-menu-toggle { display: flex; align-items: center; justify-content: center; }
    
    .cart-section { width: 300px; }
    .product-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
}

/* ========== RESPONSIVE - MOBILE (768px) ========== */
@media (max-width: 768px) {
    .container-fluid { padding: 0.75rem !important; }
    .page-body { padding: 0; }

    /* Bootstrap's negative row gutters push a few px past the viewport at phone
     * widths, which shows up as a sideways wobble. `clip` contains it without
     * creating a scroll container, so the sticky navbar keeps working -
     * `hidden` would break it. Tables still scroll inside .table-responsive. */
    .main-content { overflow-x: clip; }
    .page-header .row, .page-body .row { margin-left: 0; margin-right: 0; }
    
    .page-header { margin-bottom: 1rem !important; }
    .page-header .row { flex-direction: column; gap: 0.75rem; }
    .page-header .col-auto.ms-auto { margin-left: 0 !important; width: 100%; }
    .page-header .btn { width: 100%; }
    .page-header h2 { font-size: 1.15rem; }
    
    .row-deck.row-cards.mb-3 {
        display: flex !important;
        flex-wrap: wrap !important;
        margin: 0 -0.25rem !important;
    }
    .row-deck.row-cards.mb-3 > .col-6 {
        flex: 0 0 50% !important;
        max-width: 50% !important;
        padding: 0.25rem !important;
    }
    .stat-card {
        padding: 0.75rem;
        height: 100%;
        min-height: 85px;
    }
    .stat-card .h2 { font-size: 1.15rem; margin-bottom: 0 !important; }
    .stat-card .small { font-size: 0.7rem; line-height: 1.2; }
    .stat-card i { font-size: 1.4rem !important; }
    
    .pos-container { 
        flex-direction: column; 
        height: auto; 
        min-height: calc(100vh - 60px);
    }
    .products-section { padding: 0.5rem; }
    .cart-section { 
        width: 100%; 
        border-left: none; 
        border-top: 2px solid var(--accent);
    }
    .cart-items { max-height: 180px; }
    
    .product-grid { grid-template-columns: repeat(3, 1fr); gap: 0.4rem; }
    .product-card { padding: 0.5rem; }
    .product-card .icon { font-size: 1.2rem; margin-bottom: 0.2rem; width: 48px; height: 48px; }
    .product-card .fw-medium { font-size: 0.75rem; }
    .product-card .text-muted { font-size: 0.65rem; }
    .product-card .text-primary { font-size: 0.8rem; }
    
    .card { margin-bottom: 0.75rem; }
    .card-header { padding: 0.65rem 0.85rem; }
    .card-body { padding: 0.75rem; }
    
    .table { min-width: 600px; }
    .table th, .table td { padding: 0.5rem; font-size: 0.8rem; white-space: nowrap; }
    
    .form-control, .form-select { font-size: 16px; padding: 0.6rem 0.8rem; }
    .modal-body { padding: 1rem; }
    .modal-body .mb-3 { margin-bottom: 0.85rem !important; }
    .btn { font-size: 0.875rem; padding: 0.5rem 0.85rem; }

    /* Login card — prevent iOS zoom (16px min) and tighten padding on small screens */
    .login-wrapper { padding: 1rem; }
    .login-card { padding: 1.75rem 1.25rem; max-width: 360px; }
    .login-card .form-control { font-size: 16px !important; height: 48px; }
    .login-card .input-icon-addon { left: 0.85rem; }

    /* Modal form rows — stack side-by-side fields vertically on phones */
    .modal-body .row > .col-6 { width: 100%; flex: 0 0 100%; max-width: 100%; }

    /* Card-body form rows — stack col-6 fields that contain form inputs */
    .card-body .row > .col-6:has(.form-control),
    .card-body .row > .col-6:has(.form-select),
    .card-body .row > .col-6:has(.form-label) { width: 100%; flex: 0 0 100%; max-width: 100%; }

    /* Search box — match mobile input height */
    .search-box .form-control { height: auto; font-size: 16px; }
    
    .modal-dialog { margin: 0.5rem; max-width: calc(100% - 1rem); }

    /* Page headers that don't use Tabler .page-header class */
    .page-header-row { flex-direction: column !important; align-items: flex-start !important; }
    .page-header-row .btn, .page-header-row > a.btn { width: 100%; }
    .page-header-row h2 { font-size: 1.15rem; }

    /* Generic flex headers — wrap on mobile */
    .d-flex.justify-content-between.align-items-center:has(+ .card),
    .d-flex.align-items-center.justify-content-between {
        flex-wrap: wrap; gap: 0.5rem;
    }

    /* Shrink oversized stat values on mobile */
    .stat-value { font-size: 1.2rem !important; }
    .stat-card-modern .stat-value { font-size: 1.25rem !important; }
    .dash-stat .stat-value { font-size: 1.3rem !important; }

    /* Pagination wrap on mobile */
    .pagination-modern { flex-wrap: wrap; gap: 0.5rem; justify-content: center; }
}

/* ========== RESPONSIVE - SMALL MOBILE (480px) ========== */
@media (max-width: 480px) {
    .product-grid { grid-template-columns: repeat(2, 1fr); }
    
    .stat-card { padding: 0.6rem; min-height: 75px; }
    .stat-card .h2 { font-size: 0.9rem; }
    .stat-card i { font-size: 1.2rem !important; }
    
    .login-wrapper { padding: 0.75rem; }
    .login-card { padding: 1rem; max-width: 320px; }
    
    .sidebar { width: 85vw; max-width: 260px; }
    .sidebar-brand { padding: 0.6rem; }
    .sidebar-logo { max-width: 45px; max-height: 38px; }
    .nav-link { padding: 0.5rem 0.65rem; font-size: 0.8rem; }
}

/* ========== UTILITY CLASSES ========== */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

html { scroll-behavior: smooth; }

.btn, .product-card, .nav-link {
    -webkit-user-select: none;
    user-select: none;
}

.btn:focus, .form-control:focus, .form-select:focus, .nav-link:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ========== ANIMATIONS ========== */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
.animate-spin { animation: spin 1s linear infinite; }

/* ========== PRINT STYLES ========== */
@media print {
    .sidebar, .navbar, .mobile-menu-toggle, .btn, .no-print { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .card { break-inside: avoid; box-shadow: none; border: 1px solid #ddd; }
}

/* ========== AVATAR COLORS ========== */
/* Tinted avatar chips. Text colours are the darker "ink" variants, not the
 * bright brand colours: #f97316 on its own 10% tint is only 1:1 and #16a34a
 * barely better, so the labels these carry have to use the deeper shades. */
.avatar.bg-primary-lt, .bg-primary-lt { background: #f4f4f5 !important; color: var(--ink) !important; }
.avatar.bg-orange-lt, .bg-orange-lt   { background: var(--accent-soft) !important; color: var(--accent-ink) !important; }
.avatar.bg-green-lt, .bg-green-lt     { background: #ecfdf3 !important; color: var(--success-dark) !important; }
.avatar.bg-yellow-lt, .bg-yellow-lt   { background: #fffaeb !important; color: #b45309 !important; }
.avatar.bg-red-lt, .bg-red-lt         { background: #fef2f2 !important; color: #b91c1c !important; }
.avatar.bg-blue-lt, .bg-blue-lt       { background: #eff6ff !important; color: #1d4ed8 !important; }
.avatar.bg-purple-lt, .bg-purple-lt   { background: #f5f3ff !important; color: #6d28d9 !important; }

/* Tabler's outline variants use bright hues that fail on white. */
.btn-outline-warning, .btn-outline-orange { color: var(--accent-ink) !important; border-color: #f5c9a6 !important; }
.btn-outline-warning:hover, .btn-outline-orange:hover { background: var(--accent-soft) !important; color: var(--accent-ink) !important; }
.btn-outline-success { color: var(--success-dark) !important; border-color: #a7e8bf !important; }
.btn-outline-success:hover { background: #ecfdf3 !important; color: var(--success-dark) !important; }
.btn-outline-danger { color: #b91c1c !important; border-color: #f5b5b5 !important; }
.btn-outline-danger:hover { background: #fef2f2 !important; color: #b91c1c !important; }

/* ========== PRODUCT IMAGES ========== */
.product-card .icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
}

/* Inventory table product image */
.table td .avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
}

/* Photo upload preview */
#photoPreview img {
    transition: transform 0.2s;
}
#photoPreview img:hover {
    transform: scale(1.05);
}

/* ========== GLOBAL FONT SIZES ========== */
body {
    font-size: var(--font-size-base);
    line-height: 1.6;
}

h1, .h1 { font-size: 2rem; }
h2, .h2 { font-size: 1.6rem; }
h3, .h3 { font-size: 1.3rem; }
h4, .h4 { font-size: 1.1rem; }
h5, .h5 { font-size: 1rem; }

.form-control, .form-select {
    font-size: 0.95rem;
}

.btn {
    font-size: 0.9rem;
    font-weight: 500;
}

.badge {
    font-size: 0.8rem;
    font-weight: 600;
}

.text-muted {
    font-size: 0.9rem;
}

.small, small {
    font-size: 0.85rem;
}

.table {
    font-size: 0.9rem;
}

.table th {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.card-header .section-title,
.card-title {
    font-size: 1rem;
    font-weight: 600;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
}

/* ========== SHARED STAT CARD (used by sales, customers, invoices, categories-brands) ========== */
.stat-card-modern {
    background: white;
    border-radius: 16px;
    padding: 1.25rem;
    border: 1px solid var(--line);
    transition: all 0.15s ease;
    position: relative;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
    display: flex;
    flex-direction: column;
}
.stat-card-modern:hover {
    box-shadow: 0 6px 20px rgba(0,0,0,0.06);
    transform: translateY(-1px);
}
.stat-card-modern::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
}
.stat-card-modern.primary::before { background: var(--ink-2); }
.stat-card-modern.success::before { background: var(--success); }
.stat-card-modern.warning::before { background: var(--accent); }
.stat-card-modern.info::before { background: var(--info); }
.stat-card-modern .stat-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--ink-3);
    margin-bottom: 0.35rem;
}
.stat-card-modern .stat-value {
    font-size: 1.6rem;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.15;
    letter-spacing: -0.02em;
}
.stat-card-modern .stat-sub {
    font-size: 0.78rem;
    color: var(--ink-3);
    margin-top: 0.2rem;
}
.stat-card-modern .stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
    flex-shrink: 0;
}
.stat-card-modern .stat-icon.primary { background: #f4f4f5; color: var(--primary); }
.stat-card-modern .stat-icon.success { background: rgba(22,163,74,0.08); color: #16a34a; }
.stat-card-modern .stat-icon.warning { background: rgba(234,88,12,0.08); color: #ea580c; }
.stat-card-modern .stat-icon.info { background: rgba(59,130,246,0.08); color: #3b82f6; }

.stat-label, .stat-card-modern .stat-label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.stat-value, .stat-card-modern .stat-value {
    font-size: 1.6rem;
    font-weight: 700;
}

.sale-number {
    font-size: 0.85rem;
}

.status-badge, .payment-badge, .credit-badge, .loyalty-badge {
    font-size: 0.8rem;
}

.dropdown-item {
    font-size: 0.9rem;
}

.page-btn {
    font-size: 0.9rem;
}

.action-btn {
    font-size: 1rem;
}

/* ========== POS CHECKOUT PANEL (page-pos scoped) ========== */
.page-pos .checkout-panel {
    padding: 0;
    background: #fff;
    flex-shrink: 0;
    box-shadow: none;
    border-top: 1px solid var(--line);
    max-height: 55vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* Total display — the hero of the checkout panel */
.checkout-total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.85rem 1.15rem;
    background: var(--raised);
    border-bottom: 1px solid var(--line);
}

.checkout-total-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--ink-3);
}

.checkout-total-amount {
    font-size: 1.65rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.checkout-subtotal {
    font-size: 0.75rem;
    color: var(--ink-3);
    margin-top: 2px;
}

.checkout-actions {
    padding: 0.75rem 1.15rem 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.checkout-compact-label {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--ink-3);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 0.3rem;
}

.checkout-discount-row {
    margin-bottom: 0;
}

.checkout-discount-row .input-group-sm .form-control,
.checkout-discount-row .input-group-sm .form-select {
    font-size: 0.85rem;
    padding: 0.4rem 0.6rem;
    border-radius: 10px;
}

/* Payment method toggle buttons */
.page-pos .payment-toggle-group {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.page-pos .payment-toggle {
    flex: 1;
    padding: 0.6rem 0.5rem;
    border-radius: 14px;
    font-weight: 600;
    font-size: 0.85rem;
    border: 1px solid var(--line-strong);
    background: #fff;
    color: var(--ink-2);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
}

.page-pos .payment-toggle i {
    font-size: 1.1rem;
}

.page-pos .payment-toggle:hover {
    border-color: var(--line-strong);
    background: var(--raised);
}

.page-pos .btn-check:checked + .payment-toggle {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent-ink);
    box-shadow: none;
}

.page-pos .btn-check:checked + .payment-toggle::after {
    content: '';
    position: absolute;
    top: -2px;
    left: 1.5rem;
    right: 1.5rem;
    height: 3px;
    background: var(--accent);
    border-radius: 0 0 3px 3px;
}

.page-pos .btn-check:focus-visible + .payment-toggle {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Checkout action button */
.checkout-btn {
    min-height: 50px;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    border-radius: 14px;
    box-shadow: 0 2px 12px rgba(249, 115, 22, 0.2);
    transition: transform 0.08s ease, box-shadow 0.15s ease, opacity 0.15s ease;
    position: relative;
    overflow: hidden;
}

.checkout-btn:not(:disabled):hover {
    box-shadow: 0 4px 20px rgba(249, 115, 22, 0.35);
}

.checkout-btn:not(:disabled):active {
    transform: scale(0.97);
    box-shadow: 0 1px 6px rgba(249, 115, 22, 0.15);
}

.checkout-btn:disabled {
    box-shadow: none;
    opacity: 0.4;
}

/* Cart count badge */
.cart-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.01em;
}

.cart-header .cart-count-badge {
    margin-left: auto;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.checkout-compact-select {
    font-size: 0.85rem;
    padding: 0.45rem 0.6rem;
    border-radius: 10px;
}

/* ========== POS FILTER BAR ========== */
.page-pos .filter-bar {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 0.65rem 0.85rem;
    margin-bottom: 0.85rem;
    border: 1px solid var(--line);
    box-shadow: none;
}

/* The products pane is a flex column, not the viewport, so Bootstrap's
 * viewport-keyed `d-lg-inline` on the Retail/Wholesale label doesn't know the
 * column is narrow - the two buttons in col-md-2 pushed ~27px past the pane and
 * put a scrollbar under the product grid. min-width:0 lets flex children shrink
 * below their content width so they stay inside. */
.page-pos .filter-bar [class*="col-"] { min-width: 0; }
.page-pos .filter-bar .btn { white-space: nowrap; }

/* ---- Mobile-only checkout UI ----------------------------------------------
 * The slide-up checkout sheet, its backdrop and the bottom cart bar are styled
 * ENTIRELY inside the max-width:768px block below. Without an explicit desktop
 * hide they are unstyled divs at wider viewports, so they render in normal flow
 * as a duplicate cart stacked underneath the page - visible as soon as you
 * scroll past the fold. The mobile block overrides these, and comes later in
 * the file, so it still wins where it should. */
@media (min-width: 769px) {
    .page-pos .checkout-sheet,
    .page-pos .checkout-sheet-backdrop,
    .page-pos .mobile-checkout-bar { display: none; }

    /* The POS is a fixed-height app shell. The site footer sits under it and is
     * 114px tall, which forced the whole page to scroll and pushed the checkout
     * controls below the fold. A till screen has no use for a marketing footer.
     *
     * Sizing the shell with flex rather than calc(100vh - 60px) also drops a
     * magic number that no longer matched the 58px navbar. */
    body.page-pos .footer { display: none; }
    body.page-pos .main-content { display: flex; flex-direction: column; height: 100vh; }
    body.page-pos .pos-container { flex: 1 1 auto; height: auto; min-height: 0; }
}

/* Empty states sit directly inside .product-grid, which is a grid of ~130px
 * columns - without this they are squeezed into one column and their buttons
 * spill outside it. */
.product-grid > .text-center,
.product-grid > .empty-state {
    grid-column: 1 / -1;
    /* min() so the cap never exceeds a phone-width grid column */
    max-width: min(34rem, 100%);
    margin: 0 auto;
}
.product-grid > .text-center .btn { white-space: normal; }

.page-pos .filter-bar .form-control,
.page-pos .filter-bar .form-select {
    border-color: var(--line);
    border-radius: 10px;
    font-size: 0.9rem;
    background: var(--raised);
    transition: all 0.15s ease;
}

.page-pos .filter-bar .form-control:focus,
.page-pos .filter-bar .form-select:focus {
    border-color: var(--accent);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.08);
}

.page-pos .filter-bar .input-icon-addon {
    color: var(--ink-3);
}

/* Product card refinements */
.page-pos .product-card {
    background: white;
    border-radius: 14px;
    padding: 0.8rem 0.65rem;
    text-align: center;
    cursor: pointer;
    border: 1.5px solid var(--line);
    transition: all 0.12s ease;
    box-shadow: 0 2px 6px rgba(0,0,0,0.03);
    position: relative;
}

.page-pos .product-card:hover {
    border-color: var(--accent);
    background: var(--accent-softer);
}

.page-pos .product-card:active {
    transform: scale(0.96);
    transition: transform 0.05s ease;
}

.page-pos .product-card .icon {
    border-radius: 12px;
}

/* ========== POS EMPTY STATE ========== */
.page-pos .empty-state {
    grid-column: 1 / -1;
    padding: 3rem 1.5rem;
    text-align: center;
    color: var(--ink-3);
}

.page-pos .products-section {
    background: var(--raised);
}

.page-pos .products-section .row.g-3 {
    align-items: center;
}

/* ========== CHECKOUT MODAL (desktop) ========== */
.checkout-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1055;
    background: rgba(15, 23, 42, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}
.checkout-modal-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

.checkout-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.98);
    z-index: 1060;
    width: 94vw;
    max-width: 780px;
    max-height: 90vh;
    background: var(--surface);
    border-radius: 16px;
    box-shadow: 0 24px 70px rgba(0,0,0,0.22);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.checkout-modal.open {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%) scale(1);
}

.checkout-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--line);
}
.checkout-modal-header h5 {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0;
}

/* Two panes: what is being charged on the left, taking the money on the right.
 * The cashier confirms the order without leaving the payment step. */
.checkout-modal-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    -webkit-overflow-scrolling: touch;
}

.co-pane { padding: 1.1rem 1.25rem; min-width: 0; }
.co-pane-order {
    background: var(--raised);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
}

.co-eyebrow {
    display: block;
    font-size: 0.66rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-3);
    margin-bottom: 0.45rem;
}
.co-eyebrow span { text-transform: none; letter-spacing: 0; font-weight: 500; }

.co-close {
    border: none;
    background: transparent;
    color: var(--ink-3);
    width: 32px; height: 32px;
    border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer;
}
.co-close:hover { background: #f4f4f5; color: var(--ink); }

/* Order lines */
.co-items {
    list-style: none;
    margin: 0 0 0.75rem;
    padding: 0;
    max-height: 30vh;
    overflow-y: auto;
}
.co-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0 0.6rem;
    padding: 0.45rem 0;
    border-bottom: 1px solid var(--line);
    font-size: 0.85rem;
}
.co-item:last-child { border-bottom: none; }
.co-item-name { color: var(--ink); font-weight: 500; }
.co-item-qty { grid-column: 1; font-size: 0.76rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.co-item-total {
    grid-row: 1 / span 2;
    grid-column: 2;
    align-self: center;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--ink);
}

.co-money { margin: 0 0 0.6rem; border-top: 1px solid var(--line); padding-top: 0.6rem; }
.co-money-row { display: flex; justify-content: space-between; font-size: 0.83rem; margin: 0 0 0.25rem; }
.co-money-row dt { color: var(--ink-3); font-weight: 400; }
.co-money-row dd { margin: 0; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.co-money-discount dd { color: var(--success-dark); }

/* The figure everything else defers to */
.co-total {
    margin-top: auto;
    padding-top: 0.7rem;
    border-top: 2px solid var(--ink);
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
}
.co-total-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-3);
}
.co-total-amount {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}

.co-discount-control { margin-top: 0.85rem; }

/* Payment pane */
.co-field { margin-bottom: 0.95rem; }
.co-field:last-child { margin-bottom: 0; }

.co-tender-input {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    padding: 0.3rem 0.5rem;
    background: var(--surface);
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.co-tender-input:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.12);
}
.co-tender-cur { font-size: 0.72rem; font-weight: 600; color: var(--ink-3); letter-spacing: 0.04em; }
.co-tender {
    flex: 1;
    min-width: 0;
    border: none;
    outline: none;
    background: transparent;
    font-size: 1.3rem;
    font-weight: 650;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
    padding: 0.1rem 0;
}
.co-tender::-webkit-outer-spin-button,
.co-tender::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.co-tender[type=number] { -moz-appearance: textfield; appearance: textfield; }
.co-tender-clear {
    border: none; background: transparent; color: var(--ink-3);
    width: 26px; height: 26px; border-radius: 6px; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
}
.co-tender-clear:hover { background: #f4f4f5; color: var(--ink); }

/* Quick-tender amounts, derived from the total */
.co-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.5rem; }
.co-chip {
    flex: 1 1 auto;
    min-width: 62px;
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: var(--ink-2);
    border-radius: 999px;
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.co-chip:hover { background: #f4f4f5; color: var(--ink); }
.co-chip.is-active {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent-ink);
}

/* Change readout - the answer the cashier is looking for.
 *
 * Pinned to the bottom of the scrolling body. On a short screen (a 514px-tall
 * window clipped it behind the footer) the change figure would otherwise sit
 * below the fold, which is exactly the number you cannot afford to hide at a
 * till. Sticky keeps it in view while the rest of the form scrolls. */
.co-change {
    position: sticky;
    bottom: 0;
    z-index: 2;
    margin-top: 0.7rem;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-sm);
    background: var(--raised);
    border: 1px solid var(--line);
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
}
.co-change-label {
    font-size: 0.68rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.07em; color: var(--ink-3);
}
.co-change-amount {
    font-size: 1.35rem; font-weight: 700; letter-spacing: -0.02em;
    color: var(--ink-3); font-variant-numeric: tabular-nums;
}
.co-change.is-change { background: #ecfdf3; border-color: #d1fadf; }
.co-change.is-change .co-change-label { color: var(--success-dark); }
.co-change.is-change .co-change-amount { color: var(--success-dark); }
.co-change.is-short { background: #fef3f2; border-color: #fecdca; }
.co-change.is-short .co-change-label { color: #b42318; }
.co-change.is-short .co-change-amount { color: #b42318; }

/* Single column once the two panes stop earning their width */
@media (max-width: 720px) {
    .checkout-modal-body { grid-template-columns: minmax(0, 1fr); }
    .co-pane-order { border-right: none; border-bottom: 1px solid var(--line); }
    .co-items { max-height: 22vh; }
    .co-total-amount { font-size: 1.5rem; }
}

.checkout-modal-footer {
    display: flex;
    gap: 0.65rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--line);
    background: var(--raised);
}

.checkout-modal-footer .btn {
    border-radius: 12px;
    min-height: 46px;
    font-weight: 600;
}

body.modal-open {
    overflow: hidden;
}

/* Cart item highlight animation */
.cart-item.added {
    animation: checkout-item-added 0.6s ease;
}

@keyframes checkout-item-added {
    0% { background: #fef3c7; }
    100% { background: transparent; }
}

/* ========== MOBILE CHECKOUT BAR & SHEET (≤768px) ========== */
@media (max-width: 768px) {
    /* Hide desktop cart on mobile */
    .page-pos .cart-section {
        display: none;
    }

    /* Clear floating bottom bar */
    .page-pos .products-section {
        padding-bottom: 90px;
    }

    /* Fixed bottom checkout bar — native app tab bar feel */
    .page-pos .mobile-checkout-bar {
        display: flex;
        align-items: center;
        gap: 0.65rem;
        position: fixed;
        left: 0.5rem;
        right: 0.5rem;
        bottom: 0.5rem;
        z-index: 1030;
        background: #fff;
        border: 1px solid var(--line);
        padding: 0.4rem 0.75rem;
        padding-bottom: calc(0.4rem + env(safe-area-inset-bottom, 0px));
        border-radius: 16px;
        box-shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
    }

    .page-pos .mobile-cart-info {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        flex: 1;
        cursor: pointer;
        min-width: 0;
        padding: 0.3rem 0;
        border-radius: 10px;
        transition: background 0.1s ease;
    }

    .page-pos .mobile-cart-info:active {
        background: var(--raised);
    }

    .page-pos .mobile-cart-label {
        font-size: 0.75rem;
        color: var(--ink-3);
        white-space: nowrap;
        font-weight: 500;
    }

    .page-pos .mobile-cart-total {
        font-weight: 700;
        font-size: 1rem;
        color: var(--primary);
        margin-left: auto;
        letter-spacing: -0.01em;
        font-variant-numeric: tabular-nums;
    }

    .page-pos .mobile-checkout-btn {
        flex: 0 0 auto;
        min-width: 110px;
        min-height: 44px;
        background: var(--accent-btn);
        border: none;
        color: #fff;
        font-weight: 700;
        font-size: 0.9rem;
        border-radius: 12px;
        box-shadow: none;
        cursor: pointer;
        transition: transform 0.08s ease, box-shadow 0.15s ease;
        letter-spacing: 0.2px;
    }

    .page-pos .mobile-checkout-btn:active {
        transform: scale(0.95);
        box-shadow: 0 1px 4px rgba(249, 115, 22, 0.2);
    }

    .page-pos .mobile-checkout-btn:disabled {
        opacity: 0.35;
        box-shadow: none;
    }

    /* Slide-up checkout sheet backdrop */
    .page-pos .checkout-sheet-backdrop {
        position: fixed;
        inset: 0;
        z-index: 1055;
        background: rgba(15, 23, 42, 0.5);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s ease;
    }

    .page-pos .checkout-sheet-backdrop.open {
        opacity: 1;
        pointer-events: auto;
    }

    /* Slide-up checkout sheet — native iOS/Android bottom sheet feel */
    .page-pos .checkout-sheet {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1060;
        max-height: 92vh;
        display: flex;
        flex-direction: column;
        background: var(--raised);
        border-radius: 22px 22px 0 0;
        transform: translateY(105%);
        transition: transform 0.35s cubic-bezier(0.22, 0.61, 0.36, 1);
        box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.2);
        visibility: hidden;
        will-change: transform;
    }

    .page-pos .checkout-sheet.open {
        transform: translateY(0);
        visibility: visible;
    }

    .page-pos .checkout-sheet-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 1.1rem 1rem 0.85rem;
        background: #fff;
        border-bottom: 1px solid var(--line);
        border-radius: 22px 22px 0 0;
        position: relative;
        flex-shrink: 0;
    }

    .page-pos .checkout-sheet-header::before {
        content: '';
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 36px;
        height: 5px;
        border-radius: 3px;
        background: #d1d5db;
    }

    .page-pos .checkout-sheet-header h5 {
        font-size: 1.05rem;
        font-weight: 700;
    }

    .page-pos .checkout-sheet-close {
        width: 36px;
        height: 36px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .page-pos .checkout-sheet-body {
        flex: 1;
        overflow-y: auto;
        padding: 0.75rem;
        -webkit-overflow-scrolling: touch;
        padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
    }

    .page-pos .checkout-sheet-items {
        background: #fff;
        border-radius: 16px;
        border: 1px solid var(--line);
        margin-bottom: 0.75rem;
        overflow: hidden;
    }

    .page-pos .checkout-sheet-items .empty-cart-msg {
        padding: 2rem 1rem;
        text-align: center;
        color: var(--ink-3);
    }

    .page-pos .checkout-sheet-item {
        padding: 0.65rem 0.85rem;
        border-bottom: 1px solid var(--line);
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }

    .page-pos .checkout-sheet-item:last-child {
        border-bottom: none;
    }

    .page-pos .checkout-sheet-item .item-info {
        flex: 1;
        min-width: 0;
    }

    .page-pos .checkout-sheet-item .item-name {
        font-size: 0.85rem;
        font-weight: 600;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .page-pos .checkout-sheet-item .item-price {
        font-size: 0.75rem;
        color: var(--ink-2);
    }

    .page-pos .checkout-sheet-item .item-total {
        font-weight: 700;
        font-size: 0.9rem;
        color: var(--primary);
        white-space: nowrap;
    }

    .page-pos .checkout-sheet-item .qty-btn {
        min-width: 40px;
        min-height: 40px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border-radius: 10px;
        font-size: 0.85rem;
    }

    .page-pos .checkout-sheet-total-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.75rem 0.85rem;
        margin: 0.25rem -0.25rem 0.5rem;
        background: var(--raised);
        border-top: 2px solid var(--line);
        border-bottom: 1px solid var(--line);
        border-radius: 14px;
    }

    .page-pos .checkout-sheet-total {
        font-size: 1.4rem;
        font-weight: 800;
        color: var(--primary);
        letter-spacing: -0.02em;
        font-variant-numeric: tabular-nums;
    }

    /* Prevent body scroll when sheet is open */
    body.page-pos.sheet-open {
        overflow: hidden;
    }

    /* Reduced motion */
    @media (prefers-reduced-motion: reduce) {
        .page-pos .checkout-sheet,
        .page-pos .checkout-sheet-backdrop {
            transition: none;
        }
    }
}

/* Mobile checkout bar hidden by default (shown via media query) */
.mobile-checkout-bar {
    display: none;
}

/* ---------------------------------------------------------------------------
   Wholesale account panel (wholesale POS)

   The credit limit is enforced server-side. Showing only "Credit: KES 0" meant
   a cashier could fill a cart and be refused at checkout with no warning, so
   this states where the account actually stands and flags an over-limit order
   while there is still time to change it.
   --------------------------------------------------------------------------- */
.ws-account {
    margin-bottom: 0.75rem;
    padding: 0.7rem 0.8rem;
    background: var(--raised);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
}

.ws-account-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.ws-account-grid > div {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
}

.ws-account-grid span {
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--eyebrow);
}

.ws-account-grid strong {
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Running low on headroom, and over it. --warn (#d97706) only reaches 3.05:1
   on this panel, which fails AA at this size; #b45309 clears 4.5:1. */
.ws-account-grid strong.is-tight { color: #b45309; }
.ws-account-grid strong.is-over  { color: var(--danger); }

.ws-account-warn {
    margin-top: 0.6rem;
    padding: 0.5rem 0.6rem;
    font-size: 0.78rem;
    line-height: 1.45;
    color: #b42318;
    background: #fef3f2;
    border-radius: var(--radius-sm);
}

/* Three columns still fit cleanly at 375px (measured: 108px each, no clipping
   even at KES 41,500,000). Only the very narrowest phones need to stack. */
@media (max-width: 340px) {
    .ws-account-grid { grid-template-columns: 1fr 1fr; }
}

/* ---------------------------------------------------------------------------
   Report stat cards on phones

   The four summary cards sit two-up below 576px. In a 176px card the
   decorative avatar took about 50px, which pushed "KES 337,500" onto a second
   line so the figure read as "KES" / "337,500". The icon carries no
   information the label above it does not already give, so it steps aside at
   that width and the number keeps its full size on one line.
   --------------------------------------------------------------------------- */
@media (max-width: 575.98px) {
    .row-cards .card-body .avatar {
        display: none;
    }
}
