/* ================================================
   POS System - Modern Sidebar UI
   ================================================ */

/* === VARIABLES === */
:root {
  --accent:            #10b981;
  --accent-hover:      #059669;
  --accent-light:      rgba(16,185,129,0.12);

  --sb-w:              260px;
  --sb-icon-w:         66px;
  --topbar-h:          58px;

  --sb-bg:             #111827;
  --sb-border:         rgba(255,255,255,0.06);
  --sb-text:           #9ca3af;
  --sb-text-active:    #f3f4f6;
  --sb-section-color:  #4b5563;
  --sb-hover:          rgba(255,255,255,0.06);
  --sb-active-bg:      rgba(16,185,129,0.15);

  --bg:                #f1f5f9;
  --card-bg:           #ffffff;
  --card-border:       rgba(0,0,0,0.06);
  --card-shadow:       0 1px 3px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.04);
  --card-shadow-h:     0 4px 20px rgba(0,0,0,0.1);
  --card-radius:       12px;

  --topbar-bg:         #ffffff;
  --topbar-border:     rgba(0,0,0,0.06);

  --text:              #0f172a;
  --text-muted:        #64748b;
  --text-subtle:       #94a3b8;

  --input-bg:          #f8fafc;
  --input-border:      #e2e8f0;
  --input-radius:      8px;

  --tbl-head:          #f8fafc;
  --tbl-border:        #e9edf3;
  --tbl-hover:         rgba(16,185,129,0.04);

  --radius:            8px;
  --radius-lg:         12px;
  --radius-sm:         6px;
  --tr:                0.2s ease;
}

/* Dark is for the screen only: printing (reports, slips, payroll, labels)
   always uses the light values above, so nothing prints light-grey on white. */
@media screen {
[data-theme="dark"] {
  color-scheme:        dark;   /* native selects, date pickers, scrollbars, autofill */

  --sb-bg:             #0a0e1a;
  --sb-border:         rgba(255,255,255,0.05);
  --sb-text:           #8b93a1;   /* was #6b7280: 4:1 on the sidebar, under AA */
  --sb-text-active:    #e5e7eb;
  --sb-section-color:  #737b8a;   /* was #374151: headings all but vanished */
  --sb-hover:          rgba(255,255,255,0.05);
  --sb-active-bg:      rgba(16,185,129,0.12);

  --bg:                #0d1117;
  --card-bg:           #161b27;
  --card-border:       rgba(255,255,255,0.05);
  --card-shadow:       0 1px 4px rgba(0,0,0,0.3), 0 4px 16px rgba(0,0,0,0.2);
  --card-shadow-h:     0 4px 28px rgba(0,0,0,0.5);

  --topbar-bg:         #161b27;
  --topbar-border:     rgba(255,255,255,0.06);

  --text:              #e5e7eb;
  --text-muted:        #9ca3af;
  --text-subtle:       #7c8594;   /* was #4b5563 (2.3:1): placeholders, hints - now 4.6:1 */

  --input-bg:          rgba(255,255,255,0.03);
  --input-border:      rgba(255,255,255,0.11);

  --tbl-head:          rgba(255,255,255,0.03);
  --tbl-border:        rgba(255,255,255,0.07);
  --tbl-hover:         rgba(16,185,129,0.07);

  /* Bootstrap's own colours (the app uses data-theme, not data-bs-theme):
     anything Bootstrap paints from these - .border, .form-text, checkboxes,
     progress, accordion, hovered table rows, subtle alerts/badges - follows
     the dark theme too. Values from Bootstrap 5.3's dark mode where the app
     has no token. */
  --bs-body-color:              var(--text);
  --bs-body-color-rgb:          229,231,235;
  --bs-body-bg:                 var(--card-bg);
  --bs-body-bg-rgb:             22,27,39;
  --bs-emphasis-color:          #fff;
  --bs-emphasis-color-rgb:      255,255,255;
  --bs-secondary-color:         var(--text-muted);
  --bs-secondary-color-rgb:     156,163,175;
  --bs-secondary-bg:            #262d3b;
  --bs-secondary-bg-rgb:        38,45,59;
  --bs-tertiary-color:          var(--text-subtle);
  --bs-tertiary-bg:             #1c2230;
  --bs-tertiary-bg-rgb:         28,34,48;
  --bs-border-color:            rgba(255,255,255,0.12);
  --bs-border-color-translucent: rgba(255,255,255,0.15);
  --bs-link-color:              #6ea8fe;
  --bs-link-color-rgb:          110,168,254;
  --bs-link-hover-color:        #8bb9fe;
  --bs-link-hover-color-rgb:    139,185,254;
  --bs-code-color:              #e685b5;
  --bs-highlight-bg:            #664d03;
  --bs-form-valid-color:        #75b798;
  --bs-form-valid-border-color: #75b798;
  --bs-form-invalid-color:      #ea868f;
  --bs-form-invalid-border-color: #ea868f;
  --bs-primary-text-emphasis:   #6ea8fe;
  --bs-secondary-text-emphasis: #a7acb1;
  --bs-success-text-emphasis:   #75b798;
  --bs-info-text-emphasis:      #6edff6;
  --bs-warning-text-emphasis:   #ffda6a;
  --bs-danger-text-emphasis:    #ea868f;
  --bs-light-text-emphasis:     #f8f9fa;
  --bs-dark-text-emphasis:      #dee2e6;
  --bs-primary-bg-subtle:       #031633;
  --bs-secondary-bg-subtle:     #161719;
  --bs-success-bg-subtle:       #051b11;
  --bs-info-bg-subtle:          #032830;
  --bs-warning-bg-subtle:       #332701;
  --bs-danger-bg-subtle:        #2c0b0e;
  --bs-light-bg-subtle:         #343a40;
  --bs-dark-bg-subtle:          #1a1d20;
  --bs-primary-border-subtle:   #084298;
  --bs-secondary-border-subtle: #41464b;
  --bs-success-border-subtle:   #0f5132;
  --bs-info-border-subtle:      #087990;
  --bs-warning-border-subtle:   #997404;
  --bs-danger-border-subtle:    #842029;
  --bs-light-border-subtle:     #495057;
  --bs-dark-border-subtle:      #343a40;
}
}

/* === RESET === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background var(--tr), color var(--tr);
}

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

/* =======================================
   APP LAYOUT  (sidebar + page wrapper)
   ======================================= */
.app-layout {
  display: flex;
  min-height: 100vh;
  position: relative;
}

/* =======================================
   SIDEBAR
   ======================================= */
.sidebar {
  width: var(--sb-w);
  background: var(--sb-bg);
  border-right: 1px solid var(--sb-border);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 300;
  display: flex;
  flex-direction: column;
  transition: width var(--tr), transform var(--tr);
  overflow: hidden;
  flex-shrink: 0;
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-width: var(--sb-w);
  overflow: hidden;
}

/* Brand */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 14px 16px;
  border-bottom: 1px solid var(--sb-border);
  flex-shrink: 0;
  overflow: hidden;
  min-height: 64px;
  transition: padding var(--tr), gap var(--tr);
}
.sidebar-brand-icon {
  width: 36px; height: 36px;
  background: var(--accent);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px; color: #fff;
  flex-shrink: 0;
  letter-spacing: -0.5px;
}
.sidebar-brand-text { overflow: hidden; flex: 1; min-width: 0; transition: opacity var(--tr), width var(--tr); }
.sidebar-brand-name {
  font-weight: 700; font-size: 13.5px; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  line-height: 1.25; display: block;
}
.sidebar-brand-sub {
  font-size: 11px; color: var(--sb-text);
  white-space: nowrap; display: block; margin-top: 1px;
}
.sidebar-collapse-btn {
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--sb-border);
  background: transparent; color: var(--sb-text);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 14px; transition: all 0.15s; flex-shrink: 0;
  margin-left: auto;
}
.sidebar-collapse-btn:hover {
  background: var(--sb-hover); color: var(--sb-text-active);
  border-color: rgba(255,255,255,0.12);
}

/* Nav */
.sidebar-nav {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.06) transparent;
  transition: padding var(--tr);
}
.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 2px; }

.sidebar-section {
  font-size: 10.5px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--sb-section-color);
  padding: 16px 10px 5px;
  white-space: nowrap; overflow: hidden;
  transition: opacity var(--tr), width var(--tr);
}

.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius);
  color: var(--sb-text);
  font-size: 13.5px; font-weight: 500;
  cursor: pointer;
  transition: background 0.13s ease, color 0.13s ease, padding var(--tr), gap var(--tr), justify-content var(--tr);
  white-space: nowrap; overflow: hidden;
  border: none; background: none;
  width: 100%; text-align: left;
  margin-bottom: 2px;
  text-decoration: none;
}
.sidebar-link:hover {
  background: var(--sb-hover); color: var(--sb-text-active); text-decoration: none;
}
.sidebar-link.active {
  background: var(--sb-active-bg); color: var(--accent) !important;
  font-weight: 600;
}
.sidebar-link.active i { color: var(--accent) !important; }
.sidebar-link i {
  width: 20px; text-align: center; flex-shrink: 0; font-size: 15px;
  color: inherit;
}
.sidebar-link .link-text { overflow: hidden; text-overflow: ellipsis; transition: opacity var(--tr), width var(--tr); }

/* Sidebar footer */
.sidebar-footer {
  border-top: 1px solid var(--sb-border);
  padding: 10px 8px;
  flex-shrink: 0; overflow: hidden;
  transition: padding var(--tr);
}
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius);
  overflow: hidden; margin-bottom: 4px;
  transition: padding var(--tr), gap var(--tr);
}
.sidebar-avatar {
  width: 32px; height: 32px;
  background: var(--accent); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px; color: #fff; flex-shrink: 0;
}
.sidebar-user-info { overflow: hidden; flex: 1; min-width: 0; transition: opacity var(--tr), width var(--tr); }
.sidebar-user-name {
  font-size: 13px; font-weight: 600; color: var(--sb-text-active);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  line-height: 1.25; display: block;
}
.sidebar-user-role {
  font-size: 11px; color: var(--sb-text); white-space: nowrap; display: block;
}

/* Mobile backdrop */
.sidebar-backdrop {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.5); z-index: 299;
  backdrop-filter: blur(2px);
}

/* =======================================
   COLLAPSED SIDEBAR  (desktop)
   ======================================= */
.app-layout.sidebar-collapsed .sidebar { width: var(--sb-icon-w); }
.app-layout.sidebar-collapsed .sidebar-brand-text,
.app-layout.sidebar-collapsed .sidebar-section,
.app-layout.sidebar-collapsed .sidebar-link .link-text,
.app-layout.sidebar-collapsed .sidebar-user-info {
  opacity: 0; pointer-events: none; width: 0; overflow: hidden;
}
.app-layout.sidebar-collapsed .sidebar-brand {
  justify-content: center; padding: 18px 8px; gap: 0;
}
/* No room beside the logo when collapsed - the top bar's ☰ (or Ctrl+K) opens it. */
.app-layout.sidebar-collapsed .sidebar-collapse-btn { display: none; }
.app-layout.sidebar-collapsed .sidebar-link {
  justify-content: center; padding: 9px 6px; gap: 0;
}
.app-layout.sidebar-collapsed .sidebar-link i { width: auto; margin: 0; }
.app-layout.sidebar-collapsed .sidebar-user {
  justify-content: center; padding: 8px 6px; gap: 0;
}
/* .sidebar-inner keeps the full width (no text re-wrapping while it slides)
   - but collapsed, that left every link 248px wide in a 66px bar, so a
   centered icon sat off-screen and only links with a shortcut badge (which
   pushed their icon to the left edge) showed one. */
.app-layout.sidebar-collapsed .sidebar-inner { min-width: var(--sb-icon-w); }
.app-layout.sidebar-collapsed .sidebar-link .shortcut-badge { display: none; }
/* Section headings become thin dividers instead of empty gaps. */
.app-layout.sidebar-collapsed .sidebar-section {
  width: auto; height: 1px; padding: 0; margin: 8px 10px;
  font-size: 0; background: var(--sb-border); opacity: 1;
}
.app-layout.sidebar-collapsed .sidebar-nav { padding: 8px 6px; }
.app-layout.sidebar-collapsed .sidebar-footer { padding: 10px 6px; }

/* =======================================
   PAGE WRAPPER
   ======================================= */
.page-wrapper {
  flex: 1;
  margin-left: var(--sb-w);
  transition: margin-left var(--tr);
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.app-layout.sidebar-collapsed .page-wrapper {
  margin-left: var(--sb-icon-w);
}

/* =======================================
   TOPBAR
   ======================================= */
.topbar {
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  padding: 0 20px;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  position: sticky; top: 0; z-index: 200;
  flex-shrink: 0;
  box-shadow: 0 1px 0 var(--topbar-border);
}
.topbar-hamburger {
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--input-border);
  background: transparent; color: var(--text-muted);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 17px; transition: all 0.13s; flex-shrink: 0;
}
.topbar-hamburger:hover {
  background: var(--accent-light); border-color: var(--accent); color: var(--accent);
}
.topbar-title {
  font-size: 15px; font-weight: 700; color: var(--text); flex: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar-actions { display: flex; align-items: center; gap: 6px; }
.topbar-btn {
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--input-border);
  background: transparent; color: var(--text-muted);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 14px; transition: all 0.13s; text-decoration: none;
  padding: 0;
}
.topbar-btn:hover {
  background: var(--accent-light); border-color: var(--accent); color: var(--accent);
}
.topbar-user {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px 5px 6px;
  border-radius: 50px;
  cursor: pointer; transition: background 0.13s;
  color: var(--text);
  border: 1px solid var(--input-border);
  background: transparent;
}
.topbar-user:hover { background: var(--accent-light); border-color: var(--accent); }
.topbar-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px; flex-shrink: 0;
}
.topbar-user-name { font-size: 13px; font-weight: 600; color: var(--text); }
.topbar .form-control-color {
  padding: 2px !important; height: 34px !important; width: 34px !important;
  border-radius: var(--radius-sm) !important;
  border: 1px solid var(--input-border) !important;
  cursor: pointer; background: transparent;
}

/* =======================================
   PAGE CONTENT
   ======================================= */
.page-content { flex: 1; padding: 24px; background: var(--bg); }
.page-content > .container,
.page-content .container { max-width: 100%; padding: 0; }

/* =======================================
   LOGIN
   ======================================= */
/* ERX monogram look: off-white paper, frosted card, black + gold. */
.login-wrapper {
  --lx-text: #111111;
  --lx-muted: #666666;
  --lx-gold: #B89752;
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  font-family: "Plus Jakarta Sans", "Inter", sans-serif;
  color: var(--lx-text);
  -webkit-font-smoothing: antialiased;
  background-color: #F8F9FA;
  background-image:
    linear-gradient(to right, rgba(0,0,0,0.02) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(0,0,0,0.02) 1px, transparent 1px),
    radial-gradient(at 10% 10%, rgba(220,210,195,0.25) 0px, transparent 50%),
    radial-gradient(at 90% 90%, rgba(230,225,215,0.3) 0px, transparent 50%);
  background-size: 30px 30px, 30px 30px, 100% 100%, 100% 100%;
}
.login-main {
  width: 100%; max-width: 448px; margin: 32px 0;
  animation: lxFadeIn .8s cubic-bezier(0.16,1,0.3,1) both;
}
.login-card {
  position: relative; overflow: hidden;
  background: rgba(255,255,255,0.88);
  -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px);
  border: 1px solid rgba(0,0,0,0.07);
  border-radius: 24px;
  box-shadow: 0 20px 40px -15px rgba(0,0,0,0.05), 0 0 1px 1px rgba(0,0,0,0.03);
  padding: 44px;
}
.login-accent {
  position: absolute; top: 0; left: 0; right: 0; height: 3px; opacity: .8;
  background: linear-gradient(to right, transparent, var(--lx-gold), transparent);
}
.login-brand { text-align: center; margin-bottom: 36px; }
.login-logo {
  display: inline-block; padding: 18px 20px; margin-bottom: 12px;
  background: #fff; border: 1px solid rgba(0,0,0,0.05); border-radius: 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  animation: lxFloat 8s ease-in-out infinite;
}
.login-logo img { display: block; width: 112px; height: auto; }
.login-title {
  font-family: "Cinzel", "Didot", "Bodoni MT", Georgia, serif;
  font-size: 24px; font-weight: 700; letter-spacing: .2em;
  color: var(--lx-text); margin: 8px 0 0;
}
.login-sub {
  font-size: 11px; font-weight: 500; letter-spacing: .3em; text-transform: uppercase;
  color: var(--lx-muted); margin: 4px 0 0;
}
.login-error {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 20px; padding: 12px 14px; border-radius: 12px;
  background: #FDF3F2; border: 1px solid rgba(180,35,24,0.15);
  color: #B42318; font-size: 13px; font-weight: 500;
}
.login-field { margin-bottom: 20px; }
.login-field label {
  display: block; margin-bottom: 8px;
  font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase;
  color: var(--lx-text);
}
.login-input { position: relative; }
.login-input-icon {
  position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
  font-size: 13px; color: #9ca3af; pointer-events: none;
}
.login-input input {
  width: 100%; padding: 14px 44px;
  background: #FAFAFA; border: 1px solid rgba(0,0,0,0.12); border-radius: 12px;
  font: inherit; font-size: 14px; color: var(--lx-text);
  transition: all .25s cubic-bezier(0.16,1,0.3,1);
}
.login-input input::placeholder { color: #9ca3af; }
.login-input input:focus {
  background: #fff; border-color: var(--lx-text); outline: none;
  box-shadow: 0 0 0 4px rgba(0,0,0,0.04);
}
.login-eye {
  position: absolute; right: 0; top: 0; bottom: 0; padding: 0 16px;
  background: none; border: 0; color: #9ca3af; font-size: 14px; cursor: pointer;
  transition: color .2s;
}
.login-eye:hover, .login-eye:focus-visible { color: var(--lx-text); }
.login-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; margin-top: 28px; padding: 16px 24px;
  background: var(--lx-text); color: #fff; border: 0; border-radius: 12px;
  font: inherit; font-size: 12px; font-weight: 500; letter-spacing: .2em; text-transform: uppercase;
  cursor: pointer;
  transition: all .3s cubic-bezier(0.16,1,0.3,1);
}
.login-btn:hover { background: #222; transform: translateY(-1px); box-shadow: 0 10px 20px -5px rgba(0,0,0,0.2); }
.login-btn:active { transform: translateY(0); }
.login-btn:disabled { opacity: .85; cursor: wait; transform: none; box-shadow: none; }
.login-spin { font-size: 14px; animation: lxSpin 1s linear infinite; }
.login-foot {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-top: 24px; font-size: 11px; color: #9ca3af;
}
.login-foot i { color: var(--lx-gold); font-size: 12px; }
@keyframes lxFadeIn { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: none; } }
@keyframes lxFloat { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes lxSpin { to { transform: rotate(360deg); } }
@media (max-width: 480px) { .login-card { padding: 32px 22px; } }
@media (prefers-reduced-motion: reduce) { .login-main, .login-logo { animation: none; } }

/* =======================================
   CARDS
   ======================================= */
.card {
  background: var(--card-bg) !important;
  color: var(--text) !important;
  border: 1px solid var(--card-border) !important;
  border-radius: var(--card-radius) !important;
  box-shadow: var(--card-shadow) !important;
  transition: box-shadow 0.2s ease !important;
}
.card:hover { box-shadow: var(--card-shadow-h) !important; }
.stat-card {
  cursor: pointer;
  transition: box-shadow 0.2s ease, transform 0.15s ease !important;
  color: var(--text) !important;
}
.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.13) !important;
  color: var(--text) !important;
}
.stat-card:hover .text-muted { color: var(--text-muted) !important; }
.card-header {
  background: transparent !important;
  border-bottom: 1px solid var(--card-border) !important;
  padding: 14px 18px !important;
  font-weight: 600; font-size: 13.5px;
}
.card-body { padding: 18px !important; }
.card-footer {
  background: transparent !important;
  border-top: 1px solid var(--card-border) !important;
  padding: 12px 18px !important;
}
.card-title { font-weight: 700 !important; color: var(--text) !important; margin-bottom: 4px !important; }
.card-text { color: var(--text-muted) !important; font-size: 13px !important; }

/* =======================================
   TABLES
   ======================================= */
.table { color: var(--text) !important; border-color: var(--tbl-border) !important; margin-bottom: 0; }
.table thead th {
  background: var(--tbl-head) !important;
  color: var(--text-muted) !important;
  font-size: 11px !important; font-weight: 700 !important;
  letter-spacing: 0.07em !important; text-transform: uppercase !important;
  border-bottom: 2px solid var(--tbl-border) !important;
  padding: 10px 14px !important; white-space: nowrap;
}
.table td {
  padding: 10px 14px !important; vertical-align: middle !important;
  border-bottom: 1px solid var(--tbl-border) !important;
  font-size: 13px;
}
.table tbody tr:hover td { background: var(--tbl-hover) !important; }
/* Bootstrap paints table cells with its own (light) body colour; the app's
   dark theme is set via data-theme, not data-bs-theme, so hand the table
   the page's colours or every table stays white in dark mode. */
[data-theme="dark"] .table { --bs-table-bg: transparent; --bs-table-color: var(--text); --bs-table-striped-bg: rgba(255,255,255,0.03); --bs-table-striped-color: var(--text); }
.table-responsive { border-radius: var(--card-radius); }

/* =======================================
   FORMS
   ======================================= */
.form-control, .form-select {
  background: var(--input-bg) !important;
  border: 1px solid var(--input-border) !important;
  border-radius: var(--input-radius) !important;
  color: var(--text) !important;
  font-size: 13.5px;
  padding: 8px 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus, .form-select:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px rgba(16,185,129,0.12) !important;
  background: var(--card-bg) !important;
  outline: none;
}
.form-control::placeholder { color: var(--text-subtle) !important; }
.form-label {
  font-size: 12.5px; font-weight: 600; color: var(--text-muted); margin-bottom: 5px;
}
.input-group .form-control:not(:first-child) { border-left: none !important; }
.input-group .form-control:not(:last-child) { border-right: none !important; }
.input-group-text {
  background: var(--input-bg) !important;
  border-color: var(--input-border) !important;
  color: var(--text-muted) !important;
  font-size: 13px;
}
.form-check-input:checked { background-color: var(--accent) !important; border-color: var(--accent) !important; }
.form-check-input:focus { box-shadow: 0 0 0 3px rgba(16,185,129,0.15) !important; }

/* =======================================
   BUTTONS
   ======================================= */
.btn {
  font-size: 13.5px; font-weight: 600;
  border-radius: var(--radius) !important;
  padding: 7px 15px;
  transition: all 0.15s ease !important;
  border-width: 1px !important;
}
.btn:focus { box-shadow: none !important; }

.btn-primary {
  background: var(--accent) !important;
  border-color: var(--accent) !important; color: #fff !important;
}
.btn-primary:hover {
  background: var(--accent-hover) !important;
  border-color: var(--accent-hover) !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16,185,129,0.35) !important;
}
.btn-outline-primary {
  color: var(--accent) !important;
  border-color: var(--accent) !important; background: transparent !important;
}
.btn-outline-primary:hover {
  background: var(--accent) !important; color: #fff !important;
}
.btn-secondary {
  background: var(--input-bg) !important;
  border-color: var(--input-border) !important; color: var(--text) !important;
}
.btn-secondary:hover { background: var(--tbl-border) !important; }
.btn-danger {
  background: #ef4444 !important; border-color: #ef4444 !important; color: #fff !important;
}
.btn-danger:hover { background: #dc2626 !important; border-color: #dc2626 !important; }
.btn-success {
  background: #10b981 !important; border-color: #10b981 !important; color: #fff !important;
}
.btn-warning {
  background: #f59e0b !important; border-color: #f59e0b !important; color: #fff !important;
}
.btn-info {
  background: #3b82f6 !important; border-color: #3b82f6 !important; color: #fff !important;
}
.btn-sm { padding: 4px 10px !important; font-size: 12px !important; }
.btn-lg { padding: 10px 20px !important; font-size: 15px !important; }

/* =======================================
   BADGES
   ======================================= */
.badge { font-weight: 600 !important; font-size: 11px !important; letter-spacing: 0.02em; }
.badge.bg-success { background: rgba(16,185,129,0.15) !important; color: #059669 !important; }
.badge.bg-danger  { background: rgba(239,68,68,0.15)   !important; color: #dc2626 !important; }
.badge.bg-warning { background: rgba(245,158,11,0.15)  !important; color: #d97706 !important; }
.badge.bg-info    { background: rgba(59,130,246,0.15)  !important; color: #2563eb !important; }
.badge.bg-primary { background: rgba(16,185,129,0.15)  !important; color: var(--accent) !important; }
.badge.bg-secondary { background: var(--input-bg) !important; color: var(--text-muted) !important; border: 1px solid var(--input-border) !important; }

/* =======================================
   ALERTS
   ======================================= */
.alert {
  border-radius: var(--radius) !important;
  font-size: 13.5px; border-width: 1px !important; padding: 12px 16px !important;
}
.alert-success { background: rgba(16,185,129,0.08) !important; border-color: rgba(16,185,129,0.25) !important; color: #065f46 !important; }
.alert-danger   { background: rgba(239,68,68,0.07)  !important; border-color: rgba(239,68,68,0.25)  !important; color: #991b1b !important; }
.alert-warning  { background: rgba(245,158,11,0.08) !important; border-color: rgba(245,158,11,0.25) !important; color: #92400e !important; }
.alert-info     { background: rgba(59,130,246,0.08) !important; border-color: rgba(59,130,246,0.2)  !important; color: #1e40af !important; }

/* =======================================
   MODALS
   ======================================= */
.modal-content {
  background: var(--card-bg) !important;
  border: 1px solid var(--card-border) !important;
  border-radius: 14px !important;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35) !important;
  color: var(--text) !important;
}
.modal-header {
  border-bottom: 1px solid var(--card-border) !important;
  padding: 16px 20px !important;
}
.modal-footer {
  border-top: 1px solid var(--card-border) !important;
  padding: 12px 20px !important;
}
.modal-title { font-weight: 700 !important; font-size: 15px !important; }
.modal-body { padding: 20px !important; }
.btn-close { filter: var(--close-filter); }
[data-theme="dark"] .btn-close { filter: invert(1) grayscale(1); }

/* =======================================
   DROPDOWNS
   ======================================= */
.dropdown-menu {
  background: var(--card-bg) !important;
  border: 1px solid var(--card-border) !important;
  border-radius: var(--radius-lg) !important;
  box-shadow: 0 8px 30px rgba(0,0,0,0.15) !important;
  padding: 6px !important; font-size: 13.5px;
}
.dropdown-item {
  border-radius: var(--radius-sm) !important;
  color: var(--text) !important;
  padding: 7px 12px !important; font-size: 13.5px;
}
.dropdown-item:hover { background: var(--accent-light) !important; color: var(--accent) !important; }
.dropdown-divider { border-color: var(--card-border) !important; }
.dropdown-item-text { font-size: 12px; color: var(--text-muted); padding: 6px 12px !important; }

/* =======================================
   TABS / PILLS
   ======================================= */
.nav-tabs { border-color: var(--tbl-border) !important; }
.nav-tabs .nav-link {
  color: var(--text-muted) !important;
  border-color: transparent !important;
  font-size: 13.5px; font-weight: 500;
  padding: 8px 16px;
  border-radius: var(--radius) var(--radius) 0 0 !important;
}
.nav-tabs .nav-link.active {
  color: var(--accent) !important;
  border-color: var(--tbl-border) var(--tbl-border) var(--card-bg) !important;
  background: var(--card-bg) !important; font-weight: 600;
}
.nav-tabs .nav-link:hover { color: var(--text) !important; }

/* =======================================
   PAGINATION
   ======================================= */
.pagination .page-link {
  background: var(--card-bg) !important;
  border-color: var(--input-border) !important;
  color: var(--text-muted) !important;
  font-size: 13px; padding: 6px 12px;
}
.pagination .page-link:hover { background: var(--accent-light) !important; color: var(--accent) !important; }
.pagination .page-item.active .page-link {
  background: var(--accent) !important; border-color: var(--accent) !important; color: #fff !important;
}

/* =======================================
   UTILITY OVERRIDES
   ======================================= */
.text-muted { color: var(--text-muted) !important; }
.text-success { color: #10b981 !important; }
.text-danger  { color: #ef4444 !important; }
.text-warning { color: #f59e0b !important; }
.text-info    { color: #3b82f6 !important; }
.bg-light { background: var(--input-bg) !important; color: var(--text) !important; }
hr { border-color: var(--card-border) !important; opacity: 1 !important; }
.list-group-item {
  background: var(--card-bg) !important; color: var(--text) !important;
  border-color: var(--card-border) !important;
}
/* POS and Quick Restock search: the row picked with the arrow keys. Needs
   !important because the themed background above would otherwise hide
   Bootstrap's .active. */
#searchResults .list-group-item.active,
#rcSearchResults .list-group-item.active {
  background: var(--input-bg) !important;
  background: color-mix(in srgb, var(--accent) 14%, var(--card-bg)) !important;
  box-shadow: inset 4px 0 0 var(--accent);
  color: var(--text) !important;
  border-color: var(--card-border) !important;
}
.breadcrumb-item + .breadcrumb-item::before { color: var(--text-subtle) !important; }

/* =======================================
   HEADINGS IN PAGE CONTENT
   ======================================= */
.page-content h1, .page-content h2, .page-content h3,
.page-content h4, .page-content h5 {
  color: var(--text); font-weight: 700; margin-top: 0;
}
.page-content h3 { font-size: 18px; margin-bottom: 16px; }
.page-content h4 { font-size: 15px; margin-bottom: 12px; }

/* =======================================
   MOBILE
   ======================================= */
@media (max-width: 991px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sb-w) !important;
  }
  .app-layout.sidebar-open .sidebar { transform: translateX(0); }
  .app-layout.sidebar-open .sidebar-backdrop { display: block; }
  .page-wrapper { margin-left: 0 !important; }
  .page-content { padding: 16px; }
  .topbar { padding: 0 14px; }
}

/* Fade-in animation */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.card { animation: fadeIn 0.25s ease both; }

/* =======================================
   KEYBOARD SHORTCUTS
   ======================================= */
kbd {
  display: inline-block;
  padding: 3px 8px;
  font-family: 'SF Mono', 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  color: var(--text);
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05), inset 0 -1px 0 rgba(0,0,0,0.1);
  text-transform: uppercase;
  white-space: nowrap;
  min-width: 24px;
  text-align: center;
}

[data-theme="dark"] kbd {
  box-shadow: 0 1px 2px rgba(0,0,0,0.2), inset 0 -1px 0 rgba(255,255,255,0.05);
}

/* Keyboard shortcuts window (assets/js/app.js openEditor) */
#shortcutsHelpModal .modal-body { padding: 20px 24px; }
.sc-intro { color: var(--text-muted); font-size: 13px; margin-bottom: 16px; }
.sc-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
.sc-group h6 {
  font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted); margin-bottom: 8px;
}
.sc-list { list-style: none; margin: 0; padding: 0; }
.sc-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; align-items: center;
  gap: 6px; padding: 6px 0; border-bottom: 1px solid var(--tbl-border);
}
.sc-row:last-child { border-bottom: none; }
.sc-desc { font-size: 13px; color: var(--text); }
.sc-key {
  min-width: 88px; padding: 4px 10px; border-radius: 6px; cursor: pointer;
  font-family: 'SF Mono', 'Consolas', 'Monaco', 'Courier New', monospace; font-size: 12px; font-weight: 600;
  color: var(--text); background: var(--input-bg); border: 1px solid var(--input-border);
  box-shadow: inset 0 -1px 0 rgba(0,0,0,0.08); white-space: nowrap; transition: var(--tr);
}
.sc-key:hover, .sc-key:focus-visible { border-color: var(--accent); outline: none; }
.sc-key.is-empty { color: var(--text-subtle); font-weight: 500; font-style: italic; }
.sc-key.is-changed { border-color: var(--accent); background: var(--accent-light); }
.sc-key.is-capturing { border-color: var(--accent); color: var(--accent); animation: scPulse 1s ease-in-out infinite; }
@keyframes scPulse { 50% { box-shadow: 0 0 0 3px var(--accent-light); } }
.sc-icon {
  width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: 6px; background: none; color: var(--text-muted); font-size: 12px;
}
.sc-icon:hover:not(:disabled) { background: var(--input-bg); color: var(--text); }
.sc-icon:disabled { opacity: .25; }
.sc-note { grid-column: 1 / -1; font-size: 12px; padding: 4px 8px; border-radius: 6px; }
.sc-note.error { color: #b91c1c; background: rgba(239,68,68,.1); }
.sc-note.warn { color: #92400e; background: rgba(245,158,11,.12); }
.sc-note.info { color: var(--text-muted); background: var(--input-bg); }
[data-theme="dark"] .sc-note.error { color: #fca5a5; }
[data-theme="dark"] .sc-note.warn { color: #fcd34d; }
.sc-status { font-size: 13px; color: var(--text-muted); }
@media (max-width: 991.98px) { .sc-grid { grid-template-columns: minmax(0, 1fr); } }

/* Toast notification */
.alert.position-fixed {
  max-width: 400px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translate(-50%, -20px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

/* Sidebar shortcut badges */
.sidebar-link .badge {
  margin-left: auto;
  transition: opacity var(--tr);
}

.sidebar-collapsed .sidebar-link .badge {
  opacity: 0 !important;
  pointer-events: none;
}

.sidebar-link:hover .badge {
  opacity: 0.9 !important;
}

/* Keyboard help button in header */
.header .btn-outline-secondary {
  border-color: var(--input-border);
  color: var(--text-muted);
}

.header .btn-outline-secondary:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}

/* Quick search button styling */
.topbar-btn .bi-search {
  font-size: 1.1rem;
}

.topbar-btn[title*="Quick Search"] {
  position: relative;
}

.topbar-btn[title*="Quick Search"]:hover {
  color: var(--accent);
  background: var(--accent-light);
}
/* Inventory: inactive products and row selection */
.inv-sel-col { width: 52px; }
.inv-lead { display: flex; align-items: center; gap: 8px; min-height: 20px; }
.inv-idle-moon { color: var(--text-muted); font-size: 14px; line-height: 1; cursor: help; }
.inv-idle-moon:focus-visible { outline: 2px solid var(--accent, #10b981); outline-offset: 2px; border-radius: 4px; }
.inv-row-idle > td { color: var(--text-muted); }
.inv-row-idle img, .inv-row-idle .bi-image { opacity: .55; }
.inv-row-picked > td { background: var(--tbl-hover) !important; }
.inv-idle-note { font-size: 11px; line-height: 1.2; }
.inv-bulkbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 8px 12px; margin-bottom: 12px;
  background: var(--input-bg); border: 1px solid var(--input-border); border-radius: var(--radius);
  position: sticky; top: calc(var(--topbar-h, 60px) + 8px); z-index: 5;
}
.inv-bulkbar[hidden] { display: none; }
/* sticky: needs a solid colour in dark (--input-bg is see-through there) */
[data-theme="dark"] .inv-bulkbar { background: #1d222e; }

/* ── Stock Transfers (pages/stock_transfers.php) ── */
.st-results { position: absolute; left: calc(var(--bs-gutter-x) * .5); right: calc(var(--bs-gutter-x) * .5); top: 100%; z-index: 30; max-height: 320px; overflow-y: auto; box-shadow: var(--card-shadow-h); }
.st-results:empty { display: none; }
.st-results .list-group-item { background: var(--card-bg); color: var(--text); border-color: var(--tbl-border); }
.st-results .list-group-item-action:hover, .st-results .list-group-item.active { background: var(--accent-light); color: var(--text); border-color: var(--tbl-border); }
.st-results .st-stock { background: var(--input-bg); color: var(--text); border: 1px solid var(--input-border); font-weight: 600; }
.st-lines .st-qty { max-width: 90px; }
.st-lines tr.st-flash > td { background: var(--accent-light); transition: background .6s; }
.st-pre { white-space: pre-line; }
.st-dir { font-weight: 600; }
.st-dir-out { background: rgba(234,88,12,.14); color: #c2410c; }

/* ---- Stock Count / Gard (pages/inventory_count.php, assets/js/stock_count.js) ---- */
.sc-steps { padding-inline-start: 1.2rem; }
.sc-steps li { margin-bottom: 6px; }
.sc-badge { font-size: .55em; }
.sc-results { position: absolute; left: 0; right: 0; top: 100%; z-index: 30; max-height: 340px; overflow-y: auto; box-shadow: var(--card-shadow-h); }
.sc-results:empty { display: none; }
.sc-results .list-group-item { background: var(--card-bg); color: var(--text); border-color: var(--tbl-border); }
.sc-results .list-group-item-action:hover, .sc-results .list-group-item.active { background: var(--accent-light); color: var(--text); border-color: var(--tbl-border); }
.sc-results .sc-stock { background: var(--input-bg); color: var(--text); border: 1px solid var(--input-border); font-weight: 600; }
.sc-quick { max-width: 220px; margin-top: 6px; }
.sc-entry { margin-top: 14px; padding: 14px; border: 2px solid var(--accent); border-radius: var(--radius-lg); background: var(--accent-light); }
.sc-entry-name { font-size: 1.1rem; }
.sc-entry .sc-num, .sc-entry .sc-expiry { font-size: 1.15rem; font-weight: 600; }
.sc-filter { max-width: 240px; }
.sc-table tr.sc-flash > td { background: var(--accent-light); transition: background .6s; }
.sc-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.sc-chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 4px 2px 8px; border-radius: 999px; border: 1px solid var(--input-border); background: var(--input-bg); font-size: .8rem; white-space: nowrap; }
.sc-chip.is-none { border-style: dashed; }
.sc-chip-x { display: grid; place-items: center; width: 20px; height: 20px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--text-muted); }
.sc-chip-x:hover, .sc-chip-x:focus-visible { background: rgba(239, 68, 68, .15); color: #dc2626; }
.sc-skipped { max-height: 180px; overflow-y: auto; padding-inline-start: 1.1rem; }
@media print { .sc-page .btn { display: none; } }
.st-dir-in { background: rgba(16,185,129,.14); color: #047857; }
[data-theme="dark"] .st-dir-out { color: #fdba74; }
[data-theme="dark"] .st-dir-in { color: #6ee7b7; }
.st-slip-kicker { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); }
.st-slip-no { font-weight: 700; letter-spacing: .02em; }
.st-party { border: 1px solid var(--tbl-border); border-radius: var(--radius); padding: 10px 12px; background: var(--input-bg); }
.st-party span { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.st-party strong { font-size: 1.05rem; }
.st-signatures { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 24px; margin-top: 36px; font-size: 12px; color: var(--text-muted); }
.st-sign-line { display: block; border-bottom: 1px solid var(--text-muted); height: 36px; margin-bottom: 6px; }
@media print {
  .sidebar, .sidebar-backdrop, .topbar, .st-no-print, .page-content > .container > .alert { display: none !important; }
  .page-wrapper { margin: 0 !important; }
  .page-content { padding: 0 !important; background: #fff !important; }
  .st-slip { border: 0 !important; box-shadow: none !important; background: #fff !important; color: #000 !important; }
  .st-slip .table { color: #000; }
  .st-slip .table-responsive { overflow: visible; }
  .st-party { background: #fff !important; border-color: #999 !important; }
  .st-dir { border: 1px solid #999; color: #000 !important; background: #fff !important; }
  .st-signatures { color: #000; break-inside: avoid; }
  .st-sign-line { border-color: #000; }
}

/* ===== POS cart: a product's name links to its Inventory edit form ===== */
#cartTable .cart-name-edit {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  border-radius: var(--radius-sm); padding: 2px 8px; margin: -2px -8px;
  font-weight: 600; color: inherit; text-decoration: none; line-height: 1.3; cursor: pointer;
  transition: background var(--tr), color var(--tr);
}
#cartTable .cart-name-edit span { overflow-wrap: anywhere; }
#cartTable .cart-name-edit:hover,
#cartTable .cart-name-edit:focus-visible { background: var(--accent-light); color: var(--accent); }
#cartTable .cart-name-edit:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Quick Restock search list: scrolls inside itself, like the POS list */
.rc-search-results {
  max-height: min(420px, 60vh); overflow-y: auto; overscroll-behavior: contain;
  border-radius: var(--radius); box-shadow: var(--card-shadow-h);
}
.rc-search-results:empty { display: none; }

/* ── Quick Restock lines (pages/purchase_orders.php) ── */
/* the theme pads every table cell 10px 14px !important - too roomy for 8 columns */
.rc-items-table thead th, .rc-items-table td { padding: 8px 5px !important; vertical-align: top !important; }
.rc-items-table thead th { white-space: normal; }
.rc-items-table thead th:first-child, .rc-items-table td:first-child { padding-left: 12px !important; min-width: 120px; }
.rc-items-table .form-control-sm { padding-left: .3rem; padding-right: .3rem; }
.rc-items-table .rc-price-input { min-width: 108px; }
.rc-items-table .rc-qty { min-width: 58px; }
.rc-items-table .rc-expiry { min-width: 68px; }
.rc-items-table .rc-auto { background: var(--accent-light); font-style: italic; }
.rc-hint { font-size: 11px; line-height: 1.25; margin-top: 3px; color: var(--text-muted); }
.rc-hint:empty { display: none; }
.rc-hint-up { color: #047857; }
.rc-hint-down { color: #b45309; }
.rc-hint-bad { color: #b91c1c; }
[data-theme="dark"] .rc-hint-up { color: #6ee7b7; }
[data-theme="dark"] .rc-hint-down { color: #fcd34d; }
[data-theme="dark"] .rc-hint-bad { color: #fca5a5; }
.rc-tier { font-size: 11px; line-height: 1.3; margin-top: 2px; color: var(--text-muted); white-space: pre-line; }
.rc-tier:empty { display: none; }
.rc-name { font-size: 15px; font-weight: 700; line-height: 1.3; color: var(--text); overflow-wrap: anywhere; }
.rc-line-total { font-weight: 600; white-space: nowrap; }
.rc-line-unit { font-size: 11px; color: var(--text-muted); white-space: nowrap; }

/* ---- Inventory: search & filters (pages/inventory.php) ---- */
.inv-filters .card-body { display: flex; flex-direction: column; gap: 14px; }
.inv-search-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.inv-search { flex: 1 1 280px; min-width: 0; }
.inv-search .input-group-text { background: var(--input-bg); border-color: var(--input-border); color: var(--text-muted); }
.inv-category { flex: 0 1 220px; width: auto; }
.inv-switch { margin: 0 4px; white-space: nowrap; }
.inv-switch .bi-star-fill { color: #f59e0b; }
.inv-search-btn { flex: 0 0 auto; min-width: 120px; }
.inv-sort { flex: 0 1 250px; width: auto; }
.inv-sort .input-group-text { background: var(--input-bg); border-color: var(--input-border); color: var(--text-muted); }

/* Sortable list headers: the whole label is the link, the arrow shows the direction. */
th.inv-sortable { white-space: nowrap; }
th.inv-sortable a { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
th.inv-sortable a:hover { color: var(--accent); }
th.inv-sortable i { font-size: 11px; opacity: .45; }
th.inv-sortable.is-sorted a { color: var(--accent); }
th.inv-sortable.is-sorted i { opacity: 1; }

.inv-chip-groups { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 22px; padding-top: 12px; border-top: 1px solid var(--input-border); }
.inv-chip-group { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.inv-chip-label { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); margin-right: 2px; }
.inv-chip {
  --tone: var(--accent); --tone-bg: var(--accent-light);
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 11px;
  border: 1px solid var(--input-border); border-radius: 999px;
  font-size: 13px; line-height: 1.4; color: var(--text); background: transparent;
  transition: background var(--tr), border-color var(--tr), color var(--tr);
}
.inv-chip i { color: var(--tone); font-size: 13px; }
.inv-chip:hover { color: var(--text); border-color: var(--tone); background: var(--tone-bg); }
.inv-chip.is-active { color: var(--tone); border-color: var(--tone); background: var(--tone-bg); font-weight: 600; }
.inv-chip.tone-warn   { --tone: #b45309; --tone-bg: rgba(245,158,11,.12); }
.inv-chip.tone-danger { --tone: #dc2626; --tone-bg: rgba(220,38,38,.10); }
.inv-chip.tone-muted  { --tone: #64748b; --tone-bg: rgba(100,116,139,.12); }
.inv-chip.tone-dark   { --tone: var(--text); --tone-bg: rgba(100,116,139,.12); }
[data-theme="dark"] .inv-chip.tone-warn   { --tone: #fcd34d; }
[data-theme="dark"] .inv-chip.tone-danger { --tone: #fca5a5; }
[data-theme="dark"] .inv-chip.tone-muted  { --tone: #9ca3af; }
.inv-chip-toggle { margin-left: auto; }

.inv-active { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; }
.inv-active-tag { display: inline-flex; align-items: center; gap: 2px; padding: 2px 6px 2px 10px; border-radius: 999px; background: var(--accent-light); color: var(--accent); font-weight: 500; }
.inv-active-tag:hover { background: var(--accent); color: #fff; }
.inv-clear { margin-left: 4px; color: var(--text-muted); text-decoration: underline; }
.inv-clear:hover { color: var(--text); }

@media (max-width: 575.98px) {
  .inv-category, .inv-sort, .inv-search-btn { flex: 1 1 100%; }
  .inv-chip-toggle { margin-left: 0; }
}

/* ---- Shifts: fingerprint attendance & payroll (pages/attendance/*.php) ---- */
.att-tabs .nav-link { color: var(--text-muted); }
.att-tabs .nav-link.active { color: var(--text); font-weight: 600; }
.att-stats { display: flex; flex-wrap: wrap; gap: 10px; }
.att-stat { display: flex; align-items: baseline; gap: 6px; padding: 8px 16px; border: 1px solid var(--input-border); border-radius: var(--radius); background: var(--card-bg); font-size: 13px; color: var(--text-muted); }
.att-stat-n { font-size: 22px; font-weight: 700; color: var(--text); }
.att-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #94a3b8; vertical-align: middle; margin-right: 4px; }
.att-dot.is-on { background: #10b981; box-shadow: 0 0 0 3px rgba(16,185,129,.2); }
.att-dot.is-off { background: #ef4444; }
.att-device { padding: 12px 14px; border: 1px solid var(--input-border); border-radius: var(--radius); margin-bottom: 10px; }
.att-device.is-pending { border-color: #f59e0b; background: rgba(245,158,11,.06); }
.att-device.is-blocked { opacity: .7; }
.att-unknown { padding: 6px 10px; border: 1px dashed var(--input-border); border-radius: var(--radius-sm); font-size: 13px; }
.att-tiers { max-width: 30rem; }
.att-tier-min { width: 5rem; }
.att-formula { padding: 10px 12px; border: 1px solid var(--input-border); border-radius: var(--radius-sm); }
.att-formula-text { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; font-size: 14px; }
.att-term.is-minus { color: var(--bs-danger, #dc3545); }
.att-term.is-plus { color: var(--bs-success, #198754); }
.att-steps { padding-left: 1.2rem; }
.att-steps li { margin-bottom: 6px; }
.att-values { max-width: 420px; }
.att-values td:first-child { color: var(--text-muted); width: 50%; }
.att-payroll .att-pay-detail > td { background: var(--input-bg); }
@media print {
  .sidebar, .topbar, .att-tabs, .d-print-none, .modal { display: none !important; }
  .att-payroll .collapse { display: table-row !important; }
}

/* Admin > Expenses (pages/expenses.php) */
.exp-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.exp-stat { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border: 1px solid var(--input-border); border-radius: var(--radius-sm); background: var(--bs-body-bg, transparent); }
.exp-stat-label { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; opacity: .7; }
.exp-stat-n { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.exp-stat-sub { font-size: 12px; opacity: .6; }
.exp-stat.is-out .exp-stat-n { color: var(--bs-danger, #dc3545); }
.exp-stat.is-total { border-width: 2px; }
.exp-cat + .exp-cat { margin-top: 10px; }
.exp-bar { height: 6px; border-radius: 3px; background: var(--input-border); overflow: hidden; margin-top: 4px; }
.exp-bar > span { display: block; height: 100%; background: var(--bs-primary, #0d6efd); }
@media print { .exp-wrap .card { break-inside: avoid; } }

/* Cash Drawer (pages/drawer.php) */
.dw-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 16px; }
.dw-head h3 { margin-bottom: 4px; }
.dw-head .dw-finalize { margin-left: auto; border-radius: 12px; padding: 10px 22px; font-weight: 600; box-shadow: 0 6px 18px rgba(16, 185, 129, .28); }
[dir="rtl"] .dw-head .dw-finalize { margin-left: 0; margin-right: auto; }
.dw-shift-line { font-size: 13px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.dw-live { width: 9px; height: 9px; border-radius: 50%; background: #10b981; box-shadow: 0 0 0 0 rgba(16, 185, 129, .6); animation: dwPulse 1.8s infinite; }
@keyframes dwPulse { 0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, .55); } 70% { box-shadow: 0 0 0 9px rgba(16, 185, 129, 0); } 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); } }
@media (prefers-reduced-motion: reduce) { .dw-live { animation: none; } }
.dw-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.dw-tile { padding: 14px 16px; border-radius: 14px; border: 1px solid var(--input-border); background: var(--card-bg, var(--bs-body-bg)); display: flex; flex-direction: column; gap: 4px; }
.dw-tile.is-cash { grid-column: span 2; background: linear-gradient(135deg, rgba(16, 185, 129, .14), rgba(16, 185, 129, .03)); border-color: rgba(16, 185, 129, .35); }
@media (max-width: 575px) { .dw-tile.is-cash { grid-column: auto; } }
.dw-tile-label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.dw-tile-n { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.2; }
.dw-tile.is-cash .dw-tile-n { font-size: 30px; color: #059669; }
.dw-tile-n small { font-size: 14px; font-weight: 600; opacity: .7; }
.dw-tile-sub { font-size: 12px; color: var(--text-muted); }
.dw-table td, .dw-table th { white-space: nowrap; }
.dw-table td.small:last-child { white-space: normal; }
.dw-vault { display: flex; flex-direction: column; gap: 6px; }
.dw-vault-row, .dw-result-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; border: 1px solid var(--input-border); border-radius: 10px; }
.dw-result-row + .dw-result-row { margin-top: 6px; }
.dw-done-icon { font-size: 44px; }
/* ERX: items sold in the shift just finalized (assets/js/drawer.js) */
.dw-items-scroll { max-height: 45vh; overflow-y: auto; border: 1px solid var(--input-border); border-radius: 10px; margin-top: 6px; }
.dw-items-scroll thead th { position: sticky; top: 0; background: var(--bs-body-bg, #fff); z-index: 1; }
.dw-items-scroll tr.dw-item-out td { background: rgba(220,53,69,0.08); }
.dw-items-scroll tr.dw-item-low td { background: rgba(255,193,7,0.10); }

/* ---- Cash Drawer: history log filters ---- */
.dw-hist { padding: 10px 12px; border: 1px dashed var(--input-border); border-radius: 12px; }
.dw-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; margin-bottom: 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: rgba(13, 110, 253, .1); color: var(--bs-primary); }

/* ---- General Ledger (pages/ledger.php) ---- */
.led-table td, .led-table th { white-space: nowrap; }
.led-table td:nth-child(3) { white-space: normal; min-width: 180px; }
.led-note { max-width: 320px; font-size: 12px; }
.led-table tr.led-memo td { opacity: .7; }
.led-table tr.led-memo td:first-child { box-shadow: inset 3px 0 0 var(--input-border); }
[dir="rtl"] .led-table tr.led-memo td:first-child { box-shadow: inset -3px 0 0 var(--input-border); }

/* Login: the User field's saved-users dropdown + "Remember me" */
.login-users {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 20;
  max-height: 240px; overflow-y: auto; margin: 0; padding: 6px; list-style: none;
  background: #fff; border: 1px solid rgba(0,0,0,0.12); border-radius: 12px;
  box-shadow: 0 12px 28px -8px rgba(0,0,0,0.18);
}
.login-users[hidden] { display: none; }
.login-users li {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 12px; border-radius: 8px; cursor: pointer; font-size: 14px; color: var(--lx-text);
}
.login-users li[hidden] { display: none; }
.login-users li:hover, .login-users li.is-active { background: #F3F1EC; }
.login-users li.is-active { box-shadow: inset 3px 0 0 var(--lx-gold); }
.login-user-name small { color: var(--lx-muted); }
.login-forget {
  flex: none; padding: 2px 6px; border: 0; border-radius: 6px; background: none;
  color: #9ca3af; font-size: 12px; cursor: pointer;
}
.login-forget:hover, .login-forget:focus-visible { color: #B42318; background: #FDF3F2; }
.login-remember {
  display: flex; align-items: center; gap: 10px; margin: 4px 0 0;
  font-size: 13px; color: var(--lx-muted); cursor: pointer; user-select: none;
}
.login-remember input { width: 16px; height: 16px; margin: 0; accent-color: var(--lx-text); cursor: pointer; }
.login-remember[hidden] { display: none; }
/* Caps Lock warning under the sign-in password (assets/js/caps_lock.js) */
.caps-warn {
  display: flex; align-items: center; gap: 8px; margin-top: 8px; padding: 8px 12px;
  background: #FFF4D6; border: 1px solid #F0B429; border-radius: 10px;
  color: #7A4D00; font-size: 13px; font-weight: 600;
}
.caps-warn[hidden] { display: none; }
.caps-warn i { font-size: 16px; }
input.caps-on { border-color: #F0B429 !important; box-shadow: 0 0 0 3px rgba(240,180,41,0.25) !important; }

/* ---- In-page messages and questions (assets/js/dialogs.js) ---- */
.pos-toast-stack { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 2000; display: flex; flex-direction: column; align-items: center; gap: 8px; width: min(440px, calc(100vw - 32px)); pointer-events: none; }
.pos-toast { --tone: #0ea5e9; position: relative; display: flex; align-items: flex-start; gap: 10px; width: 100%; padding: 12px 12px 14px 14px; overflow: hidden; pointer-events: auto; cursor: pointer;
  background: var(--card-bg); color: var(--text); border: 1px solid var(--card-border); border-inline-start: 4px solid var(--tone); border-radius: var(--radius-lg); box-shadow: 0 10px 30px rgba(15, 23, 42, .16);
  opacity: 0; transform: translateY(-12px) scale(.98); transition: opacity .2s ease, transform .2s ease; }
.pos-toast.is-in { opacity: 1; transform: none; }
.pos-toast.is-out { opacity: 0; transform: translateY(-8px) scale(.98); }
.pos-toast-success { --tone: var(--accent); }
.pos-toast-warning { --tone: #f59e0b; }
.pos-toast-danger  { --tone: #ef4444; }
.pos-toast-icon { color: var(--tone); font-size: 18px; line-height: 1.3; }
.pos-toast-text { flex: 1; min-width: 0; font-size: 14px; line-height: 1.45; white-space: pre-line; overflow-wrap: anywhere; }
.pos-toast-close { flex: none; display: grid; place-items: center; width: 26px; height: 26px; margin: -3px -3px 0 0; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--text-muted); font-size: 12px; }
.pos-toast-close:hover, .pos-toast-close:focus-visible { background: var(--input-bg); color: var(--text); }
.pos-toast-bar { position: absolute; inset-inline-start: 0; bottom: 0; height: 3px; width: 100%; background: var(--tone); opacity: .35; transform-origin: left; transform: scaleX(1); }
[dir="rtl"] .pos-toast-bar { transform-origin: right; }
.pos-toast.is-timing .pos-toast-bar { transform: scaleX(0); transition: transform var(--pos-toast-time, 5s) linear; }
/* Out of stock in the POS: solid red, a bit bigger, one pulse to catch the eye. */
.pos-toast.pos-toast-loud { width: min(520px, calc(100vw - 32px)); padding: 14px 14px 16px 16px; background: #dc2626; color: #fff; border-color: #b91c1c; border-inline-start-color: #7f1d1d;
  box-shadow: 0 12px 32px rgba(220, 38, 38, .45); }
.pos-toast-loud.is-in { animation: posToastPulse .9s ease-out 2; }
.pos-toast-loud .pos-toast-icon { color: #fff; font-size: 24px; line-height: 1.1; }
.pos-toast-loud .pos-toast-text { font-size: 16.5px; font-weight: 600; }
.pos-toast-loud .pos-toast-close { color: #fff; }
.pos-toast-loud .pos-toast-close:hover, .pos-toast-loud .pos-toast-close:focus-visible { background: rgba(255, 255, 255, .2); color: #fff; }
.pos-toast-loud .pos-toast-bar { background: #fff; opacity: .55; }
@keyframes posToastPulse { from { box-shadow: 0 12px 32px rgba(220, 38, 38, .45), 0 0 0 0 rgba(239, 68, 68, .6); } to { box-shadow: 0 12px 32px rgba(220, 38, 38, .45), 0 0 0 14px rgba(239, 68, 68, 0); } }

.pos-dialog-backdrop { position: fixed; inset: 0; z-index: 2010; display: grid; place-items: center; padding: 16px; background: rgba(15, 23, 42, .45); opacity: 0; transition: opacity .16s ease; }
.pos-dialog-backdrop.is-in { opacity: 1; }
.pos-dialog { width: min(420px, 100%); padding: 20px; background: var(--card-bg); color: var(--text); border: 1px solid var(--card-border); border-radius: 14px; box-shadow: 0 24px 60px rgba(15, 23, 42, .3); transform: translateY(8px) scale(.97); transition: transform .16s ease; }
.pos-dialog-backdrop.is-in .pos-dialog { transform: none; }
.pos-dialog-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.pos-dialog-head .bi { font-size: 22px; color: var(--accent); }
.pos-dialog.is-danger .pos-dialog-head .bi { color: #ef4444; }
.pos-dialog-title { margin: 0; font-size: 17px; font-weight: 700; }
.pos-dialog-msg { margin: 0 0 16px; font-size: 14px; line-height: 1.5; color: var(--text-muted); white-space: pre-line; overflow-wrap: anywhere; }
.pos-dialog-input { margin: -4px 0 16px; }
.pos-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.pos-dialog-actions .btn { min-width: 92px; font-weight: 600; }
.pos-dialog-keys { margin-top: 12px; font-size: 11px; color: var(--text-subtle); text-align: end; }
[data-theme="dark"] .pos-dialog-backdrop { background: rgba(0, 0, 0, .6); }
[data-theme="dark"] .pos-dialog .btn-light { background: var(--input-bg); border-color: var(--input-border); color: var(--text); }
@media (prefers-reduced-motion: reduce) { .pos-toast, .pos-dialog, .pos-dialog-backdrop, .pos-toast.is-timing .pos-toast-bar { transition: none; } .pos-toast-loud.is-in { animation: none; } }
.pos-receipt-box { display: flex; flex-direction: column; gap: 12px; max-width: 100%; max-height: calc(100vh - 32px); padding: 14px; background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 14px; box-shadow: 0 24px 60px rgba(15, 23, 42, .3); transform: translateY(8px) scale(.97); transition: transform .16s ease; }
.pos-dialog-backdrop.is-in .pos-receipt-box { transform: none; }
.pos-receipt-frame { display: block; max-width: 100%; height: min(70vh, 680px); margin: 0 auto; border: 1px solid var(--card-border); border-radius: 8px; background: #fff; }
.pos-receipt-box .pos-dialog-keys { margin-top: -4px; }
@media (prefers-reduced-motion: reduce) { .pos-receipt-box { transition: none; } }
/* Admin > WhatsApp (pages/whatsapp.php) */
.wa-page .wa-alert-field { width: auto; max-width: 290px; }
.wa-page .wa-alert-field .form-control { max-width: 100px; }
.wa-page .wa-log-msg { max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-bubble { position: relative; padding: 8px 10px; background: #dcf8c6; color: #111b21; border-radius: 8px 0 8px 8px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.45; box-shadow: 0 1px 1px rgba(0, 0, 0, .12); }
[data-theme="dark"] .wa-bubble { background: #005c4b; color: #e9edef; }
.wa-qr-box { width: 280px; height: 280px; max-width: 100%; background: #fff; border-radius: 12px; border: 1px solid var(--card-border); }
.wa-qr-box img { max-width: 100%; height: auto; image-rendering: pixelated; }
@media (max-width: 575.98px) { .wa-page .wa-alert-field { max-width: 100%; } .wa-page .wa-log-msg { max-width: 200px; } }

/* Offline mode (assets/js/pos_offline.js, POS and Quick Restock): a small
   faded-red wifi badge pinned over the middle of the top bar while there's
   no internet (a green one for a moment when it's back). It floats, so the
   page never moves; hover or tap it for the details. */
.pos-offline-bar {
  position: fixed; z-index: 210; left: 50%; top: calc((var(--topbar-h, 58px) - 34px) / 2);
  transform: translateX(-50%); animation: pos-net-in .25s ease-out;
}
.pos-offline-bar[hidden] { display: none; }
@keyframes pos-net-in { from { opacity: 0; transform: translate(-50%, -6px); } }
.pos-net-pill {
  display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 999px;
  border: 1px solid; font-size: 13px; font-weight: 600; white-space: nowrap; cursor: default;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); outline: none;
}
.pos-net-pill .bi { font-size: 16px; }
.pos-offline-bar.is-offline .pos-net-pill { background: rgba(239, 68, 68, .1); border-color: rgba(239, 68, 68, .3); color: rgba(185, 28, 28, .8); }
.pos-offline-bar.is-back .pos-net-pill { background: rgba(16, 185, 129, .12); border-color: rgba(16, 185, 129, .35); color: #047857; }
.pos-net-pill:focus-visible { box-shadow: 0 0 0 3px rgba(239, 68, 68, .25); }
.pos-offline-count { min-width: 20px; padding: 1px 6px; border-radius: 999px; background: rgba(239, 68, 68, .75); color: #fff; font-size: 11px; text-align: center; }
.pos-net-act { color: inherit; text-decoration: underline; }
.pos-net-detail {
  display: none; position: absolute; top: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  width: min(380px, calc(100vw - 24px)); padding: 10px 14px; border-radius: var(--radius, 8px);
  background: var(--card-bg, #fff); color: var(--text, #0f172a); border: 1px solid var(--card-border, #e5e7eb);
  box-shadow: var(--card-shadow-h, 0 8px 24px rgba(0, 0, 0, .12)); font-size: 13px; line-height: 1.45; white-space: normal;
}
.pos-offline-bar:hover .pos-net-detail, .pos-offline-bar:focus-within .pos-net-detail { display: block; }
.pos-net-detail a { color: inherit; font-weight: 600; }
.pos-net-detail small { display: block; margin-top: 6px; opacity: .75; }
.pos-net-pending { margin-top: 6px; font-weight: 600; color: #b91c1c; }
[data-theme="dark"] .pos-offline-bar.is-offline .pos-net-pill { background: rgba(248, 113, 113, .12); border-color: rgba(248, 113, 113, .3); color: rgba(252, 165, 165, .85); }
[data-theme="dark"] .pos-offline-bar.is-back .pos-net-pill { color: #6ee7b7; }
[data-theme="dark"] .pos-net-pending { color: #fca5a5; }
/* Phones: the icon (and count) only, so the page title stays readable. */
@media (max-width: 575.98px) { .pos-net-pill .pos-net-label { display: none; } .pos-net-pill { padding: 0 10px; } }

/* =======================================
   DARK MODE - BOOTSTRAP COMPONENTS
   Bootstrap's own dark mode (data-bs-theme) isn't used, so whatever it
   paints from fixed light colours gets the theme's colours here. Screen
   only, like the tokens: printing looks the same as in light mode.
   ======================================= */
@media screen {
/* Native controls: the option list, and the browser's autofill box (white
   or yellow with dark text otherwise). */
[data-theme="dark"] option,
[data-theme="dark"] optgroup { background-color: var(--card-bg); color: var(--text); }
[data-theme="dark"] input:-webkit-autofill,
[data-theme="dark"] textarea:-webkit-autofill,
[data-theme="dark"] select:-webkit-autofill {
  -webkit-text-fill-color: var(--text); caret-color: var(--text);
  box-shadow: 0 0 0 1000px #1d222e inset !important;   /* --input-bg over a card, made solid */
}
[data-theme="dark"] input:-webkit-autofill:focus {
  box-shadow: 0 0 0 1000px var(--card-bg) inset, 0 0 0 3px rgba(16,185,129,0.12) !important;
}
/* ERX: the login is always the light monogram look, so its controls stay light. */
[data-theme="dark"] .login-wrapper { color-scheme: light; }
[data-theme="dark"] .login-wrapper input:-webkit-autofill,
[data-theme="dark"] .login-wrapper input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--lx-text); caret-color: var(--lx-text);
  box-shadow: 0 0 0 1000px #fff inset !important;
}

/* Checkboxes, radios and switches: a visible box, and a light switch knob. */
[data-theme="dark"] .form-check-input { background-color: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.28); }
[data-theme="dark"] .form-switch .form-check-input:not(:checked):not(:focus) {
  --bs-form-switch-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='rgba%28255, 255, 255, 0.35%29'/%3e%3c/svg%3e");
}

/* Light and coloured table parts (thead/tfoot.table-light, rows marked
   table-warning / table-danger / ...): pastel with black text otherwise. */
[data-theme="dark"] .table-light, [data-theme="dark"] .table-secondary, [data-theme="dark"] .table-primary,
[data-theme="dark"] .table-success, [data-theme="dark"] .table-danger, [data-theme="dark"] .table-warning,
[data-theme="dark"] .table-info, [data-theme="dark"] .table-active {
  --bs-table-color: var(--text); --bs-table-striped-color: var(--text);
  --bs-table-active-color: var(--text); --bs-table-hover-color: var(--text);
  --bs-table-border-color: var(--tbl-border);
  --bs-table-striped-bg: rgba(255,255,255,0.03); --bs-table-active-bg: rgba(255,255,255,0.06); --bs-table-hover-bg: rgba(255,255,255,0.05);
}
[data-theme="dark"] .table-light     { --bs-table-bg: var(--tbl-head); }
[data-theme="dark"] .table-secondary { --bs-table-bg: rgba(148,163,184,0.12); }
[data-theme="dark"] .table-primary   { --bs-table-bg: rgba(59,130,246,0.14); }
[data-theme="dark"] .table-success   { --bs-table-bg: rgba(16,185,129,0.12); }
[data-theme="dark"] .table-danger    { --bs-table-bg: rgba(239,68,68,0.14); }
[data-theme="dark"] .table-warning   { --bs-table-bg: rgba(245,158,11,0.14); }
[data-theme="dark"] .table-info      { --bs-table-bg: rgba(14,165,233,0.14); }
/* A sticky header needs a solid colour, or the rows show through it
   (--tbl-head is see-through in dark). */
[data-theme="dark"] .table > .sticky-top > tr > th { background: #1d222e !important; }

/* Alerts: the light theme's dark text colours read badly on dark. */
[data-theme="dark"] .alert-success { color: #6ee7b7 !important; }
[data-theme="dark"] .alert-danger  { color: #fca5a5 !important; }
[data-theme="dark"] .alert-warning { color: #fcd34d !important; }
[data-theme="dark"] .alert-info    { color: #93c5fd !important; }
[data-theme="dark"] .alert-secondary,
[data-theme="dark"] .alert-light   { background: var(--input-bg) !important; border-color: var(--input-border) !important; color: var(--text) !important; }
[data-theme="dark"] .alert .alert-link { color: inherit; }

/* Badges and coloured text: brighter shades, so they keep AA contrast. */
[data-theme="dark"] .badge.bg-success { color: #34d399 !important; }
[data-theme="dark"] .badge.bg-danger  { color: #f87171 !important; }
[data-theme="dark"] .badge.bg-warning { color: #fbbf24 !important; }
[data-theme="dark"] .badge.bg-info    { color: #60a5fa !important; }
[data-theme="dark"] .text-danger    { color: #f87171 !important; }
[data-theme="dark"] .text-info      { color: #60a5fa !important; }
[data-theme="dark"] .text-primary   { color: #6ea8fe !important; }
[data-theme="dark"] .text-secondary { color: var(--text-muted) !important; }
/* text-dark on its own (not on a yellow/cyan badge or block) */
[data-theme="dark"] .text-dark:not([class*="bg-"]) { color: var(--text) !important; }

/* Buttons Bootstrap paints light (btn-light) or too dim for dark. */
[data-theme="dark"] .btn-light {
  --bs-btn-color: var(--text); --bs-btn-bg: rgba(255,255,255,0.06); --bs-btn-border-color: var(--input-border);
  --bs-btn-hover-color: var(--text); --bs-btn-hover-bg: rgba(255,255,255,0.12); --bs-btn-hover-border-color: var(--input-border);
  --bs-btn-active-color: var(--text); --bs-btn-active-bg: rgba(255,255,255,0.16); --bs-btn-active-border-color: var(--input-border);
  --bs-btn-disabled-color: var(--text-muted); --bs-btn-disabled-bg: rgba(255,255,255,0.04); --bs-btn-disabled-border-color: var(--input-border);
}
[data-theme="dark"] .btn-outline-secondary {
  --bs-btn-color: var(--text-muted); --bs-btn-border-color: rgba(255,255,255,0.2);
  --bs-btn-disabled-color: var(--text-muted); --bs-btn-disabled-border-color: rgba(255,255,255,0.12);
}
[data-theme="dark"] .btn-outline-danger  { --bs-btn-color: #f87171; --bs-btn-border-color: #f87171; --bs-btn-disabled-color: #f87171; --bs-btn-disabled-border-color: #f87171; }
[data-theme="dark"] .btn-outline-success { --bs-btn-color: #34d399; --bs-btn-border-color: #34d399; --bs-btn-disabled-color: #34d399; --bs-btn-disabled-border-color: #34d399; }

/* Accordion chevrons are dark SVGs. */
[data-theme="dark"] .accordion {
  --bs-accordion-btn-icon: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23e5e7eb'%3e%3cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e");
  --bs-accordion-btn-active-icon: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%236ea8fe'%3e%3cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e");
}

/* Floating panels: the light theme's soft shadows disappear on dark. */
[data-theme="dark"] .dropdown-menu { box-shadow: 0 8px 30px rgba(0,0,0,0.5) !important; }
[data-theme="dark"] .pos-toast:not(.pos-toast-loud) { box-shadow: 0 10px 30px rgba(0,0,0,0.45); }

/* App parts above that use Bootstrap's (light-only) status colours. */
[data-theme="dark"] .att-term.is-minus,
[data-theme="dark"] .exp-stat.is-out .exp-stat-n { color: #f87171; }
[data-theme="dark"] .att-term.is-plus,
[data-theme="dark"] .dw-tile.is-cash .dw-tile-n { color: #34d399; }
[data-theme="dark"] .dw-chip { color: #6ea8fe; }
[data-theme="dark"] .sc-chip-x:hover, [data-theme="dark"] .sc-chip-x:focus-visible { color: #f87171; }
}

/* A count on a sidebar link (shelf items to refill) - a dot on the icon when collapsed. */
.sidebar-link { position: relative; }
.sidebar-badge { font-size: 11px; line-height: 1.2; }
.app-layout.sidebar-collapsed .sidebar-badge {
  position: absolute; top: 3px; inset-inline-end: 6px; padding: 2px 5px; font-size: 9.5px;
}
