/* =====================================================================
   TEJPATA — Godown Management System
   Consolidated stylesheet

   1.  Theme tokens (10 skins)
   2.  Base / typography
   3.  Login screen
   4.  Navbar & page header
   5.  Cards & KPI tiles
   6.  Filter panel + table layout pattern
   7.  Tables (zebra, sticky head/foot, column menus)
   8.  Forms, Select2, buttons
   9.  Scan modal & barcode labels
   10. Dashboard, timeline, misc components
   11. Print rules (labels 50x25mm + documents)
   12. Responsive
   ===================================================================== */

/* =====================================================================
   1. THEME TOKENS
   Each skin only overrides the palette; every component reads variables.
   ===================================================================== */

:root,
[data-theme="default"] {
  /* Sampled from the Tejpata wordmark: #444F23 olive. Everything else in
     this skin is derived from it so the UI matches the logo exactly. */
  --brand:        #444f23;
  --brand-dark:   #333c1a;
  --brand-2:      #6b7c3a;
  --brand-soft:   #eef1e4;
  --navbar-bg:    linear-gradient(120deg, #2c3416 0%, #444f23 55%, #6b7c3a 100%);
  --navbar-fg:    #ffffff;

  --bg:           #f4f5ef;
  --surface:      #ffffff;
  --surface-2:    #fafbf6;
  --border:       #e4e7da;
  --text:         #24281a;
  --text-muted:   #6f7663;

  --row-alt:      #f9faf4;
  --row-hover:    #eef1e4;
  --thead-bg:     #f0f2e7;
  --tfoot-bg:     #e6ead8;

  --ok:      #4f7a2a;
  --warn:    #c8791b;
  --danger:  #c0392f;
  --info:    #2f6f8f;

  --radius:      14px;
  --radius-sm:   10px;
  --shadow:      0 2px 6px rgba(36, 40, 26, .06), 0 10px 24px rgba(36, 40, 26, .07);
  --shadow-lift: 0 6px 14px rgba(36, 40, 26, .10), 0 18px 38px rgba(36, 40, 26, .13);
  --ease:        cubic-bezier(.4, 0, .2, 1);
}

/* Ten deliberately DISTINCT hues, spread around the wheel so no two skins read
   as "the same colour". Two of them (dark, midnight) are full dark skins with
   opposite accents — amber vs indigo — so even the dark pair is unmistakable.
   Structure per theme: brand + darker + lighter + soft tint, a navbar gradient,
   and light surface/row tints keyed to the hue. */

/* Amber accent on a neutral charcoal — was an olive duplicate of default. */
[data-theme="dark"] {
  --brand: #e0a13c; --brand-dark: #c2842a; --brand-2: #f0bd68; --brand-soft: #2b2417;
  --navbar-bg: linear-gradient(120deg, #15181f 0%, #1e222c 55%, #2a2f3b 100%);
  --navbar-fg: #f1ece1;
  --bg: #14161c; --surface: #1c1f27; --surface-2: #23262f; --border: #30343f;
  --text: #ecebe4; --text-muted: #a6a599;
  --row-alt: #202430; --row-hover: #292d3a; --thead-bg: #242833; --tfoot-bg: #292d3a;
  --ok:#4ec584; --warn:#e6b053; --danger:#ee6d80; --info:#5aa9e6;
  --shadow: 0 2px 6px rgba(0,0,0,.35), 0 10px 24px rgba(0,0,0,.35);
  --shadow-lift: 0 6px 14px rgba(0,0,0,.45), 0 18px 38px rgba(0,0,0,.5);
}

/* Cyan-blue */
[data-theme="ocean"] {
  --brand: #0c7fb8; --brand-dark: #0a6597; --brand-2: #3fa6d8; --brand-soft: #e2f2fb;
  --navbar-bg: linear-gradient(120deg, #064a70 0%, #0c7fb8 55%, #2f9bd0 100%);
  --navbar-fg: #ffffff;
  --bg: #edf4f9; --surface: #ffffff; --surface-2: #f5fafd; --border: #d8e7f0;
  --text: #12293a; --text-muted: #5f7789;
  --row-alt: #f4fafd; --row-hover: #e2f2fb; --thead-bg: #e9f3f9; --tfoot-bg: #d9eaf4;
}

/* True leaf green (pushed away from the olive default) */
[data-theme="forest"] {
  --brand: #2e8b40; --brand-dark: #226b31; --brand-2: #57b268; --brand-soft: #e6f5e8;
  --navbar-bg: linear-gradient(120deg, #1b5e26 0%, #2e8b40 55%, #48a95a 100%);
  --navbar-fg: #ffffff;
  --bg: #eff6f0; --surface: #ffffff; --surface-2: #f6fbf7; --border: #dcebde;
  --text: #182a1c; --text-muted: #63796a;
  --row-alt: #f5fbf6; --row-hover: #e6f5e8; --thead-bg: #ecf6ee; --tfoot-bg: #ddeede;
}

/* Warm orange */
[data-theme="sunset"] {
  --brand: #e0611f; --brand-dark: #bb4d16; --brand-2: #f28c4e; --brand-soft: #fdecdf;
  --navbar-bg: linear-gradient(120deg, #a83e12 0%, #e0611f 55%, #f28a4c 100%);
  --navbar-fg: #ffffff;
  --bg: #faf3ee; --surface: #ffffff; --surface-2: #fef8f4; --border: #eddccf;
  --text: #331e13; --text-muted: #856c5b;
  --row-alt: #fdf7f2; --row-hover: #fdecdf; --thead-bg: #f8ebe0; --tfoot-bg: #f3ddcc;
}

/* Vivid violet */
[data-theme="royal"] {
  --brand: #6d28d9; --brand-dark: #571fae; --brand-2: #9366e8; --brand-soft: #efe8fc;
  --navbar-bg: linear-gradient(120deg, #491a94 0%, #6d28d9 55%, #8b57e0 100%);
  --navbar-fg: #ffffff;
  --bg: #f4f0fb; --surface: #ffffff; --surface-2: #faf8fe; --border: #e4dbf5;
  --text: #241a3a; --text-muted: #6e6486;
  --row-alt: #faf8fe; --row-hover: #efe8fc; --thead-bg: #f0eafb; --tfoot-bg: #e5daf7;
}

/* Neutral slate — the calm, colourless option */
[data-theme="slate"] {
  --brand: #4b5a6e; --brand-dark: #384556; --brand-2: #71829a; --brand-soft: #eaeef3;
  --navbar-bg: linear-gradient(120deg, #2b3543 0%, #4b5a6e 55%, #65758e 100%);
  --navbar-fg: #ffffff;
  --bg: #f1f3f6; --surface: #ffffff; --surface-2: #f8f9fb; --border: #e0e5ec;
  --text: #1e2530; --text-muted: #6c7684;
  --row-alt: #f7f9fb; --row-hover: #eaeef3; --thead-bg: #eef1f5; --tfoot-bg: #e2e7ee;
}

/* Rose / magenta (formerly a near-duplicate green "emerald"; the slug is kept
   so a saved preference still resolves — the visible label is "Rose"). */
[data-theme="emerald"] {
  --brand: #c42a95; --brand-dark: #a11f7b; --brand-2: #dc5cb4; --brand-soft: #fbe6f4;
  --navbar-bg: linear-gradient(120deg, #86156a 0%, #c42a95 55%, #d857b0 100%);
  --navbar-fg: #ffffff;
  --bg: #fbeff7; --surface: #ffffff; --surface-2: #fef6fb; --border: #f0d9ea;
  --text: #2c1424; --text-muted: #8a6180;
  --row-alt: #fdf5fa; --row-hover: #fbe6f4; --thead-bg: #f9e8f3; --tfoot-bg: #f4d8ec;
}

/* Bold red */
[data-theme="crimson"] {
  --brand: #c62233; --brand-dark: #9f1a29; --brand-2: #e05360; --brand-soft: #fbe6e8;
  --navbar-bg: linear-gradient(120deg, #8e1622 0%, #c62233 55%, #dc5460 100%);
  --navbar-fg: #ffffff;
  --bg: #faf0f1; --surface: #ffffff; --surface-2: #fef6f7; --border: #efd9dc;
  --text: #2e1518; --text-muted: #886468;
  --row-alt: #fdf6f7; --row-hover: #fbe6e8; --thead-bg: #f8e9eb; --tfoot-bg: #f2d9dc;
}

/* Indigo accent on deep navy — the second dark skin, opposite the amber one */
[data-theme="midnight"] {
  --brand: #5b74ff; --brand-dark: #4459d8; --brand-2: #8497ff; --brand-soft: #1a2140;
  --navbar-bg: linear-gradient(120deg, #0a1226 0%, #121d3a 55%, #1c2c57 100%);
  --navbar-fg: #dbe4f5;
  --bg: #0b1122; --surface: #131a30; --surface-2: #18213b; --border: #26314f;
  --text: #dfe6f5; --text-muted: #8e9bba;
  --row-alt: #161e38; --row-hover: #1d284a; --thead-bg: #182144; --tfoot-bg: #1d284a;
  --ok:#57cf90; --warn:#e6b053; --danger:#f0708c; --info:#6aa8ff;
  --shadow: 0 2px 6px rgba(0,0,0,.45), 0 10px 24px rgba(0,0,0,.45);
  --shadow-lift: 0 6px 14px rgba(0,0,0,.55), 0 18px 38px rgba(0,0,0,.6);
}

/* =====================================================================
   2. BASE
   ===================================================================== */

* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-size: .9rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background .3s var(--ease), color .3s var(--ease);
}

.app-main { flex: 1 0 auto; padding: 1.1rem .9rem 2rem; }

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); }

.text-muted { color: var(--text-muted) !important; }
hr { border-color: var(--border); opacity: 1; }

/* fade-in for AJAX-swapped regions */
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.fade-up { animation: fadeUp .32s var(--ease) both; }

@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-7px); }
  40%, 60% { transform: translateX(7px); }
}
.shake { animation: shake .5s var(--ease); }

/* =====================================================================
   3. LOGIN
   ===================================================================== */

/* Split layout: a brand hero beside the sign-in form. Both sides read from the
   theme variables, so the whole screen re-skins with the chosen theme (the
   inline script in index.php restores it before paint). The hero collapses on
   narrow screens, where a compact logo header takes its place. */
.login-body { min-height: 100vh; background: var(--bg); }

.login-shell {
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  min-height: 100vh;
}

/* ---- brand hero (uses the theme's navbar gradient) ---- */
.login-hero {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: center;
  padding: 3.4rem 3.4rem 2rem;
  color: #fff;
  background: var(--navbar-bg);
}
.login-hero-bg { position: absolute; inset: 0; z-index: 0; overflow: hidden; }
.login-hero-bg .blob {
  position: absolute; border-radius: 50%; filter: blur(64px); opacity: .5;
  animation: float 16s ease-in-out infinite;
  mix-blend-mode: soft-light;
}
/* Blobs are theme-neutral light/brand tints so they lift any navbar gradient. */
.blob.b1 { width: 420px; height: 420px; background: rgba(255, 255, 255, .55); top: -110px; left: -80px; }
.blob.b2 { width: 320px; height: 320px; background: var(--brand-2); bottom: -70px; right: -50px; animation-delay: -6s; opacity: .55; }
.blob.b3 { width: 240px; height: 240px; background: rgba(255, 255, 255, .4); top: 46%; left: 58%; animation-delay: -10s; }
/* faint engineering grid over the gradient */
.hero-grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(circle at 30% 40%, #000 0%, transparent 78%);
}

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%      { transform: translate(30px, -25px) scale(1.08); }
  66%      { transform: translate(-20px, 20px) scale(.95); }
}

.login-hero-body { position: relative; z-index: 1; max-width: 460px; }
.hero-logo {
  height: 96px; width: auto; max-width: 100%; display: block;
  margin-bottom: 1.8rem;
  filter: brightness(0) invert(1);
  animation: fadeUp .6s var(--ease) both;
}
.hero-tag {
  font-size: 1.7rem; font-weight: 700; line-height: 1.2;
  letter-spacing: -.4px; margin: 0 0 .6rem;
  animation: fadeUp .6s var(--ease) .05s both;
}
.hero-lead {
  font-size: .96rem; color: rgba(255, 255, 255, .78);
  margin: 0 0 2rem; max-width: 30rem;
  animation: fadeUp .6s var(--ease) .1s both;
}
.hero-points { list-style: none; margin: 0; padding: 0; display: grid; gap: .9rem; }
.hero-points li {
  display: flex; align-items: flex-start; gap: .8rem;
  font-size: .9rem; color: rgba(255, 255, 255, .92);
  animation: fadeUp .6s var(--ease) both;
}
.hero-points li:nth-child(1) { animation-delay: .16s; }
.hero-points li:nth-child(2) { animation-delay: .22s; }
.hero-points li:nth-child(3) { animation-delay: .28s; }
.hero-points i {
  flex-shrink: 0; width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center; font-size: 1rem;
  background: rgba(255, 255, 255, .14);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18);
}
.login-hero-foot {
  position: relative; z-index: 1;
  margin-top: 2.4rem; padding-top: 1.2rem;
  border-top: 1px solid rgba(255, 255, 255, .16);
  font-size: .74rem; letter-spacing: .4px;
  color: rgba(255, 255, 255, .6);
}

/* ---- form panel (themed surface) ---- */
.login-panel {
  display: flex; align-items: center; justify-content: center;
  padding: 2rem 1.5rem;
  background: var(--surface);
}
.login-form-wrap {
  width: 100%; max-width: 384px;
  animation: fadeUp .5s var(--ease) both;
}
.login-panel-head { margin-bottom: 1.6rem; }
.panel-logo {
  height: 72px; width: auto; max-width: 82%;
  display: none;                                  /* shown only when hero is hidden */
  margin-bottom: 1.2rem;
}
.login-panel-head h1 {
  font-size: 1.6rem; font-weight: 700; letter-spacing: -.4px;
  color: var(--text); margin: 0;
}
.login-panel-head p { font-size: .87rem; color: var(--text-muted); margin: .3rem 0 0; }

/* Inputs sit on the themed --surface-2, not stark white. */
.login-form-wrap .form-control {
  height: calc(3.4rem + 2px);
  border-radius: 12px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  color: var(--text);
}
.login-form-wrap .form-control::placeholder { color: transparent; }
.login-form-wrap .form-control:focus {
  background: var(--surface);
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent);
}

/* Bootstrap paints a white strip behind the floating label (its ::after) to
   cut through the input border — that is the "white highlight" to remove.
   Make it transparent so the label sits on the input's own themed background. */
.login-form-wrap .form-floating > label { color: var(--text-muted); }
.login-form-wrap .form-floating > label::after {
  background-color: transparent !important;
}
.login-form-wrap .form-floating > .form-control:focus ~ label,
.login-form-wrap .form-floating > .form-control:not(:placeholder-shown) ~ label {
  color: var(--brand);
  opacity: 1;
}

.login-submit {
  border-radius: 12px; font-weight: 600; font-size: .96rem;
  margin-top: .4rem; height: 3rem;
}
.login-foot { text-align: center; margin-top: 1.4rem; padding-top: .95rem; border-top: 1px solid var(--border); }

.btn-eye {
  position: absolute; right: .6rem; top: 50%; transform: translateY(-50%);
  background: none; border: 0; color: var(--text-muted); padding: .3rem; z-index: 5;
}
.btn-eye:hover { color: var(--brand); }

@media (max-width: 860px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-hero { display: none; }
  .panel-logo { display: block; }
  .login-panel { min-height: 100vh; }
}

/* =====================================================================
   4. NAVBAR & PAGE HEADER
   ===================================================================== */

.app-navbar {
  background: var(--navbar-bg);
  box-shadow: 0 2px 14px rgba(0, 0, 0, .16);
  padding: .35rem .25rem;
  z-index: 1030;
}

/* The wordmark stands on its own in the navbar — no tile, no separate text,
   since the artwork already says "Tejpata". Knocked out to white to read on
   the dark bar. */
.app-navbar .navbar-brand {
  display: flex; align-items: center;
  padding: .2rem .5rem;
}
.brand-logo {
  height: 44px; width: auto;
  display: block;
  filter: brightness(0) invert(1);           /* olive artwork -> white */
  transition: transform .3s var(--ease), opacity .2s var(--ease);
}
.navbar-brand:hover .brand-logo { transform: scale(1.04); opacity: .92; }

.app-navbar .nav-link {
  color: rgba(255, 255, 255, .86);
  font-weight: 500; font-size: .87rem;
  padding: .5rem .78rem; border-radius: 9px;
  position: relative; transition: all .22s var(--ease);
}
.app-navbar .nav-link:hover,
.app-navbar .nav-link:focus { color: #fff; background: rgba(255, 255, 255, .14); }
.app-navbar .nav-link.active,
.app-navbar .nav-item.show > .nav-link { color: #fff; background: rgba(255, 255, 255, .2); }
.app-navbar .nav-link.active::after {
  content: ""; position: absolute; left: 50%; bottom: 2px; transform: translateX(-50%);
  width: 18px; height: 2.5px; border-radius: 2px; background: #fff;
}
.app-navbar .navbar-toggler { border: 0; color: #fff; font-size: 1.4rem; box-shadow: none !important; }

.dropdown-menu {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lift);
  padding: .4rem; font-size: .87rem;
  animation: fadeUp .18s var(--ease) both;
}
.dropdown-menu-wide { min-width: 262px; }
.dropdown-item {
  color: var(--text); border-radius: 8px; padding: .48rem .65rem;
  transition: background .18s var(--ease), transform .18s var(--ease);
}
.dropdown-item:hover, .dropdown-item:focus { background: var(--brand-soft); color: var(--brand-dark); transform: translateX(3px); }
.dropdown-item.active { background: var(--brand); color: #fff; }
.dropdown-header { color: var(--text-muted); font-size: .7rem; text-transform: uppercase; letter-spacing: 1px; font-weight: 700; }
.dropdown-divider { border-color: var(--border); }

/* right-hand tools — always visible, never collapsed into the burger menu */
.nav-tools {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: .4rem;
  margin-left: auto;
}

/* hairline divider that groups the tool cluster */
.nav-sep {
  width: 1px; height: 22px; flex-shrink: 0;
  background: rgba(255, 255, 255, .22);
  margin: 0 .2rem;
}

.btn-icon {
  width: 38px; height: 38px; padding: 0;
  display: grid; place-items: center;
  border: 0; border-radius: 10px; font-size: 1.05rem;
  color: rgba(255, 255, 255, .9); background: rgba(255, 255, 255, .13);
  transition: all .22s var(--ease);
}
.btn-icon:hover { background: rgba(255, 255, 255, .26); color: #fff; transform: translateY(-2px); }
.btn-scan { background: rgba(255, 255, 255, .22); }
.btn-scan:hover { animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(255,255,255,.5); } 70% { box-shadow: 0 0 0 9px rgba(255,255,255,0); } }

.notif-dot {
  position: absolute; top: -3px; right: -3px;
  min-width: 18px; height: 18px; padding: 0 4px;
  display: grid; place-items: center;
  background: var(--danger); color: #fff;
  font-size: .66rem; font-weight: 700; border-radius: 9px;
  border: 2px solid rgba(255, 255, 255, .35);
}

.global-search { position: relative; width: 250px; }
.global-search .gs-icon {
  position: absolute; left: .7rem; top: 50%; transform: translateY(-50%);
  color: rgba(255, 255, 255, .7); font-size: .9rem; pointer-events: none;
}
.global-search .form-control {
  background: rgba(255, 255, 255, .15); border: 1px solid rgba(255, 255, 255, .2);
  color: #fff; padding-left: 2.1rem; height: 38px; border-radius: 10px; font-size: .84rem;
  transition: all .25s var(--ease);
}
.global-search .form-control::placeholder { color: rgba(255, 255, 255, .62); }
.global-search .form-control:focus {
  background: rgba(255, 255, 255, .27); border-color: rgba(255, 255, 255, .45);
  box-shadow: none; color: #fff; width: 100%;
}
.gs-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lift);
  max-height: 420px; overflow-y: auto; display: none; z-index: 1050;
}
.gs-results.show { display: block; animation: fadeUp .18s var(--ease) both; }
.gs-group { padding: .45rem .7rem .2rem; font-size: .68rem; text-transform: uppercase;
  letter-spacing: 1px; font-weight: 700; color: var(--text-muted); }
.gs-item { display: flex; gap: .6rem; align-items: center; padding: .5rem .7rem; color: var(--text); }
.gs-item:hover { background: var(--brand-soft); color: var(--brand-dark); }
.gs-item > i:first-child { color: var(--brand); font-size: 1rem; flex-shrink: 0; }
.gs-item span { min-width: 0; flex: 1; }
.gs-item .gs-label { font-weight: 600; font-size: .84rem; }
.gs-item .gs-meta  { font-size: .74rem; color: var(--text-muted); }
/* "opens in a modal" hint, revealed on hover of a drill-down result */
.gs-item .gs-open {
  margin-left: auto; flex-shrink: 0;
  font-size: .82rem; color: var(--text-muted);
  opacity: 0; transition: opacity .16s var(--ease);
}
.gs-item:hover .gs-open { opacity: .8; }
.gs-empty { padding: 1rem; text-align: center; color: var(--text-muted); font-size: .84rem; }

.notif-menu { width: 340px; padding: 0; overflow: hidden; }
.notif-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: .7rem .9rem; border-bottom: 1px solid var(--border);
  font-weight: 600; background: var(--surface-2);
}
.notif-list { max-height: 380px; overflow-y: auto; }
.notif-item { display: block; padding: .7rem .9rem; border-bottom: 1px solid var(--border); color: var(--text); }
.notif-item:hover { background: var(--brand-soft); }
.notif-item .nt-title { font-weight: 600; font-size: .84rem; }
.notif-item .nt-msg   { font-size: .78rem; color: var(--text-muted); }
.notif-item .nt-time  { font-size: .7rem; color: var(--text-muted); }
.notif-empty { padding: 2rem 1rem; text-align: center; color: var(--text-muted); font-size: .85rem; }

.theme-menu { width: 290px; padding: .6rem; }
.theme-head { font-size: .7rem; text-transform: uppercase; letter-spacing: 1px;
  font-weight: 700; color: var(--text-muted); padding: .2rem .3rem .5rem; }
.theme-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .35rem; }
.theme-chip {
  display: flex; align-items: center; gap: .45rem;
  padding: .45rem .55rem; border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface-2); color: var(--text); font-size: .78rem; text-align: left;
  transition: all .2s var(--ease);
}
.theme-chip:hover { border-color: var(--brand); transform: translateY(-2px); box-shadow: var(--shadow); }
.chip-dot { width: 16px; height: 16px; border-radius: 5px; flex-shrink: 0; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); }
.chip-label { flex: 1; }
.chip-check { opacity: 0; color: var(--brand); }
.theme-chip.is-active { border-color: var(--brand); background: var(--brand-soft); font-weight: 600; }
.theme-chip.is-active .chip-check { opacity: 1; }

/* Profile control is an avatar only — the name, email, role and outlet all
   live inside the dropdown, keeping the bar compact at every width. */
.btn-avatar {
  width: 38px; height: 38px; flex-shrink: 0;
  display: grid; place-items: center;
  border: 0; border-radius: 50%; padding: 0;
  background: linear-gradient(135deg, rgba(255,255,255,.34), rgba(255,255,255,.16));
  color: #fff; font-weight: 700; font-size: .95rem; line-height: 1;
  box-shadow: 0 0 0 1.5px rgba(255, 255, 255, .28);
  transition: transform .22s var(--ease), box-shadow .22s var(--ease);
}
.btn-avatar:hover,
.btn-avatar[aria-expanded="true"] {
  color: #fff; transform: translateY(-1px);
  box-shadow: 0 0 0 2.5px rgba(255, 255, 255, .55), 0 4px 12px rgba(0, 0, 0, .22);
}
.btn-avatar::after { display: none; }   /* no caret */

.profile-menu { min-width: 262px; }
.profile-id { display: flex; gap: .7rem; align-items: center; padding: .75rem .8rem .6rem; }
.avatar-lg {
  width: 44px; height: 44px; flex-shrink: 0;
  display: grid; place-items: center; border-radius: 50%;
  background: var(--brand); color: #fff; font-weight: 700; font-size: 1.15rem;
}
.pi-text { min-width: 0; }
.pi-name { font-weight: 600; font-size: .9rem; line-height: 1.2; }
.pi-mail {
  font-size: .74rem; color: var(--text-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 170px;
}
.pi-badges { display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .3rem; }
.badge-role   { background: var(--brand); color: #fff; font-weight: 500; font-size: .68rem; }
.badge-outlet { background: var(--info); color: #fff; font-weight: 500; font-size: .68rem; }

.page-head { background: var(--surface); border-bottom: 1px solid var(--border); padding: .9rem 0; }
.page-title { font-size: 1.24rem; font-weight: 700; margin: 0; letter-spacing: -.3px; }
.page-title i { color: var(--brand); }
.page-sub { font-size: .8rem; color: var(--text-muted); margin: .12rem 0 0; }

.app-footer {
  background: var(--surface); border-top: 1px solid var(--border);
  padding: .8rem 0; font-size: .78rem; color: var(--text-muted); flex-shrink: 0;
}

/* =====================================================================
   5. CARDS & KPI TILES
   ===================================================================== */

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  transition: transform .26s var(--ease), box-shadow .26s var(--ease);
}
.card:hover { box-shadow: var(--shadow-lift); }
.card.lift:hover { transform: translateY(-4px); }

.card-header {
  background: var(--surface-2); border-bottom: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0 !important;
  padding: .7rem .95rem; font-weight: 600; font-size: .88rem;
  display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap;
}
.card-header i { color: var(--brand); }
.card-body { padding: .95rem; }
.card-footer { background: var(--surface-2); border-top: 1px solid var(--border); padding: .6rem .95rem; }

.kpi {
  display: flex; align-items: center; gap: .85rem;
  padding: 1rem; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow); position: relative; overflow: hidden;
  transition: transform .26s var(--ease), box-shadow .26s var(--ease);
}
.kpi:hover { transform: translateY(-4px); box-shadow: var(--shadow-lift); }
.kpi::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--brand);
}
.kpi.k-ok::before     { background: var(--ok); }
.kpi.k-warn::before   { background: var(--warn); }
.kpi.k-danger::before { background: var(--danger); }
.kpi.k-info::before   { background: var(--info); }

.kpi-icon {
  width: 48px; height: 48px; flex-shrink: 0;
  display: grid; place-items: center; border-radius: 13px;
  font-size: 1.35rem; color: var(--brand); background: var(--brand-soft);
}
.kpi.k-ok .kpi-icon     { color: var(--ok);     background: color-mix(in srgb, var(--ok) 14%, transparent); }
.kpi.k-warn .kpi-icon   { color: var(--warn);   background: color-mix(in srgb, var(--warn) 14%, transparent); }
.kpi.k-danger .kpi-icon { color: var(--danger); background: color-mix(in srgb, var(--danger) 14%, transparent); }
.kpi.k-info .kpi-icon   { color: var(--info);   background: color-mix(in srgb, var(--info) 14%, transparent); }

.kpi-value { font-size: 1.4rem; font-weight: 700; line-height: 1.1; letter-spacing: -.5px; }
.kpi-label { font-size: .74rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .6px; }
.kpi-sub   { font-size: .74rem; color: var(--text-muted); }

/* =====================================================================
   6. FILTER PANEL + TABLE LAYOUT PATTERN
   Left: sticky filter form. Right: fixed-height scrolling table.
   ===================================================================== */

.work-layout { display: grid; grid-template-columns: 290px 1fr; gap: 1rem; align-items: start; }
.work-layout.wide-filter { grid-template-columns: 330px 1fr; }

.filter-panel {
  position: sticky; top: 74px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  max-height: calc(100vh - 96px); display: flex; flex-direction: column;
}
.filter-panel .fp-head {
  padding: .7rem .9rem; border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: .86rem; background: var(--surface-2);
  border-radius: var(--radius) var(--radius) 0 0;
  display: flex; align-items: center; justify-content: space-between;
}
.filter-panel .fp-head i { color: var(--brand); }
.filter-panel .fp-body { padding: .85rem; overflow-y: auto; flex: 1; }
.filter-panel .fp-foot { padding: .7rem .85rem; border-top: 1px solid var(--border); background: var(--surface-2);
  border-radius: 0 0 var(--radius) var(--radius); display: flex; gap: .5rem; }

.table-panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
  display: flex; flex-direction: column;
}
.table-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap;
  padding: .6rem .85rem; border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.table-toolbar .tt-title { font-weight: 600; font-size: .88rem; display: flex; align-items: center; gap: .4rem; }
.table-toolbar .tt-count { font-size: .74rem; color: var(--text-muted); font-weight: 400; }

/* the fixed-height scroll container */
.table-scroll { height: calc(100vh - 250px); min-height: 300px; overflow: auto; position: relative; }
.table-scroll.short { height: calc(100vh - 340px); min-height: 240px; }
.table-scroll.tall  { height: calc(100vh - 200px); }

/* On the reports page the table panel is sized (by App.syncFilterHeights) to
   match the filter panel exactly, so the two columns line up bottom-to-bottom.
   The scroll area then flexes to fill whatever height the panel is given. */
.report-layout .table-scroll,
.report-layout .table-scroll.short {
  height: auto; flex: 1 1 auto; min-height: 200px;
}

/* Quick date-range buttons injected above every date filter.
   Sized to content and wrapped, so the full nine presets stay compact in a
   narrow filter column instead of stretching to ragged widths. */
.date-quick {
  display: flex; flex-wrap: wrap; gap: .3rem;
  margin-bottom: .85rem;
}
.date-quick .btn {
  flex: 0 1 auto;
  padding: .26rem .55rem;
  font-size: .74rem;
  white-space: nowrap;
  border-radius: 999px;      /* pill chips read as quick toggles, not form buttons */
}
.date-quick .btn.active {
  background: var(--brand); border-color: var(--brand); color: #fff;
  box-shadow: 0 2px 6px color-mix(in srgb, var(--brand) 30%, transparent);
}

/* A faint label so the row of chips is obviously the date shortcut set. */
.date-quick::before {
  content: "Quick range";
  flex-basis: 100%;
  font-size: .72rem; font-weight: 600;
  color: var(--text-muted);
  margin-bottom: .1rem;
}

/* =====================================================================
   7. TABLES
   ===================================================================== */

.table {
  margin: 0; font-size: .83rem; color: var(--text);
  --bs-table-bg: transparent; border-color: var(--border);
}
.table > :not(caption) > * > * { background: transparent; color: var(--text); border-color: var(--border); }

.table thead th {
  position: sticky; top: 0; z-index: 5;
  background: var(--thead-bg); color: var(--text);
  font-size: .73rem; text-transform: uppercase; letter-spacing: .5px; font-weight: 700;
  white-space: nowrap; padding: .6rem .6rem; border-bottom: 2px solid var(--border);
  vertical-align: middle;
}
.table tbody td { padding: .5rem .6rem; vertical-align: middle; border-bottom: 1px solid var(--border); }
.table tbody tr:nth-child(even) { background: var(--row-alt); }
.table tbody tr { transition: background .16s var(--ease); }
.table tbody tr:hover { background: var(--row-hover); }
.table tbody tr.is-selected { background: var(--brand-soft); box-shadow: inset 3px 0 0 var(--brand); }

/* sticky totals row */
.table tfoot th, .table tfoot td {
  position: sticky; bottom: 0; z-index: 6;
  background: var(--tfoot-bg); font-weight: 700; font-size: .82rem;
  border-top: 2px solid var(--border); padding: .55rem .6rem; white-space: nowrap;
}

/* column header menu (sort + filter) */
.th-wrap { display: flex; align-items: center; gap: .3rem; justify-content: space-between; }
.th-menu-btn {
  background: none; border: 0; padding: 1px 3px; border-radius: 5px;
  color: var(--text-muted); font-size: .72rem; opacity: .55; transition: all .18s var(--ease);
}
th:hover .th-menu-btn { opacity: 1; }
.th-menu-btn:hover { background: var(--brand); color: #fff; opacity: 1; }
.th-menu-btn.is-filtered { opacity: 1; color: var(--brand); }
.th-menu-btn.is-sorted   { opacity: 1; color: var(--brand); }

.col-menu {
  position: absolute; z-index: 1060; min-width: 210px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lift); padding: .45rem;
  animation: fadeUp .16s var(--ease) both;
}
.col-menu .cm-item {
  display: flex; align-items: center; gap: .5rem; width: 100%;
  padding: .4rem .55rem; border: 0; background: none; border-radius: 7px;
  color: var(--text); font-size: .82rem; text-align: left;
}
.col-menu .cm-item:hover { background: var(--brand-soft); color: var(--brand-dark); }
.col-menu .cm-sep { height: 1px; background: var(--border); margin: .35rem .2rem; }
.col-menu input { font-size: .82rem; }

.text-end-num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: "Consolas", "SFMono-Regular", ui-monospace, monospace; }

.barcode-chip {
  display: inline-flex; align-items: center; gap: .3rem;
  font-family: "Consolas", ui-monospace, monospace; font-size: .78rem; font-weight: 600;
  background: var(--brand-soft); color: var(--brand-dark);
  padding: .12rem .45rem; border-radius: 6px; border: 1px solid color-mix(in srgb, var(--brand) 22%, transparent);
}

.badge-status { font-size: .68rem; font-weight: 600; padding: .25rem .5rem; border-radius: 6px; text-transform: capitalize; }
.st-in_stock, .st-active, .st-completed { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.st-issued   { background: color-mix(in srgb, var(--info) 16%, transparent); color: var(--info); }
.st-pending  { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.st-consumed { background: color-mix(in srgb, var(--text-muted) 18%, transparent); color: var(--text-muted); }
.st-damaged, .st-rejected, .st-inactive, .st-returned_supplier {
  background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }

.sev-out      { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); font-weight: 700; }
.sev-critical { background: color-mix(in srgb, var(--warn) 20%, transparent);  color: var(--warn);  font-weight: 700; }
.sev-low      { background: color-mix(in srgb, var(--info) 16%, transparent);  color: var(--info); }

.row-actions { display: flex; gap: .25rem; }
.btn-row {
  width: 28px; height: 28px; padding: 0; display: grid; place-items: center;
  border: 1px solid var(--border); background: var(--surface); border-radius: 7px;
  color: var(--text-muted); font-size: .78rem; transition: all .18s var(--ease);
}
.btn-row:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.btn-row.r-edit:hover  { border-color: var(--info);   color: var(--info); }
.btn-row.r-del:hover   { border-color: var(--danger); color: var(--danger); }
.btn-row.r-view:hover  { border-color: var(--brand);  color: var(--brand); }
.btn-row.r-print:hover { border-color: var(--brand-2); color: var(--brand-2); }

.table-empty { padding: 3rem 1rem; text-align: center; color: var(--text-muted); }
.table-empty i { font-size: 2.4rem; opacity: .35; display: block; margin-bottom: .6rem; }

.table-loading { position: absolute; inset: 0; display: grid; place-items: center;
  background: color-mix(in srgb, var(--surface) 72%, transparent); z-index: 20; }

/* =====================================================================
   8. FORMS, SELECT2, BUTTONS
   ===================================================================== */

.form-label { font-size: .76rem; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .4px; margin-bottom: .25rem; }

.form-control, .form-select {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  border-radius: 9px; font-size: .85rem; padding: .45rem .65rem;
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.form-control:focus, .form-select:focus {
  background: var(--surface); color: var(--text);
  border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent);
}
.form-control::placeholder { color: var(--text-muted); opacity: .7; }
.form-control:disabled, .form-control[readonly] { background: var(--surface-2); opacity: .85; }
.form-control-sm, .form-select-sm { font-size: .8rem; padding: .32rem .55rem; }

.form-floating > label { color: var(--text-muted); }
.form-floating > .form-control:focus ~ label { color: var(--brand); }

.invalid-feedback { font-size: .74rem; }
.form-control.is-invalid, .form-select.is-invalid { border-color: var(--danger); }
.is-invalid ~ .invalid-feedback { display: block; }

.btn { border-radius: 9px; font-size: .85rem; font-weight: 500; padding: .45rem .85rem;
  transition: transform .18s var(--ease), box-shadow .18s var(--ease), background .18s var(--ease); }
.btn:active { transform: translateY(1px); }

.btn-brand { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-brand:hover, .btn-brand:focus { background: var(--brand-dark); border-color: var(--brand-dark);
  color: #fff; box-shadow: 0 5px 14px color-mix(in srgb, var(--brand) 40%, transparent); transform: translateY(-2px); }
.btn-outline-brand { border: 1px solid var(--brand); color: var(--brand); background: transparent; }
.btn-outline-brand:hover { background: var(--brand); color: #fff; }

.btn-soft { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); }
.btn-soft:hover { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-dark); }

.btn-toolbar-group .btn { font-size: .78rem; padding: .32rem .6rem; }

/* Select2 skinned to match */
.select2-container--default .select2-selection--single,
.select2-container--default .select2-selection--multiple {
  background: var(--surface); border: 1px solid var(--border); border-radius: 9px;
  min-height: 36px; color: var(--text);
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
  color: var(--text); line-height: 34px; font-size: .85rem; padding-left: .65rem;
}
.select2-container--default .select2-selection--single .select2-selection__arrow { height: 34px; }
.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--focus .select2-selection--multiple {
  border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent);
}
.select2-dropdown {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lift);
}
.select2-container--default .select2-results__option { color: var(--text); font-size: .85rem; padding: .4rem .65rem; }
.select2-container--default .select2-results__option--highlighted[aria-selected] { background: var(--brand); color: #fff; }
.select2-container--default .select2-search--dropdown .select2-search__field {
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 7px;
}
.select2-container--default .select2-selection--multiple .select2-selection__choice {
  background: var(--brand-soft); border: 1px solid var(--brand); color: var(--brand-dark); border-radius: 6px;
}

/* modal skin */
.modal-content { background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lift); }
.modal-header { border-bottom: 1px solid var(--border); background: var(--surface-2);
  border-radius: var(--radius) var(--radius) 0 0; }
.modal-footer { border-top: 1px solid var(--border); background: var(--surface-2);
  border-radius: 0 0 var(--radius) var(--radius); }
.modal-title { font-size: 1rem; font-weight: 600; }
.modal-title i { color: var(--brand); }
.btn-close { filter: none; }
[data-theme="dark"] .btn-close, [data-theme="midnight"] .btn-close { filter: invert(1) grayscale(1); }

.nav-pills .nav-link { color: var(--text-muted); border-radius: 8px; font-size: .84rem; }
.nav-pills .nav-link.active { background: var(--brand); color: #fff; }

/* wizard stepper */
.stepper { display: flex; gap: .4rem; margin-bottom: 1rem; flex-wrap: wrap; }
.step {
  display: flex; align-items: center; gap: .5rem; flex: 1; min-width: 160px;
  padding: .6rem .8rem; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border);
  transition: all .25s var(--ease);
}
.step .step-no {
  width: 26px; height: 26px; flex-shrink: 0; display: grid; place-items: center;
  border-radius: 50%; background: var(--border); color: var(--text-muted);
  font-weight: 700; font-size: .76rem;
}
.step .step-label { font-size: .8rem; font-weight: 600; line-height: 1.1; }
.step .step-hint  { font-size: .7rem; color: var(--text-muted); }
.step.is-active { border-color: var(--brand); background: var(--brand-soft); box-shadow: var(--shadow); }
.step.is-active .step-no { background: var(--brand); color: #fff; }
.step.is-done .step-no { background: var(--ok); color: #fff; }
.step.is-done .step-no::before { content: "\F26E"; font-family: "bootstrap-icons"; }
.step.is-done .step-no span { display: none; }

/* cart list used by every scan-based flow */
.cart-list { max-height: 340px; overflow-y: auto; }
.cart-item {
  display: flex; align-items: center; gap: .7rem;
  padding: .55rem .7rem; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); margin-bottom: .45rem;
  animation: fadeUp .22s var(--ease) both;
}
.cart-item .ci-main { flex: 1; min-width: 0; }
.cart-item .ci-name { font-weight: 600; font-size: .85rem; }
.cart-item .ci-meta { font-size: .74rem; color: var(--text-muted); }
.cart-empty { padding: 2.4rem 1rem; text-align: center; color: var(--text-muted); }
.cart-empty i { font-size: 2.2rem; opacity: .35; display: block; margin-bottom: .5rem; }

/* =====================================================================
   9. SCAN MODAL & BARCODE LABELS
   ===================================================================== */

.scan-tabs .nav-link { font-size: .82rem; }
.scan-reader { width: 100%; min-height: 260px; border-radius: var(--radius-sm);
  overflow: hidden; background: #000; }
.scan-reader video { width: 100% !important; border-radius: var(--radius-sm); }

.scan-result:empty { display: none; }
.scan-card {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: .8rem; background: var(--surface-2); animation: fadeUp .25s var(--ease) both;
}
.scan-card .sc-code { font-family: ui-monospace, Consolas, monospace; font-size: 1.1rem;
  font-weight: 700; color: var(--brand); }
.scan-card .sc-name { font-weight: 600; }
.scan-card .sc-meta { font-size: .78rem; color: var(--text-muted); }
.scan-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .7rem; }

/* on-screen preview of the printable label sheet */
.label-sheet { display: flex; flex-wrap: wrap; gap: 4mm; }
.label {
  width: 50mm; height: 25mm; box-sizing: border-box;
  border: 1px dashed #b9c4c0; border-radius: 3px;
  padding: 1.2mm 1.6mm; background: #fff; color: #000;
  display: flex; flex-direction: column; justify-content: space-between;
  font-family: Arial, Helvetica, sans-serif; overflow: hidden;
}
.label .lb-name { font-size: 7.4pt; font-weight: 700; line-height: 1.05;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.label .lb-bar { flex: 1; display: grid; place-items: center; min-height: 0; }
.label .lb-bar svg { max-width: 100%; height: 100%; }
.label .lb-foot { display: flex; justify-content: space-between; font-size: 6pt; line-height: 1; }
.label .lb-qty { font-weight: 700; }

/* =====================================================================
   10. DASHBOARD & MISC
   ===================================================================== */

.chart-box { position: relative; height: 280px; }
.chart-box.sm { height: 220px; }

.timeline { position: relative; padding-left: 1.6rem; }
.timeline::before { content: ""; position: absolute; left: .45rem; top: .3rem; bottom: .3rem;
  width: 2px; background: var(--border); }
.tl-item { position: relative; padding-bottom: 1rem; }
.tl-item::before {
  content: ""; position: absolute; left: -1.35rem; top: .28rem;
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--brand); border: 2px solid var(--surface); box-shadow: 0 0 0 2px var(--brand);
}
.tl-item.t-in::before     { background: var(--ok);     box-shadow: 0 0 0 2px var(--ok); }
.tl-item.t-out::before    { background: var(--info);   box-shadow: 0 0 0 2px var(--info); }
.tl-item.t-bad::before    { background: var(--danger); box-shadow: 0 0 0 2px var(--danger); }
.tl-title { font-weight: 600; font-size: .85rem; }
.tl-meta  { font-size: .76rem; color: var(--text-muted); }

.activity-feed { max-height: 380px; overflow-y: auto; }
.act-item { display: flex; gap: .65rem; padding: .55rem 0; border-bottom: 1px solid var(--border); }
.act-item:last-child { border-bottom: 0; }
.act-icon { width: 30px; height: 30px; flex-shrink: 0; display: grid; place-items: center;
  border-radius: 8px; background: var(--brand-soft); color: var(--brand); font-size: .82rem; }
.act-text { font-size: .82rem; line-height: 1.3; }
.act-time { font-size: .72rem; color: var(--text-muted); }

.perm-table th { position: sticky; top: 0; }
.perm-table td, .perm-table th { text-align: center; }
.perm-table td:first-child, .perm-table th:first-child { text-align: left; }
.perm-group-row td { background: var(--thead-bg); font-weight: 700; font-size: .74rem;
  text-transform: uppercase; letter-spacing: .6px; }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }

.print-frame { position: fixed; width: 0; height: 0; border: 0; visibility: hidden; }

.swal2-popup { border-radius: var(--radius) !important; font-size: .9rem; }

.spin-overlay { position: fixed; inset: 0; z-index: 2000; display: grid; place-items: center;
  background: rgba(0, 0, 0, .35); backdrop-filter: blur(2px); }

/* =====================================================================
   11. PRINT
   ===================================================================== */

@media print {
  .app-navbar, .page-head, .app-footer, .filter-panel,
  .table-toolbar, .no-print, .modal, .btn { display: none !important; }
  body { background: #fff; color: #000; }
  .work-layout { display: block; }
  .table-scroll { height: auto !important; overflow: visible !important; }
  .table thead th { position: static; background: #eee !important; color: #000 !important; }
  .table tfoot th, .table tfoot td { position: static; background: #eee !important; color: #000 !important; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}

/* label sheet printing — exact 50mm x 25mm stock */
@page label-page { size: 50mm 25mm; margin: 0; }

.print-labels-only { display: none; }

@media print {
  .print-labels-only { display: block; }
  .print-labels-only .label {
    width: 50mm; height: 25mm; border: 0; border-radius: 0;
    page-break-after: always; break-after: page;
    margin: 0; padding: 1.2mm 1.6mm;
  }
  .print-labels-only .label:last-child { page-break-after: auto; break-after: auto; }
  /* grid mode: many labels on one A4 sheet */
  .print-labels-only.sheet-grid { display: grid; grid-template-columns: repeat(4, 50mm); gap: 2mm; }
  .print-labels-only.sheet-grid .label {
    page-break-after: auto; break-after: auto;
    border: 1px dotted #999;
  }
}

/* =====================================================================
   12. RESPONSIVE
   ===================================================================== */

@media (max-width: 1399.98px) {
  .global-search { width: 190px; }
  .app-navbar .nav-link { padding: .45rem .6rem; font-size: .84rem; }
}

@media (max-width: 1199.98px) {
  .nav-tools { width: 100%; margin-top: .6rem; flex-wrap: wrap; }
  .global-search { width: 100%; order: -1; }
  .app-navbar .navbar-collapse { max-height: 78vh; overflow-y: auto; padding-bottom: .6rem; }
  /* Scoped to .navbar-nav: these menus sit INSIDE the collapsed panel, so a
     translucent fill reads correctly against the navbar. The tool dropdowns
     (profile, notifications, theme) float over page content and are styled
     separately below with a solid surface. */
  .app-navbar .navbar-nav .dropdown-menu { background: rgba(255, 255, 255, .07); border: 0; box-shadow: none; }
  .app-navbar .navbar-nav .dropdown-item { color: rgba(255, 255, 255, .9); }
  .app-navbar .navbar-nav .dropdown-item:hover { background: rgba(255, 255, 255, .16); color: #fff; }
  .app-navbar .navbar-nav .dropdown-header { color: rgba(255, 255, 255, .6); }
}

@media (max-width: 991.98px) {
  .work-layout, .work-layout.wide-filter { grid-template-columns: 1fr; }
  .filter-panel { position: static; max-height: none; }
  .filter-panel .fp-body { max-height: 340px; }
  .table-scroll { height: 60vh; }
  .kpi-value { font-size: 1.2rem; }
}

@media (max-width: 575.98px) {
  .app-main { padding: .8rem .5rem 1.6rem; }
  .page-title { font-size: 1.05rem; }
  .table { font-size: .78rem; }
  .table thead th { font-size: .68rem; }
  .theme-grid { grid-template-columns: 1fr; }
  .notif-menu { width: 300px; }
  .step { min-width: 100%; }
}

/* =====================================================================
   13. VENDOR PAYMENTS & DUES
   ===================================================================== */

/* Outstanding summary shown inside the payment modal once a supplier is
   chosen, so the user sees what is owed before typing an amount. */
.due-box {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .6rem;
  padding: .8rem .9rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  animation: fadeUp .22s var(--ease) both;
}
.due-box-item { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.due-box-item .dbl {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .8px;
  font-weight: 700; color: var(--text-muted);
}
.due-box-item strong { font-size: 1.02rem; font-weight: 700; }

/* Ageing legend in the report filter panel */
.ageing-legend { display: flex; flex-direction: column; gap: .4rem; }
.al-title {
  font-size: .68rem; text-transform: uppercase; letter-spacing: 1px;
  font-weight: 700; color: var(--text-muted); margin-bottom: .1rem;
}
.al-item { display: flex; align-items: center; gap: .45rem; font-size: .78rem; color: var(--text); }
.al-item b { margin-left: auto; font-size: .76rem; font-variant-numeric: tabular-nums; }
.al-dot { width: 11px; height: 11px; border-radius: 3px; flex-shrink: 0; }
.al-dot.b1 { background: #2e9e6b; }
.al-dot.b2 { background: #e0a83b; }
.al-dot.b3 { background: #e0762c; }
.al-dot.b4 { background: #d1435b; }

/* Supplier statement modal */
.stmt-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .7rem; }
.ss-item {
  display: flex; flex-direction: column; gap: .2rem;
  padding: .7rem .8rem;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.ss-item span {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .8px;
  font-weight: 700; color: var(--text-muted);
}
.ss-item strong { font-size: 1.05rem; font-variant-numeric: tabular-nums; }

/* Overdue bill rows read as a warning without shouting. */
.row-overdue { background: rgba(208, 56, 78, .08) !important; }
.row-overdue td { border-color: rgba(208, 56, 78, .25) !important; }

/* Neutral pill used for "On account", payment modes, etc. */
.badge-soft {
  display: inline-block; padding: .2rem .55rem;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; font-size: .72rem; font-weight: 600;
  color: var(--text-muted); white-space: nowrap;
}
.link-brand { color: var(--brand); font-weight: 600; text-decoration: none; }
.link-brand:hover { color: var(--brand-dark); text-decoration: underline; }

@media (max-width: 575.98px) {
  .due-box { grid-template-columns: 1fr; }
}

/* =====================================================================
   14. UI REFINEMENTS
   Loaded last so these intentionally win over the base component rules.
   ===================================================================== */

/* ---- navbar ---- */
.app-navbar {
  padding: .3rem .25rem;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .08) inset, 0 4px 22px rgba(0, 0, 0, .18);
}
.app-navbar .container-fluid { gap: .5rem; }
.app-navbar .nav-link { font-size: .855rem; padding: .46rem .7rem; border-radius: 10px; }
.app-navbar .nav-link.active::after {
  width: 60%; height: 2px; bottom: 3px; border-radius: 2px;
  transition: width .25s var(--ease);
}

/* Login screen wordmark — full colour on its light background. */

/* Icon buttons: circular, matching the avatar on a consistent 38px rhythm. */
.btn-icon {
  border-radius: 50%;
  background: rgba(255, 255, 255, .12);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .1);
}
.btn-icon:hover {
  background: rgba(255, 255, 255, .26);
  transform: translateY(-1px);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .24), 0 4px 12px rgba(0, 0, 0, .2);
}

/* Fixed width — deliberately does NOT grow on focus. Widening it reflowed the
   flex row and pushed the menu items into a ragged second line. */
.global-search { width: 200px; flex-shrink: 0; }
.global-search .form-control { border-radius: 999px; height: 38px; width: 100%; }
.global-search .form-control:focus { width: 100%; }

/* ---- cards ---- */
.card { border-radius: var(--radius); transition: transform .25s var(--ease), box-shadow .25s var(--ease); }
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.card-header {
  font-weight: 600; letter-spacing: -.2px;
  background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.card-header i { color: var(--brand); }

.kpi { border-radius: var(--radius); }
.kpi::before { width: 4px; border-radius: var(--radius) 0 0 var(--radius); }
.kpi:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); }
.kpi-value { font-variant-numeric: tabular-nums; letter-spacing: -.5px; }

/* ---- buttons ---- */
.btn-brand {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
  border: 0; color: #fff; font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .12);
  transition: transform .18s var(--ease), box-shadow .18s var(--ease), filter .18s var(--ease);
}
.btn-brand:hover {
  color: #fff; filter: brightness(1.07); transform: translateY(-1px);
  box-shadow: 0 5px 16px rgba(0, 0, 0, .18);
}
.btn-brand:active { transform: translateY(0); }

.btn-soft {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  font-weight: 500; transition: all .18s var(--ease);
}
.btn-soft:hover {
  background: var(--brand-soft); border-color: var(--brand);
  color: var(--brand-dark); transform: translateY(-1px);
}

/* ---- tables ---- */
.table thead th {
  text-transform: uppercase; font-size: .7rem; letter-spacing: .6px;
  font-weight: 700; color: var(--text-muted);
}
.table tbody tr { transition: background .15s var(--ease); }
.table td, .table th { vertical-align: middle; }
.mono, .table .text-end { font-variant-numeric: tabular-nums; }

/* ---- filter panel ---- */
.filter-panel { border-radius: var(--radius); }
.fp-head { font-size: .72rem; text-transform: uppercase; letter-spacing: 1px; font-weight: 700; color: var(--text-muted); }

/* ---- forms ---- */
.form-control, .form-select {
  border-radius: var(--radius-sm);
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}
.form-control:focus, .form-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(46, 125, 91, .16);
}
.form-label { font-size: .78rem; font-weight: 600; color: var(--text-muted); }

/* ---- modals ---- */
.modal-content { border: 0; border-radius: var(--radius); box-shadow: var(--shadow-lift); }
.modal-header {
  background: var(--surface-2); border-bottom: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
}
.modal-header .modal-title i { color: var(--brand); }

/* ---- responsive header ----
   The navbar expands at xl (1200px). Below that the menu collapses, so the
   inline search field is swapped for an icon that opens a full-width panel —
   this keeps the bar to: brand | icons | burger at every small size. */
@media (max-width: 1199.98px) {
  .global-search { display: none; }
  .global-search.is-open {
    display: block;
    position: absolute; top: 100%; left: 0; right: 0;
    width: auto; padding: .6rem .75rem;
    background: var(--navbar-bg);
    box-shadow: 0 8px 18px rgba(0, 0, 0, .22);
    z-index: 1041;
  }
  .global-search.is-open .gs-results { left: .75rem; right: .75rem; }
  .nav-sep { display: none; }
  .nav-tools { gap: .3rem; }

  /* Collapsed menu becomes a proper stacked panel instead of floating items.
     overflow-y is only allowed once the panel is actually open — leaving it
     scrollable while collapsed is what painted a scrollbar across the header. */
  .app-navbar .navbar-collapse {
    background: rgba(0, 0, 0, .16);
    border-radius: var(--radius-sm);
    margin-top: .5rem;
    padding: .4rem;
  }
  .app-navbar .navbar-collapse.show,
  .app-navbar .navbar-collapse.collapsing {
    max-height: 70vh;
    overflow-y: auto;
  }
  .app-navbar .navbar-collapse:not(.show):not(.collapsing) {
    overflow: hidden;
  }
  .app-navbar .navbar-nav .nav-link { padding: .6rem .8rem; }
  /* Nav menus only — see the note in the 1199px block above. */
  .app-navbar .navbar-nav .dropdown-menu {
    border: 0; box-shadow: none;
    background: rgba(255, 255, 255, .06);
    margin: .15rem 0 .35rem .6rem;
  }
  .app-navbar .navbar-nav .dropdown-item { color: rgba(255, 255, 255, .9); }
  .app-navbar .navbar-nav .dropdown-item:hover,
  .app-navbar .navbar-nav .dropdown-item:focus { background: rgba(255, 255, 255, .16); color: #fff; }
  .app-navbar .navbar-nav .dropdown-header { color: rgba(255, 255, 255, .6); }

  /* Tool dropdowns float above page content, so they need a solid, opaque
     surface — a translucent fill left them unreadable on mobile. */
  .nav-tools .dropdown-menu {
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lift);
    color: var(--text);
  }
  .nav-tools .dropdown-item { color: var(--text); }
  .nav-tools .dropdown-item:hover,
  .nav-tools .dropdown-item:focus { background: var(--brand-soft); color: var(--brand-dark); }
  .nav-tools .dropdown-header { color: var(--text-muted); }
  /* Viewport anchoring for these menus is handled in the 767px block below —
     it pins them with left/right gutters so they never overflow the screen. */
  .app-navbar .dropdown-divider { border-color: rgba(255, 255, 255, .18); }
}

/* Show the search-toggle icon exactly when the field is hidden. */
#btnSearchToggle { display: none; }
@media (max-width: 1199.98px) {
  #btnSearchToggle { display: grid; }
}

/* The navbar itself must never scroll — a stray overflow here put a
   scrollbar across the top of every page. */
.app-navbar,
.app-navbar > .container-fluid { overflow: visible; }
.app-navbar .navbar-nav { overflow: visible; }

/* --- mobile: brand centred above the tool row --- */
@media (max-width: 767.98px) {
  .app-navbar > .container-fluid {
    flex-wrap: wrap;
    justify-content: center;
    row-gap: .35rem;
  }
  .app-navbar .navbar-brand {
    width: 100%;
    justify-content: center;
    margin: 0;
    padding-top: .3rem;
  }
  /* The brand has its own full-width row here, so the wordmark can breathe. */
  .brand-logo { height: 58px; }

  /* Tools become their own centred row rather than hugging the right edge. */
  .nav-tools {
    width: 100%;
    margin-left: 0;
    justify-content: center;
    gap: .3rem;
    flex-wrap: nowrap;          /* keep every tool + the toggler on one line */
  }

  /* Consistent circular tool icons on mobile. The `.btn min-height: 40px`
     comfort rule elsewhere in this block was stretching the .btn-classed ones
     (scan / bell / theme) to 40px tall while width stayed 36px, rendering them
     as ovals — so pin an equal width AND height here and beat that min-height. */
  .nav-tools .btn-icon,
  .nav-tools .btn-avatar,
  .app-navbar .navbar-toggler {
    width: 36px; height: 36px; min-height: 36px;
    flex: 0 0 36px;
    padding: 0;
    display: grid; place-items: center;
    border-radius: 50%;
    font-size: 1rem; line-height: 1;
  }
  .app-navbar .navbar-toggler { font-size: 1.25rem; }
  .nav-tools .btn-icon i,
  .app-navbar .navbar-toggler i { line-height: 1; }

  /* Keep the toggler last and the avatar just before it. The .nav-sep in the
     markup already separates this pair — no positioned wrapper needed, which
     is what previously collapsed the profile menu (see the dropdown rule). */
  .nav-tools .navbar-toggler { order: 99; margin-left: .1rem; }
  .nav-tools .dropdown:has(.btn-avatar) { order: 98; }

  /* Tool dropdowns (notifications / theme / profile) pin to the viewport so a
     wide menu can never run off an edge. The toggles carry
     data-bs-display="static", so Popper sets no inline transform to fight.
     Every wrapper MUST stay position:static so the menu's containing block is
     .app-navbar (sticky = positioned), not the 38px wrapper — a positioned
     wrapper made left:8px/right:8px collapse the menu to a ~22px sliver. */
  .nav-tools .dropdown { position: static; }
  .nav-tools .dropdown-menu {
    position: absolute;
    top: 100%; left: 8px; right: 8px;
    width: auto !important; min-width: 0 !important; max-width: none !important;
    transform: none !important;
    margin-top: .4rem;
    max-height: calc(100vh - 130px);
    overflow-y: auto;
  }
  /* Theme swatches get two roomy columns across the full width. */
  .nav-tools .theme-menu .theme-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 400px) {
  .brand-logo { height: 50px; }
}

/* =====================================================================
   15. ENTITY DRILL-DOWN MODAL
   ===================================================================== */

.detail-header { align-items: flex-start; }
.dh-main { display: flex; gap: .8rem; align-items: center; min-width: 0; }
.dh-icon {
  width: 44px; height: 44px; flex-shrink: 0;
  display: grid; place-items: center; border-radius: 12px;
  background: var(--brand-soft); color: var(--brand); font-size: 1.3rem;
}
.dh-sub { font-size: .78rem; color: var(--text-muted); margin-top: .1rem; }

.detail-rangebar {
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem;
  padding: .7rem 1rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.dr-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .8px;
  font-weight: 700; color: var(--text-muted); }
.detail-rangebar input[type="date"] { width: 150px; }
.dr-to { font-size: .8rem; color: var(--text-muted); }
.dr-presets { display: flex; flex-wrap: wrap; gap: .3rem; margin-left: auto; }
.dr-presets .btn { font-size: .74rem; padding: .25rem .6rem; }

.detail-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: .7rem; margin-bottom: 1.1rem;
}
.ds-item {
  display: flex; flex-direction: column; gap: .15rem;
  padding: .75rem .85rem; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border);
  border-left: 3px solid var(--border);
}
.ds-item.t-ok     { border-left-color: var(--ok); }
.ds-item.t-info   { border-left-color: var(--info); }
.ds-item.t-warn   { border-left-color: var(--warn); }
.ds-item.t-danger { border-left-color: var(--danger); }
.ds-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .8px;
  font-weight: 700; color: var(--text-muted); }
.ds-value { font-size: 1.08rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.ds-sub { font-size: .72rem; color: var(--text-muted); }

.detail-block { margin-bottom: 1.3rem; }
.detail-block:last-child { margin-bottom: 0; }
.detail-block h6 {
  font-size: .84rem; font-weight: 700; margin-bottom: .5rem;
  padding-bottom: .4rem; border-bottom: 1px solid var(--border);
}
.detail-block h6 i { color: var(--brand); }
.detail-table thead th {
  background: var(--thead-bg); position: sticky; top: 0; z-index: 1;
  font-size: .68rem;
}
.detail-table tbody tr:nth-child(even) { background: var(--row-alt); }
.detail-table tbody tr:hover { background: var(--row-hover); }
/* Totals row pinned to the bottom of each drill-down table. */
.detail-table tfoot .detail-total th {
  position: sticky; bottom: 0; z-index: 1;
  background: var(--tfoot-bg);
  border-top: 2px solid var(--brand);
  font-weight: 700; font-size: .74rem;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.detail-empty {
  padding: 1.2rem; text-align: center; color: var(--text-muted);
  font-size: .82rem; background: var(--surface-2);
  border: 1px dashed var(--border); border-radius: var(--radius-sm);
}

/* Clickable master-row names */
.js-detail { cursor: pointer; transition: color .16s var(--ease); }
.js-detail:hover { color: var(--brand); text-decoration: underline; }

/* =====================================================================
   17. CONFIRMATIONS, TWO-COLUMN REPORTS MENU, CLICKABLE TILES
   ===================================================================== */

/* Reports menu in two columns.
   IMPORTANT: the grid is applied ONLY on `.show`. Styling the base
   `.dropdown-menu.reports-menu` with a display value overrides Bootstrap's
   `display: none` and pins the menu permanently open. */
.dropdown-menu.reports-menu {
  min-width: 540px;
  padding: .5rem;
}
.dropdown-menu.reports-menu.show {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 .4rem;
}
/* Headers and dividers span both columns so the groups stay readable. */
.reports-menu > li.rm-full { grid-column: 1 / -1; }
.reports-menu .dropdown-header { padding-top: .45rem; }

@media (max-width: 1199.98px) {
  /* Inside the collapsed mobile panel a grid would be cramped. */
  .dropdown-menu.reports-menu { min-width: 0; }
  .dropdown-menu.reports-menu.show { display: block; }
}

/* Rows waiting on the current user get a warm left edge. */
.row-pending td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.row-pending { background: color-mix(in srgb, var(--warn) 7%, transparent); }

/* KPI tiles that navigate or filter. */
.kpi-link {
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}
.kpi-link:hover { color: inherit; }
.kpi-link:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.kpi-link::after {
  content: "\F285";                       /* bootstrap-icons chevron-right */
  font-family: "bootstrap-icons";
  position: absolute; right: .7rem; top: 50%;
  transform: translateY(-50%) translateX(-4px);
  opacity: 0; font-size: .9rem; color: var(--text-muted);
  transition: opacity .2s var(--ease), transform .2s var(--ease);
}
.kpi-link:hover::after { opacity: .8; transform: translateY(-50%) translateX(0); }

/* Confirm/reject row buttons */
/* =====================================================================
   18. ACTION BUTTONS, HIGHLIGHTED BALANCES, PER-OUTLET COLOURS
   ===================================================================== */

/* Confirm / reject and the admin approve / decline pair are decisions, not
   navigation — they get solid fills so they read at a glance instead of
   looking like every other icon button in the row. */
.btn-row.r-ok,
.btn-row.js-confirm,
.btn-row.js-admin-ok {
  background: var(--ok);
  border-color: var(--ok);
  color: #fff;
}
.btn-row.r-ok:hover,
.btn-row.js-confirm:hover,
.btn-row.js-admin-ok:hover {
  background: color-mix(in srgb, var(--ok) 82%, #000);
  border-color: color-mix(in srgb, var(--ok) 82%, #000);
  color: #fff;
}

.btn-row.js-reject,
.btn-row.js-admin-no {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.btn-row.js-reject:hover,
.btn-row.js-admin-no:hover {
  background: color-mix(in srgb, var(--danger) 82%, #000);
  border-color: color-mix(in srgb, var(--danger) 82%, #000);
  color: #fff;
}

/* The admin pair is a different decision from a receipt, so it is tinted
   amber rather than reusing the green/red of confirm/reject. Darkened from
   --warn so white icons clear 4.5:1 against it. */
.btn-row.js-admin-ok {
  background: #a45f12;
  border-color: #a45f12;
}
.btn-row.js-admin-ok:hover {
  background: #8a4f0d;
  border-color: #8a4f0d;
}

/* Keep the view button neutral so the coloured pair stands out. */
.row-actions .btn-row.r-view { background: var(--surface); }

/* ---- highlighted stock balances ----
   The quantity is the number people come to these screens for, so it is
   given a tinted chip instead of being plain text in a row of plain text. */
.stock-figure {
  display: inline-block;
  padding: .18rem .5rem;
  border-radius: 7px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: var(--brand-soft);
  /* --text (not --brand-dark): --brand-soft is a DARK tint in the dark skins,
     where a mid-tone brand foreground drops under 4:1. --text always contrasts
     with its own surface, so the chip stays legible in all ten themes. */
  color: var(--text);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand) 30%, transparent);
}
.stock-figure.is-low {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--danger);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--danger) 32%, transparent);
}
.stock-figure.is-zero {
  background: var(--surface-2);
  color: var(--text-muted);
  box-shadow: inset 0 0 0 1px var(--border);
}
.stock-figure .sf-unit { font-weight: 500; opacity: .75; font-size: .86em; }

.stock-value {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

/* ---- per-outlet colour coding ----
   Every outlet gets its own hue so a name is recognisable at a glance in a
   mixed list. Assigned by id in app.js (outletTint), which cycles this set. */
.outlet-tag {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .18rem .55rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: .78rem;
  white-space: nowrap;
  background: var(--ot-bg, var(--surface-2));
  color: var(--ot-fg, var(--text));
  box-shadow: inset 0 0 0 1px var(--ot-br, var(--border));
}
.outlet-tag::before {
  content: "";
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ot-fg, var(--text-muted));
  flex-shrink: 0;
}
/* The godown itself is deliberately neutral — it is not one of the outlets. */
.outlet-tag.is-godown {
  --ot-bg: var(--surface-2);
  --ot-fg: var(--text-muted);
  --ot-br: var(--border);
}

/* The tint palette is picked for light surfaces. `dark` and `midnight` are the
   only skins with a dark --surface, where those mid-tone hues would sink into
   the background — so lift the text toward white and strengthen the fill. */
[data-theme="dark"] .outlet-tag,
[data-theme="midnight"] .outlet-tag {
  color: color-mix(in srgb, var(--ot-fg, var(--text)) 35%, #ffffff);
  background: color-mix(in srgb, var(--ot-fg, var(--text)) 26%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ot-fg, var(--text)) 48%, transparent);
}
[data-theme="dark"] .outlet-tag::before,
[data-theme="midnight"] .outlet-tag::before {
  background: color-mix(in srgb, var(--ot-fg, var(--text)) 30%, #ffffff);
}

/* Optimum-level warning list inside the issue screen */
.optimum-warn { margin: 0; padding-left: 1.1rem; font-size: .82rem; }
.optimum-warn li { margin-bottom: .2rem; }

/* =====================================================================
   BARCODE PRINT SETUP
   ===================================================================== */

.setup-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 1.1rem;
  align-items: start;
}
.setup-side { position: sticky; top: 82px; }

@media (max-width: 991.98px) {
  .setup-grid { grid-template-columns: 1fr; }
  .setup-side { position: static; }
}

/* Single vs double column picker */
.col-choice { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.col-opt { margin: 0; cursor: pointer; }
.col-opt input { position: absolute; opacity: 0; pointer-events: none; }
.co-card {
  display: flex; align-items: center; gap: .7rem;
  padding: .8rem .9rem; height: 100%;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2);
  transition: border-color .18s var(--ease), background .18s var(--ease), box-shadow .18s var(--ease);
}
.col-opt:hover .co-card { border-color: var(--brand); }
.col-opt input:checked + .co-card {
  border-color: var(--brand);
  background: var(--brand-soft);
  box-shadow: inset 0 0 0 1px var(--brand);
}
.col-opt input:focus-visible + .co-card { outline: 2px solid var(--brand); outline-offset: 2px; }
.co-vis {
  display: flex; gap: 3px; flex-shrink: 0;
  width: 44px; height: 30px; padding: 3px;
  border: 1px solid var(--border); border-radius: 5px; background: var(--surface);
}
.co-vis i {
  flex: 1; border-radius: 2px;
  background: repeating-linear-gradient(90deg, var(--brand) 0 1px, transparent 1px 3px);
  opacity: .8;
}
.co-txt { display: flex; flex-direction: column; line-height: 1.15; }
.co-txt small { color: var(--text-muted); font-size: .72rem; }

/* Live preview stage — a soft "roll" behind the label tags */
.preview-stage {
  padding: 1rem;
  border-radius: var(--radius-sm);
  background:
    repeating-linear-gradient(90deg, transparent 0 6px, rgba(0,0,0,.03) 6px 7px),
    var(--surface-2);
  border: 1px solid var(--border);
  overflow: auto;
}
.preview-stage .label-sheet { display: grid; justify-content: center; }
/* Each preview tag reads as a physical die-cut label. */
.preview-stage .label {
  background: #fff;
  border: 1px solid #d8d8d0;
  box-shadow: 0 1px 3px rgba(0,0,0,.12);
  box-sizing: border-box;
  padding: 1.2mm 1.6mm;
  display: flex; flex-direction: column; justify-content: space-between;
  overflow: hidden; color: #111;
}
.preview-stage .lb-co   { font-size: 6pt; font-weight: 700; text-align: center; color: #333; line-height: 1; }
.preview-stage .lb-name { font-size: 7.4pt; font-weight: 700; text-align: center; line-height: 1.05;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preview-stage .lb-bar  { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0; }
.preview-stage .lb-bar svg { max-width: 100%; height: 100%; }
.preview-stage .lb-foot { display: flex; justify-content: space-between; font-size: 6pt; line-height: 1; }
.preview-stage .lb-qty  { font-weight: 700; }

.guide-card ol { margin-bottom: .5rem; }
.guide-card li { margin-bottom: .35rem; }

/* Purchase line — Rate cell: a calculated read-out with a pen to override it.
   The pen only appears on row hover / focus so the grid stays calm. */
.rate-cell { position: relative; }
.rate-view {
  display: flex; align-items: center; justify-content: flex-end; gap: .3rem;
  min-height: 31px;
}
.rate-view .ln-rate-display {
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}
.rate-pen {
  width: 22px; height: 22px; flex-shrink: 0;
  display: grid; place-items: center;
  border: 0; border-radius: 6px; padding: 0;
  background: transparent; color: var(--text-muted);
  font-size: .72rem; opacity: 0;
  transition: opacity .15s var(--ease), background .15s var(--ease), color .15s var(--ease);
}
#lineTable tr:hover .rate-pen,
.rate-cell:focus-within .rate-pen { opacity: 1; }
.rate-pen:hover { background: var(--brand-soft); color: var(--brand-dark); }
/* While a rate is being overridden, mark the field so it is clearly manual. */
.rate-cell .ln-rate:not(.d-none) {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--warn) 32%, transparent);
}

/* "Apply to every outlet" — visually set apart, because it is a bulk
   overwrite rather than an ordinary field. */
.apply-all-box {
  padding: .7rem .85rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  transition: border-color .2s var(--ease), background .2s var(--ease);
}
.apply-all-box:has(input:checked) {
  border-color: var(--warn);
  border-style: solid;
  background: rgba(217, 131, 36, .08);
}
.apply-all-box .form-check-label { cursor: pointer; }

/* Soft navigation (fullscreen): a slim progress hint while the next page
   is fetched, since there is no browser loading indicator in this mode. */
.soft-nav-loading::after {
  content: "";
  position: fixed; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--brand), var(--brand-2), var(--brand));
  background-size: 200% 100%;
  animation: softNavBar .9s linear infinite;
  z-index: 2000;
}
@keyframes softNavBar {
  from { background-position: 0 0; }
  to   { background-position: 200% 0; }
}
.soft-nav-loading { cursor: progress; }

@media (max-width: 575.98px) {
  .dr-presets { margin-left: 0; width: 100%; }
  .detail-rangebar input[type="date"] { width: calc(50% - 1.2rem); }
  .detail-stats { grid-template-columns: 1fr 1fr; }
}

/* =====================================================================
   16. FINISHING PASS
   Depth, motion and mobile ergonomics. Last in the file on purpose.
   ===================================================================== */

/* Subtle depth behind the content instead of a flat fill. */
body {
  background-image:
    radial-gradient(1100px 520px at 8% -8%,  rgba(46, 125, 91, .07), transparent 60%),
    radial-gradient(900px 460px at 102% 4%, rgba(44, 123, 182, .06), transparent 62%);
  background-attachment: fixed;
}

/* Themed scrollbars — the default grey clashes with every dark skin. */
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border); border-radius: 8px;
  border: 2px solid var(--surface);
}
::-webkit-scrollbar-thumb:hover { background: var(--brand); }

/* Content settles in rather than snapping. */
.app-main > * { animation: fadeUp .28s var(--ease) both; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
  }
}

/* Page header gets the brand accent bar. */
.page-head {
  border-bottom: 0;
  box-shadow: 0 1px 0 var(--border);
  position: relative;
}
.page-head::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: linear-gradient(180deg, var(--brand), var(--brand-2));
}

/* Table polish: tighter zebra, clearer sticky footer. */
.table tbody tr:hover td { background: var(--row-hover); }
.table tfoot td {
  background: var(--tfoot-bg);
  font-weight: 700;
  border-top: 2px solid var(--brand);
}

/* Status pills read as pills, not boxes. */
.badge-status {
  border-radius: 999px;
  padding: .22rem .6rem;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .2px;
}

/* Toolbar buttons keep a consistent height next to the table title. */
.table-toolbar .btn { padding: .35rem .7rem; font-size: .8rem; }

/* Barcode chips in carts and grids. */
.barcode-chip, .mono {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: .3px;
}

/* --- mobile ergonomics --- */
@media (max-width: 767.98px) {
  /* Filter panel and table stack instead of fighting for width. */
  .work-layout { display: block; }
  .filter-panel { position: static; width: auto; margin-bottom: 1rem; }
  .table-scroll { max-height: 62vh; }

  /* Comfortable tap targets. */
  .btn, .form-control, .form-select { min-height: 40px; }
  .btn-row { width: 34px; height: 34px; }

  /* Page actions go full width so they are not cramped beside the title. */
  #pageActions { width: 100%; }
  #pageActions .btn { flex: 1 1 auto; justify-content: center; }

  .page-title { font-size: 1.08rem; }
  .modal-dialog { margin: .5rem; }
  .detail-stats { gap: .5rem; }
  .table-toolbar { flex-wrap: wrap; gap: .5rem; }
}

/* Very small screens: let wide tables breathe horizontally. */
@media (max-width: 480px) {
  .app-main { padding-left: .6rem; padding-right: .6rem; }
  .card-body { padding: .85rem; }
  .kpi { padding: .8rem .9rem; }
  .kpi-value { font-size: 1.15rem; }
}

/* KPI tiles must grow to fit their content — a long currency value was
   being clipped against a fixed height on narrow screens. */
.kpi {
  height: auto;
  min-height: 0;
  overflow: visible;
  align-items: flex-start;
}
.kpi > div:last-child { min-width: 0; flex: 1; }
.kpi-value {
  overflow-wrap: anywhere;
  line-height: 1.15;
}
.kpi-label {
  overflow-wrap: anywhere;
  white-space: normal;
  line-height: 1.25;
}

@media (max-width: 575.98px) {
  /* Stack the icon above the text so the value gets the full tile width. */
  .kpi { flex-direction: column; gap: .45rem; }
  .kpi-icon { width: 34px; height: 34px; font-size: .95rem; }
  .kpi-value { font-size: 1.05rem; }
  .kpi-label { font-size: .68rem; }
  .kpi-sub { font-size: .66rem; }
  .kpi-link::after { display: none; }   /* chevron steals width here */
}
