/* Responsive block: dense desktop first, narrowing in two steps.
   <=1200px: tighter nav, wrapping toolbar, 2-col KPIs, stacked split panels.
   <=820px: stacked bars, scrollable nav/toolbar, single-column grids,
   compact two-line status bar (still fixed to the bottom). */
@media (max-width: 1200px) {
  .shell-nav a { padding: calc(var(--gap) / 2) calc(var(--gap) / 2); font-size: var(--fs-sm); }
  .wordmark { font-size: var(--fs-base); }
  .kpi-row { grid-template-columns: 1fr 1fr; }
  .shell-toolbar-inner { flex-wrap: wrap; padding-top: calc(var(--gap) / 2); padding-bottom: calc(var(--gap) / 2); }
  .report-layout { grid-template-columns: 180px 1fr; }
  .split-2 { grid-template-columns: minmax(0, 1fr); }
  .dash-row, .dash-half { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 820px) {
  :root { --fs-kpi: 26px; }
  .shell-top-inner { flex-wrap: wrap; padding-top: calc(var(--gap) / 2); padding-bottom: calc(var(--gap) / 2); }
  .shell-nav { order: 3; width: 100%; overflow-x: auto; margin-left: 0; }
  .shell-tools { margin-left: auto; }
  .shell-toolbar-inner { flex-wrap: nowrap; overflow-x: auto; }
  .btn-toolbar { flex: 0 0 auto; }
  .statusbar-inner { flex-wrap: wrap; column-gap: var(--gap); row-gap: 0; padding-top: 4px; padding-bottom: 4px; }
  .statusbar .spacer { display: none; }
  body.has-statusbar { padding-bottom: calc(var(--statusbar-h) * 2 + var(--gap)); }
  .kpi-row, .tile-grid { grid-template-columns: 1fr; }
  .report-layout { grid-template-columns: 1fr; }
  .form-row { flex-direction: column; }
  .filterbar .filter-actions, .toolbar .filter-actions { margin-left: 0; flex-wrap: wrap; }
  .toolbar { flex-wrap: wrap; }
  .toolbar .btn { margin-left: 0; }
  .topbar-inner { flex-wrap: wrap; }
  .auth-wrap { margin-top: calc(var(--gap) * 2); }
  .auth-card { padding: calc(var(--gap) * 2); }
}

/* ===== Full-width layout on every screen size (added 2026-10-06) =====
   Before: header, toolbar, page content and status bar stopped at 1366px
   (billing at 1800px), so big PC monitors (1600, 1920, 2560 wide) showed
   empty grey space on both sides. Now they use the whole window width.
   Layout only: colours, fonts and the theme are unchanged.
   Remove this whole block to go back to the old fixed width. */
/* Screen only, and 'clip' (not 'hidden'): a hidden overflow makes the page a
   scroll box when printing, which cuts labels and bills or splits them over 2 pages. */
@media screen { html, body { max-width: 100%; overflow-x: clip; } }
.shell-top-inner,
.shell-toolbar-inner,
.statusbar-inner,
.wrap-wide { max-width: none; width: 100%; }
body[data-page="billing"] main.wrap-wide { max-width: none; }
img { max-width: 100%; height: auto; }

/* Top menu (12 items with Rojkram): never runs into the Firm box. It may
   shrink and, when a screen is still too narrow, scroll sideways. */
.shell-nav { flex: 0 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.shell-nav::-webkit-scrollbar { display: none; }
.shell-tools { flex: 0 0 auto; }
@media (max-width: 1440px) and (min-width: 1201px) {
  .shell-nav a { padding-left: 7px; padding-right: 7px; }
}

/* Big monitors: a little more breathing room at the edges. */
@media (min-width: 1600px) {
  .shell-top-inner, .shell-toolbar-inner, .statusbar-inner { padding-left: calc(var(--gap) * 2); padding-right: calc(var(--gap) * 2); }
  .wrap-wide { padding-left: calc(var(--gap) * 2); padding-right: calc(var(--gap) * 2); }
}
/* Very large / 2K-4K monitors: slightly larger text so it stays readable. */
@media (min-width: 2400px) {
  :root { --fs-xs: 12px; --fs-sm: 13px; --fs-base: 15px; --fs-md: 16px; --fs-lg: 20px; --fs-xl: 24px; --row-h: 36px; }
}

/* Tablets and phones: billing becomes one column and the page scrolls
   (the one-screen billing layout only fits on a laptop/PC). */
@media (max-width: 1080px) {
  body[data-page="billing"] { height: auto; min-height: 100vh; overflow: visible; }
  body[data-page="billing"] main.wrap-wide { flex: 0 0 auto; }
  body[data-page="billing"] .pos-cols { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto; }
  body[data-page="billing"] .pos-left, body[data-page="billing"] .pos-right { overflow: visible; }
  body[data-page="billing"] .pos-mid { min-height: 300px; }
  body[data-page="billing"] .statusbar { position: static; }

  /* Billing on tablet / mobile (added 2026-10-21) */
  /* 1. Bill toolbar scrolls sideways in one line (rules in components.css);
        here the push-right spacer goes so the buttons sit together. */
  body[data-page="billing"] .pos-bar > span[style] { display: none; }
  /* 2. Section tab scroller above the panels, stays on top while scrolling. */
  body[data-page="billing"] .pos-tabs {
    display: flex; gap: 6px; position: sticky; top: 0; z-index: 20;
    overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; scroll-snap-type: x proximity;
    background: #fff; border: 1px solid var(--bl-card-border); border-radius: var(--bl-radius);
    padding: 6px; box-shadow: 0 2px 6px rgba(16, 24, 40, .08);
  }
  body[data-page="billing"] .pos-tabs::-webkit-scrollbar { display: none; }
  body[data-page="billing"] .pos-tabs a {
    flex: 0 0 auto; scroll-snap-align: start; display: inline-flex; align-items: center; gap: 6px;
    min-height: 38px; padding: 0 14px; border: 1px solid var(--c-border-strong); border-radius: 999px;
    background: var(--c-toolbar); color: var(--c-text); font-size: var(--fs-base); font-weight: 600;
    white-space: nowrap; text-decoration: none;
  }
  body[data-page="billing"] .pos-tabs a.is-active { background: var(--c-navy); border-color: var(--c-navy); color: #fff; }
  body[data-page="billing"] .pos-tabs a.is-active .pos-badge { background: #fff; color: var(--c-navy); }
  /* 3. Blocks in working order: customer, scan, items, payment, fast items, categories. */
  body[data-page="billing"] .pos-left { display: contents; }
  body[data-page="billing"] .pos-left > .pos-block {
    background: #fff; border: 1px solid var(--bl-card-border); border-radius: var(--bl-radius);
    box-shadow: 0 1px 2px rgba(16, 24, 40, .05); padding: 12px;
  }
  body[data-page="billing"] #sec-customer { order: 1; }
  body[data-page="billing"] #sec-scan     { order: 2; }
  body[data-page="billing"] #sec-items    { order: 3; }
  body[data-page="billing"] #sec-pay      { order: 4; }
  body[data-page="billing"] #sec-fast     { order: 5; }
  body[data-page="billing"] #sec-cats     { order: 6; }
  body[data-page="billing"] .pos-cols > *, body[data-page="billing"] .pos-left > .pos-block { scroll-margin-top: 64px; }
  /* 4. Item table: scrolls sideways inside its box instead of squeezing the columns. */
  body[data-page="billing"] .pos-mid { -webkit-overflow-scrolling: touch; }
  body[data-page="billing"] .pos-grid { min-width: 660px; }
}
/* Section tabs are for tablet / mobile only. */
.pos-tabs { display: none; }
@media (max-width: 820px) {
  /* 16px text in boxes stops phones zooming in when a box is tapped. */
  body[data-page="billing"] .pos input, body[data-page="billing"] .pos select { font-size: 16px; }
  body[data-page="billing"] .pos-grand-val { font-size: 32px; }
  body[data-page="billing"] .pos-pay-btn { min-height: 52px; }
  body[data-page="billing"] .pos-complete { min-height: 52px; font-size: 16px; }
}
@media (max-width: 400px) {
  body[data-page="billing"] .pos-fast, body[data-page="billing"] .pos-pay { grid-template-columns: 1fr 1fr; gap: 6px; }
  body[data-page="billing"] .pos-billdisc { display: flex; margin: 4px 0 0; }
}

/* Phones: wide tables scroll sideways inside their box instead of
   pushing the page wider than the screen; forms use the full width. */
@media (max-width: 820px) {
  main div:has(> table), main section:has(> table) { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .form-card { max-width: 100%; }
  .modal { max-width: calc(100% - var(--gap) * 2); max-height: 90vh; overflow-y: auto; }
  .pos-qa-grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .wordmark { display: none; }
  .wrap-wide { padding-left: calc(var(--gap) * 0.8); padding-right: calc(var(--gap) * 0.8); }
  .firm-select label { display: none; }
  .firm-select select { max-width: 130px; }
  .lang-toggle { padding: 0 8px; }
}
/* ===== end Full-width layout ===== */
