/* ============================================================
   BILLER BRO. — BRAND LAYER
   Loaded after styles.css. Everything the brand kit sets —
   palette, type, logo, navigation, login, install card — lives
   here, so styles.css keeps the layout rules it already had.

   Palette (brand kit)
     Primary   Navy    #03265b   trust, stability
     Secondary Orange  #e5912f   growth, efficiency
     Accent    Red     #eb212a   energy, alerts
     Background        #f5f7fb
     Text              #1a1a1a
   Type: Poppins — Bold headings, SemiBold subheads,
         Regular body, Medium captions.
   ============================================================ */

:root {
  --indigo: #03265b;
  --indigo-dark: #021b44;
  --indigo-light: #e9eff8;
  --navy: #03265b;
  --navy-deep: #021a40;
  --orange: #e5912f;
  --orange-light: #fdf3e6;
  --brand-red: #eb212a;
  --red: #eb212a;
  --red-light: #fdecec;
  --bg: #f5f7fb;
  --ink: #1a1a1a;
  --focus-ring: rgba(3, 38, 91, .18);
  --brand-grad: linear-gradient(180deg, #f39a2e 0%, #ee6a2c 55%, #e3232b 100%);
  --brand-grad-x: linear-gradient(90deg, #f39a2e 0%, #e3232b 100%);

  /* UI icon colours (brand kit "App UI icon style") */
  --ic-blue: #1f5fd1;
  --ic-orange: #e5912f;
  --ic-red: #eb212a;
  --ic-purple: #5b4fd1;
  --ic-dark: #2b3445;
}

body {
  font-family: "Poppins", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .topbar h1, .auth-pane h1 { font-weight: 700; }
.panel-head h3, .section-label { font-weight: 600; }

/* Icon sprite: every <svg class="i"> uses a <symbol> from the sprite */
.i {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ---------- Wordmark ---------- */
.wordmark {
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1;
  white-space: nowrap;
  color: var(--navy);
}
.wordmark b {
  font-weight: 700;
  background: var(--brand-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.wordmark sup {
  font-size: .32em;
  font-weight: 600;
  vertical-align: super;
  margin-left: 1px;
  color: currentColor;
}
.brand-sub {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .08em;
  white-space: nowrap;
}
.brand-sub::before,
.brand-sub::after {
  content: "";
  width: 16px;
  height: 1.5px;
  background: currentColor;
  opacity: .8;
}

/* ---------- Buttons ---------- */
.btn-primary { background: var(--navy); }
.btn-primary:hover { background: var(--indigo-dark); }
.btn-accent {
  background: var(--brand-grad-x);
  color: #fff;
  border-color: transparent;
}
.btn-accent:hover { filter: brightness(1.05); }
a { color: var(--navy); }

/* ---------- Sidebar ---------- */
.sidebar {
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-deep) 100%);
  color: #dbe4f3;
}
.brand {
  gap: 10px;
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, .1);
  padding: 0 16px 18px 18px;
}
.brand-mark { width: 30px; height: auto; flex-shrink: 0; display: block; }
.brand-text { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.brand .wordmark { color: #fff; font-size: 19px; }
.brand .brand-sub { color: rgba(255, 255, 255, .6); font-size: 8.5px; gap: 5px; letter-spacing: .06em; }
.brand .brand-sub::before,
.brand .brand-sub::after { width: 8px; height: 1px; }
.drawer-close { color: rgba(255, 255, 255, .7); }
.drawer-close:hover { color: #fff; }

.company-chip {
  background: rgba(255, 255, 255, .07);
  border-left-color: var(--orange);
}
.company-meta { color: rgba(255, 255, 255, .6); }

.nav-scroll { scrollbar-color: rgba(255, 255, 255, .2) transparent; }
.nav-scroll::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .2); }

.nav-item {
  color: rgba(255, 255, 255, .74);
  border-radius: 0 10px 10px 0;
  margin-right: 10px;
}
.nav-item:hover { color: #fff; background: rgba(255, 255, 255, .07); }
.nav-item.active {
  color: #fff;
  background: rgba(255, 255, 255, .12);
  border-left-color: var(--orange);
}
.nav-icon { width: 20px; display: inline-flex; align-items: center; justify-content: center; }
.nav-icon .i { width: 19px; height: 19px; }
.nav-item.active .nav-icon { color: var(--orange); }
.nav-sep { color: rgba(255, 255, 255, .45); }

.sidebar-foot { border-top: 1px solid rgba(255, 255, 255, .1); }
.avatar { background: var(--brand-grad); }
.user-name { color: #fff; }
.user-role { color: rgba(255, 255, 255, .6); }
.sidebar .foot-actions .btn-outline {
  background: transparent;
  color: #fff;
  border-color: rgba(255, 255, 255, .25);
  box-shadow: none;
}
.sidebar .foot-actions .btn-outline:hover { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .4); }

/* "Install app" entry in the sidebar */
.nav-install { color: #fff; }
.nav-install .nav-icon { color: var(--orange); }
.nav-install[hidden] { display: none !important; }

/* ---------- Top bar ---------- */
.topbar {
  background: var(--navy);
  border-bottom: 0;
  color: #fff;
  padding-top: max(16px, env(safe-area-inset-top));
}
.topbar h1 { color: #fff; }
.topbar .btn-outline {
  background: rgba(255, 255, 255, .1);
  color: #fff;
  border-color: rgba(255, 255, 255, .22);
  box-shadow: none;
}
.topbar .btn-outline:hover { background: rgba(255, 255, 255, .18); border-color: rgba(255, 255, 255, .35); }
.topbar .hamburger { color: #fff; }
.topbar .hamburger:active { background: rgba(255, 255, 255, .12); }
.topbar-mark { display: none; width: 26px; height: auto; flex-shrink: 0; }

/* ---------- Stat cards ---------- */
.stat-card {
  border-radius: 14px;
  border-top: 3px solid var(--navy);
}
.stat-grid > .stat-card:nth-child(4n+2) { border-top-color: var(--orange); }
.stat-grid > .stat-card:nth-child(4n+3) { border-top-color: var(--ic-blue); }
.stat-grid > .stat-card:nth-child(4n+4) { border-top-color: var(--brand-red); }
.stat-card .value { color: var(--navy); }
.stat-card.profit .value { color: var(--green); }
.stat-card.alert .value { color: var(--red); }

/* ---------- Dashboard menu tiles (phones) ----------
   Every sidebar menu not in the bottom bar, built by app-nav.js. */
.dash-welcome,
.quick-tiles { display: none; }

.quick-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  padding: 10px 6px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  font: 500 11.5px/1.2 "Poppins", system-ui, sans-serif;
  color: var(--ink);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform .12s ease, box-shadow .12s ease;
}
.quick-tile:active { transform: scale(.97); }
.quick-tile:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
.quick-tile[hidden] { display: none !important; }
.quick-tile .i { width: 26px; height: 26px; stroke-width: 1.8; }
.quick-tile[data-tone="blue"] .i { color: var(--ic-blue); }
.quick-tile[data-tone="orange"] .i { color: var(--ic-orange); }
.quick-tile[data-tone="red"] .i { color: var(--ic-red); }
.quick-tile[data-tone="purple"] .i { color: var(--ic-purple); }
.quick-tile[data-tone="dark"] .i { color: var(--ic-dark); }

/* ---------- Bottom navigation (phones & portrait tablets) ---------- */
.bottom-nav { display: none; }

@media (max-width: 820px) {
  body.has-bottom-nav .hamburger { display: none !important; }
  .topbar { padding: max(10px, env(safe-area-inset-top)) 14px 12px; }
  .topbar-mark { display: block; }

  .bottom-nav {
    flex-shrink: 0;
    display: flex;
    align-items: stretch;
    background: #fff;
    border-top: 1px solid var(--border);
    box-shadow: 0 -6px 18px rgba(3, 38, 91, .06);
    padding: 0 max(4px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(4px, env(safe-area-inset-left));
    position: relative;
    z-index: 11;
  }
  .bottom-nav__item {
    flex: 1 1 0;
    min-width: 0;
    min-height: 58px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 7px 2px 6px;
    border: 0;
    background: transparent;
    color: #6b7280;
    font: 500 10.5px/1.1 "Poppins", system-ui, sans-serif;
    cursor: pointer;
    position: relative;
    -webkit-tap-highlight-color: transparent;
  }
  .bottom-nav__item[hidden] { display: none !important; }
  .bottom-nav__item .i { width: 23px; height: 23px; }
  .bottom-nav__item span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .bottom-nav__item.is-active { color: var(--navy); font-weight: 600; }
  .bottom-nav__item.is-active .i { stroke-width: 2.2; }
  .bottom-nav__item.is-active::before {
    content: "";
    position: absolute;
    top: 0;
    left: 28%;
    right: 28%;
    height: 3px;
    border-radius: 0 0 3px 3px;
    background: var(--brand-grad-x);
  }
  .bottom-nav__item:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: -3px; border-radius: 10px; }

  /* INVOICE — the highlighted tab. A raised brand-gradient circle that
     sits proud of the bar, always in colour; when it is the open screen
     its label turns navy and the circle gets a ring. */
  .bottom-nav__item--feature { color: var(--navy); font-weight: 600; }
  .bottom-nav__badge {
    display: grid;
    place-items: center;
    width: 50px;
    height: 50px;
    margin-top: -22px;
    border-radius: 50%;
    background: var(--brand-grad);
    color: #fff;
    border: 4px solid #fff;
    box-shadow: 0 6px 14px rgba(227, 35, 43, .30), 0 1px 3px rgba(3, 38, 91, .18);
    transition: transform .12s ease, box-shadow .12s ease;
  }
  .bottom-nav__item--feature .bottom-nav__badge .i { width: 24px; height: 24px; stroke-width: 2.1; color: #fff; }
  .bottom-nav__item--feature:active .bottom-nav__badge { transform: scale(.94); }
  .bottom-nav__item--feature.is-active::before { display: none; }
  .bottom-nav__item--feature.is-active .bottom-nav__badge {
    box-shadow: 0 0 0 3px rgba(229, 145, 47, .35), 0 6px 14px rgba(227, 35, 43, .30);
  }
  .bottom-nav__item--feature:focus-visible { outline: none; }
  .bottom-nav__item--feature:focus-visible .bottom-nav__badge { outline: 3px solid var(--focus-ring); outline-offset: 2px; }

  /* The bar takes the home-indicator inset now, so the content needn't */
  body.has-bottom-nav .content { padding-bottom: 20px; }
  body.has-bottom-nav .content.fit > .view.active { padding-bottom: 12px; }
  body.has-bottom-nav #toast { bottom: calc(70px + env(safe-area-inset-bottom)); }

  /* Quick access strip on the dashboard */
  .dash-welcome {
    display: block;
    flex: 0 0 auto;
    margin-bottom: 10px;
  }
  .dash-welcome small { display: block; font-size: 12px; color: var(--gray); }
  .dash-welcome strong { display: block; font-size: 16px; font-weight: 700; color: var(--navy); line-height: 1.3; }
  /* All menus at a glance: a wrapping grid, four across on a phone,
     six on a portrait tablet. The phone dashboard scrolls as one page
     (syncContentFit in script.js), so every tile is reachable. */
  /* All menus in ONE ROW that scrolls sideways, with an arrow at each end
     while there is more that way (app-nav.js shows / hides them). */
  .qt-scroller { position: relative; flex: 0 0 auto; margin: 0 0 14px; }
  .quick-tiles {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x proximity;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 2px 2px 4px;
    margin: 0;
  }
  .quick-tiles::-webkit-scrollbar { display: none; }
  .quick-tile {
    flex: 0 0 76px;
    width: 76px;
    min-height: 76px;
    padding: 10px 4px 8px;
    text-align: center;
    scroll-snap-align: start;
  }
  .qt-arrow {
    position: absolute; top: 50%; z-index: 2;
    width: 30px; height: 30px; margin-top: -17px;
    display: flex; align-items: center; justify-content: center;
    border: 1px solid var(--border); border-radius: 50%;
    background: var(--card); color: var(--navy);
    box-shadow: 0 2px 8px rgba(3, 38, 91, .18);
    font: 700 22px/1 system-ui, sans-serif; padding: 0 0 3px;
    cursor: pointer; -webkit-tap-highlight-color: transparent;
  }
  .qt-arrow[hidden] { display: none; }
  .qt-arrow:active { transform: scale(.94); }
  .qt-arrow--left { left: -6px; }
  .qt-arrow--right { right: -6px; }
  /* A soft fade under each arrow so a half-hidden tile reads as "more". */
  .qt-scroller::before, .qt-scroller::after {
    content: ""; position: absolute; top: 0; bottom: 4px; width: 28px;
    pointer-events: none; z-index: 1; opacity: 0; transition: opacity .15s;
  }
  .qt-scroller::before { left: 0; background: linear-gradient(90deg, var(--bg, #f4f6fa), transparent); }
  .qt-scroller::after { right: 0; background: linear-gradient(270deg, var(--bg, #f4f6fa), transparent); }
  .qt-scroller.can-left::before, .qt-scroller.can-right::after { opacity: 1; }
  .quick-tile span {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    max-width: 100%;
    font-size: 11px;
    line-height: 1.2;
  }
}
@media (min-width: 560px) and (max-width: 820px) {
  .quick-tile { flex-basis: 88px; width: 88px; }
}

/* ============================================================
   LOGIN SCREEN
   Navy hero with the logo, install card, then the sign-in card.
   ============================================================ */
.auth-wrap {
  flex-direction: column;
  justify-content: flex-start;
  gap: 16px;
  padding: max(28px, calc(env(safe-area-inset-top) + 18px)) 16px max(28px, env(safe-area-inset-bottom));
  background:
    linear-gradient(180deg, var(--navy) 0, var(--navy-deep) 300px, transparent 300px),
    var(--bg);
  position: relative;
  overflow: hidden;
}
/* Brand kit "brand elements": slanted bars */
.auth-wrap::before,
.auth-wrap::after {
  content: "";
  position: absolute;
  pointer-events: none;
  border-radius: 18px;
  transform: skewX(-32deg);
}
.auth-wrap::before {
  top: 46px;
  right: -40px;
  width: 170px;
  height: 34px;
  background: linear-gradient(90deg, #f39a2e, #e5912f);
  opacity: .9;
}
.auth-wrap::after {
  top: 96px;
  right: -70px;
  width: 150px;
  height: 34px;
  background: linear-gradient(90deg, #ee4b2c, #e3232b);
  opacity: .85;
}
.auth-wrap > * { position: relative; z-index: 1; width: 100%; max-width: 440px; }

.auth-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  color: #fff;
  padding: 6px 0 4px;
}
.auth-hero__mark { width: 64px; height: auto; display: block; }
.auth-hero .wordmark { color: #fff; font-size: 34px; margin-top: 14px; }
.auth-hero .brand-sub { color: rgba(255, 255, 255, .85); margin-top: 10px; }
.auth-hero__tagline {
  margin: 14px 0 0;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  letter-spacing: .01em;
}
.auth-hero__tagline::after {
  content: "";
  display: block;
  width: 44px;
  height: 3px;
  margin: 8px auto 0;
  border-radius: 3px;
  background: var(--brand-grad-x);
}

.auth-card {
  max-width: 440px;
  border-radius: 20px;
  border: 1px solid var(--border);
  box-shadow: 0 18px 44px rgba(3, 38, 91, .12);
}
.auth-brand { display: none; }
.auth-pane h1 { font-size: 19px; color: var(--navy); }
.auth-card .btn-block {
  border-radius: 999px;
  min-height: 46px;
  font-size: 14.5px;
  font-weight: 600;
}

.auth-powered {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  text-align: center;
}
.auth-powered small { font-size: 11px; color: var(--gray); }
.jpr-mark {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
}
.jpr-mark__word {
  font-size: 20px;
  letter-spacing: -.01em;
  white-space: nowrap;
}
.jpr-mark__word b { font-weight: 800; font-style: italic; color: var(--navy); }
.jpr-mark__word span { font-weight: 500; color: var(--orange); margin-left: 3px; }
.jpr-mark__sub {
  margin-top: 4px;
  font-size: 6.5px;
  font-weight: 600;
  letter-spacing: .28em;
  color: var(--navy);
}

@media (max-width: 480px) {
  .auth-hero .wordmark { font-size: 30px; }
  .auth-wrap::before { width: 120px; height: 26px; right: -44px; }
  .auth-wrap::after { width: 104px; height: 26px; right: -60px; top: 84px; }
}

/* ============================================================
   OWNER CONSOLE — orange accent keeps it distinct
   ============================================================ */
.owner-sidebar .nav-item.active { border-left-color: var(--brand-red); }
.owner-badge {
  display: inline-block;
  margin-top: 8px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .14);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
}

/* Sidebar "Install app" entry (a button, deliberately not a .nav-item) */
.nav-install {
  display: flex;
  align-items: center;
  gap: 10px;
  width: calc(100% - 10px);
  margin: 8px 10px 8px 0;
  padding: 11px 20px;
  border: 0;
  border-left: 3px solid transparent;
  border-radius: 0 10px 10px 0;
  background: rgba(229, 145, 47, .14);
  color: #fff;
  font: 500 14px/1.3 "Poppins", system-ui, sans-serif;
  text-align: left;
  cursor: pointer;
}
.nav-install:hover { background: rgba(229, 145, 47, .24); }
.nav-install:focus-visible { outline: 3px solid rgba(255, 255, 255, .5); outline-offset: -3px; }

/* Top bar refresh: icon + label, icon only on narrow phones */
.btn-refresh { gap: 7px; }
.i-sm { width: 17px; height: 17px; }
@media (max-width: 420px) {
  .btn-refresh { padding: 8px 10px !important; }
  .btn-refresh__label { display: none; }
}

/* iOS steps banner sits above the bottom bar */
@media (max-width: 820px) {
  body.has-bottom-nav .ios-install-banner { bottom: calc(70px + env(safe-area-inset-bottom)); }
}

/* Customers: Freezers given · Fridges given · Given neither — always 3 in a row */
#customerEquipmentStats.stat-grid,
.content.fit > .view.active > #customerEquipmentStats.stat-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
@media (max-width: 820px) {
  #customerEquipmentStats.stat-grid { gap: 8px; }
  #customerEquipmentStats .stat-card { padding: 10px 10px; min-width: 0; }
  #customerEquipmentStats .stat-card .label { font-size: 9.5px; letter-spacing: .01em; line-height: 1.25; }
  #customerEquipmentStats .stat-card .value { font-size: 18px; }
}

/* Phone dashboard scrolls as one page (see syncContentFit); keep its two
   table switches side by side, as they were when it was fitted */
@media (max-width: 820px) {
  #dashSwitch { flex-direction: row; flex-wrap: nowrap; gap: 10px; }
  #dashSwitch .btn { flex: 1 1 0; min-width: 0; }
}

/* JPR Exports logo under "Powered by" (the company's own artwork) */
.jpr-logo { display: block; width: 180px; max-width: 60vw; height: auto; margin-top: 2px; }

/* Top-left logo = menu button on phones: tapping it opens the sidebar */
.topbar-menu { display: none; }
@media (max-width: 820px) {
  .topbar-menu {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    margin: -8px -6px -8px -8px;
    padding: 6px 8px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .topbar-menu:active { background: rgba(255, 255, 255, .14); }
  .topbar-menu:focus-visible { outline: 3px solid rgba(255, 255, 255, .55); outline-offset: 0; }
  .topbar-menu .topbar-mark { display: block; }
}

/* ---------- Stock: whole cases in bold, loose bottles apart ---------- */
.qty-whole { font-weight: 700; color: var(--navy); }
.qty-loose {
  display: inline-block;
  margin-left: 2px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--orange-light);
  color: #9a5a12;
  font-size: .86em;
  font-weight: 600;
  white-space: nowrap;
}

/* Products is not a dashboard tile (it lives in the sidebar / More).
   Belt and braces: hides it even if an older index.html still has one. */
.quick-tile[data-views~="products"] { display: none !important; }

.app-version {
  margin-top: 8px;
  font-size: 10.5px;
  color: rgba(255, 255, 255, .45);
  text-align: center;
  letter-spacing: .02em;
}

/* ---------- Invoice / quotation products, opened under the row ---------- */
tr.doc-lines-row > td { padding: 8px 10px 12px 26px; }
table.doc-lines {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  font-size: 12.5px;
}
table.doc-lines th {
  background: #f3f6fb;
  color: var(--gray);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .03em;
  text-align: left;
  padding: 6px 8px;
  position: static;
}
table.doc-lines td { padding: 6px 8px; border-top: 1px solid var(--border); background: #fff; }
table.doc-lines tfoot td { background: #f9fafc; font-weight: 600; }

/* From / To date pickers in the Invoices toolbar */
.date-filter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--gray);
  font-weight: 500;
}
.date-filter input { max-width: 150px; }
@media (max-width: 820px) {
  .toolbar .date-filter { flex: 1 1 calc(50% - 4px); }
  .toolbar .date-filter input { flex: 1; max-width: none; min-width: 0; }
}

/* Whole row opens its products (invoices, quotations, batches, today's invoices) */
tr.row-click { cursor: pointer; -webkit-tap-highlight-color: transparent; }
tr.row-click:hover > td { background: #f6f8fc; }
tr.row-click:active > td { background: #eef2f9; }
tr.row-click.row-open > td { background: var(--indigo-light); }

/* Warehouse movement form: product lines fit the dialog */
#mvLinesTable { min-width: 560px; }
#mvLinesTable select, #mvLinesTable input { width: 100%; }
@media (max-width: 640px) {
  /* Phones: each product line becomes a small card — product on top,
     batch / cases / loose pieces side by side below it. */
  #mvLinesTable { min-width: 0; }
  #mvLinesTable thead { display: none; }
  #mvLinesTable tbody tr {
    display: grid;
    grid-template-columns: 1.3fr 1fr 1fr auto;
    gap: 6px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
  }
  #mvLinesTable tbody td { padding: 0; }
  #mvLinesTable tbody td:first-child { grid-column: 1 / -1; }
  #mvLinesTable tbody td:nth-child(2)::before { content: "Batch no."; }
  #mvLinesTable tbody td:nth-child(3)::before { content: "Cases"; }
  #mvLinesTable tbody td:nth-child(4)::before { content: "Loose pcs"; }
  #mvLinesTable tbody td:nth-child(n+2):not(:last-child)::before {
    display: block; font-size: 11px; font-weight: 600; color: var(--gray); margin-bottom: 2px;
  }
  #mvLinesTable tbody td:last-child { align-self: end; }
}

/* ---------- Goods Movement: stock by warehouse ---------- */
.wh-dash { flex: 0 0 auto; margin-bottom: 14px; }
.wh-dash__head { display: flex; gap: 8px; align-items: baseline; margin-bottom: 8px; color: var(--navy); font-size: 14px; }
.wh-dash__head .muted { font-size: 12px; }
.wh-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px;
}
.wh-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 12px 14px; text-align: left; cursor: pointer;
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  border-top: 3px solid var(--orange); box-shadow: var(--shadow-sm);
  font-family: inherit; color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  transition: transform .12s ease, box-shadow .12s ease;
}
.wh-card:hover { box-shadow: 0 6px 16px rgba(3, 38, 91, .10); }
.wh-card:active { transform: scale(.98); }
.wh-card:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
.wh-card--none { border-top-color: var(--gray); }
.wh-card__name { font-size: 13px; font-weight: 600; color: var(--navy); line-height: 1.25; }
.wh-card__num { font-size: 28px; font-weight: 700; color: var(--navy); line-height: 1.1; margin-top: 4px; }
.wh-card__unit { font-size: 12px; color: var(--gray); }
.wh-card__sub { font-size: 11.5px; color: var(--gray); margin-top: 4px; }
/* Goods out for delivery — on a vehicle, not yet invoiced. Orange so it reads
   apart from the on-hand figures around it. */
.wh-card__out { font-size: 11.5px; font-weight: 600; color: #b45309; margin-top: 4px; }
.wh-card--delivery { border-top-color: var(--orange); background: var(--orange-light); }
.wh-card--delivery .wh-card__num { color: #b45309; }
.stat-card.delivery .value { color: #b45309; }
.qty-out { color: #b45309; font-weight: 600; }
/* Goods movement history: the page scrolls (the view is not fitted), and the
   table keeps a tall box of its own so many movements show at once. */
#view-movements .table-wrap { max-height: max(70vh, 460px); }
#view-movements .table-wrap th { position: sticky; top: 0; z-index: 1; }
#modal-warehouse .table-wrap { max-height: 55vh; }
@media (max-width: 640px) {
  .wh-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .wh-card { padding: 10px 12px; }
  .wh-card__num { font-size: 24px; }
}

/* ---------- Dashboard cards that open another screen (1.15) ----------
   Warehouse / Delivery / Total stock open Goods Movement; Yet to Deliver
   shows the waiting invoices; Sent opens Invoices. */
.stat-card.stat-link { cursor: pointer; transition: box-shadow .15s, transform .15s; }
.stat-card.stat-link:hover { transform: translateY(-1px); }
.stat-card.stat-link:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }
.stat-card.stat-link .sub { color: var(--gray); }
/* The one-line note + link above the Delivery Stock and Yet to Deliver tables. */
.dash-link-head { margin-bottom: 8px; padding-bottom: 8px; flex-wrap: wrap; }
.dash-link-head .muted { font-size: 12.5px; }
@media (max-width: 820px) {
  /* Three switches share the row on a phone; let the labels wrap. */
  #dashSwitch .btn { white-space: normal; line-height: 1.2; padding-left: 6px; padding-right: 6px; }
}

/* ---------- Background refresh bar (1.16) ----------
   While the app refreshes behind the last data it painted, a thin moving bar
   across the top says so — instead of a spinner covering the screen. */
#syncBar {
  position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 310;
  pointer-events: none; opacity: 0; transition: opacity .2s;
  background: linear-gradient(90deg, transparent 0%, var(--orange) 40%, var(--orange) 60%, transparent 100%);
  background-size: 50% 100%; background-repeat: no-repeat;
}
#syncBar.on { opacity: 1; animation: syncbar 1.1s linear infinite; }
@keyframes syncbar { from { background-position: -50% 0; } to { background-position: 150% 0; } }
@media (prefers-reduced-motion: reduce) { #syncBar.on { animation: none; background-size: 100% 100%; } }

/* Cases + loose pieces as two lines (1.18): in a narrow column the bold cases
   and the loose-pieces pill used to wrap into each other. Each line stays whole. */
.qty-stack { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 3px; line-height: 1.25; vertical-align: top; }
.qty-stack .qty-whole { white-space: nowrap; }
.qty-stack .qty-loose { margin-left: 0; }
td.num .qty-stack { align-items: flex-end; }

/* ---------- Stock Out Sheet (1.19) ----------
   One row per invoice, one column per product. The table scrolls sideways
   when there are many products; the header stays on top while scrolling. */
#view-salessheet .table-wrap { max-height: max(68vh, 440px); overflow: auto; }
#view-salessheet .ss-table th { position: sticky; top: 0; z-index: 1; }
#view-salessheet .ss-table th.ss-prod { min-width: 96px; white-space: normal; line-height: 1.25; }
#view-salessheet .ss-table td:nth-child(-n+3) { white-space: nowrap; }
#view-salessheet .ss-table .ss-total { background: var(--orange-light); }
#view-salessheet .ss-table tfoot td { font-weight: 700; border-top: 2px solid var(--border); }
.ss-note { font-size: 12.5px; margin: -4px 0 8px; }
