/* ================================================================
   INVENTORY SYSTEM — MAIN STYLESHEET
   Invoice styles live separately in assets/css/invoice.css
   ================================================================ */


/* ================================================================
   1. PALETTE SEEDS
   Each palette is 5 numbers; all colours derive from them below.
   --h  base hue      --s  surface saturation
   --ps primary sat   --ah accent hue    --as accent saturation
   ================================================================ */
:root { --h: 150; --s: 12%; --ps: 14%; --ah: 192; --as: 45%; }

[data-palette="rose"]    { --h: 350; --s: 20%; --ps: 42%; --ah: 350; --as: 62%; }
[data-palette="red"]     { --h:   8; --s: 22%; --ps: 46%; --ah:   8; --as: 65%; }
[data-palette="p3"]      { --h: 320; --s:  9%; --ps: 14%; --ah:   6; --as: 26%; }  /* Mauve   */
[data-palette="orange"]  { --h:  30; --s: 26%; --ps: 50%; --ah:  30; --as: 70%; }
[data-palette="p2"]      { --h:  25; --s: 26%; --ps: 24%; --ah:  20; --as: 36%; }  /* Sand    */
[data-palette="amber"]   { --h:  45; --s: 30%; --ps: 48%; --ah:  45; --as: 68%; }
[data-palette="lime"]    { --h:  85; --s: 22%; --ps: 42%; --ah:  85; --as: 55%; }
[data-palette="green"]   { --h: 142; --s: 18%; --ps: 40%; --ah: 142; --as: 52%; }
[data-palette="p1"]      { --h: 150; --s: 12%; --ps: 16%; --ah: 192; --as: 45%; }  /* Coastal */
[data-palette="teal"]    { --h: 175; --s: 22%; --ps: 44%; --ah: 175; --as: 55%; }
[data-palette="cyan"]    { --h: 195; --s: 24%; --ps: 45%; --ah: 195; --as: 58%; }
[data-palette="blue"]    { --h: 215; --s: 24%; --ps: 46%; --ah: 215; --as: 62%; }
[data-palette="indigo"]  { --h: 245; --s: 20%; --ps: 44%; --ah: 245; --as: 58%; }
[data-palette="violet"]  { --h: 275; --s: 20%; --ps: 42%; --ah: 275; --as: 55%; }
[data-palette="magenta"] { --h: 305; --s: 20%; --ps: 42%; --ah: 305; --as: 55%; }
[data-palette="mono"]    { --h:   0; --s:  0%; --ps:  0%; --ah:   0; --as:  0%; }


/* ================================================================
   2. DERIVED THEME — LIGHT
   ================================================================ */
:root,
[data-theme="light"] {
  --bg:           hsl(var(--h) var(--s) 95%);
  --surface:      hsl(var(--h) var(--s) 100%);
  --surface-2:    hsl(var(--h) var(--s) 91%);
  --text:         hsl(var(--h) 16% 13%);
  --text-muted:   hsl(var(--h) 10% 38%);
  --border:       hsl(var(--h) var(--s) 85%);
  --input-border: hsl(var(--h) var(--s) 74%);

  --primary:       hsl(var(--h) var(--ps) 32%);
  --primary-hover: hsl(var(--h) var(--ps) 24%);
  --on-primary:    #ffffff;
  --accent:        hsl(var(--ah) var(--as) 66%);

  --nav-bg:         hsl(var(--h) var(--ps) 20%);
  --nav-text:       hsl(var(--h) 16% 84%);
  --nav-text-hover: #ffffff;
  --nav-active:     hsl(var(--h) var(--ps) 33%);

  --success-bg: hsl(140 40% 90%); --success-text: hsl(140 50% 22%);
  --danger:     hsl(2 55% 46%);
  --danger-bg:  hsl(2 65% 92%);   --danger-text:  hsl(2 60% 32%);
  --info-bg:    hsl(205 60% 92%); --info-text:    hsl(205 60% 28%);
  --warn-bg:    hsl(38 75% 90%);  --warn-text:    hsl(30 65% 28%);

  --shadow:    0 1px 3px hsl(var(--h) 20% 40% / .14);
  --shadow-lg: 0 12px 32px hsl(var(--h) 25% 30% / .20);
  --radius:    10px;
}


/* ================================================================
   3. DERIVED THEME — DARK
   Lightness raised across the board: muted text at 64% was
   unreadable on a 17% surface.
   ================================================================ */
[data-theme="dark"] {
  --bg:           hsl(var(--h) 12% 11%);
  --surface:      hsl(var(--h) 11% 17%);
  --surface-2:    hsl(var(--h) 10% 23%);
  --text:         hsl(var(--h) 12% 96%);
  --text-muted:   hsl(var(--h)  8% 76%);
  --border:       hsl(var(--h) 10% 32%);
  --input-border: hsl(var(--h) 10% 42%);

  --primary:       hsl(var(--ah) var(--as) 62%);
  --primary-hover: hsl(var(--ah) var(--as) 72%);
  --on-primary:    hsl(var(--h) 25% 10%);
  --accent:        hsl(var(--ah) var(--as) 66%);

  --nav-bg:         hsl(var(--h) 14% 8%);
  --nav-text:       hsl(var(--h)  8% 78%);
  --nav-text-hover: #ffffff;
  --nav-active:     hsl(var(--h) 12% 20%);

  --success-bg: hsl(140 28% 24%); --success-text: hsl(140 55% 84%);
  --danger:     hsl(2 68% 62%);
  --danger-bg:  hsl(2 38% 28%);   --danger-text:  hsl(2 80% 88%);
  --info-bg:    hsl(205 38% 28%); --info-text:    hsl(205 70% 86%);
  --warn-bg:    hsl(33 42% 26%);  --warn-text:    hsl(38 80% 84%);

  --shadow:    0 1px 3px rgba(0,0,0,.45);
  --shadow-lg: 0 12px 32px rgba(0,0,0,.55);
}


/* ================================================================
   4. MONO — explicit values; hue maths can't produce black & white
   ================================================================ */
[data-theme="light"][data-palette="mono"] {
  --bg:           #F2F2F2;
  --surface:      #FFFFFF;
  --surface-2:    #E8E8E8;
  --text:         #000000;
  --text-muted:   #4A4A4A;
  --border:       #D0D0D0;
  --input-border: #A8A8A8;

  --primary:       #111111;
  --primary-hover: #000000;
  --on-primary:    #FFFFFF;
  --accent:        #555555;

  --nav-bg:         #000000;
  --nav-text:       #C8C8C8;
  --nav-text-hover: #FFFFFF;
  --nav-active:     #262626;

  --success-bg: #E2E2E2;  --success-text: #111111;
  --danger:     #000000;
  --danger-bg:  #D8D8D8;  --danger-text:  #000000;
  --info-bg:    #EAEAEA;  --info-text:    #222222;
  --warn-bg:    #DCDCDC;  --warn-text:    #1A1A1A;
}

[data-theme="dark"][data-palette="mono"] {
  --bg:           #0A0A0A;
  --surface:      #1A1A1A;
  --surface-2:    #262626;
  --text:         #FFFFFF;
  --text-muted:   #C4C4C4;
  --border:       #3A3A3A;
  --input-border: #545454;

  --primary:       #FFFFFF;
  --primary-hover: #E0E0E0;
  --on-primary:    #000000;
  --accent:        #D8D8D8;

  --nav-bg:         #000000;
  --nav-text:       #B4B4B4;
  --nav-text-hover: #FFFFFF;
  --nav-active:     #262626;

  --success-bg: #2E2E2E;  --success-text: #FFFFFF;
  --danger:     #FFFFFF;
  --danger-bg:  #3A3A3A;  --danger-text:  #FFFFFF;
  --info-bg:    #292929;  --info-text:    #E8E8E8;
  --warn-bg:    #333333;  --warn-text:    #F0F0F0;
}


/* ================================================================
   5. BASE
   ================================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: Inter, system-ui, "Segoe UI", Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  transition: background .3s ease, color .3s ease;
}
[dir="rtl"] body { font-family: "Noto Kufi Arabic", Tahoma, sans-serif; }

a { color: var(--primary); }


/* ================================================================
   6. SIDEBAR
   ================================================================ */
:root { --side-w: 218px; }

.has-sidebar { min-height: 100vh; }

.sidebar {
  position: fixed; inset-block: 0; inset-inline-start: 0;
  width: var(--side-w);
  background: var(--nav-bg);
  display: flex; flex-direction: column;
  overflow-y: auto; z-index: 50;
  transition: background .3s ease;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.18); border-radius: 3px; }

.side-brand {
  padding: 20px 18px 15px;
  font-size: 17px; font-weight: 700;
  color: var(--nav-text-hover);
  border-bottom: 1px solid rgba(255,255,255,.12);
}

.side-nav { display: flex; flex-direction: column; padding: 10px 8px; gap: 2px; }

.side-nav a {
  display: block; padding: 10px 14px;
  border-radius: 8px;
  color: var(--nav-text); text-decoration: none;
  font-size: 14px; font-weight: 500;
  transition: background .18s, color .18s, padding-inline-start .18s;
}
.side-nav a:hover {
  background: rgba(255,255,255,.10);
  color: var(--nav-text-hover);
  padding-inline-start: 18px;
}
.side-nav a.is-active {
  background: var(--nav-active);
  color: var(--nav-text-hover);
  font-weight: 700;
}
.side-nav a.is-active::before {
  content: ''; float: inline-start;
  width: 3px; height: 16px;
  margin-inline-end: 9px; margin-top: 2px;
  background: var(--accent); border-radius: 2px;
}

.side-sep { height: 1px; margin: 10px 14px; background: rgba(255,255,255,.14); }

.app-main {
  margin-inline-start: var(--side-w);
  min-height: 100vh;
  display: flex; flex-direction: column;
}


/* ================================================================
   7. TOP BAR
   ================================================================ */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  padding: 11px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 40;
  transition: background .3s ease, border-color .3s ease;
}
.topbar nav { display: none; }          /* legacy horizontal nav, retired */

.top-user { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.user-name { color: var(--text-muted); text-decoration: none; transition: color .18s; }
.user-name:hover { color: var(--text); }


/* ================================================================
   8. SWITCHER — language, palette wheel, theme
   ================================================================ */
.switcher { display: flex; align-items: center; gap: 10px; }
.switcher.on-light { justify-content: center; margin-bottom: 16px; }

.lang-switch { display: flex; gap: 4px; }
.lang-btn {
  padding: 4px 9px; border-radius: 5px;
  font-size: 12px; font-weight: 600; line-height: 1.6;
  text-decoration: none;
  color: var(--text-muted); background: var(--surface-2);
  transition: background .18s, color .18s;
}
.lang-btn:hover { background: var(--border); color: var(--text); }
.lang-btn.is-active { background: var(--primary); color: var(--on-primary); }

.switch-sep { width: 1px; height: 18px; background: var(--border); margin: 0 3px; }

.wheel { position: relative; display: flex; align-items: center; }

.wheel-toggle {
  position: relative;
  width: 30px; height: 30px; border-radius: 50%;
  border: 0; padding: 0; cursor: pointer; display: block;
  background: conic-gradient(from 0deg,
    #E0596F, #DE5A4E, #E08A3C, #D9B23C, #9CC13F, #4FB36B,
    #3FB5A6, #3FAFC9, #4A90D9, #6C74D9, #9A63D4, #C95AB8, #E0596F);
  box-shadow: 0 0 0 2px var(--border);
  transition: transform .45s cubic-bezier(.2,.9,.3,1.4), box-shadow .25s;
}
.wheel-toggle::after {
  content: ''; position: absolute; inset: 9px;
  border-radius: 50%; background: var(--surface);
  transition: inset .3s ease, background .3s ease;
}
.wheel:hover .wheel-toggle,
.wheel:focus-within .wheel-toggle {
  transform: rotate(180deg);
  box-shadow: 0 0 0 3px var(--primary);
}
.wheel:hover .wheel-toggle::after,
.wheel:focus-within .wheel-toggle::after { inset: 12px; }

/* padding-top bridges the gap so hover doesn't drop */
.wheel-panel {
  position: absolute; top: 100%; inset-inline-start: -92px;
  padding-top: 12px; z-index: 60;
  opacity: 0; visibility: hidden;
  transition: opacity .28s ease, visibility .28s;
}
.wheel:hover .wheel-panel,
.wheel:focus-within .wheel-panel { opacity: 1; visibility: visible; }

.wheel-ring {
  position: relative;
  width: 216px; height: 216px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  transform: scale(.55) rotate(-70deg);
  transition: transform .45s cubic-bezier(.2,.9,.3,1.35), background .3s;
}
.wheel:hover .wheel-ring,
.wheel:focus-within .wheel-ring { transform: scale(1) rotate(0deg); }

.pal-dot {
  position: absolute; top: 50%; left: 50%;
  width: 24px; height: 24px; margin: -12px 0 0 -12px;
  border-radius: 50%; background: var(--sw);
  border: 2px solid transparent; opacity: 0;
  transform:
    rotate(calc(var(--i) * (360deg / var(--n))))
    translateY(0)
    rotate(calc(-1 * var(--i) * (360deg / var(--n))))
    scale(.2);
  transition: transform .45s cubic-bezier(.2,.9,.3,1.4),
              opacity .3s ease, box-shadow .2s ease;
  transition-delay: calc(var(--i) * 22ms);
}
.wheel:hover .pal-dot,
.wheel:focus-within .pal-dot {
  opacity: 1;
  transform:
    rotate(calc(var(--i) * (360deg / var(--n))))
    translateY(-78px)
    rotate(calc(-1 * var(--i) * (360deg / var(--n))))
    scale(1);
}
/* hover grows via box-shadow so it never fights the transform above */
.pal-dot:hover { box-shadow: 0 0 0 5px var(--sw); opacity: .85; }
.pal-dot.is-active { border-color: var(--surface); box-shadow: 0 0 0 3px var(--text); }

.pal-dot[title="Mono"] {
  background: linear-gradient(135deg, #FFFFFF 0 50%, #111111 50% 100%);
  box-shadow: 0 0 0 1px var(--border);
}

.theme-core {
  position: absolute; top: 50%; left: 50%;
  width: 58px; height: 58px; margin: -29px 0 0 -29px;
  border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border);
  text-decoration: none; font-size: 21px;
  transition: background .2s, color .2s,
              transform .3s cubic-bezier(.2,.9,.3,1.4);
  transition-delay: .1s;
}
.theme-core:hover {
  background: var(--primary); color: var(--on-primary); transform: scale(1.08);
}


/* ================================================================
   9. LAYOUT
   ================================================================ */
.container { max-width: 1150px; margin: 22px auto; padding: 0 22px; flex: 1; width: 100%; }

h1 { font-size: 22px; margin-bottom: 12px; color: var(--text); }

.page-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; flex-wrap: wrap; margin-bottom: 14px;
}
.page-head small { font-weight: 400; color: var(--text-muted); font-size: 14px; }
.head-actions { display: flex; gap: 8px; align-items: center; }

.footer {
  text-align: center; padding: 20px;
  color: var(--text-muted); font-size: 13px;
}

.card {
  background: var(--surface); padding: 18px;
  border-radius: var(--radius);
  box-shadow: var(--shadow); border: 1px solid var(--border);
  transition: background .3s, border-color .3s;
}
.card h3 { font-size: 15px; margin-bottom: 6px; color: var(--text); }
.card h3 small { font-weight: 400; font-size: 12px; margin-inline-start: 6px; }
.card small.txt-muted { display: block; margin-top: 4px; font-size: 12px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

.search-bar { display: flex; gap: 8px; margin-bottom: 14px; max-width: 460px; }


/* ================================================================
   10. BUTTONS
   ================================================================ */
.btn {
  display: inline-block;
  background: var(--primary); color: var(--on-primary);
  border: 0; padding: 10px 16px; border-radius: 7px;
  cursor: pointer; text-decoration: none;
  font-size: 14px; font-family: inherit;
  transition: background .18s, transform .12s;
}
.btn:hover { background: var(--primary-hover); }
.btn:active { transform: translateY(1px); }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.danger { background: var(--danger); color: #fff; }

.btn.ghost {
  background: transparent; color: var(--primary);
  border: 1.5px dashed var(--input-border); width: 100%;
}
.btn.ghost:hover { background: var(--surface-2); border-color: var(--primary); }

.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:disabled:hover { background: var(--primary); }
.btn.danger:disabled:hover { background: var(--danger); }


/* ================================================================
   11. FORMS
   ================================================================ */
input, select, textarea {
  width: 100%; padding: 9px 11px;
  border: 1px solid var(--input-border); border-radius: 7px;
  font-size: 14px; font-family: inherit;
  background: var(--surface); color: var(--text);
  text-align: start;
  transition: border-color .18s, background .3s, color .3s;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--primary); outline-offset: -1px;
  border-color: var(--primary);
}
label {
  display: block; margin: 12px 0 5px;
  font-size: 13px; font-weight: 600; color: var(--text);
}
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: auto; }

[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea { background: var(--surface-2); }
[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder { color: var(--text-muted); opacity: .65; }


/* ================================================================
   12. TABLES
   ================================================================ */
table {
  width: 100%; border-collapse: collapse;
  background: var(--surface); border-radius: var(--radius);
  overflow: hidden; border: 1px solid var(--border);
}
th, td {
  padding: 10px 12px; text-align: start;
  border-bottom: 1px solid var(--border); font-size: 14px;
}
th { background: var(--surface-2); font-weight: 600; color: var(--text); }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }

table a { color: var(--primary); text-decoration: none; }
table a:hover { text-decoration: underline; }

.row-dim td { opacity: .55; }
.row-alert td { background: var(--danger-bg); }


/* ================================================================
   13. ALERTS & BADGES
   ================================================================ */
.alert {
  padding: 10px 12px; border-radius: 7px;
  margin-bottom: 14px; font-size: 14px;
}
.alert.error   { background: var(--danger-bg);  color: var(--danger-text); }
.alert.success { background: var(--success-bg); color: var(--success-text); }

.badge {
  display: inline-block; padding: 3px 9px; border-radius: 20px;
  font-size: 12px; background: var(--surface-2); color: var(--text);
}
.badge.good { background: var(--success-bg); color: var(--success-text); }
.badge.warn { background: var(--warn-bg);    color: var(--warn-text); }
.badge.bad  { background: var(--danger-bg);  color: var(--danger-text); }

.status-in_stock { background: var(--success-bg); color: var(--success-text); }
.status-sold     { background: var(--info-bg);    color: var(--info-text); }
.status-loaned   { background: var(--warn-bg);    color: var(--warn-text); }
.status-damaged,
.status-lost     { background: var(--danger-bg);  color: var(--danger-text); }

.pay-paid    { background: var(--success-bg); color: var(--success-text); }
.pay-partial { background: var(--warn-bg);    color: var(--warn-text); }
.pay-unpaid  { background: var(--danger-bg);  color: var(--danger-text); }

.method-cash   { background: var(--success-bg); color: var(--success-text); }
.method-credit { background: var(--warn-bg);    color: var(--warn-text); }

.role-admin { background: var(--info-bg);   color: var(--info-text); }
.role-staff { background: var(--surface-2); color: var(--text-muted); }

.type-serial { background: var(--info-bg); color: var(--info-text); }
.type-meter  { background: var(--warn-bg); color: var(--warn-text); }

.txt-danger { color: var(--danger);       font-weight: 600; }
.txt-warn   { color: var(--warn-text);    font-weight: 600; }
.txt-good   { color: var(--success-text); font-weight: 600; }
.txt-muted  { color: var(--text-muted); }

code {
  font-family: ui-monospace, Consolas, monospace; font-size: 12px;
  background: var(--surface-2); color: var(--text);
  padding: 2px 7px; border-radius: 5px;
}

/* Mono has no colour coding, so outline the states instead */
[data-palette="mono"] .badge { border: 1px solid var(--border); }
[data-palette="mono"] .badge.good,
[data-palette="mono"] .status-in_stock { border: 1px solid var(--text); }
[data-palette="mono"] .badge.bad,
[data-palette="mono"] .status-damaged,
[data-palette="mono"] .status-lost,
[data-palette="mono"] .loan-overdue { border: 1px solid var(--text); font-weight: 700; }
[data-palette="mono"] .status-loaned,
[data-palette="mono"] .pay-partial { border: 1px dashed var(--text-muted); }


/* ================================================================
   14. STATS
   ================================================================ */
.stats { display: flex; gap: 12px; flex-wrap: wrap; }

.stat {
  background: var(--surface); padding: 12px 20px;
  border-radius: var(--radius); text-align: center; min-width: 90px;
  box-shadow: var(--shadow); border: 1px solid var(--border);
}
.stat span { display: block; font-size: 22px; font-weight: 700; color: var(--text); }
.stat label {
  font-size: 11px; text-transform: uppercase;
  color: var(--text-muted); margin: 0;
}
.stat label small { display: inline-block; margin-inline-start: 5px; font-size: 11px; }

.stat.kpi {
  flex: 1; min-width: 140px;
  border-block-start: 3px solid var(--primary);
  transition: transform .22s cubic-bezier(.2,.9,.3,1.3), box-shadow .22s;
}
.stat.kpi:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.stat.kpi-good { border-block-start-color: var(--success-text); }
.stat.kpi-bad  { border-block-start-color: var(--danger); }
.stat.kpi-warn { border-block-start-color: var(--warn-text); }


/* ================================================================
   15. LOGIN
   ================================================================ */
.login-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
}
.login-card {
  background: var(--surface); padding: 30px;
  border-radius: 14px; width: 350px;
  box-shadow: var(--shadow-lg); border: 1px solid var(--border);
}
.login-card h1 { text-align: center; margin-bottom: 14px; }
.login-card .btn { width: 100%; margin-top: 18px; }


/* ================================================================
   16. ANIMATIONS
   ================================================================ */
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes popIn  { from { opacity: 0; transform: scale(.7); }        to { opacity: 1; transform: none; } }
@keyframes barGrow   { to { width: var(--w); } }
@keyframes pulseSoft { 0%, 100% { opacity: 1; } 50% { opacity: .62; } }
@keyframes flashOn   { 0% { transform: scale(1); } 50% { transform: scale(1.5); } 100% { transform: scale(1); } }
@keyframes flashBad  { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

.fade-up {
  animation: fadeUp .45s cubic-bezier(.2,.7,.3,1) both;
  animation-delay: var(--d, 0s);
}
.pop {
  animation: popIn .3s cubic-bezier(.2,.9,.3,1.4) both;
  animation-delay: calc(var(--i, 0) * 28ms);
}
.stagger tbody tr,
.stagger tr:not(:first-child) {
  animation: fadeUp .4s cubic-bezier(.2,.7,.3,1) both;
  animation-delay: calc(var(--i, 0) * 35ms + .08s);
}
.flash-on { animation: flashOn .45s ease; }
.flash-bad {
  animation: flashBad .4s ease;
  border-color: var(--danger) !important;
  background: var(--danger-bg) !important;
}


/* ================================================================
   17. PURCHASE LINES
   ================================================================ */
.lines { display: flex; flex-direction: column; gap: 14px; margin: 16px 0; }

.line-card {
  position: relative;
  opacity: 0; transform: translateY(-10px) scale(.98);
  transition: opacity .35s ease,
              transform .35s cubic-bezier(.2,.9,.3,1.3),
              margin .35s ease, padding .35s ease;
}
.line-card.in  { opacity: 1; transform: none; }
.line-card.out {
  opacity: 0; transform: translateY(-8px) scale(.96);
  margin-block: -7px; padding-block: 0; height: 0; overflow: hidden;
}

.line-remove {
  position: absolute; top: 10px; inset-inline-end: 10px;
  width: 26px; height: 26px; border-radius: 50%; border: 0;
  background: var(--surface-2); color: var(--text-muted);
  font-size: 18px; line-height: 1; cursor: pointer;
  transition: background .18s, color .18s, transform .18s;
}
.line-remove:hover { background: var(--danger); color: #fff; transform: rotate(90deg); }

.line-foot {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; flex-wrap: wrap;
  margin-top: 12px; padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 14px; color: var(--text-muted);
}

.serial-count {
  font-weight: 700; padding: 1px 8px; border-radius: 12px;
  background: var(--surface-2); color: var(--text);
  transition: background .25s, color .25s;
}
.serial-count.ok  { background: var(--success-bg); color: var(--success-text); }
.serial-count.bad { background: var(--warn-bg);    color: var(--warn-text); }

.total-field { font-weight: 700; background: var(--surface-2); }
[data-theme="dark"] .total-field { background: var(--bg); }
.totals-card { margin-top: 16px; }

.unit-tag { font-weight: 400; color: var(--text-muted); font-size: 12px; }


/* ================================================================
   18. UNIT PICKER & CHIPS
   ================================================================ */
.serial-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.chip {
  font-size: 12px; padding: 3px 10px; border-radius: 14px;
  background: var(--surface-2); color: var(--text);
  direction: ltr; transition: transform .18s;
}
.chip:hover { transform: translateY(-2px); }

.unit-pool {
  display: flex; flex-wrap: wrap; gap: 7px;
  margin-top: 14px; min-height: 44px; padding: 12px;
  border-radius: var(--radius);
  background: var(--surface-2); border: 1px dashed var(--border);
  transition: background .25s;
}
.pool-msg { color: var(--text-muted); font-size: 13px; padding: 4px; }

.unit-chip {
  cursor: pointer; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  font-family: inherit; padding: 5px 12px; border-radius: 14px;
  transition: transform .18s cubic-bezier(.2,.9,.3,1.4),
              background .18s, color .18s, opacity .25s;
}
.unit-chip:hover { transform: translateY(-3px); background: var(--primary); color: var(--on-primary); }
.unit-chip.taken {
  opacity: .35; pointer-events: none;
  background: var(--surface-2); text-decoration: line-through;
}

#selectedTable tr { transition: opacity .3s ease, transform .3s cubic-bezier(.2,.9,.3,1.3); }
#selectedTable tr.row-in  { opacity: 0; transform: translateY(-8px); }
#selectedTable tr.row-out { opacity: 0; transform: translateX(24px); }
#selectedTable .line-remove { position: static; }
#selectedTable td { vertical-align: top; }
#selectedTable .js-qty[readonly] {
  background: var(--surface-2); font-weight: 700;
  width: 80px; display: inline-block;
}

.meter-box {
  margin-top: 14px; padding: 16px;
  border-radius: var(--radius);
  background: var(--surface-2); border: 1px dashed var(--border);
  animation: fadeUp .35s ease both;
}


/* ================================================================
   19. EMPTY-VALUE HIGHLIGHT
   ================================================================ */
input.is-empty,
input.needs-value:placeholder-shown {
  border-color: var(--warn-text);
  background: var(--warn-bg);
}
input.is-empty:focus,
input.needs-value:focus {
  border-color: var(--primary);
  background: var(--surface);
}

.hint {
  display: inline-block; margin-top: 4px;
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  direction: ltr; cursor: pointer;
  padding: 1px 7px; border-radius: 10px; background: var(--surface-2);
  transition: background .18s, color .18s;
}
.hint:hover { background: var(--primary); color: var(--on-primary); }
label .hint { cursor: default; margin: 0 0 0 4px; }
label .hint:hover { background: var(--surface-2); color: var(--text-muted); }


/* ================================================================
   20. TRACK TYPE TOGGLE
   ================================================================ */
.track-toggle { display: flex; gap: 10px; margin-top: 4px; flex-wrap: wrap; }

.track-opt {
  flex: 1; min-width: 180px; margin: 0; padding: 12px 14px; cursor: pointer;
  border: 1.5px solid var(--input-border); border-radius: var(--radius);
  background: var(--surface);
  font-weight: 600; font-size: 14px;
  display: flex; align-items: center; gap: 9px;
  transition: border-color .2s, background .2s, transform .18s;
}
.track-opt:hover { transform: translateY(-2px); border-color: var(--primary); }
.track-opt input { width: auto; accent-color: var(--primary); }
.track-opt input:disabled { opacity: .5; }
.track-opt.is-on { border-color: var(--primary); background: var(--surface-2); }
.track-opt span { display: flex; flex-direction: column; gap: 2px; }
.track-opt small { font-weight: 400; font-size: 11px; }


/* ================================================================
   21. FILTER TABS
   ================================================================ */
.filter-bar {
  display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px;
  padding: 5px; background: var(--surface-2);
  border-radius: 30px; width: fit-content;
}
.filter-tab {
  padding: 6px 15px; border-radius: 20px;
  font-size: 13px; font-weight: 600; white-space: nowrap;
  text-decoration: none; color: var(--text-muted);
  transition: background .22s, color .22s, transform .18s;
}
.filter-tab:hover { color: var(--text); transform: translateY(-1px); }
.filter-tab.is-active { background: var(--primary); color: var(--on-primary); }


/* ================================================================
   22. LOANS
   ================================================================ */
.loan-open     { background: var(--info-bg);    color: var(--info-text); }
.loan-partial  { background: var(--warn-bg);    color: var(--warn-text); }
.loan-returned { background: var(--success-bg); color: var(--success-text); }
.loan-overdue  {
  background: var(--danger-bg); color: var(--danger-text);
  animation: pulseSoft 2.2s ease-in-out infinite;
}


/* ================================================================
   23. PERMISSIONS GRID
   ================================================================ */
.perm-table th { font-size: 12px; }
.perm-table td { padding: 8px 12px; }
.perm-table input[type=checkbox] {
  width: 17px; height: 17px; cursor: pointer;
  accent-color: var(--primary); transition: transform .15s;
}
.perm-table input[type=checkbox]:hover { transform: scale(1.18); }

#permCard { transition: opacity .3s ease; }
.perm-disabled { opacity: .45; pointer-events: none; }

.perm-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.perm-chips .chip { font-size: 11px; padding: 2px 8px; }


/* ================================================================
   24. DASHBOARD
   ================================================================ */
.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 16px; margin-top: 18px;
}
.dash-grid .card { margin: 0; }
.dash-grid table { border: 0; background: transparent; }
.dash-grid td { padding: 8px 6px; font-size: 13px; }
.dash-grid tr:last-child td { border-bottom: 0; }
.dash-grid table a { color: var(--primary); text-decoration: none; font-weight: 600; }
.dash-grid table a:hover { text-decoration: underline; }

.dash-alert { border-inline-start: 4px solid var(--danger); }

.quick-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.quick-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 18px; border-radius: 30px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); text-decoration: none;
  font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow);
  animation: fadeUp .45s cubic-bezier(.2,.7,.3,1) both;
  animation-delay: calc(var(--i, 0) * 60ms + .1s);
  transition: transform .2s cubic-bezier(.2,.9,.3,1.4),
              background .2s, color .2s, box-shadow .2s;
}
.quick-btn:hover {
  transform: translateY(-3px);
  background: var(--primary); color: var(--on-primary);
  border-color: var(--primary); box-shadow: var(--shadow-lg);
}
.quick-plus {
  width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--primary);
  font-size: 15px; font-weight: 700; line-height: 1;
  transition: background .2s, color .2s, transform .3s;
}
.quick-btn:hover .quick-plus {
  background: rgba(255,255,255,.25); color: var(--on-primary);
  transform: rotate(90deg);
}


/* ================================================================
   25. BAR CHARTS
   ================================================================ */
.bar-list { display: flex; flex-direction: column; gap: 12px; }

.bar-row {
  animation: fadeUp .4s ease both;
  animation-delay: calc(var(--i, 0) * 70ms + .3s);
}
.bar-label {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 10px; font-size: 13px; margin-bottom: 5px;
}
.bar-track {
  height: 8px; border-radius: 6px;
  background: var(--surface-2); overflow: hidden;
}
.bar-fill {
  height: 100%; width: 0; border-radius: 6px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  animation: barGrow .9s cubic-bezier(.2,.8,.3,1) forwards;
  animation-delay: calc(var(--i, 0) * 70ms + .45s);
}
[dir="rtl"] .bar-fill { background: linear-gradient(270deg, var(--primary), var(--accent)); }
[data-palette="mono"] .bar-fill { background: var(--primary); }


/* ================================================================
   26. REPORTS
   ================================================================ */
.range-form {
  display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap;
  margin-bottom: 8px;
}
.range-form label { margin: 0 0 4px; }
.range-form input { width: 165px; }

.pl-table td { padding: 11px 12px; font-size: 14px; }
.pl-table td:last-child { text-align: end; }
.pl-table tr.pl-sub td { border-top: 1px solid var(--border); background: var(--surface-2); }
.pl-table tr.pl-total td {
  border-top: 2px solid var(--primary);
  background: var(--surface-2); font-size: 16px;
}


/* ================================================================
   27. IMPORT DROP ZONE
   ================================================================ */
.drop-zone {
  position: relative;
  padding: 34px 20px; text-align: center;
  border: 2px dashed var(--input-border); border-radius: var(--radius);
  background: var(--surface-2);
  transition: border-color .25s, background .25s, transform .2s;
}
.drop-zone:hover { border-color: var(--primary); transform: translateY(-2px); }
.drop-zone.is-over { border-color: var(--primary); background: var(--surface); transform: scale(1.015); }
.drop-zone.has-file { border-style: solid; border-color: var(--success-text); }

.drop-zone input[type=file] {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; cursor: pointer; padding: 0; border: 0;
}
.drop-text { font-size: 14px; color: var(--text-muted); pointer-events: none; }
.drop-name {
  margin-top: 8px; font-weight: 700; font-size: 14px;
  color: var(--success-text); direction: ltr; pointer-events: none;
}


/* ================================================================
   28. BACKUP & SETTINGS
   ================================================================ */
.danger-card { border: 1px solid var(--danger); }
.danger-card h3 { display: flex; align-items: center; gap: 8px; }

.warn-list {
  margin: 12px 0 0; padding-inline-start: 20px;
  font-size: 13px; color: var(--text-muted); line-height: 1.9;
}
.warn-list li::marker { color: var(--danger); }

.logo-preview {
  display: inline-block; padding: 12px;
  border-radius: var(--radius);
  background: var(--surface-2); border: 1px solid var(--border);
}
.logo-preview img { max-width: 160px; max-height: 90px; object-fit: contain; display: block; }


/* ================================================================
   29. RTL FIXES
   Numbers and codes stay LTR inside right-to-left text.
   ================================================================ */
[dir="rtl"] .ltr-text,
[dir="rtl"] input[type="number"],
[dir="rtl"] input[type="email"],
[dir="rtl"] input[type="date"] { direction: ltr; text-align: end; }
[dir="rtl"] .page-head small { direction: ltr; display: inline-block; }


/* ================================================================
   30. RESPONSIVE
   ================================================================ */
@media (max-width: 900px) {
  .sidebar {
    inset-inline-start: -240px; width: 240px;
    transition: inset-inline-start .3s ease;
  }
  .sidebar.open { inset-inline-start: 0; }
  .app-main { margin-inline-start: 0; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .dash-grid { grid-template-columns: 1fr; }
  .stat.kpi { min-width: 100%; }
  .container { padding: 0 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .wheel-toggle, .wheel-ring, .pal-dot, .theme-core { transition-duration: .01ms !important; }
  .fade-up, .pop, .stagger tr, .bar-row, .quick-btn { animation: none !important; opacity: 1 !important; }
  .bar-fill { animation: none; width: var(--w); }
}


/* ================================================================
   31. PRINT
   ================================================================ */
@media print {
  .sidebar, .topbar, .btn, .filter-bar, .search-bar, .footer { display: none !important; }
  .app-main { margin-inline-start: 0; }
  .card, table { box-shadow: none; border: 1px solid #ccc; }
  .fade-up, .pop, .stagger tr, .bar-row { animation: none !important; opacity: 1 !important; }
}

.second-total {
  display: flex; justify-content: space-between; align-items: center;
  gap: 14px; margin-top: 12px; padding: 11px 16px;
  border-radius: var(--radius);
  background: var(--info-bg); color: var(--info-text);
  font-size: 15px;
}
.second-total .lbl { font-weight: 600; font-size: 13px; }
.second-total .val { font-size: 18px; font-weight: 800; }

/* ================================================================
   SIDEBAR EXCHANGE RATE
   ================================================================ */
.side-rate {
  margin: 14px 10px 18px;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.10);
  transition: background .2s, border-color .2s;
}
.side-rate:hover { background: rgba(255,255,255,.11); }
.side-rate.saving { opacity: .6; pointer-events: none; }

.sr-label {
  font-size: 10px; letter-spacing: 1px; text-transform: uppercase;
  color: var(--nav-text); opacity: .75; margin-bottom: 7px;
}

.sr-body {
  display: flex; align-items: baseline; gap: 6px;
  direction: ltr; flex-wrap: wrap;
}
.sr-from, .sr-eq, .sr-cur { font-size: 12px; color: var(--nav-text); }

.sr-value {
  font-size: 17px; font-weight: 800; color: var(--nav-text-hover);
  cursor: pointer; padding: 1px 6px; border-radius: 5px;
  border-bottom: 1px dashed rgba(255,255,255,.45);
  transition: background .18s;
}
.sr-value:hover { background: rgba(255,255,255,.16); }
.sr-value.static { cursor: default; border-bottom: 0; }

.sr-input {
  width: 92px; padding: 3px 7px;
  font-size: 15px; font-weight: 700;
  border-radius: 5px; border: 1px solid var(--accent);
  background: rgba(0,0,0,.35); color: #fff;
  direction: ltr;
}
.sr-input:focus { outline: 2px solid var(--accent); outline-offset: 0; }

.sr-msg { font-size: 11px; margin-top: 6px; min-height: 14px; }
.sr-msg.ok  { color: #7ddc9a; }
.sr-msg.bad { color: #ff9d9d; }

/* ================================================================
   STORAGE FILTERS & PAGINATION
   ================================================================ */
.filter-card { padding: 16px 18px; }

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
  gap: 10px 12px;
}
.filter-grid label { margin: 0 0 4px; font-size: 12px; }

.pager {
  display: flex; align-items: center; gap: 5px;
  flex-wrap: wrap; margin-top: 18px;
}
.pg {
  min-width: 34px; height: 34px;
  display: grid; place-items: center;
  padding: 0 10px; border-radius: 8px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); text-decoration: none;
  font-size: 13px; font-weight: 600;
  transition: background .18s, color .18s, transform .15s;
}
.pg:hover { background: var(--surface-2); transform: translateY(-2px); }
.pg.on { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.pg.off { opacity: .35; pointer-events: none; }
.pg.gap { border: 0; background: transparent; pointer-events: none; }

.pg-info {
  margin-inline-start: 10px;
  font-size: 12px; color: var(--text-muted);
}

table input[type=checkbox] {
  width: 16px; height: 16px; cursor: pointer; accent-color: var(--primary);
}

/* ================================================================
   EXPENSES & SALARIES
   ================================================================ */
.grid-4 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.kind-general { background: var(--surface-2); color: var(--text-muted); }
.kind-salary  { background: var(--info-bg);   color: var(--info-text); }

.salary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px; margin-top: 18px;
}

.salary-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow);
  border-inline-start: 4px solid var(--warn-text);
  transition: transform .2s cubic-bezier(.2,.9,.3,1.3), box-shadow .2s;
}
.salary-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.salary-card.is-paid { border-inline-start-color: var(--success-text); opacity: .82; }

.sc-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.sc-name { font-weight: 700; font-size: 15px; }
.sc-pos  { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.sc-amount { font-size: 22px; font-weight: 800; margin: 12px 0 4px; }
.sc-phone  { font-size: 12px; color: var(--text-muted); }

.sc-foot {
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
  margin-top: 14px; padding-top: 12px;
  border-top: 1px solid var(--border);
}
.btn.ghost-sm {
  background: transparent; color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn.ghost-sm:hover { background: var(--surface-2); color: var(--text); }

/* ================================================================
   VAULT
   ================================================================ */
.vault-hero {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: var(--on-primary);
  border-radius: 14px; padding: 24px 26px;
  box-shadow: var(--shadow-lg);
}
.vh-label { font-size: 12px; letter-spacing: 1.5px; text-transform: uppercase; opacity: .8; }
.vh-amount { font-size: 40px; font-weight: 800; line-height: 1.15; margin-top: 4px; }
.vh-amount.neg { color: #ffc9c9; }
.vh-second { font-size: 15px; opacity: .85; margin-top: 2px; }

.vh-split {
  display: flex; gap: 26px; flex-wrap: wrap;
  margin-top: 18px; padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,.25);
}
.vh-part span { display: block; font-size: 19px; font-weight: 700; }
.vh-part label {
  font-size: 11px; text-transform: uppercase;
  opacity: .8; margin: 0; color: inherit;
}
.vh-part.in  span::before { content: '+ '; }
.vh-part.out span::before { content: '− '; }

.src-sale     { background: var(--success-bg); color: var(--success-text); }
.src-purchase { background: var(--info-bg);    color: var(--info-text); }
.src-expense  { background: var(--warn-bg);    color: var(--warn-text); }
.src-salary   { background: var(--danger-bg);  color: var(--danger-text); }
.src-manual   { background: var(--surface-2);  color: var(--text-muted); }

td.num, th.num { text-align: end; }

/* sidebar balance */
.side-vault {
  display: block; margin: 14px 10px 0; padding: 12px 14px;
  border-radius: 10px; text-decoration: none;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.10);
  transition: background .2s, transform .18s;
}
.side-vault:hover { background: rgba(255,255,255,.13); transform: translateY(-2px); }
.sv-label {
  display: block; font-size: 10px; letter-spacing: 1px;
  text-transform: uppercase; color: var(--nav-text); opacity: .75;
}
.sv-amount {
  display: block; font-size: 18px; font-weight: 800;
  color: var(--nav-text-hover); margin-top: 4px;
}
.side-vault.neg .sv-amount { color: #ff9d9d; }


/* ================================================================
   ITEM DETAIL — last sale banner
   ================================================================ */
.last-sale {
  margin-top: 16px; padding: 18px 22px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  border-inline-start: 4px solid var(--primary);
  box-shadow: var(--shadow);
}
.ls-tag {
  font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--text-muted); margin-bottom: 10px;
}
.ls-grid {
  display: flex; gap: 30px; flex-wrap: wrap; align-items: flex-end;
}
.ls-main { min-width: 180px; }
.ls-name { font-size: 20px; font-weight: 800; }
.ls-phone { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

.ls-cell label {
  display: block; margin: 0 0 3px;
  font-size: 10px; letter-spacing: .8px; text-transform: uppercase;
  color: var(--text-muted); font-weight: 600;
}
.ls-cell span, .ls-cell a { font-size: 15px; font-weight: 700; }

.serial-hit { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.serial-hit .chip {
  font-size: 10px; padding: 2px 8px;
  background: var(--warn-bg); color: var(--warn-text);
}

/* ---- new customer toggle ---- */
.new-cust { margin-top: 12px; }
.new-cust-btn {
  display: inline-block; cursor: pointer; list-style: none;
  padding: 9px 16px; border-radius: 8px;
  background: var(--surface-2); border: 1px dashed var(--input-border);
  color: var(--primary); font-size: 13px; font-weight: 600;
  transition: background .18s, border-color .18s;
}
.new-cust-btn::-webkit-details-marker { display: none; }
.new-cust-btn:hover { background: var(--border); border-color: var(--primary); }
.new-cust[open] .new-cust-btn {
  background: var(--primary); color: var(--on-primary); border-style: solid;
}

.cust-info {
  display: flex; gap: 14px; flex-wrap: wrap;
  margin-top: 8px; font-size: 13px; color: var(--text-muted);
}

/* ---- new customer toggle ---- */
.new-cust { margin-top: 12px; }
.new-cust-btn {
  display: inline-block; cursor: pointer; list-style: none;
  padding: 9px 16px; border-radius: 8px;
  background: var(--surface-2); border: 1px dashed var(--input-border);
  color: var(--primary); font-size: 13px; font-weight: 600;
  transition: background .18s, border-color .18s;
}
.new-cust-btn::-webkit-details-marker { display: none; }
.new-cust-btn::marker { content: ''; }
.new-cust-btn:hover { background: var(--border); border-color: var(--primary); }
.new-cust[open] .new-cust-btn {
  background: var(--primary); color: var(--on-primary); border-style: solid;
}

.cust-info {
  display: flex; gap: 14px; flex-wrap: wrap;
  margin-top: 8px; font-size: 13px; color: var(--text-muted);
}

/* ================================================================
   NEW CUSTOMER TOGGLE
   ================================================================ */
.cust-toggle {
  position: absolute;
  opacity: 0; width: 0; height: 0;
  pointer-events: none;
}

.new-cust-btn {
  display: inline-flex; align-items: center; gap: 8px;
  margin: 14px 0 0; cursor: pointer;
  padding: 11px 20px; border-radius: 9px;
  background: var(--primary); color: var(--on-primary);
  font-size: 14px; font-weight: 600;
  transition: background .18s, transform .12s;
  user-select: none;
}
.new-cust-btn:hover  { background: var(--primary-hover); }
.new-cust-btn:active { transform: scale(.97); }

.ncb-plus {
  display: grid; place-items: center;
  width: 20px; height: 20px; border-radius: 50%;
  background: rgba(255,255,255,.25);
  font-size: 15px; font-weight: 700; line-height: 1;
  transition: transform .3s cubic-bezier(.2,.9,.3,1.4);
}

/* the fields, hidden until the box is ticked */
.new-cust-fields {
  display: none;
  margin-top: 14px; padding-top: 14px;
  border-top: 1px solid var(--border);
  animation: fadeUp .3s ease both;
}
.cust-toggle:checked ~ .new-cust-fields { display: block; }
.cust-toggle:checked ~ .new-cust-btn .ncb-plus { transform: rotate(45deg); }
.cust-toggle:checked ~ .new-cust-btn { background: var(--danger); }

/* keyboard focus ring, since the real checkbox is hidden */
.cust-toggle:focus-visible ~ .new-cust-btn {
  outline: 2px solid var(--text); outline-offset: 2px;
}

.cust-info {
  display: flex; gap: 14px; flex-wrap: wrap;
  margin-top: 8px; font-size: 13px; color: var(--text-muted);
}

/* ---- add-item row ---- */
.add-row {
  display: grid;
  grid-template-columns: 1fr 110px 150px auto;
  gap: 12px; align-items: end;
}
.add-row label { margin-top: 0; }
.add-row .ar-btn .btn { width: 100%; }
.add-row small { display: block; margin-top: 4px; font-size: 11px; }
.purchase-add-row { grid-template-columns: minmax(220px,1fr) 160px 110px 150px auto; }
#purchaseCreditFields.is-cash #buyPayFull,
#purchaseCreditFields.is-cash .purchase-due-field { display: none; }

@media (max-width: 700px) {
  .add-row { grid-template-columns: 1fr 1fr; }
  .add-row .ar-item { grid-column: 1 / -1; }
  .add-row .ar-btn  { grid-column: 1 / -1; }
  .purchase-add-row { grid-template-columns: 1fr 1fr; }
}

/* ---- total strip ---- */
.sale-total {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  margin-top: 14px; padding-top: 14px;
  border-top: 2px solid var(--border);
}
.st-label { font-size: 13px; color: var(--text-muted); }
.st-value { font-size: 26px; font-weight: 800; }
.st-second { font-size: 14px; color: var(--text-muted); }

.ctrl-btn.new-btn { background: #2e7d32; border-color: #2e7d32; }
.ctrl-btn.new-btn:hover { background: #1b5e20; border-color: #1b5e20; }

.saved-toast {
  position: fixed; inset-inline-start: 50%; bottom: 26px;
  transform: translateX(-50%);
  background: #2e7d32; color: #fff;
  padding: 12px 26px; border-radius: 30px;
  font-size: 14px; font-weight: 600;
  box-shadow: 0 6px 24px rgba(0,0,0,.28);
  z-index: 500;
  transition: opacity .4s ease, transform .4s ease;
}
.saved-toast.gone { opacity: 0; transform: translateX(-50%) translateY(14px); }

@media print { .saved-toast { display: none !important; } }

/* ================================================================
   TABLE NUMBER ALIGNMENT — append to the end of style.css

   The bug: `text-align: end` resolves against the element's own
   direction. A <th class="num"> inherits the page's RTL direction so
   "end" means LEFT, while a <td class="num ltr-text"> sets
   direction:ltr so "end" means RIGHT. Header and data therefore drift
   apart on every table in the system.

   The fix: numeric cells use PHYSICAL alignment, which means the same
   thing regardless of direction. `.ltr-text` now only controls digit
   ordering, never alignment.
   ================================================================ */

/* --- .ltr-text: direction only, no alignment --- */
td.ltr-text,
th.ltr-text,
[dir="rtl"] td.ltr-text,
[dir="rtl"] th.ltr-text {
  direction: ltr;
  unicode-bidi: plaintext;
  text-align: inherit;          /* let the column class decide */
}

/* --- numeric columns: always right, in both directions --- */
th.num, td.num,
[dir="rtl"] th.num, [dir="rtl"] td.num,
[dir="ltr"] th.num, [dir="ltr"] td.num {
  direction: ltr;
  unicode-bidi: plaintext;
  text-align: right !important;
}

/* a numeric cell that also carries .ltr-text stays right-aligned */
th.num.ltr-text, td.num.ltr-text {
  text-align: right !important;
}

/* --- numeric cells without a .num class (older tables) ---
   Right-align the cell, but only when it holds nothing but a number. */
td.ltr-text:not(.c-name):not(.code) { text-align: inherit; }

/* --- inputs keep their own behaviour --- */
[dir="rtl"] input.ltr-text,
[dir="rtl"] input[type="number"],
[dir="rtl"] input[type="email"],
[dir="rtl"] input[type="date"] {
  direction: ltr;
  text-align: end;
}

/* --- header cells follow the page direction unless numeric --- */
th { text-align: start; }
th.num { text-align: right !important; }

/* --- the storage report and invoice tables already pin their own
       widths; make sure nothing here overrides them --- */
.rep-table .num, .items-table .c-qty,
.items-table .c-price, .items-table .c-total {
  text-align: right !important;
}

/* ================================================================
   AJAX PAGE SWAP — append to the end of style.css
   ================================================================ */

/* A thin progress bar across the top while the next page loads. */
.app-main { position: relative; }

.app-main.page-loading::before {
  content: '';
  position: fixed; inset-inline: 0; top: 0;
  height: 3px; z-index: 999;
  background: var(--primary);
  transform-origin: inline-start;
  animation: pageBar .9s ease-in-out infinite;
}
@keyframes pageBar {
  0%   { transform: scaleX(0);    opacity: 1; }
  70%  { transform: scaleX(.85);  opacity: 1; }
  100% { transform: scaleX(1);    opacity: 0; }
}

/* Content dims slightly rather than blanking out. */
.app-main.page-loading .container {
  opacity: .45;
  pointer-events: none;
  transition: opacity .15s linear;
}

/* Fresh content fades in so the swap reads as a transition. */
.app-main .container { animation: pageIn .28s ease both; }
@keyframes pageIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .app-main .container { animation: none; }
  .app-main.page-loading::before { animation: none; transform: scaleX(1); }
}


