:root {
    /* POS brand palette */
    --pos-blue: #2563eb;         /* primary brand blue */
    --pos-blue-dark: #1d4fc4;    /* hover / active / gradient end */
    --pos-blue-light: #7ea2f2;   /* tints, badges, subtle accents */
    --pos-cream: #eef3fd;        /* soft cool background tint */
    --pos-charcoal: #20242c;     /* dark neutral for body text */
    /* Inter renders noticeably crisper than the system-UI default at small
       dashboard sizes; the stack falls back gracefully if the CDN is unreachable. */
    --pos-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: #f4f6f9;
    font-family: var(--pos-font);
    color: var(--pos-charcoal);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6,
.navbar-brand, .stat-value, .card-title, .btn {
    letter-spacing: -0.01em;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    color: var(--pos-charcoal);
}

/* Links are never underlined (Bootstrap underlines them by default). */
a, a:hover, a:focus,
.btn-link, .btn-link:hover, .btn-link:focus {
    text-decoration: none;
}

/* The shared confirm / message dialog can open over another modal (e.g. the
   terminal's payment window), so it sits one layer above. */
#posConfirmModal {
    z-index: 1065;
}

/* ---------- Login screen ---------- */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--pos-blue) 0%, var(--pos-blue-dark) 100%);
}

.login-card {
    width: 100%;
    max-width: 380px;
    border: none;
    border-radius: 0.75rem;
    box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.25);
}

.login-logo {
    width: auto;
    height: 88px;
    max-width: 220px;
}

/* ---------- Top navbar ---------- */
.pos-navbar {
    background-color: var(--pos-blue);
}

.pos-navbar .navbar-brand {
    font-weight: 700;
    color: #fff !important;
    letter-spacing: 0.02em;
}

.pos-navbar .navbar-brand small {
    display: block;
    font-size: 0.65rem;
    font-weight: 400;
    color: var(--pos-cream);
    letter-spacing: 0.08em;
}

/* ---------- Sidebar ----------
   On a desktop the toggle folds it to icons only (the choice is kept in a
   cookie); below 992px it slides in over the page.  */
.pos-sidebar {
    width: 280px;
    min-height: calc(100vh - 56px);
    background-color: #fff;
    border-right: 1px solid #e3e6ea;
    flex-shrink: 0;
    position: relative;
    transition: width 0.2s ease, transform 0.2s ease;
}

.pos-sidebar .nav-link {
    color: #33404d;
    border-radius: 0.375rem;
    padding: 0.5rem 0.9rem;
    font-size: 0.92rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pos-sidebar .nav-link.active {
    background-color: var(--pos-blue);
    color: #fff !important;
}

.pos-sidebar .nav-link:hover:not(.active) {
    background-color: var(--pos-cream);
}

.pos-sidebar .sidebar-section {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #9aa5b1;
    margin: 0.9rem 0.9rem 0.3rem;
    white-space: nowrap;
    overflow: hidden;
}

/* The toggle sits at the top of the sidebar; the burger in the navbar opens
   the sidebar on a small screen. */
.sidebar-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.5rem 0.25rem;
}

/* Logo (or the heart-pulse icon) and the system's short name, left of the toggle. */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    padding-left: 0.65rem;
    color: var(--pos-blue);
    font-weight: 700;
    letter-spacing: 0.04em;
    text-decoration: none;
    white-space: nowrap;
}

.sidebar-brand:hover {
    color: var(--pos-blue-dark);
}

.sidebar-brand i {
    font-size: 1.35rem;
    line-height: 1;
}

.sidebar-brand img {
    width: 26px;
    height: 26px;
    object-fit: contain;
}

.sidebar-toggle-btn,
.navbar-burger {
    padding: 6px;
    border: 0;
    border-radius: 6px;
    background: none;
    color: #6c757d;
    font-size: 1.25rem;
    line-height: 1;
}

.sidebar-toggle-btn:hover {
    background-color: var(--pos-cream);
    color: var(--pos-charcoal);
}

.navbar-burger {
    color: #fff;
}

.navbar-burger:hover {
    background-color: rgba(255, 255, 255, 0.15);
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1035;
    background: rgba(0, 0, 0, 0.45);
}

.pos-content {
    flex-grow: 1;
    padding: 1rem 1.75rem 1.75rem;
    min-width: 0; /* let a collapsed sidebar actually free up space instead of the flex item refusing to shrink/grow */
}

@media (min-width: 992px) {
    .sidebar-collapsed .pos-sidebar {
        width: 64px;
    }

    .sidebar-collapsed .sidebar-toggle-row {
        justify-content: center;
        padding-left: 0;
        padding-right: 0;
    }

    .sidebar-collapsed .pos-sidebar .nav-label,
    .sidebar-collapsed .sidebar-brand {
        display: none;
    }

    /* A section title becomes a rule between the groups of icons. */
    .sidebar-collapsed .pos-sidebar .sidebar-section {
        height: 0;
        margin: 0.5rem;
        border-top: 1px solid #e3e6ea;
        font-size: 0;
    }

    .sidebar-collapsed .pos-sidebar .nav-link {
        text-align: center;
        padding: 0.55rem 0;
    }

    .sidebar-collapsed .pos-sidebar .nav-link i {
        margin-right: 0 !important;
        font-size: 1.05rem;
    }
}

@media (max-width: 991.98px) {
    .pos-sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        z-index: 1040;
        min-height: 0;
        overflow-y: auto;
        transform: translateX(-100%);
    }

    .sidebar-open .pos-sidebar {
        transform: none;
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.18);
    }

    .sidebar-open .sidebar-backdrop {
        display: block;
    }

    /* The navbar, with the burger that opens the menu, stays in reach while
       the page scrolls; the page behind an open menu does not scroll. */
    body.sidebar-open { overflow: hidden; }
    .pos-sidebar { max-width: 85vw; overscroll-behavior: contain; padding-top: env(safe-area-inset-top); }
    .pos-sidebar .nav-link { padding-top: 0.65rem; padding-bottom: 0.65rem; } /* finger-sized rows */
}

/* Copyright / developer credit at the bottom of every page */
.pos-footer {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid #e5e7eb;
    text-align: center;
    font-size: 0.78rem;
    color: #6c757d;
}
.pos-footer-sep { margin: 0 0.4rem; }

/* ---------- Reusable bits ---------- */
.stat-card {
    border: none;
    border-radius: 0.6rem;
    box-shadow: 0 0.125rem 0.5rem rgba(32, 36, 44, 0.08);
    height: 100%;
}

/* A stat card that links somewhere (it holds a .stretched-link) lifts on hover. */
.stat-card:has(.stretched-link) {
    transition: box-shadow 0.1s ease, transform 0.1s ease;
}

.stat-card:has(.stretched-link):hover {
    box-shadow: 0 0.35rem 0.9rem rgba(32, 36, 44, 0.16);
    transform: translateY(-2px);
}

.stat-card .stat-value {
    font-size: 1.9rem;
    font-weight: 700;
}

.table-responsive-card {
    background: #fff;
    border-radius: 0.6rem;
    box-shadow: 0 0.125rem 0.5rem rgba(32, 36, 44, 0.06);
    padding: 1.25rem;
}

/* ---------- Password field with an inline show/hide toggle ---------- */
.password-field {
    position: relative;
}

.password-field .form-control {
    padding-right: 2.75rem;
}

/* Edge / IE add their own reveal eye to password inputs; hide it so only our toggle shows. */
input[type="password"]::-ms-reveal,
input[type="password"]::-ms-clear {
    display: none;
}

.password-toggle-btn {
    position: absolute;
    top: 0;
    right: 0;
    width: 2.75rem;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: #6c757d;
    padding: 0;
}

.password-toggle-btn:hover,
.password-toggle-btn:focus {
    color: var(--pos-charcoal);
}

.password-toggle-btn:focus {
    outline: none;
    box-shadow: none;
}

/* ---------- Table tiles (tables/index.php, dine-in picker) ---------- */
.table-tile {
    border-radius: 0.5rem;
    padding: 0.9rem;
    color: #fff;
    min-height: 90px;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: center;
}

.table-tile .table-number {
    font-size: 1.3rem;
    font-weight: 700;
}

.table-tile.status-available { background-color: #1e9e63; }
.table-tile.status-occupied  { background-color: #c0392b; }
.table-tile.status-reserved  { background-color: #d7a52b; }

/* ---------- Product / catalog list (products/index.php) ----------
   A flex row per item instead of a per-category <table> — a fixed-width
   flex column keeps prices aligned across every category and wraps
   cleanly on narrow screens instead of squeezing. */
.menu-item-list {
    display: flex;
    flex-direction: column;
}

.menu-item-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1rem;
    padding: 0.7rem 0;
    border-bottom: 1px solid #eef0f2;
}

.menu-item-row:last-child {
    border-bottom: none;
}

.menu-item-row.menu-item-unavailable {
    opacity: 0.6;
}

.menu-item-photo {
    width: 52px;
    height: 52px;
    border-radius: 0.5rem;
    object-fit: cover;
    flex: 0 0 auto;
}

.menu-item-photo-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--pos-cream);
    color: var(--pos-blue);
    font-size: 1.3rem;
}

.menu-item-info {
    flex: 1 1 220px;
    min-width: 0;
}

.menu-item-name {
    font-weight: 600;
}

.menu-item-desc {
    margin-top: 0.1rem;
}

.menu-item-price {
    flex: 0 0 auto;
    width: 100px;
    text-align: right;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.menu-item-actions {
    flex: 0 0 auto;
    display: flex;
    gap: 0.35rem;
    margin-left: auto;
}

@media (max-width: 480px) {
    .menu-item-row { justify-content: space-between; }
    .menu-item-info { flex: 1 1 100%; order: 1; }
    .menu-item-price { order: 2; width: auto; margin-right: auto; }
    .menu-item-actions { order: 3; margin-left: 0; }
}

/* ---------- POS Terminal (pos/terminal.php) ---------- */
.pos-terminal {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.pos-catalog {
    flex: 1 1 auto;
    min-width: 0;
}

.pos-category-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.pos-category-pills .btn {
    border-radius: 2rem;
    font-size: 0.85rem;
    padding: 0.35rem 0.9rem;
}

.pos-product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
}

.pos-product-tile {
    background: var(--pos-cream); /* light tint of the theme color */
    border: 1px solid rgba(32, 36, 44, 0.1);
    border-radius: 0.6rem;
    padding: 0.85rem 0.75rem;
    cursor: pointer;
    text-align: left;
    transition: border-color 0.1s ease, box-shadow 0.1s ease, transform 0.05s ease;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-height: 96px;
}

/* One light color per category (terminal.php hands out c1..c8 in category order,
   repeating), shown on its product tiles and on its category button. */
.pos-tile-c1 { --pos-tile-bg: #e8f1fd; --pos-tile-border: #8db4f2; } /* blue */
.pos-tile-c2 { --pos-tile-bg: #e6f6ec; --pos-tile-border: #86d1a3; } /* green */
.pos-tile-c3 { --pos-tile-bg: #fdf3dc; --pos-tile-border: #f0c76a; } /* yellow */
.pos-tile-c4 { --pos-tile-bg: #fde9e7; --pos-tile-border: #f2a199; } /* coral */
.pos-tile-c5 { --pos-tile-bg: #f0eafc; --pos-tile-border: #b79df0; } /* violet */
.pos-tile-c6 { --pos-tile-bg: #e2f5f6; --pos-tile-border: #78cbd1; } /* teal */
.pos-tile-c7 { --pos-tile-bg: #fdeadb; --pos-tile-border: #f2b07a; } /* orange */
.pos-tile-c8 { --pos-tile-bg: #fce8f1; --pos-tile-border: #f09bc0; } /* pink */
.pos-product-tile[class*="pos-tile-c"] { background: var(--pos-tile-bg); border: 2px solid var(--pos-tile-border); }
/* The same pastels on the dashboard's stat cards and panels. */
.stat-card[class*="pos-tile-c"],
.table-responsive-card[class*="pos-tile-c"] { background: var(--pos-tile-bg); border: 2px solid var(--pos-tile-border); }
.table-responsive-card[class*="pos-tile-c"] .table { --bs-table-bg: transparent; }
/* Stat cards with no pastel of their own get one by their place in the row (c1..c8, repeating),
   so every summary-card row is colored; a card's own pos-tile-cN still wins. */
.row > :nth-child(8n+1) .stat-card:not([class*="pos-tile-c"]) { --pos-tile-bg: #e8f1fd; --pos-tile-border: #8db4f2; }
.row > :nth-child(8n+2) .stat-card:not([class*="pos-tile-c"]) { --pos-tile-bg: #e6f6ec; --pos-tile-border: #86d1a3; }
.row > :nth-child(8n+3) .stat-card:not([class*="pos-tile-c"]) { --pos-tile-bg: #fdf3dc; --pos-tile-border: #f0c76a; }
.row > :nth-child(8n+4) .stat-card:not([class*="pos-tile-c"]) { --pos-tile-bg: #fde9e7; --pos-tile-border: #f2a199; }
.row > :nth-child(8n+5) .stat-card:not([class*="pos-tile-c"]) { --pos-tile-bg: #f0eafc; --pos-tile-border: #b79df0; }
.row > :nth-child(8n+6) .stat-card:not([class*="pos-tile-c"]) { --pos-tile-bg: #e2f5f6; --pos-tile-border: #78cbd1; }
.row > :nth-child(8n+7) .stat-card:not([class*="pos-tile-c"]) { --pos-tile-bg: #fdeadb; --pos-tile-border: #f2b07a; }
.row > :nth-child(8n+8) .stat-card:not([class*="pos-tile-c"]) { --pos-tile-bg: #fce8f1; --pos-tile-border: #f09bc0; }
.row > * .stat-card:not([class*="pos-tile-c"]) { background: var(--pos-tile-bg, #fff); border: 2px solid var(--pos-tile-border, transparent); }
/* A highlighted (selected filter) card keeps its dark border. */
.row > * .stat-card.border-dark { border-color: var(--bs-dark) !important; }
/* Only the resting color: the selected / hovered button keeps Bootstrap's dark fill. */
.pos-category-pills .btn[class*="pos-tile-c"] { --bs-btn-bg: var(--pos-tile-bg); }

.pos-product-tile:hover {
    border-color: var(--pos-blue);
    box-shadow: 0 0.25rem 0.6rem rgba(37, 99, 235, 0.12);
}

.pos-product-tile:active {
    transform: scale(0.98);
}

.pos-product-tile:disabled,
.pos-product-tile.out-of-stock {
    opacity: 0.45;
    cursor: not-allowed;
}

.pos-product-tile .pos-product-name {
    font-weight: 700;
    font-size: 0.92rem;
    line-height: 1.25;
}

.pos-product-tile .pos-product-price {
    color: var(--pos-blue);
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.pos-product-tile .pos-product-stock {
    font-size: 0.72rem;
    font-weight: 600;
    color: #6b7480;
}

.pos-product-tile .pos-product-info {
    margin-top: auto;
    align-self: flex-start;
    font-size: 0.74rem;
    font-weight: 700;
    color: var(--pos-blue);
    padding: 0.1rem 0.4rem;
    margin-left: -0.4rem;
    border-radius: 0.3rem;
}

.pos-product-tile .pos-product-info:hover {
    background: rgba(37, 99, 235, 0.1);
}

.pos-cart-panel {
    flex: 0 0 360px;
    background: #fff;
    border-radius: 0.6rem;
    box-shadow: 0 0.125rem 0.5rem rgba(32, 36, 44, 0.08);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 1rem;
    max-height: calc(100vh - 90px);
}

.pos-cart-header {
    padding: 1rem 1rem 0.5rem;
    border-bottom: 1px solid #eef0f2;
}

.pos-cart-items {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 0.5rem 1rem;
    min-height: 120px;
}

.pos-cart-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0;
    border-bottom: 1px solid #f2f3f5;
}

.pos-cart-row:last-child {
    border-bottom: none;
}

.pos-cart-row .cart-item-name {
    font-weight: 600;
    font-size: 0.88rem;
}

.pos-cart-row .cart-item-price {
    font-size: 0.78rem;
    color: #8a93a0;
}

.pos-cart-qty {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.pos-cart-qty button {
    width: 24px;
    height: 24px;
    line-height: 1;
    padding: 0;
    border-radius: 50%;
}

.pos-cart-qty input {
    width: 42px;
    text-align: center;
    padding: 0.1rem;
    font-size: 0.85rem;
}

.pos-cart-totals {
    padding: 0.75rem 1rem;
    border-top: 1px solid #eef0f2;
    font-size: 0.92rem;
}

.pos-cart-totals .grand-total {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--pos-blue);
}

.pos-cart-footer {
    padding: 0.75rem 1rem 1rem;
    border-top: 1px solid #eef0f2;
}

.pos-cart-empty {
    text-align: center;
    color: #9aa5b1;
    padding: 2.5rem 1rem;
}

/* ---------- Kitchen / prep ticket board (kitchen/index.php) ---------- */
.ticket-board {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
}

.kitchen-ticket {
    background: #fff;
    border-radius: 0.6rem;
    box-shadow: 0 0.125rem 0.5rem rgba(32, 36, 44, 0.1);
    border-top: 4px solid var(--pos-blue);
    overflow: hidden;
}

.kitchen-ticket .ticket-header {
    padding: 0.7rem 0.9rem;
    background: var(--pos-cream);
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.kitchen-ticket .ticket-body {
    padding: 0.75rem 0.9rem;
}

.kitchen-ticket .ticket-item {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.3rem 0;
    border-bottom: 1px dashed #eef0f2;
    font-size: 0.9rem;
}

.kitchen-ticket .ticket-item:last-child {
    border-bottom: none;
}

/* ---------- Service queue board (laundry-style order tracking) ---------- */
.queue-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

@media (max-width: 992px) {
    .queue-board { grid-template-columns: repeat(2, 1fr); }
    .pos-terminal { flex-direction: column; }
    .pos-cart-panel { flex: 1 1 auto; position: static; max-height: none; width: 100%; }
}

@media (max-width: 576px) {
    .queue-board { grid-template-columns: 1fr; }
}

.queue-column {
    background: #f4f6f9;
    border-radius: 0.6rem;
    padding: 0.75rem;
}

.queue-column-title {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6c757d;
    font-weight: 700;
    margin-bottom: 0.6rem;
}

.queue-card {
    background: #fff;
    border-radius: 0.5rem;
    box-shadow: 0 0.0625rem 0.25rem rgba(32, 36, 44, 0.08);
    padding: 0.75rem;
    margin-bottom: 0.6rem;
}

/* ---------- Receipt (printable) ---------- */
.receipt-paper {
    width: 320px;
    margin: 0 auto;
    background: #fff;
    padding: 1rem 1.1rem;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
}

.receipt-paper hr {
    border-top: 1px dashed #333;
}

.receipt-paper .receipt-total {
    font-weight: 700;
    font-size: 1rem;
}

/* ---------- Mobile / small screens ---------- */
.pos-mobile-cart-bar {
    display: none;
}

@media (max-width: 767.98px) {
    .pos-navbar .navbar-brand { font-size: 1rem; min-width: 0; }
    .pos-navbar .navbar-brand small { display: none; }
    .pos-content { padding: 0.75rem 0.75rem 1.25rem; }

    /* POS terminal */
    .pos-category-pills {
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: none;
        margin-left: -0.75rem;
        margin-right: -0.75rem;
        padding: 0 0.75rem 0.25rem;
    }
    .pos-category-pills::-webkit-scrollbar { display: none; }
    .pos-category-pills .btn { flex: 0 0 auto; white-space: nowrap; }
    .pos-product-grid { grid-template-columns: repeat(auto-fill, minmax(135px, 1fr)); gap: 0.5rem; }
    .pos-product-tile { padding: 0.7rem 0.65rem; min-height: 88px; }
    .pos-product-tile .pos-product-info { font-size: 0.8rem; padding: 0.25rem 0.5rem; }
    .pos-cart-items { padding: 0.5rem 0.75rem; }
    .pos-cart-qty button { width: 32px; height: 32px; }
    .pos-cart-qty input { width: 48px; }

    .pos-mobile-cart-bar {
        display: flex;
        justify-content: space-between;
        align-items: center;
        position: sticky;
        bottom: 0.75rem;
        z-index: 20;
        width: 100%;
        border: 0;
        border-radius: 0.6rem;
        padding: 0.75rem 1rem;
        background: var(--pos-charcoal);
        color: #fff;
        box-shadow: 0 0.35rem 1rem rgba(0, 0, 0, 0.25);
    }
}

/* ---------- Sidebar typography (same as OMS) ---------- */
.pos-navbar .navbar-brand { min-width: 0; }
.pos-sidebar .nav-link { font-size: 1rem; font-weight: 500; }
.pos-sidebar .sidebar-section { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.09em; }
@media (max-width: 991.98px) {
    .pos-navbar { position: sticky; top: 0; z-index: 1020; }
}

/* ---------- Tablets & phones ---------- */
html { -webkit-text-size-adjust: 100%; }
body { -webkit-tap-highlight-color: transparent; overflow-x: hidden; }

/* Small laptops / tablets in landscape: give the terminal's catalog room beside the cart. */
@media (min-width: 992px) and (max-width: 1199.98px) {
    .pos-sidebar { width: 240px; }
    .sidebar-collapsed .pos-sidebar { width: 64px; }
    .pos-content { padding-left: 1.25rem; padding-right: 1.25rem; }
    .pos-cart-panel { flex-basis: 320px; }
    .pos-product-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
}

/* Touch screens: finger-sized buttons and menu rows. */
@media (pointer: coarse) {
    .btn-sm { min-height: 36px; min-width: 36px; display: inline-flex; align-items: center; justify-content: center; }
    .dropdown-item { padding-top: 0.55rem; padding-bottom: 0.55rem; }
    .form-select-sm, .form-control-sm { min-height: 36px; }
}

@media (max-width: 991.98px) {
    /* Room for the notch / home bar when added to the home screen. */
    .pos-navbar { padding-top: max(0.5rem, env(safe-area-inset-top)); padding-left: max(1rem, env(safe-area-inset-left)); padding-right: max(1rem, env(safe-area-inset-right)); }
    .pos-sidebar { padding-bottom: calc(1rem + env(safe-area-inset-bottom)) !important; }
    .pos-content { padding-left: max(1rem, env(safe-area-inset-left)); padding-right: max(1rem, env(safe-area-inset-right)); }
    .pos-navbar .navbar-brand { margin-right: auto; }
}

@media (max-width: 767.98px) {
    /* 16px fields: iOS zooms the page in on anything smaller. */
    .form-control, .form-select, .form-control-sm, .form-select-sm,
    .input-group-sm > .form-control, .input-group-sm > .form-select { font-size: 1rem; }
    h4, .h4 { font-size: 1.25rem; }
    h5, .h5 { font-size: 1.1rem; }
    .stat-card .stat-value { font-size: 1.35rem; }
    .stat-card .card-body, .table-responsive-card { padding: 0.85rem; }
    .table { font-size: 0.9rem; }
    .table-responsive-card { overflow-x: auto; }
    .modal-dialog:not(.modal-fullscreen) { margin: 0.5rem; }
    .modal-body { padding: 0.9rem; }
}

@media (max-width: 575.98px) {
    /* Page title + action buttons: wrap instead of squeezing or overflowing. */
    .pos-content > .d-flex.justify-content-between,
    .pos-content > .d-flex.justify-content-between > .d-flex { flex-wrap: wrap; gap: 0.5rem; }
    .nav-tabs { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
    .nav-tabs::-webkit-scrollbar { display: none; }
    .nav-tabs .nav-link { white-space: nowrap; }
    .pos-footer { font-size: 0.72rem; padding-bottom: env(safe-area-inset-bottom); }
}

/* Terminal on phones/tablets: the catalog and cart stack, and must never be wider than the screen
   (a column flex with align-items:flex-start let them grow to their content instead). */
@media (max-width: 991.98px) {
    .pos-terminal { align-items: stretch; width: 100%; max-width: 100%; }
    .pos-catalog, .pos-cart-panel { width: 100%; max-width: 100%; min-width: 0; }
    .pos-product-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 140px), 1fr)); width: 100%; }
    .pos-product-tile { min-width: 0; max-width: 100%; overflow: hidden; }
    .pos-product-tile .pos-product-name,
    .pos-product-tile .pos-product-price,
    .pos-product-tile .pos-product-stock { max-width: 100%; overflow-wrap: anywhere; word-break: break-word; }
}
@media (max-width: 575.98px) {
    /* Two items per row on a phone, whatever the width. */
    .pos-product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem; }
    .pos-product-tile { padding: 0.65rem 0.6rem; }
    .pos-product-tile .pos-product-name { font-size: 0.88rem; }
    .pos-product-tile .pos-product-price { font-size: 0.95rem; }
    /* Category buttons wrap onto several lines inside the screen, smaller than on a desktop. */
    .pos-category-pills { flex-wrap: wrap; overflow-x: visible; margin-left: 0; margin-right: 0; padding: 0; gap: 0.35rem; max-width: 100%; }
    .pos-category-pills .btn { flex: 0 1 auto; max-width: 100%; white-space: normal; text-align: left; font-size: 0.8rem; line-height: 1.2; padding: 0.35rem 0.7rem; }
}

/* ---------- Print ---------- */
@media print {
    .pos-navbar, .pos-sidebar, .sidebar-backdrop, .navbar-burger, .no-print { display: none !important; }
    .pos-content { padding: 0; }
    .table-responsive-card { box-shadow: none; padding: 0; margin-bottom: 1rem !important; }
    body { background: #fff; }
}

/* Scrollable modals whose header/body/footer sit inside a <form>: let the
   form pass Bootstrap's flex layout through so the body scrolls and the
   footer (Save button) stays in view instead of being clipped. */
.modal-dialog-scrollable .modal-content > form {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}
