/* ======================================================================
   pdrestaurant — design system กลางของหน้าร้าน (โหลดจาก layouts/tenant.php)
   เปลี่ยนสีแบรนด์ที่จุดเดียว: ตัวแปร --bk-brand* ด้านล่าง
   ====================================================================== */
:root {
    --bk-brand: #b45309;          /* amber-700 — ตัวอักษรขาวบนสีนี้ผ่าน WCAG AA */
    --bk-brand-strong: #92400e;
    --bk-brand-soft: #fef3c7;
    --bk-brand-ring: rgba(180, 83, 9, .25);
    --bk-ink: #1f2937;
    --bk-muted: #6b7280;
    --bk-surface: #ffffff;
    --bk-canvas: #f6f7f9;
    --bk-line: #e5e7eb;
    --bk-radius: 14px;
    --bk-radius-sm: 10px;
    --bk-shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 14px rgba(16, 24, 40, .06);

    --bs-primary: var(--bk-brand);
    --bs-primary-rgb: 180, 83, 9;
    --bs-link-color: var(--bk-brand);
    --bs-link-hover-color: var(--bk-brand-strong);
    --bs-body-font-family: 'Sarabun', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --bs-body-color: var(--bk-ink);
    --bs-body-bg: var(--bk-canvas);
    --bs-border-color: var(--bk-line);
    --bs-border-radius: var(--bk-radius-sm);
}

html { -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--bs-body-font-family);
    background: var(--bk-canvas);
    color: var(--bk-ink);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, h5, h6 { font-weight: 600; letter-spacing: -.01em; }
.text-muted, .form-text { color: var(--bk-muted) !important; }

/* ---- แถบเมนูบน ---- */
.bk-nav {
    background: rgba(255, 255, 255, .92);
    backdrop-filter: saturate(180%) blur(10px);
    -webkit-backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 1px solid var(--bk-line);
    padding: .5rem 0;
    position: sticky;
    top: 0;
    z-index: 1030;
}
.bk-nav .navbar-brand {
    display: inline-flex;
    align-items: center;
    gap: .55rem;
    font-weight: 700;
    color: var(--bk-ink);
    letter-spacing: -.02em;
}
.bk-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, #f59e0b, var(--bk-brand));
    color: #fff;
    font-size: 1.1rem;
    box-shadow: 0 2px 6px rgba(180, 83, 9, .35);
}
/* โลโก้ร้านที่อัปโหลด — กรอบขาว รูปพอดีกรอบไม่ยืด */
.bk-logo.bk-logo-img {
    background: #fff;
    border: 1px solid rgba(0, 0, 0, .08);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
    overflow: hidden;
    padding: 2px;
}
.bk-logo.bk-logo-img img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.bk-nav .nav-link {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    color: #4b5563;
    font-weight: 500;
    border-radius: 999px;
    padding: .4rem .85rem;
    transition: background-color .15s ease, color .15s ease;
}
.bk-nav .nav-link:hover { background: #f3f4f6; color: var(--bk-ink); }
.bk-nav .nav-link.active,
.bk-nav .nav-link.show {
    background: var(--bk-brand-soft);
    color: var(--bk-brand-strong);
}
.bk-nav .dropdown-menu {
    border: 1px solid var(--bk-line);
    border-radius: var(--bk-radius);
    box-shadow: 0 10px 30px rgba(16, 24, 40, .12);
    padding: .4rem;
    margin-top: .4rem;
}
.bk-nav .dropdown-item {
    display: flex;
    align-items: center;
    gap: .55rem;
    border-radius: 8px;
    padding: .45rem .7rem;
    font-weight: 500;
}
.bk-nav .dropdown-item i { color: var(--bk-muted); width: 1.1rem; text-align: center; }
.bk-nav .dropdown-item:hover { background: #f3f4f6; }
.bk-nav .dropdown-item.active,
.bk-nav .dropdown-item:active { background: var(--bk-brand-soft); color: var(--bk-brand-strong); }
.bk-nav .dropdown-item.active i { color: var(--bk-brand); }
.bk-branch-select { min-width: 9rem; border-radius: 999px; background-color: #f9fafb; }
.bk-branch-badge {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    background: #f3f4f6;
    color: #374151;
    border-radius: 999px;
    padding: .3rem .75rem;
    font-size: .85rem;
    font-weight: 500;
}
.bk-user {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    border-radius: 999px;
    padding: .25rem .6rem .25rem .3rem;
    color: var(--bk-ink);
    font-weight: 500;
}
.bk-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--bk-brand-soft);
    color: var(--bk-brand-strong);
    font-weight: 700;
    font-size: .85rem;
    text-transform: uppercase;
}
.navbar-toggler { border: 1px solid var(--bk-line); border-radius: 10px; padding: .3rem .55rem; }
.navbar-toggler:focus { box-shadow: 0 0 0 .2rem var(--bk-brand-ring); }

.bk-main { padding-top: 1.25rem; padding-bottom: 3rem; }
.bk-footer { color: var(--bk-muted); font-size: .8rem; text-align: center; padding: 1rem 0 2rem; }

/* ---- การ์ด / กล่อง ---- */
.card {
    border: 1px solid var(--bk-line);
    border-radius: var(--bk-radius);
    background: var(--bk-surface);
    box-shadow: var(--bk-shadow);
}
.card-header {
    background: transparent;
    border-bottom: 1px solid var(--bk-line);
    font-weight: 600;
    padding: .85rem 1.1rem;
    border-radius: var(--bk-radius) var(--bk-radius) 0 0 !important;
}
.card-header.bg-primary, .card-header.bg-success, .card-header.bg-danger, .card-header.bg-warning, .card-header.bg-info {
    border-bottom: 0;
}
.card-body { padding: 1.1rem; }

/* ---- ปุ่ม ---- */
.btn { border-radius: var(--bk-radius-sm); font-weight: 500; transition: all .15s ease; }
.btn-sm { border-radius: 8px; }
.btn-lg { border-radius: 12px; }
.btn:focus-visible { box-shadow: 0 0 0 .22rem var(--bk-brand-ring); }
.btn-primary {
    --bs-btn-bg: var(--bk-brand);
    --bs-btn-border-color: var(--bk-brand);
    --bs-btn-hover-bg: var(--bk-brand-strong);
    --bs-btn-hover-border-color: var(--bk-brand-strong);
    --bs-btn-active-bg: var(--bk-brand-strong);
    --bs-btn-active-border-color: var(--bk-brand-strong);
    --bs-btn-disabled-bg: var(--bk-brand);
    --bs-btn-disabled-border-color: var(--bk-brand);
    --bs-btn-focus-shadow-rgb: 180, 83, 9;
    box-shadow: 0 1px 2px rgba(180, 83, 9, .3);
}
.btn-outline-primary {
    --bs-btn-color: var(--bk-brand);
    --bs-btn-border-color: var(--bk-brand);
    --bs-btn-hover-bg: var(--bk-brand);
    --bs-btn-hover-border-color: var(--bk-brand);
    --bs-btn-active-bg: var(--bk-brand-strong);
    --bs-btn-active-border-color: var(--bk-brand-strong);
    --bs-btn-focus-shadow-rgb: 180, 83, 9;
}
.btn-outline-secondary { --bs-btn-color: #4b5563; --bs-btn-border-color: #d1d5db; --bs-btn-hover-bg: #f3f4f6; --bs-btn-hover-color: var(--bk-ink); --bs-btn-hover-border-color: #d1d5db; }
.bg-primary { background-color: var(--bk-brand) !important; }
.text-primary { color: var(--bk-brand) !important; }
.border-primary { border-color: var(--bk-brand) !important; }
.badge.bg-primary { background-color: var(--bk-brand) !important; }

/* ---- ฟอร์ม ---- */
.form-control, .form-select {
    border-radius: var(--bk-radius-sm);
    border-color: #d1d5db;
    padding: .5rem .8rem;
}
.form-control-sm, .form-select-sm { padding: .3rem .6rem; border-radius: 8px; }
.form-control:focus, .form-select:focus {
    border-color: var(--bk-brand);
    box-shadow: 0 0 0 .22rem var(--bk-brand-ring);
}
.form-label { font-weight: 500; color: #374151; margin-bottom: .3rem; }
.form-check-input:checked { background-color: var(--bk-brand); border-color: var(--bk-brand); }
.form-check-input:focus { border-color: var(--bk-brand); box-shadow: 0 0 0 .22rem var(--bk-brand-ring); }
.input-group > .form-control:not(:last-child), .input-group > .btn:not(:last-child) { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group > .form-control:not(:first-child), .input-group > .btn:not(:first-child) { border-top-left-radius: 0; border-bottom-left-radius: 0; }

/* ---- ตาราง ---- */
.table { --bs-table-hover-bg: #fafafa; margin-bottom: 0; }
.table > thead > tr > th, .table-light, .table > :not(caption) > * > th.table-light {
    background: #f9fafb !important;
    color: var(--bk-muted);
    font-size: .78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom: 1px solid var(--bk-line);
    white-space: nowrap;
}
.table > :not(caption) > * > * { padding: .7rem .85rem; border-bottom-color: #f0f1f3; vertical-align: middle; }
.table-hover > tbody > tr:hover > * { background: #fffbf3; }
.table-responsive { border-radius: var(--bk-radius); }
.card > .table-responsive:first-child > .table > thead > tr:first-child > th:first-child { border-top-left-radius: var(--bk-radius); }
.card > .table-responsive:first-child > .table > thead > tr:first-child > th:last-child { border-top-right-radius: var(--bk-radius); }

/* ---- แจ้งเตือน / ป้าย ---- */
.alert {
    border: 0;
    border-left: 4px solid;
    border-radius: var(--bk-radius-sm);
    box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}
.alert-success { border-left-color: #16a34a; background: #f0fdf4; color: #166534; }
.alert-danger { border-left-color: #dc2626; background: #fef2f2; color: #991b1b; }
.alert-warning { border-left-color: #f59e0b; background: #fffbeb; color: #92400e; }
.alert-info { border-left-color: #0ea5e9; background: #f0f9ff; color: #075985; }
.badge { font-weight: 600; border-radius: 999px; padding: .38em .7em; }
.badge.bg-success { background-color: #16a34a !important; }
.badge.bg-secondary { background-color: #6b7280 !important; }

/* ---- โมดัล / แท็บ / ดรอปดาวน์ ---- */
.modal-content { border: 0; border-radius: 18px; box-shadow: 0 20px 50px rgba(16, 24, 40, .25); }
.modal-header, .modal-footer { border-color: var(--bk-line); }
.nav-tabs { border-bottom: 1px solid var(--bk-line); gap: .25rem; }
.nav-tabs .nav-link { border: 0; border-bottom: 2px solid transparent; color: var(--bk-muted); font-weight: 500; border-radius: 0; }
.nav-tabs .nav-link:hover { color: var(--bk-ink); }
.nav-tabs .nav-link.active { color: var(--bk-brand-strong); border-bottom-color: var(--bk-brand); background: transparent; }
.dropdown-menu { border-radius: var(--bk-radius-sm); border-color: var(--bk-line); }
.list-group-item { border-color: var(--bk-line); }
.list-group-item-action:hover { background: #fffbf3; }

/* ---- ตัวเลขสถิติ / การ์ดเมนูลัด (ใช้ในแดชบอร์ดและหน้าอื่น) ---- */
.bk-stat { display: flex; align-items: center; gap: .9rem; }
.bk-stat-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 44px; height: 44px; border-radius: 12px;
    background: var(--bk-brand-soft); color: var(--bk-brand); font-size: 1.25rem;
}

/* ---- ตารางบนจอเล็ก → การ์ด (ใช้ class table-mobile-cards + data-label ที่ view) ---- */
@media (max-width: 767.98px) {
    .table-responsive-cards { overflow-x: visible; }
    .table-mobile-cards thead { display: none; }
    .table-mobile-cards, .table-mobile-cards tbody, .table-mobile-cards tr, .table-mobile-cards td { display: block; width: 100%; }
    .table-mobile-cards tr {
        margin-bottom: .75rem;
        border: 1px solid var(--bk-line);
        border-radius: var(--bk-radius);
        box-shadow: var(--bk-shadow);
        padding: .5rem .85rem;
        background: var(--bk-surface);
    }
    .table-mobile-cards tbody tr:last-child { margin-bottom: 0; }
    .table-mobile-cards td {
        display: flex; justify-content: space-between; align-items: center; gap: .75rem;
        text-align: right; border: 0; border-bottom: 1px solid #f3f4f6; padding: .5rem 0; min-height: 2.25rem;
    }
    .table-mobile-cards td:last-child { border-bottom: 0; padding-bottom: 0; }
    .table-mobile-cards td:first-child { padding-top: 0; }
    .table-mobile-cards td::before {
        content: attr(data-label); font-weight: 600; font-size: .8rem; color: var(--bk-muted);
        text-align: left; margin-right: auto; flex-shrink: 0;
    }
    .table-mobile-cards td:not([data-label])::before, .table-mobile-cards td[data-label=""]::before { content: none; }
    .table-mobile-cards td[colspan] { display: block; text-align: center; }
    .table-mobile-cards td[colspan]::before { content: none; }
    .table-mobile-cards td.cell-checkbox { justify-content: flex-start; gap: .5rem; }
    .table-mobile-cards td.cell-stack { display: block; text-align: left; }
    .table-mobile-cards td.cell-stack::before { display: block; margin-bottom: .35rem; }
    .table-mobile-cards td.cell-stack .form-control-sm, .table-mobile-cards td.cell-stack .form-select-sm { min-height: 40px; }
    .table-mobile-cards .btn-group { display: flex; flex-direction: column; width: 100%; }
    .table-mobile-cards .btn-group > .btn { width: 100%; border-radius: 8px !important; margin: 0 0 .35rem 0; }
    .bk-main { padding-top: .75rem; }
    .bk-nav .navbar-collapse { padding: .75rem 0; }
    .bk-nav .nav-link { border-radius: 10px; padding: .6rem .8rem; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}

/* ---- หน้าเข้าสู่ระบบ ---- */
.bk-auth-bg {
    min-height: 100vh;
    background:
        radial-gradient(1200px 500px at 15% -10%, rgba(245, 158, 11, .28), transparent 60%),
        radial-gradient(900px 500px at 100% 110%, rgba(180, 83, 9, .22), transparent 55%),
        var(--bk-canvas);
    display: flex;
    align-items: center;
    padding: 2rem 0;
}
.bk-auth-card { border: 0; border-radius: 20px; box-shadow: 0 20px 50px rgba(16, 24, 40, .14); overflow: hidden; }
.bk-auth-brand { text-align: center; margin-bottom: 1.25rem; }
.bk-auth-brand .bk-logo { width: 54px; height: 54px; font-size: 1.7rem; border-radius: 16px; }

/* ---- กราฟ SVG ฝั่งเซิร์ฟเวอร์ (App\Services\SvgChart) ---- */
.bk-chart { width: 100%; height: auto; display: block; }
.bk-chart .ch-s0 { fill: var(--bk-brand); }
.bk-chart .ch-s1 { fill: #0f766e; }
.bk-chart .ch-s2 { fill: #4f46e5; }
.bk-chart .ch-s3 { fill: #16a34a; }
.bk-chart .ch-s4 { fill: #6b7280; }
.bk-chart .ch-grid { stroke: #e5e7eb; stroke-width: 1; }
.bk-chart .ch-axis { stroke: #9ca3af; stroke-width: 1; }
.bk-chart .ch-tx { fill: #4b5563; font-family: inherit; }

/* ---- พื้นฐาน mobile-first ที่ใช้ร่วมกันทุกหน้าฝั่งร้าน ---- */
@media (max-width: 767.98px) {
    :root { --bk-touch-target: 44px; }

    html, body { min-width: 320px; }
    body { font-size: 16px; line-height: 1.5; }
    .bk-main.container-fluid {
        padding-left: max(.75rem, env(safe-area-inset-left, 0px));
        padding-right: max(.75rem, env(safe-area-inset-right, 0px));
        padding-top: .75rem;
        padding-bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
    }
    .bk-main > .container,
    .bk-main > .container-fluid { min-width: 0; }
    .bk-main h1,
    .bk-main .h1 { font-size: clamp(1.3rem, 5vw, 1.65rem); line-height: 1.3; }
    .bk-main h2,
    .bk-main .h2 { font-size: clamp(1.15rem, 4.5vw, 1.4rem); }
    .bk-main .card { margin-bottom: .85rem; }
    .bk-main .card-header { padding: .75rem .85rem; }
    .bk-main .card-body { padding: .85rem; }

    .bk-nav { padding-top: max(.35rem, env(safe-area-inset-top, 0px)); }
    .bk-nav > .container-fluid { padding-left: .75rem; padding-right: .75rem; }
    .bk-nav .navbar-brand { min-height: var(--bk-touch-target); }
    .bk-nav .navbar-toggler { min-width: var(--bk-touch-target); min-height: var(--bk-touch-target); }
    .bk-nav .navbar-collapse {
        max-height: calc(100dvh - 4rem - env(safe-area-inset-top, 0px));
        overflow-y: auto;
        overscroll-behavior: contain;
        padding: .5rem 0 .75rem;
    }
    .bk-nav .navbar-nav { align-items: stretch; }
    .bk-nav .navbar-nav .nav-link,
    .bk-nav .navbar-nav .dropdown-toggle { width: 100%; max-width: 100%; box-sizing: border-box; min-height: var(--bk-touch-target); }
    .bk-nav .dropdown-menu { position: static !important; float: none; width: 100%; margin: .15rem 0 .35rem; box-shadow: none; }
    .bk-nav .dropdown-item { min-height: var(--bk-touch-target); }
    .bk-nav .bk-branch-select { min-height: var(--bk-touch-target); width: 100%; }
    .bk-nav #branch-switch-form { width: 100%; }
    .bk-nav > .container-fluid > .navbar-collapse > .d-flex.flex-column { align-items: stretch !important; padding-top: .5rem; border-top: 1px solid var(--bk-line); }
    .bk-nav .bk-user { min-height: var(--bk-touch-target); align-self: flex-start; }

    .bk-main .btn,
    .bk-nav .btn { min-height: var(--bk-touch-target); display: inline-flex; align-items: center; justify-content: center; }
    .bk-main .btn-sm { min-height: 40px; padding-top: .4rem; padding-bottom: .4rem; }
    .bk-main .form-control,
    .bk-main .form-select,
    .bk-main textarea.form-control,
    .bk-nav .form-select { min-height: var(--bk-touch-target); font-size: 16px; }
    .bk-main .form-control,
    .bk-main .form-select,
    .bk-nav .form-select { min-width: 0 !important; max-width: 100%; box-sizing: border-box; }
    .bk-main .form-control-sm,
    .bk-main .form-select-sm { min-height: 40px; font-size: 16px; }
    .bk-main input[type="checkbox"],
    .bk-main input[type="radio"] { width: 1.2rem; height: 1.2rem; flex: 0 0 auto; }
    .bk-main .form-check { min-height: var(--bk-touch-target); display: flex; align-items: center; gap: .5rem; }
    .bk-main .form-check .form-check-input { margin: 0; }

    .bk-main .row > *,
    .bk-main .d-flex > * { min-width: 0; }
    .bk-main .input-group { flex-wrap: nowrap; }
    .bk-main .input-group > .form-control,
    .bk-main .input-group > .form-select { min-width: 0; }
    .bk-main .table-responsive { width: 100%; min-width: 0; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
    .bk-main .container-fluid.px-0 > .row,
    .bk-main .container-xxl.px-0 > .row { margin-left: 0; margin-right: 0; }
    .bk-main .table-responsive > .table { margin-bottom: 0; }
    .bk-main .table > :not(caption) > * > * { padding: .55rem .6rem; }
    .bk-main .alert { overflow-wrap: anywhere; }
    .bk-main img,
    .bk-main canvas,
    .bk-main video,
    .bk-main svg { max-width: 100%; }

    .bk-main .modal-dialog { margin: .35rem; max-width: calc(100% - .7rem); }
    .bk-main .modal-content { max-height: calc(100dvh - .7rem - env(safe-area-inset-top, 0px)); overflow: hidden; }
    .bk-main .modal-header,
    .bk-main .modal-footer { flex: 0 0 auto; }
    .bk-main .modal-body { overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
    .bk-main .modal-footer { padding-bottom: max(.75rem, env(safe-area-inset-bottom, 0px)); }

    .bk-auth-bg { min-height: 100dvh; align-items: flex-start; padding: 1rem 0 max(1rem, env(safe-area-inset-bottom, 0px)); }
    .bk-auth-bg .container { padding-left: .75rem; padding-right: .75rem; }
    .bk-auth-bg .bk-auth-brand { margin-bottom: .85rem; }
    .bk-auth-bg .bk-auth-card .card-body { padding: 1.1rem !important; }
    .bk-auth-bg .form-control,
    .bk-auth-bg .form-select { min-height: 48px; font-size: 16px; }
    .bk-auth-bg .btn { min-height: 48px; }

    :focus-visible { outline: 3px solid rgba(180, 83, 9, .65); outline-offset: 2px; }
}

@media (max-width: 380px) {
    .bk-main.container-fluid { padding-left: .55rem; padding-right: .55rem; }
    .bk-main .card-body { padding: .7rem; }
    .bk-main .row.g-3 { --bs-gutter-y: .75rem; }
    .bk-main .btn-group { flex-wrap: wrap; }
}

/* Mobile behavior for session close, reports and administration forms. */
@media (max-width: 767.98px) {
    .bk-main .session-close-preview th { width: 42%; vertical-align: top; }
    .bk-main .session-close-preview td { overflow-wrap: anywhere; }
    .bk-main #btn-open-session,
    .bk-main #btn-close-session,
    .bk-main #btn-create-branch { width: 100%; }
    .bk-main #session-history td:last-child form { flex-wrap: wrap; }
    .bk-main #session-history td:last-child form > .form-control { flex: 1 1 100%; }
    .bk-main #session-history td:last-child details > form { min-width: 0 !important; width: 100%; }
    .bk-main .report-scroll-hint { display: block; }
    .bk-main #report-table { min-width: 1040px; }
    .bk-main #report-page { max-width: 100%; min-width: 0; overflow-x: clip; }
    .bk-main #report-page .table-responsive { width: 100%; min-width: 0; max-width: 100%; overflow-x: auto; }
    .bk-main #branch-table,
    .bk-main #top-products { min-width: 0; }
    .bk-main #report-filter .btn { width: 100%; }
    .bk-main .branch-actions { align-items: stretch; }
    .bk-main .branch-actions .btn { flex: 1 1 100%; }
    .bk-main .branch-card .card-body > .small.text-muted { align-items: flex-start !important; flex-direction: column; gap: .5rem; }
    .bk-main .printer-help-table th { min-width: 0; }
    .bk-main code { overflow-wrap: anywhere; word-break: break-word; }
    .bk-main .table-mobile-cards tr,
    .bk-main .table-mobile-cards td { box-sizing: border-box; min-width: 0; max-width: 100%; }
    .bk-main .table-mobile-cards td[colspan] { width: 100%; overflow-wrap: anywhere; }
    .bk-main .mobile-key-value-table { display: block; width: 100%; }
    .bk-main .mobile-key-value-table tbody,
    .bk-main .mobile-key-value-table tr { display: block; width: 100%; }
    .bk-main .mobile-key-value-table tr { padding: .55rem 0; border-bottom: 1px solid var(--bk-line); }
    .bk-main .mobile-key-value-table tr:last-child { border-bottom: 0; }
    .bk-main .mobile-key-value-table th,
    .bk-main .mobile-key-value-table td { display: block; width: 100%; padding: .15rem 0; overflow-wrap: anywhere; }
    .bk-main .nav-tabs { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
    .bk-main .nav-tabs .nav-item { flex: 0 0 auto; }
    .bk-main .nav-tabs .nav-link { min-height: 44px; white-space: nowrap; }
    .bk-main #template-editor-page .template-editor-heading { align-items: stretch !important; flex-direction: column; }
    .bk-main #template-editor-page .template-editor-heading .btn { width: 100%; }
    .bk-main #template-editor-page .template-editor-sidebar { order: 2; }
    .bk-main #template-editor-page .template-editor-form-column { order: 1; }
    .bk-main #template-editor-page textarea { min-height: 9rem; font-size: 16px !important; line-height: 1.45; }
    .bk-main #template-editor-page .template-editor-actions { display: grid; grid-template-columns: 1fr; gap: .5rem; }
    .bk-main #template-editor-page .template-editor-actions .btn { width: 100%; }
    .bk-main #account-home .shortcut-card { min-height: 100%; }
    .bk-main #account-home .shortcut-card .card-body { padding: .8rem; }
    .bk-main #account-home .shortcut-card .small { line-height: 1.35; overflow-wrap: anywhere; }
}

@media (max-width: 380px) {
    .bk-main #account-home .row > .col-6 { flex: 0 0 100%; width: 100%; }
}

/* ---- Componentes mobile-first ที่ POS, ตรวจนับสต็อก และคืนสินค้าใช้ร่วมกัน ---- */
.bk-main .stat-card .card-body { padding: .75rem 1rem; }
@media (max-width: 767.98px) {
    .bk-main .stat-card .card-title { font-size: .8rem; margin-bottom: .25rem; }
    .bk-main .stat-card h1,
    .bk-main .stat-card h2 { font-size: 1.5rem; margin-bottom: 0; }
    .bk-main .form-row-card { border: 1px solid var(--bk-line); border-radius: var(--bk-radius-sm); padding: .75rem; background: #fff; box-shadow: var(--bk-shadow); }
    .bk-main .products-toolbar-mobile,
    .bk-main .products-toolbar-mobile .form-check-label { font-size: .8125rem; }
    .bk-main .products-toolbar-mobile .btn { font-size: .8rem; }
    .bk-main .mobile-action-bar { flex-direction: column; align-items: stretch !important; gap: .5rem; }
    .bk-main .mobile-action-bar > div { display: flex; flex-wrap: wrap; gap: .35rem; }

    .bk-main #pos-header { flex-wrap: wrap; }
    .bk-main #pos-header h1 { flex: 1 1 auto; }
    .bk-main #pos-header > button { flex: 0 0 auto; }
    .bk-main #pos-quick-links { order: 3; flex: 1 1 100%; flex-wrap: wrap; }
    .bk-main #pos-quick-links > a { flex: 1 1 30%; padding-left: .4rem; padding-right: .4rem; font-size: .78rem; }

    .bk-main .pos-bottom-tabs {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1030;
        display: flex;
        padding-bottom: env(safe-area-inset-bottom, 0px);
        background: #fff;
        border-top: 1px solid var(--bk-line);
        box-shadow: 0 -.125rem .5rem rgba(0, 0, 0, .08);
    }
    .bk-main .pos-bottom-tab {
        flex: 1 1 0;
        min-width: 0;
        min-height: 48px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: .125rem;
        padding: .35rem .2rem;
        border: 0;
        background: transparent;
        color: var(--bk-muted);
        font-size: .72rem;
        line-height: 1.1;
    }
    .bk-main .pos-bottom-tab i { font-size: 1.1rem; }
    .bk-main .pos-bottom-tab.active { color: var(--bk-brand); font-weight: 700; }
    .bk-main .pos-pay-bar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: calc(3.75rem + env(safe-area-inset-bottom, 0px));
        z-index: 1025;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: .75rem;
        padding: .5rem .75rem;
        background: #fff;
        border-top: 1px solid var(--bk-line);
        box-shadow: 0 -.125rem .35rem rgba(0, 0, 0, .05);
    }
    .bk-main .pos-pay-bar-summary { color: var(--bk-muted); font-size: .8rem; line-height: 1.2; }
    .bk-main .pos-pay-bar-total { color: var(--bk-brand-strong); font-size: 1.1rem; font-weight: 700; }
    .bk-main .pos-field-row {
        display: flex;
        align-items: center;
        gap: .75rem;
        width: 100%;
        min-height: 56px;
        margin-bottom: .5rem;
        padding: .65rem .85rem;
        border: 1px solid var(--bk-line);
        border-radius: var(--bk-radius-sm);
        background: #fff;
        text-align: left;
    }
    .bk-main .pos-field-row-icon { flex: 0 0 auto; color: var(--bk-muted); font-size: 1.15rem; }
    .bk-main .pos-field-row-text { flex: 1 1 auto; min-width: 0; }
    .bk-main .pos-field-row-label { color: var(--bk-muted); font-size: .8rem; }
    .bk-main .pos-field-row-value { overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
    .bk-main .pos-field-sheet-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; padding-bottom: .5rem; border-bottom: 1px solid var(--bk-line); font-weight: 700; }
    .bk-main .pos-field-sheet.collapse.show,
    .bk-main .pos-field-sheet.collapsing {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1060;
        max-height: 75dvh;
        overflow-y: auto;
        padding: 1rem 1rem max(1rem, env(safe-area-inset-bottom, 0px));
        border-radius: 1rem 1rem 0 0;
        background: #fff;
        box-shadow: 0 -.25rem 1rem rgba(0, 0, 0, .15);
    }
    .bk-main .pos-field-sheet-backdrop { position: fixed; inset: 0; z-index: 1055; background: rgba(0, 0, 0, .4); }
    .bk-main .cart-qty-stepper { border: 0 !important; }
    .bk-main .cart-qty-stepper .btn { flex: 0 0 40px; width: 40px; min-width: 40px; min-height: 40px; padding: 0; border-radius: 50% !important; }
    .bk-main .cart-qty-stepper input.cart-qty { min-width: 3rem; margin: 0 .25rem; border-radius: .375rem !important; text-align: center; }
    .bk-main .stock-pill,
    .bk-main .soft-pill { display: inline-flex; align-items: center; gap: .25rem; border-radius: 999px; padding: .15rem .6rem; font-size: .75rem; font-weight: 600; white-space: nowrap; }
    .bk-main .stock-pill { color: #1e7e34; background: #e6f4ea; }
    .bk-main .stock-pill-danger { color: #c0392b; background: #fdecea; }
    .bk-main .soft-pill-success { color: #1e7e34; background: #e6f4ea; }
    .bk-main .soft-pill-danger { color: #c0392b; background: #fdecea; }
    .bk-main .soft-pill-warning { color: #8a6500; background: #fff8e1; }
    .bk-main .soft-pill-info { color: #0f6fa8; background: #e7f3fb; }
    .bk-main .soft-pill-secondary { color: #546e7a; background: #eceff1; }
    .bk-main .soft-pill::before,
    .bk-main .stock-pill::before { content: ""; width: 6px; height: 6px; flex: 0 0 6px; border-radius: 50%; background: currentColor; }
    .bk-main .sticky-action-bar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1025;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: .75rem;
        padding: .5rem .75rem max(.5rem, env(safe-area-inset-bottom, 0px));
        border-top: 1px solid var(--bk-line);
        background: #fff;
        box-shadow: 0 -.25rem .5rem rgba(0, 0, 0, .08);
    }
    .bk-main .sticky-action-bar-summary { color: var(--bk-muted); font-size: .8rem; line-height: 1.2; }
    .bk-main .sticky-action-bar-total { color: var(--bk-brand-strong); font-size: 1.1rem; font-weight: 700; }
    body:has(.bk-main .sticky-action-bar) { padding-bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px)); }
    .bk-main .modal.mobile-sheet .modal-dialog { position: fixed; left: 0; right: 0; bottom: 0; width: 100%; max-width: 100%; margin: 0; transform: translateY(100%); }
    .bk-main .modal.mobile-sheet.show .modal-dialog { transform: translateY(0); }
    .bk-main .modal.mobile-sheet .modal-content { max-height: 90dvh; overflow-y: auto; padding-bottom: env(safe-area-inset-bottom, 0px); border: 0; border-radius: 1rem 1rem 0 0; }
}

@media (min-width: 768px) and (max-width: 991.98px) {
    .bk-main .pos-bottom-tabs {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1030;
        display: flex;
        padding-bottom: env(safe-area-inset-bottom, 0px);
        background: #fff;
        border-top: 1px solid var(--bk-line);
        box-shadow: 0 -.125rem .5rem rgba(0, 0, 0, .08);
    }
    .bk-main .pos-bottom-tab { flex: 1 1 0; min-height: 48px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .125rem; border: 0; background: transparent; color: var(--bk-muted); }
    .bk-main .pos-bottom-tab.active { color: var(--bk-brand); font-weight: 700; }
}

/* ---- พิมพ์ / บันทึกเป็น PDF ผ่านเบราว์เซอร์ (รายงาน) ---- */
@media print {
    @page { size: A4 landscape; margin: 10mm; }
    .navbar, .d-print-none, .toast-container { display: none !important; }
    body { background: #fff !important; }
    .card { box-shadow: none !important; border: 1px solid #ddd !important; break-inside: avoid; }
    .table-responsive { overflow: visible !important; }
    #report-table { font-size: 10px; }
    #report-table th, #report-table td { padding: .2rem .3rem; }
}
