/* ============================================================
   Snow Sweets Agency — Billing Software
   Design tokens
   ============================================================ */
:root {
  --navy-950: #071B32;
  --navy-900: #0A2A4A;
  --navy-800: #123A61;
  --blue-600: #1E73C7;
  --blue-500: #2E86DE;
  --blue-100: #E4F0FC;
  --ice: #FFFFFF;
  --paper: #F3F7FB;
  --paper-dim: #E9F0F7;
  --slate-700: #33415C;
  --slate-500: #64748B;
  --slate-300: #C7D2DE;
  --line: #DCE5EE;
  --mint-600: #16A34A;
  --mint-100: #DCFCE7;
  --amber-600: #D97706;
  --amber-100: #FEF3C7;
  --red-600: #DC2626;
  --red-100: #FEE2E2;
  --teal-600: #0D9488;
  --teal-100: #CCFBF1;
  --violet-600: #7C3AED;
  --violet-100: #EDE4FD;

  --font-display: "Outfit", "Segoe UI", system-ui, sans-serif;
  --font-body: "Inter", "Segoe UI", system-ui, sans-serif;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-card: 0 1px 2px rgba(10, 42, 74, 0.06), 0 1px 0 rgba(10, 42, 74, 0.04);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--slate-700);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, .display {
  font-family: var(--font-display);
  color: var(--navy-900);
  margin: 0;
}
a { color: inherit; }
button { font-family: inherit; }
::selection { background: var(--blue-100); }

/* ---------------- App shell ---------------- */
#app { display: none; }
#app.ready { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--navy-950), var(--navy-900) 60%);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 22px;
}
.sidebar-brand img { width: 34px; height: 34px; border-radius: 8px; }
.sidebar-brand .name { font-family: var(--font-display); font-weight: 600; font-size: 15px; line-height: 1.15; }
.sidebar-brand .sub { font-size: 10.5px; letter-spacing: .04em; color: #9FC2E8; }

.nav-group { display: flex; flex-direction: column; gap: 2px; margin-bottom: 18px; }
.nav-label { font-size: 10.5px; color: #6E93BB; padding: 10px 10px 4px; letter-spacing: .03em; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 500; color: #CFE0F2;
  cursor: pointer; text-decoration: none; border: none; background: none; width: 100%; text-align: left;
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; opacity: .85; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--blue-600); color: #fff; }
.nav-item.active svg { opacity: 1; }
/* red count of pending orders on the Orders menu item (admin + billing staff) */
.nav-badge { margin-left: auto; min-width: 20px; padding: 1px 6px; border-radius: 999px; background: #E5484D; color: #fff; font-size: 11px; font-weight: 700; line-height: 1.5; text-align: center; }

.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid rgba(255,255,255,.09); }
.who { font-size: 12.5px; color: #DCE9F7; padding: 6px 10px 2px; }
.who .role { color: #7FA8D2; font-size: 11px; }
.logout-btn {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 8px 10px; margin-top: 4px; border-radius: var(--radius-sm);
  background: none; border: none; color: #B9CFE6; font-size: 12.5px; cursor: pointer;
}
.logout-btn:hover { background: rgba(255,255,255,.07); color: #fff; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 26px; background: var(--ice); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 19px; font-weight: 600; }
.topbar .today-strip { display: flex; gap: 18px; font-size: 12.5px; color: var(--slate-500); }
.topbar .today-strip b { color: var(--navy-900); font-family: var(--font-display); font-size: 14px; }
.menu-toggle { display: none; background: none; border: none; color: var(--navy-900); }

.view { padding: 22px 26px 48px; flex: 1; }
.view-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.view-head p.hint { color: var(--slate-500); font-size: 13px; margin: 3px 0 0; }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 15px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-size: 13.5px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn-primary { background: var(--blue-600); color: #fff; }
.btn-primary:hover { background: var(--blue-500); }
.btn-ghost { background: var(--ice); color: var(--slate-700); border-color: var(--line); }
.btn-ghost:hover { background: var(--paper-dim); }
.btn-danger { background: var(--red-100); color: var(--red-600); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { background: none; border: none; cursor: pointer; color: var(--slate-500); padding: 4px; border-radius: 6px; }
.icon-btn:hover { background: var(--paper-dim); color: var(--navy-900); }

/* ---------------- Cards & KPIs ---------------- */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi-card {
  position: relative;
  background: var(--ice); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 18px 18px 16px; box-shadow: var(--shadow-card); overflow: hidden;
  transition: transform .15s ease, box-shadow .15s ease;
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(10,42,74,.09), 0 1px 0 rgba(10,42,74,.04); }
.kpi-card.kpi-clickable { cursor: pointer; }
.kpi-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--kpi-accent, var(--blue-600)); }
.kpi-card .top-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.kpi-card .icon-badge {
  width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--kpi-accent-bg, var(--blue-100)); color: var(--kpi-accent, var(--blue-600));
}
.kpi-card .icon-badge svg { width: 18px; height: 18px; }
.kpi-card .label { font-size: 11px; color: var(--slate-500); font-weight: 700; letter-spacing: .02em; }
.kpi-card .value { font-family: var(--font-display); font-size: 26px; font-weight: 600; color: var(--navy-900); margin-top: 10px; }
.kpi-card .delta { font-size: 11.5px; margin-top: 3px; color: var(--slate-500); }
.kpi-card .delta.up { color: var(--mint-600); font-weight: 600; }
.kpi-card .delta.down { color: var(--red-600); font-weight: 600; }
.kpi-card.c-blue { --kpi-accent: var(--blue-600); --kpi-accent-bg: var(--blue-100); }
.kpi-card.c-teal { --kpi-accent: var(--teal-600); --kpi-accent-bg: var(--teal-100); }
.kpi-card.c-amber { --kpi-accent: var(--amber-600); --kpi-accent-bg: var(--amber-100); }
.kpi-card.c-red { --kpi-accent: var(--red-600); --kpi-accent-bg: var(--red-100); }
.kpi-card.c-violet { --kpi-accent: var(--violet-600); --kpi-accent-bg: var(--violet-100); }

/* ---------------- Trend chart ---------------- */
.trend-card { display: flex; flex-direction: column; }
.trend-bars { display: flex; align-items: flex-end; gap: 10px; height: 110px; margin-top: 14px; padding: 0 2px; }
.trend-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.trend-bar {
  width: 100%; max-width: 34px; border-radius: 6px 6px 3px 3px;
  background: linear-gradient(180deg, var(--blue-500), var(--blue-600));
  min-height: 3px; transition: opacity .15s ease;
}
.trend-bar.today { background: linear-gradient(180deg, var(--teal-600), #0B7A70); }
.trend-bar-col:hover .trend-bar { opacity: .85; }
.trend-bar-label { font-size: 10.5px; color: var(--slate-500); font-weight: 600; }
.trend-bar-val { font-size: 10px; color: var(--slate-500); }

.card {
  background: var(--ice); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card); padding: 18px;
}
.card + .card { margin-top: 16px; }
.card h3 { font-size: 14.5px; margin-bottom: 12px; }
.card h3.with-icon { display: flex; align-items: center; gap: 8px; }
.card h3.with-icon .h-icon {
  width: 26px; height: 26px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
  background: var(--h-icon-bg, var(--blue-100)); color: var(--h-icon-fg, var(--blue-600)); flex-shrink: 0;
}
.card h3.with-icon .h-icon svg { width: 14px; height: 14px; }

.two-col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; align-items: start; }
/* On tablets and phones the page is a single column, and wide content (tables, the billing
   grid) used to stretch that column — and the whole page, with its Save button — past the
   screen edge. Let boxes shrink to the screen instead. (Desktop layout is left as it was.) */
@media (max-width: 980px) {
  .main, .view, .card, .two-col > *, .kpi-row > * { min-width: 0; }
  .card { max-width: 100%; }
}
@media (max-width: 980px) { .two-col { grid-template-columns: 1fr; } }

/* ---------------- Tables ---------------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--ice); }
.table-wrap.scroll5 { max-height: 226px; overflow-y: auto; }
.table-wrap.scroll5 thead th { position: sticky; top: 0; z-index: 1; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left; font-size: 11px; color: var(--slate-500); font-weight: 600;
  padding: 10px 14px; background: var(--paper-dim); border-bottom: 1px solid var(--line); white-space: nowrap;
}
tbody td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--paper); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }

.badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 99px; font-size: 11px; font-weight: 600; }
.badge.paid { background: var(--mint-100); color: var(--mint-600); }
.badge.partial { background: var(--amber-100); color: var(--amber-600); }
.badge.unpaid { background: var(--red-100); color: var(--red-600); }
.badge.low { background: var(--red-100); color: var(--red-600); }

.empty-state { text-align: center; padding: 46px 20px; color: var(--slate-500); }
.hint { font-size: 12.5px; line-height: 1.45; color: var(--slate-500); }
.empty-state .em-icon { font-size: 30px; margin-bottom: 8px; }

/* ---------------- Forms ---------------- */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 13px; }
.field label { font-size: 12px; font-weight: 600; color: var(--slate-700); }
.field .opt { font-weight: 400; color: var(--slate-500); }
input, select, textarea {
  font-family: inherit; font-size: 13.5px; padding: 9px 11px;
  border: 1px solid var(--slate-300); border-radius: var(--radius-sm); background: #fff; color: var(--slate-700);
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue-500); box-shadow: 0 0 0 3px var(--blue-100); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 600px) { .form-grid, .form-grid.cols-3 { grid-template-columns: 1fr; } }

/* ---------------- Modal ---------------- */
.overlay {
  position: fixed; inset: 0; background: rgba(7, 27, 50, .45);
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px;
  z-index: 40; overflow-y: auto;
}
.overlay.hidden { display: none; }
.modal {
  background: #fff; border-radius: var(--radius-lg); width: 100%; max-width: 560px;
  box-shadow: 0 20px 50px rgba(7,27,50,.25);
}
.modal.wide { max-width: 760px; }

/* Full-screen window (e.g. New purchase): fills the whole screen, covers the
   sidebar, and has no click-outside-to-close — only its own Close button. */
.overlay.fullscreen { padding: 0; align-items: stretch; background: var(--paper); overflow: hidden; }
.modal.fullscreen { max-width: none; width: 100%; height: 100%; border-radius: 0; box-shadow: none; display: flex; flex-direction: column; }
.modal.fullscreen .modal-head { padding: 14px 28px; flex-shrink: 0; }
.modal.fullscreen .modal-body { max-height: none; flex: 1; min-height: 0; overflow-y: auto; padding: 22px 28px; }
.modal.fullscreen .modal-foot { padding: 14px 28px; flex-shrink: 0; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 15.5px; }
.modal-body { padding: 20px; max-height: 72vh; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); }

/* ---------------- Billing / invoice line editor ---------------- */
/* Dense accounting-grid look for the line-item table: dark header row, tight
   rows, grid borders on every cell, zebra striping, item name + a compact
   subtitle line (brand/HSN) underneath — like a traditional billing grid. */
.line-table { border: 1px solid var(--navy-900); border-collapse: collapse; }
.line-table thead th {
  background: var(--navy-900); color: #E8F1FC; font-size: 10.5px; font-weight: 700;
  padding: 6px 8px; border-right: 1px solid rgba(255,255,255,.12);
}
.line-table th, .line-table td { padding: 5px 8px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.line-table td:last-child, .line-table th:last-child { border-right: none; }
.line-table tbody tr:nth-child(even) { background: var(--paper-dim); }
.line-table tbody tr:hover { background: var(--blue-100); }
.line-table input, .line-table select { padding: 5px 7px; font-size: 12.5px; }
.line-table td.amt { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--navy-900); }
.line-table .item-sub { font-size: 10px; color: var(--slate-500); margin-top: 2px; line-height: 1.3; }
.line-table .batch-cell select { width: 100%; min-width: 170px; font-size: 11.5px; }
.line-table .batch-cell select.shortage { border-color: var(--red-600); background: var(--red-100); color: var(--red-600); }

/* ---------------- Product search picker ---------------- */
.product-picker { min-width: 160px; }
.product-picker input { width: 100%; }
.pp-results {
  position: fixed; z-index: 300;
  background: #fff; border: 1px solid var(--slate-300); border-radius: var(--radius-sm);
  box-shadow: 0 10px 26px rgba(10,42,74,.16); max-height: 260px; overflow-y: auto;
}
.pp-results[hidden] { display: none; }
.pp-item { padding: 7px 10px; font-size: 12.5px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
.pp-item:hover { background: var(--paper-dim); }
/* the row the arrow keys are on — strong enough to see at a glance */
.pp-item.active { background: var(--blue-600); color: #fff; }
.pp-item .pp-meta { color: var(--slate-500); font-size: 11px; white-space: nowrap; }
.pp-item.active .pp-meta { color: #DCEBFA; }
/* "+ Add new product" — pinned to the bottom of the list so it's always in reach */
.pp-add { position: sticky; bottom: 0; padding: 9px 10px; font-size: 12.5px; font-weight: 600; color: var(--blue-600); background: #F4F9FF; border-top: 1px solid var(--line); cursor: pointer; }
.pp-add:hover { background: var(--blue-100); }
.pp-add.active { background: var(--blue-600); color: #fff; }
.pp-empty { padding: 10px; font-size: 12.5px; color: var(--slate-500); text-align: center; }
.add-line-btn { margin-top: 8px; }
.invoice-total-strip {
  display: flex; justify-content: flex-end; gap: 26px; padding: 12px 14px; margin-top: 0;
  background: var(--navy-950); border: 1px solid var(--navy-900); border-top: none; border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}
.invoice-total-strip .t-label { font-size: 11px; color: #9FC2E8; }
.invoice-total-strip .t-val { font-family: var(--font-display); font-size: 15px; color: #fff; }
.invoice-total-strip .t-val.grand { font-size: 20px; color: var(--teal-100 ,#fff); }
.invoice-total-strip input { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.25); color: #fff; }

/* ---------------- Login ---------------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 50% -10%, var(--navy-800), var(--navy-950) 60%);
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 360px; background: #fff; border-radius: var(--radius-lg);
  padding: 30px 28px; box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.login-card img { width: 54px; height: 54px; border-radius: 12px; display: block; margin: 0 auto 10px; }
.login-card .brand-title { text-align: center; font-family: var(--font-display); font-weight: 700; font-size: 19px; color: var(--navy-900); }
.login-card .brand-sub { text-align: center; font-size: 11.5px; color: var(--slate-500); letter-spacing: .04em; margin-bottom: 22px; }
.login-card .btn-primary { width: 100%; justify-content: center; padding: 10px; margin-top: 4px; }
.login-err { background: var(--red-100); color: var(--red-600); font-size: 12.5px; padding: 8px 11px; border-radius: 8px; margin-bottom: 12px; display: none; }

/* ---------------- Toast ---------------- */
#toast-host { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 80; }
.toast { background: var(--navy-900); color: #fff; padding: 10px 16px; border-radius: 9px; font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.toast.error { background: var(--red-600); }
.toast.success { background: var(--mint-600); }

/* ---------------- Print (invoice) ---------------- */
@media print {
  body * { visibility: hidden; }
  #print-area, #print-area * { visibility: visible; }
  #print-area { position: absolute; top: 0; left: 0; width: 100%; }
}

/* ---------------- Responsive ---------------- */
@media (max-width: 860px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 30; transform: translateX(-100%); transition: transform .2s ease; }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: inline-flex; }
  .view { padding: 16px 14px 40px; }
  .topbar { padding: 12px 14px; }
  .topbar .today-strip { display: none; }
  /* tap anywhere outside the menu drawer to close it */
  #nav-backdrop { position: fixed; inset: 0; z-index: 29; background: rgba(7,27,50,.45); }
  body.nav-open #nav-backdrop { display: block; }
}


/* =====================================================================
   PHONE LAYOUT (screens up to 700px wide)
   Goal: every screen fits the width of the phone — nothing to pinch,
   stretch or swipe sideways. Tables become cards, the line-entry grids
   become one card per item, pop-ups slide up as sheets, and the main
   screens are one tap away in a bottom tab bar.
   ===================================================================== */
.bottom-nav { display: none; }
#nav-backdrop { display: none; }

@media (max-width: 700px) {
  /* ---- shell ---- */
  .view { padding: 12px 12px calc(84px + env(safe-area-inset-bottom)); }
  .topbar { padding: 10px 14px; position: sticky; top: 0; z-index: 20; }
  .topbar h1 { font-size: 18px; }
  .card { padding: 14px; border-radius: 14px; }
  .card h3 { font-size: 15px; }
  .view-head { margin-bottom: 12px; }
  .view-head .btn { min-height: 44px; }

  /* bottom tab bar */
  .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
    background: #fff; border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -4px 16px rgba(10,42,74,.07);
  }
  .bn-item {
    flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 8px 2px 7px; font-size: 10.5px; font-weight: 600; color: var(--slate-500);
    text-decoration: none; position: relative; background: none; border: 0; cursor: pointer; font-family: inherit;
    -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  }
  .bn-item svg { width: 22px; height: 22px; }
  .bn-item span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .bn-item.active { color: var(--blue-600); }
  .bn-item.active::before { content: ""; position: absolute; top: 0; left: 24%; right: 24%; height: 3px; border-radius: 0 0 3px 3px; background: var(--blue-600); }
  .bn-item .nav-badge { position: absolute; top: 3px; left: calc(50% + 7px); margin: 0; min-width: 17px; padding: 0 5px; font-size: 10px; line-height: 17px; }

  .sidebar { width: min(82vw, 290px); }

  /* pop-up messages sit above the tab bar */
  #toast-host { left: 12px; right: 12px; bottom: calc(76px + env(safe-area-inset-bottom)); align-items: stretch; }

  /* ---- touch-friendly controls (16px stops iPhones zooming in when you tap a box) ---- */
  input, select, textarea { font-size: 16px; padding: 11px 12px; min-height: 44px; }
  .field { margin-bottom: 12px; }
  .field label { font-size: 12.5px; }
  .btn { min-height: 44px; padding: 10px 16px; font-size: 14px; touch-action: manipulation; }
  .btn-sm { min-height: 40px; padding: 8px 14px; font-size: 13px; }
  .icon-btn { min-width: 40px; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; font-size: 16px; }
  .form-grid, .form-grid.cols-3 { grid-template-columns: 1fr; }

  /* ---- dashboard cards ---- */
  .kpi-row { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
  .kpi-card { padding: 12px; }
  .kpi-card .value { font-size: 20px; margin-top: 6px; overflow-wrap: anywhere; }
  .kpi-card .label { font-size: 10.5px; }
  .kpi-card .delta { font-size: 11px; }
  .kpi-card .icon-badge { width: 30px; height: 30px; }
  .kpi-card:hover { transform: none; }
  .trend-bars { gap: 6px; }
  .kpi-row > :last-child:nth-child(odd) { grid-column: 1 / -1; }  /* an odd one out uses the full width */
  .kbd-hint { display: none !important; }  /* keyboard tips mean nothing on a phone */

  /* ---- TABLES → CARDS: one small card per row, column names shown as labels ---- */
  .table-wrap:not(:has(.line-table)) { border: none; background: transparent; overflow: visible; max-height: none; border-radius: 0; }
  .table-wrap:not(:has(.line-table)) table,
  .table-wrap:not(:has(.line-table)) tbody { display: block; width: 100%; }
  .table-wrap:not(:has(.line-table)) thead { display: none; }
  .table-wrap:not(:has(.line-table)) tbody tr {
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; align-items: start;
    padding: 12px 14px; margin-bottom: 10px;
    background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 1px 2px rgba(10,42,74,.04);
  }
  .table-wrap:not(:has(.line-table)) tbody tr:hover { background: #fff; }
  .table-wrap:not(:has(.line-table)) tbody tr.invoice-row:active { background: var(--blue-100); }
  .table-wrap:not(:has(.line-table)) td { display: block; padding: 0; border: 0; min-width: 0; text-align: left !important; overflow-wrap: anywhere; font-size: 14px; }
  .table-wrap:not(:has(.line-table)) td[data-label]::before {
    content: attr(data-label); display: block; margin-bottom: 1px;
    font-size: 10px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--slate-500);
  }
  /* first cell = the card's title */
  .table-wrap:not(:has(.line-table)) td:first-child { grid-column: 1 / -1; font-weight: 700; font-size: 15px; color: var(--navy-900); }
  .table-wrap:not(:has(.line-table)) td:first-child::before { display: none; }
  .table-wrap:not(:has(.line-table)) td[colspan] { grid-column: 1 / -1; }
  .table-wrap:not(:has(.line-table)) td.row-actions {
    grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end;
    padding-top: 8px; border-top: 1px dashed var(--line);
  }
  .table-wrap:not(:has(.line-table)) td.row-actions:empty { display: none; }
  .table-wrap:not(:has(.line-table)) td .btn-sm { flex: 1 1 auto; justify-content: center; }
  .empty-state { padding: 30px 14px; }

  /* ---- POP-UPS → bottom sheets ---- */
  .overlay { padding: 0; align-items: flex-end; }
  .modal:not(.fullscreen), .modal.wide:not(.fullscreen) {
    max-width: 100%; border-radius: 18px 18px 0 0; max-height: 92vh; max-height: 92dvh;
    display: flex; flex-direction: column;
  }
  .modal:not(.fullscreen) .modal-body { max-height: none; flex: 1; min-height: 0; padding: 14px 16px; -webkit-overflow-scrolling: touch; }
  .modal-head { padding: 14px 16px; }
  .modal-foot { flex-wrap: wrap; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
  .modal-foot .btn { flex: 1 1 auto; justify-content: center; }
  .modal.fullscreen .modal-head { padding: 12px 14px; }
  .modal.fullscreen .modal-body { padding: 12px; }
  .modal.fullscreen .modal-foot { padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); }

  /* ---- LINE-ENTRY GRIDS → one card per item (Billing, Purchases, Orders) ---- */
  .table-wrap:has(.line-table) { border: none; background: transparent; overflow: visible; border-radius: 0; }
  .line-table, .line-table tbody { display: block; border: none; width: 100%; }
  .line-table thead { display: none; }
  .line-table tbody tr {
    display: grid; gap: 10px 10px; position: relative; padding: 14px; margin-bottom: 12px;
    background: #fff !important; border: 1px solid var(--slate-300); border-radius: 12px;
  }
  .line-table th, .line-table td { border: 0; padding: 0; }
  .line-table td { display: block; min-width: 0; text-align: left !important; }
  .line-table td::before {
    display: block; margin-bottom: 2px; font-size: 10px; font-weight: 700; letter-spacing: .05em;
    text-transform: uppercase; color: var(--slate-500);
  }
  .line-table td:first-child::before { display: none; }
  .line-table input, .line-table select { width: 100% !important; min-width: 0; padding: 11px 12px; font-size: 16px; }
  .line-table .batch-cell select { min-width: 0; font-size: 14px; }
  .line-table td.amt { font-size: 15px; }
  .line-table .product-picker { min-width: 0; }
  .line-table .item-sub { font-size: 11.5px; }

  /* billing: 11 columns → Product, Batch, then Qty | Rate | Amount, then the line total.
     (HSN and the CGST/SGST breakdown stay on the printed bill; they're just not shown here.) */
  #bill-lines tbody tr { grid-template-columns: 1fr 1fr 1fr; }
  #bill-lines td:nth-child(1) { grid-column: 1 / -1; padding-right: 44px; }
  #bill-lines td:nth-child(2), #bill-lines td:nth-child(n+7):nth-child(-n+10) { display: none; }
  #bill-lines td:nth-child(3) { grid-column: 1 / -1; }
  #bill-lines td:nth-child(3)::before { content: "Batch"; }
  #bill-lines td:nth-child(4)::before { content: "Qty"; }
  #bill-lines td:nth-child(5)::before { content: "Rate ₹"; }
  #bill-lines td:nth-child(6)::before { content: "Amount"; }
  #bill-lines td:nth-child(11) { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: baseline; padding-top: 8px; border-top: 1px dashed var(--line); font-weight: 700; font-size: 16px; color: var(--navy-900); }
  #bill-lines td:nth-child(11)::before { content: "Line total"; margin: 0; font-size: 11px; }
  #bill-lines td:nth-child(12) { position: absolute; top: 6px; right: 6px; }

  /* purchases: Product, then Qty | Cost, Sell | Batch, Expiry | Amount */
  #purch-lines tbody tr { grid-template-columns: 1fr 1fr; }
  #purch-lines td:nth-child(1) { grid-column: 1 / -1; padding-right: 44px; }
  #purch-lines td:nth-child(2)::before { content: "Qty"; }
  #purch-lines td:nth-child(3)::before { content: "Cost ₹"; }
  #purch-lines td:nth-child(4)::before { content: "Sell ₹"; }
  #purch-lines td:nth-child(5)::before { content: "Batch no."; }
  #purch-lines td:nth-child(6)::before { content: "Expiry"; }
  #purch-lines td:nth-child(7)::before { content: "Amount"; }
  #purch-lines td:nth-child(8) { position: absolute; top: 6px; right: 6px; }

  /* orders: Product, then Our stock | Qty needed, then Note */
  #order-lines tbody tr { grid-template-columns: 1fr 1fr; }
  #order-lines td:nth-child(1) { grid-column: 1 / -1; padding-right: 44px; }
  #order-lines td:nth-child(2)::before { content: "Our stock"; }
  #order-lines td:nth-child(3)::before { content: "Qty needed"; }
  #order-lines td:nth-child(4) { grid-column: 1 / -1; }
  #order-lines td:nth-child(4)::before { content: "Note"; }
  #order-lines td:nth-child(5) { position: absolute; top: 6px; right: 6px; }

  /* billing totals strip + actions */
  .invoice-total-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 10px; padding: 14px; border-radius: 12px; border: none; margin-top: 4px; }
  .invoice-total-strip > div:nth-child(4), .invoice-total-strip > div:nth-child(5) { grid-column: 1 / -1; }
  .invoice-total-strip .t-label { font-size: 10.5px; }
  .invoice-total-strip > div:nth-child(4) .t-label { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; }
  .invoice-total-strip > div:nth-child(4) input { width: 120px !important; margin: 0 !important; padding: 8px 10px !important; min-height: 40px; display: inline-block; }
  .invoice-total-strip > div:nth-child(5) { display: flex; align-items: baseline; justify-content: space-between; padding-top: 8px; border-top: 1px solid rgba(255,255,255,.18); }
  .invoice-total-strip .t-val { font-size: 16px; }
  .invoice-total-strip .t-val.grand { font-size: 24px; }
  #save-sale { min-height: 50px; font-size: 16px; }
  #cancel-bill { min-height: 50px; }

  /* dropdown list of products */
  .pp-item { padding: 12px; font-size: 14px; }
  .pp-add { padding: 13px 12px; font-size: 14px; }
  .pp-empty { font-size: 14px; }
}
