/* Reusable UI components for GS Ghongade. Values come from variables.css.
   Laws honoured: 2px radius max, visible 1px borders, no shadows, no gradients
   except the KPI tint, 34px rows, 32px inputs, 6px/10px cell padding
   (calc(var(--gap) * 0.6) = 6px, since --gap is the single spacing token). */

/* ---------- Buttons ---------- */
/* Three button styles only: primary (brand blue), secondary (white + grey
   border), danger (red). Each one sets BOTH background and text colour. */
.btn-primary, .btn-secondary, .btn-danger {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--btn-h); padding: 0 calc(var(--gap) * 1.4);
  border-radius: var(--radius); font-family: var(--font-ui); font-size: var(--fs-base); font-weight: 500;
  line-height: 1.2; cursor: pointer; text-decoration: none; white-space: nowrap;
  border: 1px solid transparent;
}
.btn-primary { background: var(--c-blue); color: var(--c-text-invert); border-color: var(--c-blue); font-weight: 600; }
.btn-primary:hover { background: var(--c-blue-hover); border-color: var(--c-blue-hover); color: var(--c-text-invert); text-decoration: none; }
.btn-secondary { background: var(--c-surface); color: var(--c-text); border-color: var(--c-border-strong); }
.btn-secondary:hover { background: var(--c-toolbar); color: var(--c-text); text-decoration: none; }
.btn-danger { background: var(--c-neg); color: var(--c-text-invert); border-color: var(--c-neg); font-weight: 600; }
.btn-danger:hover { background: #8F1C13; color: var(--c-text-invert); text-decoration: none; }
.btn-warn { background: var(--c-warn-bg); color: var(--c-warn-text); border-color: var(--c-warn); font-weight: 600; }
.btn-primary:disabled, .btn-secondary:disabled, .btn-danger:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-icon { display: inline-flex; align-items: center; justify-content: center; width: var(--btn-h); min-height: var(--btn-h); padding: 0; background: var(--c-surface); color: var(--c-text); border: 1px solid var(--c-border-strong); border-radius: var(--radius); cursor: pointer; font-size: var(--fs-md); }
.btn-icon:hover { background: var(--c-toolbar); }
/* Segmented button group (e.g. attendance P / A / L) */
.seg { display: inline-flex; gap: 4px; }
.seg button { min-width: 34px; padding: 0 var(--gap); }

/* Toolbar buttons: icon-left, two-line label, full height of BAR 2 */
.btn-toolbar { display: inline-flex; align-items: center; gap: var(--gap); height: var(--toolbar-h); padding: 0 var(--gap); background: transparent; border: 1px solid transparent; border-radius: var(--radius); cursor: pointer; text-decoration: none; color: var(--c-text); }
.btn-toolbar:hover:not(:disabled) { background: var(--c-surface); border-color: var(--c-border); color: var(--c-text); text-decoration: none; }
.btn-toolbar:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-toolbar .tb-icon { font-size: var(--fs-lg); line-height: 1; }
.btn-toolbar .tb-label { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.25; }
.btn-toolbar .tb-label strong { font-size: var(--fs-base); font-weight: 600; }

/* ---------- KPI cards (the one place a tint gradient is allowed) ---------- */
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--gap); margin: var(--gap) 0; }
.kpi-card { border: 1px solid var(--c-border); border-radius: var(--radius); padding: var(--gap); background: var(--c-surface); }
.kpi-card .kpi-label { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.4px; color: var(--c-text-muted); }
.kpi-card .kpi-label { font-weight: 600; }
.kpi-card .kpi-value { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-size: var(--fs-kpi); text-align: right; line-height: 1.3; overflow-wrap: anywhere; }
.kpi-card--pos { background: linear-gradient(180deg, var(--c-pos-bg), var(--c-surface)); border-left: 4px solid var(--c-pos); }
.kpi-card--neg { background: linear-gradient(180deg, var(--c-neg-bg), var(--c-surface)); border-left: 4px solid var(--c-neg); }
.kpi-card--neutral { background: linear-gradient(180deg, var(--c-info-bg), var(--c-surface)); border-left: 4px solid var(--c-info); }

/* ---------- Panels ---------- */
.panel { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); margin: var(--gap) 0; }
.panel-head { padding: calc(var(--gap) * 0.6) var(--gap); border-bottom: 1px solid var(--c-border); font-size: var(--fs-md); font-weight: 600; display: flex; align-items: center; gap: var(--gap); min-height: var(--toolbar-h); }
.panel-head--navy { background: var(--c-navy); color: var(--c-text-invert); border-bottom: 0; }
.panel-body { padding: var(--gap); }

/* ---------- Data grid: zebra, hover, 34px rows, sticky header ---------- */
.data-grid { width: 100%; border-collapse: collapse; background: var(--c-surface); font-size: var(--fs-base); }
.data-grid th, .data-grid td { border: 1px solid var(--c-border); padding: calc(var(--gap) * 0.6) var(--gap); text-align: left; }
.data-grid thead th { background: var(--c-thead); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.4px; position: sticky; top: 0; z-index: 1; }
.data-grid tbody tr { height: var(--row-h); }
.data-grid tbody tr:nth-child(even) { background: var(--c-row-alt); }
.data-grid tbody tr:hover { background: var(--c-row-hover); }
.data-grid tbody tr.selected { background: var(--c-row-selected); }
.data-grid .num { text-align: right; font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.data-grid .col-sno { width: 44px; text-align: right; font-family: var(--font-num); }
.data-grid tr.filler td { height: var(--row-h); background: var(--c-surface); }
.data-grid tfoot.totals td { background: var(--c-thead); font-weight: 700; border-top: 2px solid var(--c-border-strong); }
.data-grid tfoot.totals .num { font-family: var(--font-num); }
.data-grid tr.net-total td { background: var(--c-status-bar); color: var(--c-text-invert); font-size: var(--fs-md); font-weight: 700; }
.data-grid tr.net-total .num { font-family: var(--font-num); text-align: right; }

/* ---------- Badges ---------- */
.badge-pos, .badge-neg, .badge-warn, .badge-info { display: inline-block; font-size: var(--fs-xs); padding: 1px 6px; border-radius: var(--radius); border: 1px solid transparent; }
.badge-pos { background: var(--c-pos-bg); color: var(--c-pos); border-color: var(--c-pos); }
.badge-neg { background: var(--c-neg-bg); color: var(--c-neg); border-color: var(--c-neg); }
.badge-warn { background: var(--c-warn-bg); color: var(--c-warn-text); border-color: var(--c-warn); }
.badge-info { background: var(--c-info-bg); color: var(--c-info); border-color: var(--c-info); }

/* ---------- Tab strip ---------- */
.tabstrip { display: flex; gap: 0; border-bottom: 2px solid var(--c-border); margin: var(--gap) 0; }
.tabstrip button { background: var(--c-surface); color: var(--c-text); border: 1px solid var(--c-border); border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0; min-height: var(--btn-h); padding: 0 calc(var(--gap) * 1.5); cursor: pointer; font-size: var(--fs-base); margin-right: -1px; }
.tabstrip button:hover { background: var(--c-toolbar); }
.tabstrip button[aria-selected="true"] { background: var(--c-navy); color: var(--c-text-invert); border-color: var(--c-navy); font-weight: 600; }
.tabpanel[hidden] { display: none; }

/* ---------- Filter bar: 11px uppercase labels over 32px inputs ---------- */
.filterbar { display: flex; align-items: flex-end; gap: var(--gap); background: var(--c-toolbar); border: 1px solid var(--c-border); border-radius: var(--radius); padding: var(--gap); margin: var(--gap) 0; flex-wrap: wrap; }
.filterbar .filter-field { display: flex; flex-direction: column; gap: 2px; }
.filterbar .filter-field > span { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.4px; color: var(--c-text-muted); }
.filterbar input, .filterbar select { min-height: var(--input-h); }
/* Shared action-button group (Product page design): buttons sit together on the right, one gap apart. */
.filterbar .filter-actions, .toolbar .filter-actions { margin-left: auto; display: flex; align-items: center; gap: var(--gap); }

/* ---------- Tile grid: 2x2 selectable tiles, 44px tinted icon ---------- */
.tile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); margin: var(--gap) 0; }
.tile { display: flex; align-items: center; justify-content: flex-start; gap: calc(var(--gap) * 1.2); background: var(--c-surface); color: var(--c-text); border: 1px solid var(--c-border); border-radius: var(--radius); padding: var(--gap) calc(var(--gap) * 1.5); cursor: pointer; text-align: left; width: 100%; min-height: 64px; white-space: normal; font-weight: 400; }
.tile:hover { background: var(--c-row-hover); color: var(--c-text); text-decoration: none; }
.tile-text { flex: 1; display: flex; align-items: center; justify-content: space-between; gap: var(--gap); }
.tile-text a, a.tile-text { font-weight: 600; }
.tile[aria-pressed="true"] { background: var(--c-row-selected); border-color: var(--c-blue); }
.tile-icon { flex: 0 0 44px; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; font-size: var(--fs-lg); background: var(--c-info-bg); color: var(--c-info); border-radius: var(--radius); }
.tile-text strong { display: block; font-size: var(--fs-md); font-weight: 600; }
.tile-text .num { display: block; text-align: right; font-family: var(--font-num); font-variant-numeric: tabular-nums; font-size: var(--fs-md); }

/* ---------- Report sidebar nav ---------- */
.report-layout { display: grid; grid-template-columns: 220px 1fr; gap: var(--gap); margin: var(--gap) 0; }
.report-nav { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); padding: calc(var(--gap) / 2); }
.report-nav h3 { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.4px; color: var(--c-text-muted); margin: var(--gap) calc(var(--gap) / 2) calc(var(--gap) / 2); }
.report-nav a { display: block; padding: calc(var(--gap) / 2) var(--gap); color: var(--c-text); text-decoration: none; border-radius: var(--radius); font-size: var(--fs-base); }
.report-nav a:hover { background: var(--c-row-hover); }
.report-nav a.active { background: var(--c-navy); color: var(--c-text-invert); font-weight: 600; }
.report-nav a.active:hover { text-decoration: none; }
.report-nav .report-nav-foot { display: block; margin: var(--gap) calc(var(--gap) / 2) calc(var(--gap) / 2); text-align: center; }
.report-main { min-width: 0; }

/* Two panels side by side that stack on narrower screens (staff screen) */
.split-2 { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: var(--gap); align-items: start; }

/* ---------- Forms ---------- */
.form-row { display: flex; gap: var(--gap); flex-wrap: wrap; margin-bottom: var(--gap); }
.form-field { display: flex; flex-direction: column; gap: 2px; flex: 1 1 160px; }
.form-field > span { font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; color: var(--c-text-muted); }
/* Help text and errors under a field read as normal sentences, not labels. */
.form-field > span.muted, .form-field > span.form-error { font-size: var(--fs-sm); font-weight: 400; text-transform: none; letter-spacing: 0; }
.form-field input, .form-field select, .form-field textarea { min-height: var(--input-h); }
.form-error { color: var(--c-neg); font-size: var(--fs-sm); }
.required::after { content: " *"; color: var(--c-neg); }

/* ---------- Modal box, toast, loading, empty state, F-key label ---------- */
.modal { background: var(--c-surface); border: 1px solid var(--c-border-strong); border-radius: var(--radius); padding: calc(var(--gap) * 2); max-width: 460px; width: calc(100% - var(--gap) * 4); }
.modal-narrow { max-width: 380px; }
.modal h2 { font-size: var(--fs-lg); margin-bottom: var(--gap); }
.modal-actions { display: flex; justify-content: flex-end; gap: var(--gap); margin-top: var(--gap); }
#toast-wrap { position: fixed; bottom: calc(var(--statusbar-h) + var(--gap)); right: var(--gap); display: flex; flex-direction: column; gap: var(--gap); z-index: 90; }
.toast { background: var(--c-status-bar); color: var(--c-text-invert); border-radius: var(--radius); padding: var(--gap) calc(var(--gap) * 2); font-size: var(--fs-base); max-width: 360px; }
.toast-error { background: var(--c-neg); }
.toast-ok { background: var(--c-pos); }
.loading-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.35); display: flex; align-items: center; justify-content: center; z-index: 100; }
.loading-overlay[hidden] { display: none; }
.loading-overlay span { background: var(--c-surface); border: 1px solid var(--c-border-strong); border-radius: var(--radius); padding: var(--gap) calc(var(--gap) * 2); }
.empty-state { border: 1px dashed var(--c-border-strong); border-radius: var(--radius); padding: calc(var(--gap) * 3); text-align: center; color: var(--c-text-muted); margin: var(--gap) 0; }
.fkey { display: inline-block; font-family: var(--font-num); font-size: var(--fs-xs); font-weight: 400; line-height: 1.5; border: 1px solid var(--c-border-strong); border-radius: var(--radius); padding: 0 4px; background: var(--c-toolbar); color: var(--c-text-muted); }
/* On a dark button the key hint stays readable instead of a white chip on white text. */
.btn .fkey, .btn-primary .fkey, .btn-danger .fkey { background: rgba(255, 255, 255, 0.16); border-color: rgba(255, 255, 255, 0.55); color: var(--c-text-invert); }

/* ---------- Shell bars (BAR 1/2/3 skeleton) ---------- */
.shell-top { background: var(--c-navy); color: var(--c-text-invert); min-height: var(--nav-h); }
.shell-top-inner { max-width: 1366px; margin: 0 auto; padding: 0 var(--gap); min-height: var(--nav-h); display: flex; align-items: center; gap: var(--gap); }
.logo-square { flex: 0 0 auto; width: 40px; height: 40px; background: var(--c-text-invert); color: var(--c-navy); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: var(--fs-lg); border-radius: var(--radius); }
.wordmark { font-weight: 700; font-size: var(--fs-md); letter-spacing: 0.4px; white-space: nowrap; }
.shell-nav { display: flex; align-items: stretch; gap: 2px; margin-left: var(--gap); }
.shell-nav a { color: var(--c-text-invert); text-decoration: none; font-size: var(--fs-base); padding: calc(var(--gap) / 2) var(--gap); border-bottom: 2px solid transparent; display: flex; align-items: center; white-space: nowrap; }
.shell-nav a:hover { background: var(--c-navy-dark); }
.shell-nav a.active { border-bottom-color: var(--c-text-invert); font-weight: 600; }
.shell-tools { margin-left: auto; display: flex; align-items: center; gap: var(--gap); }
.firm-select { display: flex; align-items: center; gap: calc(var(--gap) / 2); }
.firm-select select { min-height: var(--input-h); border-radius: var(--radius); }
.user-menu { position: relative; }
.user-menu summary { list-style: none; cursor: pointer; width: 40px; height: 40px; border-radius: var(--radius); background: var(--c-navy-dark); color: var(--c-text-invert); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: var(--fs-md); }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu-body { position: absolute; right: 0; top: 46px; background: var(--c-surface); color: var(--c-text); border: 1px solid var(--c-border-strong); border-radius: var(--radius); min-width: 200px; z-index: 50; padding: calc(var(--gap) / 2); }
.user-menu-body a, .user-menu-body button.menu-btn { display: block; width: 100%; text-align: left; padding: calc(var(--gap) / 2) var(--gap); background: none; border: 0; color: var(--c-text); text-decoration: none; font-size: var(--fs-base); cursor: pointer; border-radius: var(--radius); }
.user-menu-body a:hover, .user-menu-body button.menu-btn:hover { background: var(--c-row-hover); }
.user-menu-body form { margin: 0; }
.shell-toolbar { background: var(--c-toolbar); border-bottom: 1px solid var(--c-border); min-height: var(--toolbar-h); }
.shell-toolbar-inner { max-width: 1366px; margin: 0 auto; padding: 0 var(--gap); min-height: var(--toolbar-h); display: flex; align-items: stretch; gap: var(--gap); }
/* BAR 3: always pinned to the bottom of the window on every screen size. */
.statusbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: var(--c-status-bar); color: var(--c-text-invert); min-height: var(--statusbar-h); font-size: var(--fs-sm); border-top: 1px solid rgba(255, 255, 255, 0.12); }
.statusbar-inner { max-width: 1366px; margin: 0 auto; padding: 0 var(--gap); min-height: var(--statusbar-h); display: flex; align-items: center; gap: calc(var(--gap) * 2); }
.statusbar-inner > span { white-space: nowrap; }
.statusbar .sb-label { opacity: 0.8; }
.statusbar .sb-value { font-weight: 600; }
.statusbar .spacer { margin-left: auto; }
.statusbar .num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.wrap-wide { max-width: 1366px; margin: 0 auto; padding: calc(var(--gap) * 1.5) var(--gap) 0; }

/* ---------- Billing: 📄 product-details button + pop-up ---------- */
.data-grid .info-btn { width: 30px; min-height: 28px; font-size: 15px; line-height: 1; vertical-align: middle; }
.modal:has(.info-table) { max-width: 580px; }
.info-table th { width: 38%; text-align: left; background: var(--c-thead); font-weight: 600; }
.info-table td { font-size: var(--fs-md); }

/* ======================= Billing (POS) screen ======================= */
.pos { display: flex; flex-direction: column; gap: var(--gap); }
.pos-bar { display: flex; align-items: center; gap: var(--gap); background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); padding: 8px 10px; }
.pos-chip { font-size: var(--fs-sm); color: var(--c-text-muted); padding: 3px 10px; border: 1px solid var(--c-border); border-radius: 12px; background: var(--c-toolbar); }
.pos-badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--c-navy); color: #fff; font-size: calc(12 * var(--u, 1px)); line-height: 18px; text-align: center; }
.pos-cols { display: grid; grid-template-columns: 330px minmax(0, 1fr) 340px; gap: var(--gap); align-items: stretch; min-height: calc(100vh - 250px); }
.pos-left, .pos-right { background: var(--c-toolbar); border: 1px solid var(--c-border); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 14px; }
.pos-right { background: var(--c-surface); gap: 8px; }
.pos-block { display: flex; flex-direction: column; gap: 6px; }
.pos-label { font-size: calc(13 * var(--u, 1px)); font-weight: 700; letter-spacing: .5px; color: var(--c-text-muted); text-transform: uppercase; margin: 0; }
.pos-label-accent { color: var(--c-navy); }
.pos-label-row { display: flex; justify-content: space-between; align-items: center; }
.pos-label-row .btn-link { font-size: var(--fs-sm); }
.pos-newcust { background: var(--c-surface); border: 1px dashed var(--c-border-strong); border-radius: var(--radius); padding: 8px; }
.pos-newcust .form-row { margin-bottom: 4px; }
.small-note { font-size: var(--fs-sm); margin: 4px 0 0; }
.pos-scanblock { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); padding: 10px; }
.pos-scan { display: flex; align-items: center; border: 2px solid var(--c-navy); border-radius: var(--radius); background: #fff; padding: 0 10px; }
.pos-scan:focus-within { box-shadow: 0 0 0 3px rgba(27, 79, 140, .25); }
.pos-scan-icon { font-size: calc(22 * var(--u, 1px)); color: var(--c-navy); margin-right: 8px; }
.pos-scan input { border: 0; outline: 0 !important; min-height: 46px; font-size: calc(17 * var(--u, 1px)); padding: 0; background: transparent; }
.pos-results { display: flex; flex-direction: column; max-height: 240px; overflow-y: auto; }
.pos-results:empty { display: none; }
.pos-result { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; align-items: center; width: 100%; min-height: 34px; text-align: left; background: var(--c-surface); border: 1px solid var(--c-border); border-top-width: 0; border-radius: 0; padding: 4px 8px; font-weight: 400; white-space: normal; }
.pos-result:first-child { border-top-width: 1px; }
.pos-result:hover, .pos-result.is-hi { background: var(--c-row-selected); }
.pos-result code { font-size: calc(12 * var(--u, 1px)); color: var(--c-text-muted); }
.pos-result b { font-family: var(--font-num); font-size: calc(13 * var(--u, 1px)); }
.pos-fast { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pos-fast-btn { flex-direction: column; min-height: 64px; background: #E3E7ED; border: 1px solid var(--c-border-strong); color: var(--c-text); font-weight: 600; white-space: normal; line-height: 1.25; text-align: center; padding: 6px; }
.pos-fast-btn small { font-weight: 400; color: var(--c-text-muted); font-size: calc(12 * var(--u, 1px)); }
.pos-fast-btn:hover { background: var(--c-row-selected); }
.pos-cats { display: flex; flex-direction: column; gap: 6px; }
.pos-cat { justify-content: space-between; background: var(--c-surface); border: 1px solid var(--c-border-strong); font-weight: 400; min-height: 36px; padding: 0 12px; }
.pos-cat:hover { background: var(--c-row-hover); }
.pos-catlist { display: flex; flex-direction: column; max-height: 55vh; overflow-y: auto; margin-bottom: 8px; }
.modal:has(.pos-catlist) { max-width: 560px; }
/* middle: bill grid */
.pos-mid { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); overflow: auto; position: relative; }
.pos-grid { width: 100%; border-collapse: collapse; font-size: var(--fs-base); }
.pos-grid thead th { position: sticky; top: 0; z-index: 1; background: var(--c-thead); font-size: calc(12.5 * var(--u, 1px)); font-weight: 700; letter-spacing: .4px; text-transform: uppercase; text-align: left; padding: 10px 8px; border-bottom: 2px solid var(--c-border-strong); white-space: nowrap; }
.pos-grid thead th.num { text-align: right; }
.pos-grid td { padding: 5px 8px; border-bottom: 1px solid var(--c-border); vertical-align: middle; }
.pos-grid td small { display: block; color: var(--c-text-muted); font-size: calc(12.5 * var(--u, 1px)); }
.pos-grid td input { width: 70px; min-height: 30px; padding: 2px 6px; text-align: right; }
.pos-grid td input[data-f="price"] { width: 86px; }
.pos-grid td input[data-f="discount"] { width: 56px; }
.pos-grid td input[readonly] { background: transparent; border-color: transparent; }
.pos-grid .c-no { width: 34px; text-align: center; color: var(--c-text-muted); }
.pos-grid .c-code { white-space: nowrap; }
.pos-grid .c-code code { font-size: calc(12.5 * var(--u, 1px)); }
.pos-grid .c-total { font-family: var(--font-num); font-size: calc(15 * var(--u, 1px)); }
.pos-grid .c-act { width: 84px; white-space: nowrap; text-align: right; padding-right: 6px; }
.pos-grid tr.is-hi td { background: #E8F0FA; }
.pos-grid tr.is-hi td:first-child { box-shadow: inset 4px 0 0 var(--c-navy); color: var(--c-navy); font-weight: 700; }
.pos-grid tr.filler td { height: 38px; }
.pos-del { color: var(--c-neg); font-size: calc(16 * var(--u, 1px)); padding: 0 6px; margin-left: 4px; }
.pos-empty { position: absolute; left: 0; right: 0; top: 45%; text-align: center; pointer-events: none; font-size: var(--fs-md); margin: 0; }
@keyframes posFlash { from { background: #CDEFD6; } to { background: #E8F0FA; } }
.pos-grid tr.pos-flash td { animation: posFlash .9s ease-out; }
/* right: totals + payment */
.pos-sum { width: 100%; border-collapse: collapse; }
.pos-sum td { padding: 5px 0; font-size: var(--fs-base); }
.pos-sum td.num { text-align: right; font-family: var(--font-num); white-space: nowrap; }
.pos-sum tr.neg td { color: var(--c-neg); }
.pos-sum tr.net td { border-top: 1px solid var(--c-border); font-weight: 700; font-size: var(--fs-md); color: var(--c-text); padding-top: 8px; }
.pos-billdisc { display: inline-flex; gap: 3px; margin-left: 4px; vertical-align: middle; }
.pos-sum small { display: block; font-size: calc(12 * var(--u, 1px)); }
.pos-billdisc select { width: 48px; min-height: 26px; padding: 0 2px; }
.pos-billdisc input { width: 64px; min-height: 26px; padding: 0 4px; text-align: right; }
.pos-grand { background: var(--c-navy); color: #fff; text-align: center; padding: 12px 8px 14px; border-radius: var(--radius); border-bottom: 4px solid #5B84B1; margin-top: 4px; }
.pos-grand-label { font-size: calc(13 * var(--u, 1px)); font-weight: 700; letter-spacing: 1.5px; opacity: .85; }
.pos-grand-val { font-size: calc(40 * var(--u, 1px)); font-weight: 800; font-family: var(--font-ui); line-height: 1.1; }
.pos-pay { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pos-pay-btn { flex-direction: column; gap: 2px; min-height: 58px; background: #E3E7ED; border: 1px solid var(--c-border-strong); color: var(--c-text); font-weight: 700; font-size: calc(13.5 * var(--u, 1px)); position: relative; }
.pos-pay-btn span { font-size: calc(20 * var(--u, 1px)); line-height: 1; }
.pos-pay-btn[aria-checked="true"] { background: #fff; border: 2px solid var(--c-navy); color: var(--c-navy); }
.pos-pay-btn[aria-checked="true"]::after { content: ""; position: absolute; top: 6px; right: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--c-navy); }
.pos-pay-btn:disabled { opacity: .45; }
.pos-split-link { align-self: flex-start; font-size: var(--fs-sm); }
/* GST row in the totals (only for a firm with GST on). */
.pos-sum tr.pos-gst td { padding-top: 6px; border-top: 1px dashed var(--c-border); }
.pos-gst .check { font-size: var(--fs-sm); }
.pos-gst-buyer { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.pos-gst-buyer[hidden] { display: none; }
.pos-gst-buyer input { width: 100%; min-height: 30px; }
/* GST box on the purchase form (only for a firm with GST on). */
.gst-panel { border: 1px dashed var(--c-border-strong); border-radius: var(--radius); padding: var(--gap); margin: var(--gap) 0; }
.gst-panel[hidden], .gst-panel .form-row[hidden] { display: none; }
.pos-sum tr.gst-tax td { font-size: var(--fs-sm); color: var(--c-text-muted); padding-top: 1px; padding-bottom: 1px; }
.pos-split-link.is-on { font-weight: 700; text-decoration: underline; }
.pos-pane { border: 1px solid var(--c-border); border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.pos-tender { min-height: 48px !important; font-size: calc(24 * var(--u, 1px)) !important; font-weight: 700; text-align: right; font-family: var(--font-num); }
.pos-change { display: flex; justify-content: space-between; align-items: baseline; border-top: 1px dashed var(--c-border-strong); padding-top: 8px; color: var(--c-neg); font-weight: 700; font-size: calc(13.5 * var(--u, 1px)); }
.pos-change strong { font-size: calc(24 * var(--u, 1px)); font-family: var(--font-num); }
.pos-change strong.is-short { color: var(--c-warn-text); }
.pos-credit-who { margin: 0; font-size: var(--fs-sm); }
.pos-credit-who.is-warn { color: var(--c-warn-text); font-weight: 600; }
.pos-complete { width: 100%; min-height: 54px; margin-top: auto; background: #1E7B34; border: 0; color: #fff; font-size: calc(16 * var(--u, 1px)); font-weight: 800; letter-spacing: .4px; }
.pos-complete:hover { background: #17652a; }
.pos-complete .fkey { background: rgba(255,255,255,.16); color: #fff; border-color: rgba(255,255,255,.55); }
.pos-complete:disabled { opacity: .6; cursor: wait; }
@media (max-width: 1280px) { .pos-cols { grid-template-columns: 290px minmax(0, 1fr) 300px; } .pos-grand-val { font-size: calc(32 * var(--u, 1px)); } }
@media (max-width: 1080px) { .pos-cols { grid-template-columns: 1fr; } .pos-mid { min-height: 300px; } }

/* ---------- Dashboard: layout rows + 7-day bar chart ---------- */
.dash-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: var(--gap); align-items: start; }
.dash-half { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--gap); align-items: start; }
.kpi-sub { font-size: var(--fs-sm); color: var(--c-text-muted); text-align: right; }
.kpi-sub .up { color: var(--c-pos); font-weight: 600; }
.kpi-sub .down { color: var(--c-neg); font-weight: 600; }
.bar-chart { display: flex; align-items: flex-end; gap: calc(var(--gap) * 1.2); height: 170px; padding: var(--gap) var(--gap) 0; border-bottom: 1px solid var(--c-border);
  background-image: linear-gradient(var(--c-chart-grid) 1px, transparent 1px); background-size: 100% 25%; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar { width: 100%; max-width: 46px; background: var(--c-chart-bar); border-radius: var(--radius) var(--radius) 0 0; min-height: 2px; }
.bar-col.is-today .bar { background: var(--c-chart-bar-hi); }
.bar-val { font-family: var(--font-num); font-size: var(--fs-xs); color: var(--c-text-muted); margin-bottom: 2px; white-space: nowrap; }
.bar-labels { display: flex; gap: calc(var(--gap) * 1.2); padding: 4px var(--gap) 0; }
.bar-labels span { flex: 1; text-align: center; font-size: var(--fs-xs); color: var(--c-text-muted); text-transform: uppercase; }
.panel-head .head-link { margin-left: auto; font-size: var(--fs-sm); font-weight: 400; }

/* ===== Billing layout redesign ===== */
/* /billing as a one-screen dashboard: the page never scrolls. Header,
   toolbars and status bar keep their height; the three columns share the
   rest. Only the item table (and the left panel, when it is long) scroll
   inside. Layout only: no element, id or class used by the scripts changed.
   Remove this whole block to go back to the old look. */
body[data-page="billing"] {
  --bl-card-border: #e5e7eb; --bl-line: #eef0f3; --bl-radius: 8px;
  height: 100vh; overflow: hidden; display: flex; flex-direction: column;
  padding-bottom: 0 !important; background: #f4f6f9;
}
body[data-page="billing"] > .impersonate-banner,
body[data-page="billing"] > .shell-top,
body[data-page="billing"] > .shell-toolbar { flex: 0 0 auto; }
body[data-page="billing"] .statusbar { position: static; flex: 0 0 auto; }
body[data-page="billing"] main.wrap-wide {
  flex: 1 1 auto; min-height: 0; width: 100%; max-width: 1800px;
  padding: 8px 12px; display: flex; flex-direction: column; gap: 8px;
}
body[data-page="billing"] main.wrap-wide > p { flex: 0 0 auto; margin: 0; }   /* flash message */

/* Cards */
body[data-page="billing"] .pos { flex: 1 1 auto; min-height: 0; gap: 8px; }
body[data-page="billing"] .pos-left,
body[data-page="billing"] .pos-mid,
body[data-page="billing"] .pos-right {
  background: #fff; border: 1px solid var(--bl-card-border); border-radius: var(--bl-radius);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .05);
}
/* Bill toolbar strip and its buttons look like the Product page's action bar (.filterbar + .btn-primary/.btn-secondary). */
body[data-page="billing"] .pos-bar { flex: 0 0 auto; background: var(--c-toolbar); padding: var(--gap); gap: var(--gap); }
/* Bill toolbar (New Bill, Hold, Recall, chip, Test bill, Print/Save): always
   one line; when the screen is too narrow it scrolls sideways (swipe on
   touch, mouse wheel / Shift+wheel on PC) instead of wrapping or cutting off. */
body[data-page="billing"] .pos-bar {
  flex-wrap: nowrap; min-width: 0; overflow-x: auto; overflow-y: hidden;
  -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; scroll-snap-type: x proximity;
  scrollbar-width: thin; scrollbar-color: var(--c-border-strong) transparent;
}
body[data-page="billing"] .pos-bar::-webkit-scrollbar { height: 5px; }
body[data-page="billing"] .pos-bar::-webkit-scrollbar-thumb { background: var(--c-border-strong); border-radius: 3px; }
body[data-page="billing"] .pos-bar > * { flex: 0 0 auto; white-space: nowrap; scroll-snap-align: start; }

/* Three columns filling the remaining height */
body[data-page="billing"] .pos-cols {
  flex: 1 1 auto; min-height: 0; gap: 8px;
  grid-template-columns: var(--pos-left-w, 330px) minmax(0, 1fr) var(--pos-right-w, 372px); grid-template-rows: minmax(0, 1fr);
  position: relative;
}
body[data-page="billing"] .pos-left,
body[data-page="billing"] .pos-right { min-height: 0; overflow-y: auto; padding: 12px; }

/* Left: customer + scan, stacked tightly */
body[data-page="billing"] .pos-left { gap: 12px; }
body[data-page="billing"] .pos-block { gap: 8px; }
body[data-page="billing"] .pos-left .form-field { flex: 0 0 auto; }   /* fields no longer stretch to fill the panel */
body[data-page="billing"] .pos-left .form-field > span { font-size: calc(13 * var(--u, 1px)); font-weight: 600; color: var(--c-text-muted); }
body[data-page="billing"] .pos-left .form-field input { min-height: 38px; font-size: var(--fs-base); }
body[data-page="billing"] .pos-left .small-note { margin: 0; line-height: 1.35; }
body[data-page="billing"] .pos-newcust { padding: 8px; }
body[data-page="billing"] .pos-newcust .form-row { gap: 8px; margin-bottom: 0; }
body[data-page="billing"] .pos-scanblock { padding: 10px; border-color: var(--bl-card-border); }
body[data-page="billing"] .pos-scan input { min-height: 40px; font-size: var(--fs-md); }
body[data-page="billing"] .pos-fast-btn { min-height: 52px; }
body[data-page="billing"] .pos-cat { min-height: 32px; }

/* New customer quick-add (notice + inline form) */
.pos-qa-notice { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 10px; border-radius: 6px; background: #fff7e6; border: 1px solid #f3d9a4; color: #7a4b00; font-size: calc(13 * var(--u, 1px)); font-weight: 600; }
.pos-qa-notice[hidden], .pos-qa[hidden] { display: none; }
.pos-qa-notice .btn-link { font-size: calc(13 * var(--u, 1px)); font-weight: 600; }
.pos-qa { display: flex; flex-direction: column; gap: 8px; padding: 10px; border: 1px solid var(--c-navy); border-radius: 8px; background: #f8fafc; }
.pos-qa-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pos-qa .form-field { flex: 0 0 auto; min-width: 0; }
.pos-qa .form-field input { min-height: 36px; width: 100%; }
.pos-qa-actions { display: flex; gap: 8px; }
.pos-qa-actions .btn-primary { background: var(--c-navy); border-color: var(--c-navy); }
.pos-qa-actions button { flex: 1; min-height: 34px; }
.pos-qa .field-error { margin: 0; }

/* Middle: items table, header fixed, rows scroll inside */
body[data-page="billing"] .pos-mid { min-height: 0; overflow: auto; }
body[data-page="billing"] #cart-filler { display: none; }   /* no empty row lines */
body[data-page="billing"] .pos-grid { table-layout: fixed; }
body[data-page="billing"] .pos-grid thead th {
  background: #f3f4f6; font-size: calc(12.5 * var(--u, 1px)); font-weight: 600; color: var(--c-text-muted);
  padding: 9px 8px; border-bottom: 1px solid var(--bl-card-border);
}
body[data-page="billing"] .pos-grid td { height: 40px; padding: 4px 8px; border-bottom: 1px solid var(--bl-line); }
body[data-page="billing"] .pos-grid tbody#cart-rows tr:nth-child(even) td { background: #fafbfc; }
body[data-page="billing"] .pos-grid tbody#cart-rows tr.is-hi td { background: #E8F0FA; }
body[data-page="billing"] .pos-grid .c-no { width: 40px; }
body[data-page="billing"] .pos-grid .c-code { width: 120px; overflow: hidden; text-overflow: ellipsis; }
body[data-page="billing"] .pos-grid .c-qty { width: 80px; }
body[data-page="billing"] .pos-grid .c-price { width: 100px; }
body[data-page="billing"] .pos-grid .c-disc { width: 80px; }
body[data-page="billing"] .pos-grid .c-total { width: 110px; text-align: right; }
body[data-page="billing"] .pos-grid .c-act { width: 84px; }
body[data-page="billing"] .pos-grid td input { max-width: 100%; }
body[data-page="billing"] .pos-empty { top: 50%; transform: translateY(-50%); }

/* Right: compact totals, grand total, payment, tender, complete */
body[data-page="billing"] .pos-right { gap: 8px; }
body[data-page="billing"] .pos-sum td { height: 30px; padding: 2px 0; border-bottom: 1px solid var(--bl-line); font-size: var(--fs-base); }
body[data-page="billing"] .pos-sum td.num { font-variant-numeric: tabular-nums; }
body[data-page="billing"] .pos-sum tr.net td { padding-top: 2px; font-weight: 600; }
body[data-page="billing"] .pos-sum small { display: inline; margin-left: 4px; }
body[data-page="billing"] .pos-grand { padding: 8px; margin-top: 0; border-bottom-width: 3px; border-radius: var(--bl-radius); }
body[data-page="billing"] .pos-grand-label { font-size: calc(12.5 * var(--u, 1px)); }
body[data-page="billing"] .pos-grand-val { font-size: calc(34 * var(--u, 1px)); }
body[data-page="billing"] .pos-right > .pos-label { margin-top: 4px !important; }
body[data-page="billing"] .pos-pay { gap: 8px; }
body[data-page="billing"] .pos-pay-btn { min-height: 50px; font-size: calc(13.5 * var(--u, 1px)); }
body[data-page="billing"] .pos-pay-btn span { font-size: calc(18 * var(--u, 1px)); }
body[data-page="billing"] .pos-pane { padding: 8px 10px; gap: 4px; border-color: var(--bl-card-border); }
body[data-page="billing"] .pos-tender { min-height: 40px !important; font-size: calc(22 * var(--u, 1px)) !important; }
body[data-page="billing"] .pos-change { padding-top: 4px; }
body[data-page="billing"] .pos-change strong { font-size: calc(20 * var(--u, 1px)); }
body[data-page="billing"] .pos-complete { flex: 0 0 auto; min-height: 46px; }

/* Smaller screens (1366 wide and below): slightly narrower columns. */
@media (max-width: 1440px) {
  body[data-page="billing"] .pos-cols { grid-template-columns: var(--pos-left-w, 300px) minmax(0, 1fr) var(--pos-right-w, 340px); }
  body[data-page="billing"] .pos-grid .c-code { width: 100px; }
}
/* Short screens (1366x768 laptops): tighter rows so everything stays in view. */
@media (max-height: 820px) {
  body[data-page="billing"] main.wrap-wide { padding: 6px 10px; gap: 6px; }
  body[data-page="billing"] .pos, body[data-page="billing"] .pos-cols { gap: 6px; }
  body[data-page="billing"] .pos-left, body[data-page="billing"] .pos-right { padding: 8px 10px; gap: 6px; }
  body[data-page="billing"] .pos-block { gap: 6px; }
  body[data-page="billing"] .pos-left .form-field input { min-height: 34px; }
  body[data-page="billing"] .pos-scan input { min-height: 36px; }
  body[data-page="billing"] .pos-sum td { height: 25px; font-size: calc(13.5 * var(--u, 1px)); }
  body[data-page="billing"] .pos-billdisc select, body[data-page="billing"] .pos-billdisc input { min-height: 22px; }
  body[data-page="billing"] .pos-grand { padding: 4px 8px 5px; }
  body[data-page="billing"] .pos-grand-label { font-size: calc(12 * var(--u, 1px)); }
  body[data-page="billing"] .pos-grand-val { font-size: calc(28 * var(--u, 1px)); }
  body[data-page="billing"] .pos-pay { gap: 6px; }
  body[data-page="billing"] .pos-pay-btn { min-height: 38px; flex-direction: row; gap: 6px; }
  body[data-page="billing"] .pos-pay-btn span { font-size: calc(15 * var(--u, 1px)); }
  body[data-page="billing"] .pos-pane { padding: 5px 8px; gap: 3px; }
  body[data-page="billing"] .pos-pane .pos-label { font-size: calc(12 * var(--u, 1px)); }
  body[data-page="billing"] .pos-tender { min-height: 34px !important; font-size: calc(19 * var(--u, 1px)) !important; }
  body[data-page="billing"] .pos-change { padding-top: 2px; font-size: calc(12.5 * var(--u, 1px)); }
  body[data-page="billing"] .pos-change strong { font-size: calc(17 * var(--u, 1px)); }
  body[data-page="billing"] .pos-complete { min-height: 38px; font-size: calc(15 * var(--u, 1px)); }
  body[data-page="billing"] .pos-grid td { height: 36px; }
}
/* 1366x768 laptops: the browser chrome leaves roughly 650px of viewport */
@media (max-height: 700px) {
  body[data-page="billing"] { --nav-h: 48px; }   /* menu tabs a little shorter only on short screens (action toolbar keeps the Product page size) */
  body[data-page="billing"] main.wrap-wide { padding: 4px 8px; gap: 4px; }
  body[data-page="billing"] .pos, body[data-page="billing"] .pos-cols { gap: 4px; }
  body[data-page="billing"] .pos-left, body[data-page="billing"] .pos-right { padding: 6px 8px; gap: 4px; }
  body[data-page="billing"] .pos-block { gap: 4px; }
  body[data-page="billing"] .pos-sum td { height: 22px; font-size: calc(13 * var(--u, 1px)); }
  body[data-page="billing"] .pos-grand-val { font-size: calc(24 * var(--u, 1px)); }
  body[data-page="billing"] .pos-pay-btn { min-height: 34px; }
  body[data-page="billing"] .pos-tender { min-height: 32px !important; font-size: calc(18 * var(--u, 1px)) !important; }
  body[data-page="billing"] .pos-complete { min-height: 34px; }
  body[data-page="billing"] .pos-left .form-field input { min-height: 32px; }
  body[data-page="billing"] .pos-grid td { height: 32px; }
}
/* ===== end Billing layout redesign ===== */

/* Billing: drag the edge between two panels to make them wider / narrower
   (double-click = back to normal). Widths are remembered on each computer. */
.pos-resizer { position: absolute; top: 0; bottom: 0; width: 10px; margin-left: -5px; cursor: col-resize; z-index: 5; touch-action: none; }
.pos-resizer::after { content: ""; position: absolute; top: 50%; left: 3px; width: 4px; height: 44px; margin-top: -22px; border-radius: 2px; background: var(--c-border-strong, #b8c0cc); opacity: .55; }
.pos-resizer:hover::after, .pos-resizer.is-dragging::after { background: var(--c-blue, #1B3B6F); opacity: 1; }
body.pos-resizing, body.pos-resizing * { cursor: col-resize !important; user-select: none !important; }
@media (max-width: 1080px) { .pos-resizer { display: none; } }
