/* =====================================================================
   POS THEME  -  design system + app shell
   Visual target: design_reference/*.html (client mockups)

   Token rules
   - :root holds the LIGHT palette (the client design).
   - [data-theme="dark"] overrides tokens only, never component rules.
   - Legacy token names (--accent, --bg-card, --text-muted ...) are kept
     because ~70 templates reference them directly. New code should use
     the demo names (--primary, --ink, --surface ...), which alias them.
   ===================================================================== */

:root {
  /* ── Brand ─────────────────────────────── */
  --accent:          #15803d;   /* white text on it 5:1 (was #16a34a, 3.3:1) */
  --accent-hover:    #166534;
  --accent-dim:      #dcfce7;
  --accent-rgb:      21, 128, 61;
  --accent-ring:     rgba(21, 128, 61, .18);
  --accent-grad:     linear-gradient(160deg, #16803c, #14672f);
  --btn-primary-text:#ffffff;

  /* ── Status ────────────────────────────── */
  --accent-red:      #dc2626;
  --accent-red-dim:  #fee2e2;
  --accent-red-line: #fecaca;
  --accent-yellow:   #d97706;
  --accent-yellow-dim:#fef3c7;
  --accent-blue:     #2563eb;
  --accent-blue-dim: #dbeafe;
  --red-text:        #b91c1c;   /* on --accent-red-dim 5.3:1 */
  --amber-text:      #92400e;   /* on --accent-yellow-dim 6.4:1 */
  --blue-text:       #1d4ed8;   /* on --accent-blue-dim 5.5:1 */
  --green-text:      #166534;

  /* ── Surfaces ──────────────────────────── */
  --bg-base:         #f4f6f9;
  --bg-sidebar:      #ffffff;
  --bg-card:         #ffffff;
  --bg-card-hover:   #f8fafc;
  --bg-subtle:       #f8fafc;   /* demo --surface-2 */
  --input-bg:        #ffffff;
  --border:          #e5e7eb;
  --border-soft:     #f1f5f9;   /* demo --line-2 */

  /* ── Text ──────────────────────────────── */
  --text-primary:    #0f172a;
  --text-secondary:  #334155;   /* demo --ink-2 */
  --text-muted:      #5b6577;   /* 5.4:1 on the page (was 4.4) */
  --text-dim:        #64707e;   /* 4.7:1 (was 2.4) */

  /* ── Shape & depth ─────────────────────── */
  --radius:          14px;
  --radius-sm:       10px;
  --shadow-sm:       0 1px 2px rgba(15, 23, 42, .05);
  --shadow-md:       0 4px 16px rgba(15, 23, 42, .06);
  --shadow-lg:       0 20px 50px rgba(15, 23, 42, .18);
  --shadow-accent:   0 10px 24px rgba(22, 163, 74, .35);

  /* ── Layout ────────────────────────────── */
  --sidebar-w-open:  240px;
  --sidebar-w-mini:  72px;
  --sidebar-w:       var(--sidebar-w-open);
  --topbar-h:        72px;

  /* ── Type ──────────────────────────────── */
  /* Inter has no Bengali glyphs: Nirmala UI (built into Windows) / Noto Sans Bengali draw the ৳ sign */
  --font-main:       'Inter', 'Nirmala UI', 'Noto Sans Bengali', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono:       var(--font-main);   /* numbers use Inter tabular figures */

  /* ── Misc helpers ──────────────────────── */
  --nav-hover-bg:    #f8fafc;
  --alert-close-filter: none;
  --date-picker-filter: none;
  --scrollbar-track: transparent;
  --scrollbar-thumb: #cbd5e1;
  --overlay:         rgba(15, 23, 42, .45);

  /* ── Aliases: demo names ───────────────── */
  --primary:         var(--accent);
  --primary-hover:   var(--accent-hover);
  --primary-soft:    var(--accent-dim);
  --primary-ring:    var(--accent-ring);
  --ink:             var(--text-primary);
  --ink-2:           var(--text-secondary);
  --muted:           var(--text-muted);
  --subtle:          var(--text-dim);
  --line:            var(--border);
  --line-2:          var(--border-soft);
  --surface:         var(--bg-card);
  --surface-2:       var(--bg-subtle);
  --bg:              var(--bg-base);
  --danger-soft:     var(--accent-red-dim);

  /* ── Aliases: names some pages use but base never defined ── */
  --danger:          var(--accent-red);
  --warning:         var(--accent-yellow);
  --success:         var(--accent);
  --accent-green:    var(--accent);
  --text-main:       var(--text-primary);
  --text-base:       var(--text-primary);
  --bg-input:        var(--input-bg);

  color-scheme: light;
}

/* ── DARK THEME (same design, dark surfaces) ─────────────────────── */
[data-theme="dark"] {
  --accent:          #22c55e;
  --accent-hover:    #4ade80;
  --accent-dim:      rgba(34, 197, 94, .14);
  --accent-rgb:      34, 197, 94;
  --accent-ring:     rgba(34, 197, 94, .22);
  --accent-grad:     linear-gradient(160deg, #22c55e, #16a34a);
  --btn-primary-text:#052e16;

  --accent-red:      #f87171;
  --accent-red-dim:  rgba(248, 113, 113, .14);
  --accent-red-line: rgba(248, 113, 113, .35);
  --accent-yellow:   #fbbf24;
  --accent-yellow-dim:rgba(251, 191, 36, .14);
  --accent-blue:     #60a5fa;
  --accent-blue-dim: rgba(96, 165, 250, .14);
  --red-text:        #fca5a5;
  --amber-text:      #fcd34d;
  --blue-text:       #93c5fd;
  --green-text:      #86efac;

  --bg-base:         #0b1120;
  --bg-sidebar:      #111827;
  --bg-card:         #111827;
  --bg-card-hover:   #172033;
  --bg-subtle:       #0f172a;
  --input-bg:        #0b1120;
  --border:          #243047;
  --border-soft:     #1b2538;

  --text-primary:    #e5e7eb;
  --text-secondary:  #cbd5e1;
  --text-muted:      #94a3b8;
  --text-dim:        #8b97aa;   /* dark: 5.5:1 (was 3.4) */

  --shadow-sm:       0 1px 2px rgba(0, 0, 0, .3);
  --shadow-md:       0 4px 16px rgba(0, 0, 0, .3);
  --shadow-lg:       0 20px 50px rgba(0, 0, 0, .55);
  --shadow-accent:   0 10px 24px rgba(34, 197, 94, .25);

  --nav-hover-bg:    rgba(255, 255, 255, .04);
  --alert-close-filter: invert(1);
  --date-picker-filter: invert(1) brightness(.8);
  --scrollbar-thumb: #334155;
  --overlay:         rgba(0, 0, 0, .6);

  color-scheme: dark;
}

/* Collapsed sidebar: every layout calc that uses --sidebar-w follows */
html.sb-collapsed { --sidebar-w: var(--sidebar-w-mini); }

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

body {
  font-family: var(--font-main);
  font-feature-settings: 'tnum' 1, 'cv11' 1;   /* tabular numbers, straight 'l' */
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  font-size: 14.5px;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font-family: inherit; }
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

/* Bootstrap utility colour overrides */
.text-muted { color: var(--text-muted) !important; }

/* =====================================================================
   SIDEBAR
   ===================================================================== */
#sidebar {
  position: fixed; top: 0; left: 0;
  width: var(--sidebar-w); height: 100vh;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 1000;
  transition: width .25s ease, transform .25s ease;
  overflow: hidden;
}

.sidebar-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  height: var(--sidebar-head-h, 72px); flex-shrink: 0;
  padding: 0 14px 0 18px;
  border-bottom: 1px solid var(--border-soft);
}
.brand {
  display: flex; align-items: center; gap: 10px; min-width: 0;
  text-decoration: none; color: var(--text-primary);
}
.brand:hover { color: var(--text-primary); }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
  background: var(--accent-grad); color: #fff;
  display: grid; place-items: center;
  font-size: 16px; font-weight: 800;
  box-shadow: 0 6px 14px rgba(var(--accent-rgb), .3);
}
.brand-text { min-width: 0; line-height: 1.15; }
.brand-text .shop-name {
  font-size: 15px; font-weight: 800; letter-spacing: -.2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand-text .shop-sub {
  font-size: 10.5px; font-weight: 700; color: var(--accent);
  text-transform: uppercase; letter-spacing: .8px; white-space: nowrap;
}

.icon-btn {
  width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
  background: var(--bg-subtle); border: 1px solid var(--border);
  color: var(--text-secondary); font-size: 17px;
  display: grid; place-items: center; cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.icon-btn:hover { background: var(--border-soft); color: var(--text-primary); }

.sidebar-nav {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 6px 6px 12px 12px;
  scrollbar-gutter: stable;          /* the menu keeps its width whether the bar shows or not */
}
/* Scrollbar: only when the menu is taller than the screen (overflow: auto). It fades in while the
   mouse is over the menu or it scrolls, and fades out a moment after (JS toggles .sb-show).
   Scrollbar parts can't be animated, so the thumb paints with currentColor and the menu's
   color is what fades; every child gets its text colour back below. */
.sidebar-nav { color: transparent; transition: color .45s ease; }
.sidebar-nav.sb-show { color: var(--scrollbar-thumb); transition-duration: .15s; }
.sidebar-nav > * { color: var(--text-primary); }
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: transparent; border: 0; border-radius: 6px; box-shadow: inset 0 0 0 6px; }
@supports not selector(::-webkit-scrollbar) {
  .sidebar-nav { scrollbar-width: thin; scrollbar-color: transparent transparent; transition: scrollbar-color .45s ease; }
  .sidebar-nav.sb-show { scrollbar-color: var(--scrollbar-thumb) transparent; }
}

.nav-section-label {
  font-size: 11px; font-weight: 700; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .8px;
  padding: 16px 10px 6px; white-space: nowrap;
}

.nav-link-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; margin-bottom: 2px;
  border-radius: 10px;
  color: var(--text-muted); text-decoration: none;
  font-size: 14px; font-weight: 500; white-space: nowrap;
  transition: background .15s, color .15s;
}
.nav-link-item i {
  font-size: 17px; width: 20px; flex-shrink: 0;
  display: grid; place-items: center;
}
.nav-link-item:hover { background: var(--nav-hover-bg); color: var(--text-primary); }
.nav-link-item.active {
  background: var(--accent-dim); color: var(--accent-hover); font-weight: 600;
}
[data-theme="dark"] .nav-link-item.active { color: var(--accent); }
.nav-link-item.nav-sub { padding-left: 24px; font-size: 13px; }
.nav-link-item.nav-sub i { font-size: 15px; }
.nav-label { overflow: hidden; text-overflow: ellipsis; }
.nav-count {
  margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  background: #b45309; color: #fff; font-size: 11px; font-weight: 800;
  display: inline-grid; place-items: center;
}
/* ── Sidebar groups, pins, quick jump ──────────────────────── */
.nav-jump {
  display: flex; align-items: center; gap: 10px; width: 100%; margin: 4px 0 8px; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--bg-subtle);
  color: var(--text-muted); font-size: 13px; cursor: pointer; text-align: left;
}
.nav-jump:hover { border-color: var(--accent); color: var(--text-primary); }
.nav-jump i { font-size: 14px; width: 20px; display: grid; place-items: center; }
.nav-jump kbd { margin-left: auto; font-size: 10.5px; padding: 1px 6px; border-radius: 5px; border: 1px solid var(--border);
                background: var(--bg-card); color: var(--text-muted); font-family: inherit; box-shadow: none; }
.nav-group { margin-top: 2px; }
.nav-group-head {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 12px 10px 6px; border: 0; background: none;
  color: var(--text-muted); font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; cursor: pointer;
}
.nav-group-head:hover { color: var(--text-primary); }
.nav-group-head .nav-group-icon { display: none; }
.nav-group-head .chev { margin-left: auto; font-size: 11px; transition: transform .15s; }
.nav-group-head .group-badge { display: none; margin-left: 4px; }
.nav-group.closed .nav-group-items { display: none; }
.nav-group.closed .chev { transform: rotate(-90deg); }
.nav-group.closed .group-badge { display: inline-grid; }
.nav-flyout-title { display: none; }
.nav-link-item { position: relative; }
.nav-pin {
  margin-left: 6px; width: 22px; height: 22px; border-radius: 6px; display: none; place-items: center;
  color: var(--text-dim); cursor: pointer; flex: none;
  margin-block: -4px;                /* taller than the text line: never let it grow the row on hover */
}
.nav-pin i { font-size: 12px !important; width: auto !important; }
.nav-link-item:hover .nav-pin { display: inline-grid; }
.nav-count + .nav-pin { margin-left: 4px; }
.nav-link-item .nav-label + .nav-pin { margin-left: auto; }
.nav-pin:hover { color: var(--accent-yellow); background: var(--bg-card); }
.nav-pin.on { color: var(--accent-yellow); }
.nav-pinned { padding-bottom: 6px; margin-bottom: 6px; border-bottom: 1px solid var(--border-soft); }
.nav-pinned .nav-section-label { padding-top: 6px; }
.nav-settings { margin-top: 10px; border-top: 1px solid var(--border-soft); border-radius: 0 0 10px 10px; padding-top: 12px; }

@media (min-width: 992px) {
/* Mini (icon) rail: a group is one icon; its links fly out on hover */
html.sb-collapsed .nav-jump { justify-content: center; padding: 9px 0; }
html.sb-collapsed .nav-jump kbd { display: none; }
html.sb-collapsed .nav-group-head { justify-content: center; padding: 10px 0; border-radius: 10px; color: var(--text-muted); }
html.sb-collapsed .nav-group-head:hover, html.sb-collapsed .nav-group.fly .nav-group-head { background: var(--nav-hover-bg); color: var(--text-primary); }
html.sb-collapsed .nav-group.has-active .nav-group-head { background: var(--accent-dim); color: var(--accent-hover); }
html.sb-collapsed .nav-group-head .nav-group-icon { display: grid; font-size: 17px; width: 20px; place-items: center; }
html.sb-collapsed .nav-group-head .nav-group-label, html.sb-collapsed .nav-group-head .chev { display: none; }
html.sb-collapsed .nav-group-head .group-badge { display: inline-grid; position: absolute; margin: 0; transform: translate(12px, -10px);
                                                  min-width: 16px; height: 16px; font-size: 10px; padding: 0 4px; }
html.sb-collapsed .nav-group { position: relative; }
html.sb-collapsed .nav-group .nav-group-items,
html.sb-collapsed .nav-group.closed .nav-group-items {
  display: none; position: fixed; left: calc(var(--sidebar-w-mini) - 4px); width: 230px; z-index: 1100; padding: 6px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-md);
}
html.sb-collapsed .nav-group.fly .nav-group-items { display: block; }
html.sb-collapsed .nav-group-items .nav-label { display: inline; }
html.sb-collapsed .nav-group-items .nav-link-item { justify-content: flex-start; padding: 8px 10px; }
html.sb-collapsed .nav-group-items .nav-count { position: static; margin-left: auto; }
html.sb-collapsed .nav-flyout-title { display: block; padding: 6px 10px 4px; font-size: 11px; font-weight: 700; text-transform: uppercase;
                                      letter-spacing: .8px; color: var(--text-dim); }
html.sb-collapsed .nav-pinned .nav-section-label { display: none; }
html.sb-collapsed .nav-pin { display: none !important; }
html.sb-collapsed .nav-settings { border-top: 0; padding-top: 10px; }

}

/* Quick jump dialog */
.jump-backdrop { position: fixed; inset: 0; z-index: 2200; background: rgba(15, 23, 42, .35); display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; }
.jump-backdrop[hidden] { display: none; }
.jump { width: min(520px, 100%); background: var(--bg-card); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); overflow: hidden; }
.jump-search { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border-soft); }
.jump-search i { color: var(--text-muted); }
.jump-search input { flex: 1; border: 0; outline: none; background: transparent; font-size: 15px; color: var(--text-primary); }
.jump-search kbd { font-size: 10.5px; padding: 1px 6px; border-radius: 5px; border: 1px solid var(--border); background: var(--bg-subtle); color: var(--text-muted); font-family: inherit; box-shadow: none; }
.jump-list { max-height: 50vh; overflow-y: auto; padding: 6px; }
.jump-item { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 8px; color: var(--text-secondary); text-decoration: none; font-size: 14px; }
.jump-item i { width: 20px; color: var(--text-muted); text-align: center; }
.jump-item small { margin-left: auto; color: var(--text-dim); font-size: 12px; }
.jump-item.on { background: var(--accent-dim); color: var(--text-primary); }
.jump-item.on i { color: var(--accent); }
.jump-empty { padding: 18px; text-align: center; color: var(--text-dim); font-size: 14px; }

html.sb-collapsed .nav-link-item { position: relative; }
html.sb-collapsed .nav-count { position: absolute; top: 2px; right: 8px; min-width: 16px; height: 16px; font-size: 10px; padding: 0 4px; }

.sidebar-user-wrap { position: relative; flex-shrink: 0; border-top: 1px solid var(--border-soft); }
.sidebar-user {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 12px 14px; border: 0; background: none; text-align: left; cursor: pointer; font: inherit; color: inherit;
}
.sidebar-user:hover, .sidebar-user[aria-expanded="true"] { background: var(--nav-hover-bg); }
.sidebar-user:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.user-info { display: block; }
.user-info .user-name, .user-info .user-role { display: block; }
.user-chev { color: var(--text-muted); font-size: 14px; }
.user-menu { position: absolute; left: 10px; right: 10px; bottom: calc(100% + 6px); z-index: 1001; padding: 6px;
             background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); }
.user-menu[hidden] { display: none; }
.user-menu-who { padding: 6px 10px 8px; font-size: 13px; font-weight: 600; color: var(--text-primary); border-bottom: 1px solid var(--border-soft); margin-bottom: 4px; }
.user-menu-who small { display: block; font-size: 12px; font-weight: 500; color: var(--text-muted); }
.user-menu-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; font-size: 14px; font-weight: 500;
                  color: var(--text-primary); text-decoration: none; }
.user-menu-item:hover, .user-menu-item:focus { background: var(--nav-hover-bg); outline: none; }
.user-menu-item.danger { color: var(--accent-red); }
.user-menu-item.danger:hover, .user-menu-item.danger:focus { background: var(--accent-red-dim); color: var(--accent-red); }
html.sb-collapsed .user-chev { display: none; }
html.sb-collapsed .user-menu { left: calc(100% + 8px); right: auto; bottom: 8px; width: 220px; }
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent-dim); color: var(--accent-hover);
  display: grid; place-items: center;
  font-size: 14px; font-weight: 700;
}
[data-theme="dark"] .user-avatar { color: var(--accent); }
.user-info { flex: 1; min-width: 0; }
.user-info .user-name {
  font-size: 13.5px; font-weight: 600; color: var(--text-primary);
  line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-info .user-role {
  font-size: 11px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .5px; font-weight: 600;
}

/* ── Collapsed (desktop mini sidebar) ─────────────────── */
html.sb-collapsed .brand-text,
html.sb-collapsed .nav-label,
html.sb-collapsed .user-info { display: none; }
html.sb-collapsed .sidebar-head {
  flex-direction: column; justify-content: center; gap: 0; padding: 0;
}
html.sb-collapsed .sidebar-head .brand { display: none; }
html.sb-collapsed .sidebar-nav { padding: 6px 10px 12px; }
html.sb-collapsed .nav-section-label {
  font-size: 0; padding: 0; margin: 10px 8px; height: 1px; background: var(--border-soft);
}
html.sb-collapsed .nav-link-item { justify-content: center; padding: 10px 0; }
html.sb-collapsed .nav-link-item.nav-sub { padding-left: 0; }
html.sb-collapsed .sidebar-user { justify-content: center; padding: 12px 0; }

/* =====================================================================
   TOPBAR
   ===================================================================== */
#topbar {
  position: fixed; top: 0; right: 0;
  left: var(--sidebar-w);
  height: var(--topbar-h);
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px;
  padding: 0 24px;
  z-index: 999;
  transition: left .25s ease;
}
.topbar-menu { display: none; }
.topbar-head { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; }
.topbar-title {
  min-width: 0;
  font-size: 19px; font-weight: 800; letter-spacing: -.3px; color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-title .pos-badge { font-size: 11px; vertical-align: middle; letter-spacing: 0; }
.topbar-info { position: relative; display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; flex: none;
               color: var(--text-muted); cursor: help; font-size: 15px; }
.topbar-info:hover, .topbar-info:focus { color: var(--text-primary); background: var(--bg-subtle); outline: none; }
.topbar-info:has(.topbar-tip:empty) { display: none; }
.topbar-tip { position: absolute; left: 0; top: calc(100% + 8px); z-index: 1002; width: max-content; max-width: 340px; padding: 8px 12px;
              border-radius: 9px; background: var(--text-primary); color: var(--bg-card); font-size: 13px; font-weight: 500; line-height: 1.45;
              white-space: normal; box-shadow: var(--shadow-md); opacity: 0; visibility: hidden; transition: opacity .12s; pointer-events: none; }
.topbar-info:hover .topbar-tip, .topbar-info:focus .topbar-tip { opacity: 1; visibility: visible; }
.topbar-status { display: inline-flex; flex: none; }
.topbar-status .autosave-status { margin: 0; white-space: nowrap; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.topbar-btn {           /* legacy small square button, still used by pages */
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--bg-subtle); border: 1px solid var(--border);
  color: var(--text-muted); font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; text-decoration: none;
  transition: all .15s;
}
.topbar-btn:hover { color: var(--text-primary); border-color: var(--text-dim); }

.btn-new-sale, .btn-logout {
  display: inline-flex; align-items: center; gap: 8px;
  height: 42px; padding: 0 16px; border-radius: 10px;
  font-size: 14px; font-weight: 600; text-decoration: none; white-space: nowrap;
  transition: background .15s, box-shadow .15s, filter .15s;
}
.btn-new-sale {
  background: var(--accent-grad); color: var(--btn-primary-text); border: 0;
  box-shadow: 0 6px 16px rgba(var(--accent-rgb), .28);
}
.btn-new-sale:hover { color: var(--btn-primary-text); filter: brightness(1.05); box-shadow: var(--shadow-accent); }
.btn-logout {
  background: var(--bg-card); color: var(--accent-red);
  border: 1px solid var(--accent-red-line);
}
.btn-logout:hover { background: var(--accent-red-dim); color: var(--accent-red); }
.btn-new-sale i, .btn-logout i { font-size: 16px; }

/* =====================================================================
   MAIN CONTENT
   ===================================================================== */
#main-content {
  margin-left: var(--sidebar-w);
  padding-top: var(--topbar-h);
  min-height: 100vh;
  transition: margin-left .25s ease;
}
.content-body { padding: 20px 24px 32px; }   /* fills the width beside the sidebar, wide or collapsed */

.sidebar-backdrop {
  position: fixed; inset: 0; background: var(--overlay);
  z-index: 998; display: none;
}

/* =====================================================================
   PAGE HEADER
   ===================================================================== */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  margin-bottom: 20px;
}
.page-header h1 {
  font-size: 1.3rem; font-weight: 800; letter-spacing: -.3px; color: var(--text-primary);
}
.page-header p { font-size: .85rem; color: var(--text-muted); margin-top: 2px; }
.page-bar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 12px; margin: 0 0 16px; min-height: 40px; }
.page-bar:empty, .page-bar:has(> .page-status:only-child:empty) { display: none; }
.page-lead { display: flex; align-items: center; gap: 6px; min-width: 0; }
.page-title-sm { font-size: 1.15rem; font-weight: 800; letter-spacing: -.2px; color: var(--text-primary); margin: 0; line-height: 1.25;
                 overflow-wrap: anywhere; }
.page-title-sm .pos-badge { font-size: 11px; vertical-align: middle; letter-spacing: 0; }
.page-lead .topbar-info { display: inline-grid; }
.page-lead .topbar-info:has(.topbar-tip:empty) { display: none; }
.page-status .autosave-status { margin: 0; white-space: nowrap; }
.desk-only { display: none !important; }
/* PC: no top bar on normal pages (the POS / purchase screens keep theirs) */
@media (min-width: 992px) {
  .page-lead.desk-only, .page-status.desk-only { display: flex !important; }
  .page-new-sale.desk-only { display: inline-flex !important; }
  body:not(.page-screen) { --topbar-h: 0px; }
  body:not(.page-screen) #topbar { display: none; }
}
.page-meta { font-size: .87rem; color: var(--text-muted); min-width: 0; }
.page-meta a { color: var(--text-muted); text-decoration: none; }
.page-meta a:hover { color: var(--text-primary); text-decoration: underline; }
.page-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-left: auto; }
.page-actions > div { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }

/* Period filter (core/_period_filter.html): chips + a custom From / To */
.period-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.chips { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--border); border-radius: 10px; padding: 3px; background: var(--bg-card); }
.chips a { padding: 5px 12px; border-radius: 7px; font-size: .82rem; color: var(--text-muted); text-decoration: none; white-space: nowrap; }
.chips a:hover { color: var(--text-primary); }
.chips a.on { background: var(--bg-subtle); color: var(--text-primary); font-weight: 600; box-shadow: inset 0 0 0 1px var(--border); }
.period-custom { display: inline-flex; gap: 6px; align-items: center; }
.period-custom[hidden] { display: none; }
.period-custom input { height: 36px; width: auto; }
.period-to { color: var(--text-muted); font-size: .85rem; }

/* Form pages: one card up to 820px, short fields two per row, actions at the bottom */
.form-page { max-width: 820px; }
.form-page.narrow { max-width: 560px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid > .full { grid-column: 1 / -1; }
.form-grid .form-label { margin-bottom: 4px; }
.form-help { font-size: .78rem; color: var(--text-muted); margin-top: 4px; }
.form-err { font-size: .8rem; color: var(--red-text); margin-top: 4px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border-soft); }
@media (max-width: 640px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }
/* "Status: Active" switch (core/_active_switch.html): a box as tall as the inputs next to it */
.switch-field { display: flex; align-items: center; gap: 12px; min-height: 42px; margin: 0; padding: 6px 14px; cursor: pointer;
                border: 1px solid var(--border); border-radius: 10px; background: var(--input-bg, var(--bg-card)); }
.switch-field:hover { border-color: var(--accent); }
.switch-field .form-check-input { flex: none; width: 2.3em; height: 1.25em; margin: 0; cursor: pointer; float: none; }
.switch-field .switch-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.switch-field .switch-text b { font-size: .9rem; color: var(--text-primary); }
.switch-field .switch-text small { font-size: .74rem; color: var(--text-muted); }
.switch-field:has(input:not(:checked)) .switch-text b { color: var(--text-muted); }

/* "Nothing here" message in a list / table (one style everywhere) */
.empty-cell { text-align: center !important; padding: 28px 16px !important; color: var(--text-muted) !important; font-size: .9rem; }
.empty-cell > i.bi:first-child, .empty-cell > div > i.bi:first-child { display: block; font-size: 1.6rem; margin: 0 auto 6px; color: var(--text-dim); }
.empty-cell a { color: var(--accent); }

/* Phones: wide list tables become stacked rows (base.html marks them .is-stacked) */
@media (max-width: 640px) {
  table.is-stacked, table.is-stacked > tbody { display: block; width: 100%; min-width: 0 !important; }
  table.is-stacked > thead { display: none; }
  table.is-stacked > tbody > tr { display: flex; flex-direction: column; padding: 10px 2px; border-bottom: 1px solid var(--border); }
  table.is-stacked > tbody > tr > td { display: flex; justify-content: flex-end; flex-wrap: wrap; column-gap: 8px !important; align-items: center; gap: 12px;
                                       padding: 3px 0 !important; border: 0 !important; text-align: right !important;
                                       width: auto !important; min-height: 0; background: none !important; white-space: normal; }
  table.is-stacked > tbody > tr > td::before { content: attr(data-label); flex: none; max-width: 45%; text-align: left; margin-right: auto;
                                               font-size: .76rem; font-weight: 600; color: var(--text-muted); }
  table.is-stacked > tbody > tr > td[data-label=""]::before { content: none; }
  table.is-stacked > tbody > tr > td[data-label=""] { justify-content: flex-end; }
  table.is-stacked > tbody > tr > td.td-lead { display: block; order: -1; text-align: left !important; font-size: .95rem; padding-bottom: 6px !important; }
  table.is-stacked > tbody > tr > td.td-lead::before { content: none; }
  table.is-stacked > tbody > tr > td:empty, table.is-stacked > tbody > tr > td.td-blank { display: none; }
  table.is-stacked > tbody > tr > td[colspan] { display: block; text-align: center !important; }
  table.is-stacked > tbody > tr > td[colspan]::before { content: none; }
  table.is-stacked > tbody > tr > td:not(.td-lead) > .d-flex { justify-content: flex-end; }
}

/* =====================================================================
   CARDS
   ===================================================================== */
.pos-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px;
}
.pos-card-title {
  font-size: 15px; font-weight: 700; color: var(--text-primary);
  margin-bottom: 8px;
}

/* Summary card: one style everywhere (the Dashboard's): small icon + label on top, the figure under it.
   Markup stays <div class="stat-card"><div class="stat-icon"><i></i></div><div><div class="stat-value"/>
   <div class="stat-label"/> [sub lines]</div></div> - the grid reorders it. */
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; min-width: 0; height: 100%;
  display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 6px; row-gap: 4px; align-items: center;
}
.stat-card > div:has(> .stat-value) { display: contents; }
.stat-icon {
  grid-row: 1; grid-column: 1; width: auto; height: auto; background: none !important;
  font-size: .9rem; line-height: 1; color: var(--text-muted);
}
.stat-icon.green  { color: var(--green-text); }
.stat-icon.red    { color: var(--red-text); }
.stat-icon.yellow { color: var(--amber-text); }
.stat-icon.blue   { color: var(--blue-text); }
.stat-label { grid-row: 1; grid-column: 2; font-size: .76rem; font-weight: 600; color: var(--text-muted); margin: 0; min-width: 0; }
.stat-value {
  grid-row: 2; grid-column: 1 / -1; font-size: 1.55rem; font-weight: 700; letter-spacing: -.3px;
  color: var(--text-primary); line-height: 1.2; overflow-wrap: anywhere;
}
.stat-card > div:has(> .stat-value) > :not(.stat-value):not(.stat-label) { grid-column: 1 / -1; font-size: .78rem; color: var(--text-muted); }
@media (max-width: 575.98px) {
  .row > [class*="col"]:has(> .stat-card) { flex: 0 0 50%; max-width: 50%; }   /* two per row on phones */
  .stat-card { padding: 12px; }
  .stat-value { font-size: 1.2rem; }
}

/* =====================================================================
   ALERTS (flash messages)
   ===================================================================== */
/* In-page notices: plain card, the icon carries the colour (no coloured borders) */
.alert {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--bg-card); color: var(--text-secondary);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 14px; font-size: .875rem; font-weight: 500; box-shadow: none;
}
.alert > .bi:first-child, .alert > span > .bi:first-child { font-size: 1rem; }
.alert-success > .bi:first-child, .alert-success > span > .bi:first-child { color: var(--accent); }
.alert-danger  > .bi:first-child, .alert-danger  > span > .bi:first-child { color: var(--accent-red); }
.alert-info    > .bi:first-child, .alert-info    > span > .bi:first-child { color: var(--accent-blue); }
.alert-warning > .bi:first-child, .alert-warning > span > .bi:first-child { color: var(--accent-yellow); }
.alert-danger  { background: var(--bg-card); }

/* Barcode inputs: scanner icon inside the left edge (same icon as the POS scan box) */
.scan-field { position: relative; display: block; min-width: 0; }
.scan-field > .bi-upc-scan {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%); z-index: 2;
  color: var(--text-muted); font-size: 1rem; line-height: 1; pointer-events: none;
}
.scan-field > input { padding-left: 34px !important; width: 100%; }
.scan-field.sm > .bi-upc-scan { left: 8px; font-size: .85rem; }
.scan-field.sm > input { padding-left: 26px !important; }

/* Auto-save status (settings pages) */
.autosave-status { display: inline-flex; align-items: center; gap: 6px; margin-top: 4px; font-size: .8rem; color: var(--text-muted); }
.autosave-status[data-state="saving"] i { animation: as-spin 1s linear infinite; }
.autosave-status[data-state="saved"] { color: var(--accent); }
.autosave-status[data-state="saved"] span { color: var(--text-muted); }
.autosave-status[data-state="error"] { color: var(--accent-red); }
@keyframes as-spin { to { transform: rotate(360deg); } }
.autosave-invalid { border-color: var(--accent-red) !important; box-shadow: 0 0 0 3px var(--accent-red-dim) !important; }
.autosave-err { color: var(--accent-red); font-size: .78rem; margin-top: 4px; }

/* Toasts (flash messages + posToast): top right, under the top bar */
.toast-stack {
  position: fixed; top: calc(var(--topbar-h) + 12px); right: 20px; z-index: 2100;
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
  width: min(380px, calc(100vw - 32px)); pointer-events: none;
}
.toast-stack:empty { display: none; }
.alert.toast-card {
  pointer-events: auto; width: 100%; margin: 0; flex-wrap: nowrap; align-items: flex-start;
  padding: 11px 10px 11px 14px; border-radius: 12px; color: var(--text-primary);
  box-shadow: 0 10px 30px rgba(15, 23, 42, .12), 0 1px 3px rgba(15, 23, 42, .08);
  animation: toast-in .22s ease-out;
}
.toast-card .tc-icon { font-size: 1.05rem; line-height: 1.3; flex: none; }
.toast-card .tc-msg { flex: 1; min-width: 0; line-height: 1.4; overflow-wrap: anywhere; }
.toast-card .tc-close {
  flex: none; width: 24px; height: 24px; margin: -2px 0 0 4px; border: 0; border-radius: 6px; padding: 0;
  background: transparent; color: var(--text-dim); display: grid; place-items: center; font-size: 1.05rem; cursor: pointer;
}
.toast-card .tc-close:hover { background: var(--bg-subtle); color: var(--text-primary); }
.toast-card.leaving { opacity: 0; transform: translateX(16px); transition: opacity .2s, transform .2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
[data-theme="dark"] .alert.toast-card { box-shadow: 0 10px 30px rgba(0, 0, 0, .45); }
.btn-close { filter: var(--alert-close-filter); }

/* =====================================================================
   TABLES
   ===================================================================== */
.pos-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.pos-table th {
  font-size: 11.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .6px;
  color: var(--text-muted);
  padding: 12px 16px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.pos-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-soft);
  font-size: .9rem; color: var(--text-primary);
  vertical-align: middle;
}
.pos-table tbody tr { transition: background .15s; }
.pos-table tr:hover td { background: var(--bg-card-hover); }
.pos-table tr:last-child td { border-bottom: none; }
/* Wide tables scroll inside their card instead of pushing the page sideways
   (base.html wraps every .pos-table in .table-scroll) */
.table-scroll { overflow-x: auto; max-width: 100%; -webkit-overflow-scrolling: touch; }
.table-scroll > .pos-table { min-width: 100%; }
/* Money / number cells ("৳ 100.00") must not break between symbol and value */
.pos-table td[style*="font-mono"] { white-space: nowrap; }
/* Rounded header corners when the table sits flush in a card */
.pos-table thead tr:first-child th:first-child { border-top-left-radius: 10px; }
.pos-table thead tr:first-child th:last-child  { border-top-right-radius: 10px; }

/* =====================================================================
   BADGES
   ===================================================================== */
.pos-badge {
  display: inline-block;
  padding: 3px 10px; border-radius: 999px;
  font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em;
  white-space: nowrap;
}
.pos-badge-green  { background: var(--accent-dim);        color: var(--green-text); }
.pos-badge-red    { background: var(--accent-red-dim);    color: var(--red-text); }
.pos-badge-yellow { background: var(--accent-yellow-dim); color: var(--amber-text); }
.pos-badge-blue   { background: var(--accent-blue-dim);   color: var(--blue-text); }
.pos-badge-gray   { background: var(--border-soft);       color: var(--text-muted); }
[data-theme="dark"] .pos-badge-green { color: var(--accent); }

/* =====================================================================
   FORMS
   ===================================================================== */
.form-control, .form-select {
  background-color: var(--input-bg) !important;
  border: 1px solid var(--border) !important;
  color: var(--text-primary) !important;
  border-radius: 10px;
  font-size: .9rem; font-weight: 500;
  padding: 9px 12px;
  min-height: 42px;
  transition: border-color .15s, box-shadow .15s;
}
textarea.form-control { min-height: 0; }
.form-control:focus, .form-select:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 4px var(--accent-ring) !important;
  outline: none;
}
.form-control::placeholder { color: var(--text-dim) !important; font-weight: 400; }
.form-control:disabled, .form-control[readonly] { background-color: var(--bg-subtle) !important; }
input[type="date"]::-webkit-calendar-picker-indicator {
  filter: var(--date-picker-filter); cursor: pointer; opacity: 1;
}
.form-label {
  font-size: 11.5px; font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase; letter-spacing: .6px;
}
.form-check-input { background-color: var(--input-bg); border-color: var(--border); }
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }
.form-check-input:focus { box-shadow: 0 0 0 4px var(--accent-ring); border-color: var(--accent); }
.input-group-text {
  background: var(--bg-subtle); border-color: var(--border);
  color: var(--text-muted); border-radius: 10px;
}

/* =====================================================================
   BUTTONS
   ===================================================================== */
.btn-pos {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px; min-height: 40px;
  border-radius: 10px; border: 1px solid transparent;
  font-size: .875rem; font-weight: 600;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .08s;
}
.btn-pos:active { transform: scale(.98); }
.btn-pos:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-pos-primary {
  background: var(--accent); color: var(--btn-primary-text);
  box-shadow: 0 4px 12px rgba(var(--accent-rgb), .25);
}
.btn-pos-primary:hover { background: var(--accent-hover); color: var(--btn-primary-text); }
[data-theme="dark"] .btn-pos-primary:hover { background: var(--accent-hover); }
.btn-pos-secondary {
  background: var(--bg-card); border-color: var(--border); color: var(--text-secondary);
}
.btn-pos-secondary:hover { background: var(--bg-subtle); border-color: var(--text-dim); color: var(--text-primary); }
.btn-pos-danger {
  background: var(--bg-card); border-color: var(--accent-red-line); color: var(--accent-red);
}
.btn-pos-danger:hover { background: var(--accent-red-dim); color: var(--accent-red); }

/* Large gradient action button (SELL / SAVE in the client design) */
.btn-action {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border: 0; border-radius: var(--radius);
  background: var(--accent-grad); color: #fff;
  font-size: 22px; font-weight: 800; letter-spacing: 1px;
  padding: 14px 28px;
  box-shadow: var(--shadow-accent);
  cursor: pointer;
  transition: transform .08s ease, box-shadow .15s, filter .15s;
}
.btn-action:hover { box-shadow: 0 14px 30px rgba(var(--accent-rgb), .4); filter: brightness(1.03); }
.btn-action:active { transform: scale(.98); }
.btn-action:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
.btn-action small { font-size: 11px; font-weight: 600; letter-spacing: .5px; opacity: .85; }

/* =====================================================================
   TOAST (shared; window.posToast)
   ===================================================================== */
/* (old .app-toast replaced by .toast-stack / .toast-card) */

/* =====================================================================
   MISC
   ===================================================================== */
.pos-divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--scrollbar-track); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

/* =====================================================================
   RESPONSIVE
   Below 992px the sidebar becomes an off-canvas drawer.
   ===================================================================== */
@media (max-width: 991.98px) {
  :root, html.sb-collapsed { --sidebar-w: 0px; }
  #sidebar {
    width: var(--sidebar-w-open);
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  html.sb-mobile-open #sidebar { transform: none; }
  html.sb-mobile-open .sidebar-backdrop { display: block; }
  /* the mini (collapsed) state does not apply to the drawer */
  html.sb-collapsed .brand-text,
  html.sb-collapsed .nav-label,
  html.sb-collapsed .user-info { display: block; }
  html.sb-collapsed .sidebar-head { flex-direction: row; justify-content: space-between; padding: 0 14px 0 18px; }
  html.sb-collapsed .sidebar-head .brand { display: flex; }
  html.sb-collapsed .nav-section-label { font-size: 11px; padding: 16px 10px 6px; margin: 0; height: auto; background: none; }
  html.sb-collapsed .nav-link-item { justify-content: flex-start; padding: 9px 12px; }
  html.sb-collapsed .nav-link-item.nav-sub { padding-left: 24px; }
  html.sb-collapsed .sidebar-user { justify-content: flex-start; padding: 12px 14px; }
  .sidebar-toggle-desktop { display: none !important; }
  .topbar-menu { display: grid; }
  #topbar { padding: 0 16px; }
  .content-body { padding: 16px; }
}
@media (max-width: 575.98px) {
  :root { --topbar-h: 60px; }
  .topbar-title { font-size: 16px; }
  .btn-new-sale span, .btn-logout span { display: none; }
  .btn-new-sale, .btn-logout { padding: 0 12px; }
  .content-body { padding: 12px; }
}

/* Small button (tables, compact rows) */
.btn-pos.btn-pos-sm { padding: 4px 9px; min-height: 30px; font-size: .78rem; border-radius: 8px; gap: 4px; }

.nav-count.bad { background: var(--danger); }

/* ── Confirm / alert dialog (posConfirm / posAlert) ── */
.pc-backdrop {
  position: fixed; inset: 0; z-index: 3000; display: none; align-items: center; justify-content: center; padding: 16px;
  background: rgba(15, 23, 42, .5); backdrop-filter: blur(3px);
}
.pc-backdrop.show { display: flex; }
.pc-dialog {
  width: min(440px, 100%); overflow: hidden; background: var(--bg-card); color: var(--text-primary);
  border-radius: 16px; box-shadow: 0 24px 60px rgba(15, 23, 42, .28), 0 0 0 1px rgba(15, 23, 42, .06);
  animation: pcIn .16s cubic-bezier(.2, .9, .3, 1.2);
}
@keyframes pcIn { from { opacity: 0; transform: translateY(8px) scale(.96); } to { opacity: 1; transform: none; } }
.pc-main { display: flex; gap: 16px; padding: 24px 24px 20px; }
.pc-icon {
  width: 46px; height: 46px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 21px;
  background: rgba(34, 197, 94, .12); color: var(--accent);
  box-shadow: 0 0 0 6px rgba(34, 197, 94, .06);
}
.pc-danger .pc-icon, .pc-error .pc-icon {
  background: rgba(239, 68, 68, .12); color: var(--accent-red); box-shadow: 0 0 0 6px rgba(239, 68, 68, .06);
}
.pc-body { min-width: 0; padding-top: 3px; }
.pc-title { font-size: 1.06rem; font-weight: 700; line-height: 1.35; color: var(--text-primary); overflow-wrap: anywhere; }
.pc-msg { margin-top: 6px; font-size: .9rem; line-height: 1.5; color: var(--text-muted); overflow-wrap: anywhere; white-space: pre-line; }
.pc-msg[hidden] { display: none; }
.pc-actions {
  display: flex; justify-content: flex-end; gap: 10px; padding: 14px 24px;
  background: var(--bg-subtle); border-top: 1px solid var(--border);
}
.pc-btn {
  min-width: 100px; height: 40px; padding: 0 18px; border-radius: 10px; font-size: .9rem; font-weight: 600; cursor: pointer;
  border: 1px solid var(--border); background: var(--bg-card); color: var(--text-primary);
  transition: background .12s, box-shadow .12s, filter .12s;
}
.pc-btn:hover { background: var(--bg-base); }
.pc-btn:focus { outline: none; }
.pc-btn:focus-visible { box-shadow: 0 0 0 3px rgba(100, 116, 139, .25); }
.pc-btn.pc-ok { background: var(--accent); border-color: transparent; color: #fff; box-shadow: 0 1px 2px rgba(15, 23, 42, .15); }
.pc-btn.pc-ok:hover { filter: brightness(.94); }
.pc-btn.pc-ok:focus-visible { box-shadow: 0 0 0 3px rgba(34, 197, 94, .35); }
.pc-btn.pc-ok.danger { background: var(--accent-red); }
.pc-btn.pc-ok.danger:focus-visible { box-shadow: 0 0 0 3px rgba(239, 68, 68, .35); }
.pc-btn[hidden] { display: none; }
@media (max-width: 440px) { .pc-main { padding: 20px 18px 16px; } .pc-actions { padding: 12px 18px; } .pc-actions .pc-btn { flex: 1; } }
.pc-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.pc-btn kbd {
  font-family: inherit; font-size: .66rem; font-weight: 600; line-height: 1; padding: 3px 5px; border-radius: 4px; letter-spacing: .02em;
  background: var(--bg-subtle); color: var(--text-muted); border: 1px solid var(--border); box-shadow: none;
}
.pc-btn.pc-ok kbd { background: rgba(255, 255, 255, .2); color: #fff; border-color: rgba(255, 255, 255, .25); }

/* Touch screens: small icon buttons, checkboxes and chips get a finger-sized target */
@media (pointer: coarse) {
  .ct-btn, .lc-btn { width: 38px !important; height: 38px !important; }
  .content-body input[type=checkbox]:not(.form-check-input[role=switch]) { width: 22px; height: 22px; }
  .chips a, .chips button { min-height: 36px; display: inline-flex; align-items: center; }
  .content-body .btn-icon, .content-body .act-btn { min-width: 38px; min-height: 38px; }
}

/* ── Filter bar: one quiet line at the top of a list card (search + a few dropdowns, they apply on change) ── */
.filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.fb-search { position: relative; flex: 1 1 220px; min-width: 180px; max-width: 380px; }
/* search on the left, the dropdowns grouped on the right */
.fb-search + .fb-select, .fb-search + input[type=hidden] + .fb-select { margin-left: auto; }
.fb-search > i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-dim); font-size: .9rem; pointer-events: none; }
.fb-search input { width: 100%; height: 38px; padding: 0 12px 0 36px; border: 1px solid var(--border); border-radius: 10px;
                   background: var(--bg-card); color: var(--text-primary); font-size: .88rem; outline: none; }
.fb-search input:focus, .fb-select:focus, .fb-dates input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim, rgba(21,128,61,.15)); }
.fb-select { height: 38px; width: auto; max-width: 200px; padding: 0 30px 0 12px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer;
             background: var(--bg-card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%2364707e' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 11px center;
             appearance: none; -webkit-appearance: none; color: var(--text-secondary, var(--text-primary)); font-size: .85rem; font-weight: 600; outline: none; }
/* A dropdown that is filtering: green outline + green text on the normal background (no tinted fill) */
.fb-select.is-set { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); color: var(--green-text);
                    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%2315803d' stroke-width='1.6'/%3E%3C/svg%3E"); }
.fb-select[data-fb-period] { max-width: 250px; }
/* PC / laptop: one line - dropdowns give up width (their text clips) before anything wraps */
@media (min-width: 641px) {
  .filter-bar { flex-wrap: nowrap; }
  .fb-select { flex: 0 1 auto; min-width: 96px; text-overflow: ellipsis; }
  .fb-search { min-width: 150px; }
  .fb-dates { flex: 0 0 auto; }
  .fb-dates input { width: 128px; }
  .fb-clear { flex: none; }
}
/* narrow laptops: the date boxes need the room, so the row may wrap then */
@media (min-width: 641px) and (max-width: 1199.98px) { .filter-bar:has(.fb-dates:not([hidden])) { flex-wrap: wrap; } }
/* laptops: dropdowns a little narrower so the search keeps room for its words */
@media (min-width: 641px) and (max-width: 1439.98px) {
  .fb-select { max-width: 165px; }
  .fb-select[data-fb-period] { max-width: 200px; }
  .fb-search { min-width: 220px; }
}
/* The opened list always plain, whatever the closed dropdown looks like */
.fb-select option, .fb-select optgroup { background: var(--bg-card); color: var(--text-primary); font-weight: 500; }
.fb-select optgroup { color: var(--text-muted); font-weight: 700; }
/* Searching a PO / invoice number: the other filters are paused */
.filter-bar.fb-paused .fb-select, .filter-bar.fb-paused .fb-dates { opacity: .45; }
.fb-note { display: flex; align-items: center; gap: 8px; padding: 9px 16px; font-size: .84rem; color: var(--blue-text);
           background: var(--accent-blue-dim, #dbeafe); border-bottom: 1px solid var(--border); }
.fb-dates { display: inline-flex; align-items: center; gap: 6px; color: var(--text-muted); }
.fb-dates[hidden] { display: none; }
.fb-dates input { height: 38px; width: 140px; padding: 0 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-card); color: var(--text-primary); font-size: .85rem; outline: none; }
.fb-clear { display: inline-flex; align-items: center; gap: 5px; height: 38px; padding: 0 12px; border-radius: 10px; flex: none;
            background: var(--accent-red-dim); color: var(--red-text); font-size: .84rem; font-weight: 600; text-decoration: none;
            border: 1px solid transparent; transition: background .15s, border-color .15s; }
.fb-clear:hover { border-color: var(--red-text); color: var(--red-text); }
@media (max-width: 640px) {
  .fb-search { flex-basis: 100%; max-width: none; }
  .fb-select { flex: 1 1 calc(50% - 4px); width: calc(50% - 4px); max-width: none; }
  .fb-dates { flex-basis: 100%; }
  .fb-dates input { flex: 1; width: auto; }
}
/* Stacked rows inside a flush (p-0) card keep the card's side padding */
@media (max-width: 640px) { .pos-card.p-0 table.is-stacked > tbody > tr { padding: 12px 16px; } }

/* A number card that is also a filter link */
a.stat-card.stat-link { text-decoration: none; color: inherit; transition: border-color .15s, box-shadow .15s; }
a.stat-card.stat-link:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); }
a.stat-card.stat-link.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }

/* List table helpers: numbers right, small grey second line, red due, totals row */
.pos-table th.num, .pos-table td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pos-table td.strong { font-weight: 700; }
.pos-table .sub { font-size: .78rem; color: var(--text-muted); }
.pos-table .due { color: var(--red-text); font-weight: 700; }
.pos-table .plain-link { color: var(--text-primary); text-decoration: none; }
.pos-table .plain-link:hover { color: var(--accent); text-decoration: underline; }
.pos-table tfoot td { padding: 12px 16px; font-weight: 700; background: var(--bg-subtle); border-top: 1px solid var(--border); font-size: .88rem; }
.pos-table tr.is-cancelled td { color: var(--text-muted); }
.pos-table tr.is-cancelled .po-no { text-decoration: line-through; }
.po-no { font-family: var(--font-mono); font-weight: 700; color: var(--accent); text-decoration: none; white-space: nowrap; }
.pos-table td .sub { white-space: nowrap; }
.po-no:hover { text-decoration: underline; }

/* Pager under a list */
.pager { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 14px; font-size: .82rem; color: var(--text-muted); }
.pager-links { display: flex; gap: 4px; }
.pager-links a, .pager-links span { min-width: 36px; height: 36px; padding: 0 10px; display: inline-grid; place-items: center; border-radius: 9px;
                                    border: 1px solid var(--border); background: var(--bg-card); color: var(--text-primary); text-decoration: none; font-weight: 600; }
.pager-links a:hover { border-color: var(--accent); color: var(--accent); }
.pager-links .on { background: var(--accent); border-color: var(--accent); color: var(--btn-primary-text, #fff); }

/* Phones: page buttons stay on one row and share it; long labels shrink instead of wrapping */
@media (max-width: 640px) {
  .page-bar .page-meta { flex-basis: 100%; }
  .page-actions { margin-left: 0; width: 100%; flex-wrap: nowrap; }
  .page-actions > .btn-pos, .page-actions > div > .btn-pos { flex: 1 1 0; min-width: 0; justify-content: center; padding-left: 10px; padding-right: 10px;
                                                             white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .84rem; }
  .page-actions > div { flex: 1 1 auto; flex-wrap: nowrap; min-width: 0; }
  /* totals row of a stacked table: one block like the rows above it */
  table.is-stacked > tfoot, table.is-stacked > tfoot > tr { display: block; width: 100%; }
  table.is-stacked > tfoot > tr { padding: 12px 16px; }
  table.is-stacked > tfoot > tr > td { display: flex; justify-content: flex-end; align-items: center; gap: 8px; padding: 3px 0 !important;
                                       border: 0 !important; background: none !important; text-align: right !important; }
  table.is-stacked > tfoot > tr > td::before { content: attr(data-label); margin-right: auto; font-size: .76rem; font-weight: 600; color: var(--text-muted); }
  table.is-stacked > tfoot > tr > td[colspan] { display: block; text-align: left !important; padding-bottom: 6px !important; }
  table.is-stacked > tfoot > tr > td[colspan]::before, table.is-stacked > tfoot > tr > td[data-label=""]::before { content: none; }
  table.is-stacked > tfoot > tr > td:empty { display: none; }
  table.is-stacked > tfoot { background: var(--bg-subtle); }
}

/* ── Pop-up window (stock adjust; static/js/stock_adjust.js) ── */
.am-open { overflow: hidden; }
.am-backdrop { position: fixed; inset: 0; z-index: 2500; display: flex; align-items: flex-start; justify-content: center;
               padding: 8vh 16px 16px; background: rgba(15, 23, 42, .5); backdrop-filter: blur(3px); overflow-y: auto; }
.am-dialog.am-wide { width: min(640px, 100%); }
.am-dialog.am-wide .form-actions { justify-content: flex-end; }
.am-dialog textarea { height: 64px; min-height: 64px; }
.am-dialog { width: min(520px, 100%); background: var(--bg-card); color: var(--text-primary); border-radius: 16px;
             box-shadow: 0 24px 60px rgba(15, 23, 42, .28), 0 0 0 1px rgba(15, 23, 42, .06); animation: pcIn .16s cubic-bezier(.2, .9, .3, 1.2); }
.am-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.am-title { margin: 0; font-size: 1.05rem; font-weight: 700; }
.am-x { width: 36px; height: 36px; display: grid; place-items: center; border: 0; border-radius: 9px; background: none; color: var(--text-muted); cursor: pointer; }
.am-x:hover { background: var(--bg-subtle); color: var(--text-primary); }
.am-body { padding: 18px 20px 20px; }
.am-loading { padding: 30px 0; text-align: center; color: var(--text-muted); }
@media (max-width: 640px) {
  .am-backdrop { padding: 0; align-items: flex-end; }
  .am-dialog { border-radius: 16px 16px 0 0; max-height: 92vh; overflow-y: auto; }
}

/* ── Stock adjust form (pop-up and full page) ── */
.adj-seg { display: flex; padding: 4px; gap: 4px; border-radius: 12px; background: var(--bg-subtle); margin-bottom: 16px; }
.adj-seg label { flex: 1; margin: 0; padding: 8px 10px; border-radius: 9px; font-weight: 600; font-size: .88rem; cursor: pointer; color: var(--text-muted); text-align: center; }
.adj-seg input { position: absolute; opacity: 0; pointer-events: none; }
.adj-seg label:has(input:checked) { background: var(--bg-card); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); color: var(--text-primary); }
.adj-seg label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }
.adj-field { margin-bottom: 14px; min-width: 0; }
.adj-field .form-label { margin-bottom: 5px; font-weight: 600; font-size: .84rem; }
.adj-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 14px; }
.adj-row > .adj-field:only-child, .adj-row > .adj-field:first-child:has(+ [hidden]) { grid-column: 1 / -1; }
.adj-note { font-size: .76rem; color: var(--text-muted); margin-top: 4px; }
.adj-note code { color: var(--red-text); }
.adj-alert { padding: 9px 12px; margin-bottom: 14px; border-radius: 10px; background: var(--accent-red-dim); color: var(--red-text); font-size: .86rem; }
.adj-form .field-err { color: var(--red-text); font-size: .8rem; margin-top: 4px; }
.adj-new { margin-top: 8px; }
.adj-search { position: relative; }
.adj-search > i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-dim); pointer-events: none; }
.adj-search input { width: 100%; height: 42px; padding: 0 12px 0 38px; border: 1px solid var(--border); border-radius: 10px;
                    background: var(--bg-card); color: var(--text-primary); outline: none; }
.adj-search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.adj-results { position: absolute; z-index: 5; top: calc(100% + 4px); left: 0; right: 0; max-height: 280px; overflow-y: auto; padding: 4px;
               background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 30px rgba(15, 23, 42, .16); }
.adj-hit { display: flex; flex-direction: column; align-items: flex-start; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px;
           background: none; color: var(--text-primary); text-align: left; cursor: pointer; }
.adj-hit:hover, .adj-hit.on { background: var(--accent-dim); }
.adj-hit-name { font-weight: 600; font-size: .9rem; }
.adj-hit-sub { font-size: .76rem; color: var(--text-muted); }
.adj-empty { padding: 10px; color: var(--text-muted); font-size: .86rem; }
.adj-chosen { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-subtle); }
.adj-chosen[hidden], .adj-search[hidden] { display: none; }
.adj-chosen-main { flex: 1; min-width: 0; }
.adj-chosen-name { font-weight: 700; overflow-wrap: anywhere; }
.adj-chosen-sub { font-size: .8rem; color: var(--text-muted); }
.adj-change { flex: none; border: 1px solid var(--border); background: var(--bg-card); color: var(--text-primary); border-radius: 8px; padding: 5px 10px; font-size: .8rem; font-weight: 600; cursor: pointer; }
.adj-change:hover { border-color: var(--accent); color: var(--accent); }
.adj-qty { display: flex; align-items: center; gap: 8px; }
.adj-qty input { flex: 1; min-width: 0; }
.adj-unit { flex: none; font-size: .84rem; color: var(--text-muted); }
.adj-after { margin: -4px 0 14px; padding: 8px 12px; border-radius: 10px; background: var(--bg-subtle); font-size: .86rem; color: var(--text-secondary); }
.adj-after.up { background: var(--accent-dim); color: var(--green-text); }
.adj-after.down { background: var(--accent-yellow-dim); color: var(--amber-text); }
.adj-after.bad { background: var(--accent-red-dim); color: var(--red-text); }
.adj-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 14px; border-top: 1px solid var(--border-soft); }
@media (max-width: 640px) { .adj-row { grid-template-columns: minmax(0, 1fr); } .adj-wide { display: none; } .adj-seg label { white-space: nowrap; } }

/* Long lists: the filter bar and the column headings stay at the top while the rows scroll (PC / tablet) */
@media (min-width: 641px) {
  .pos-card:has(> .filter-bar) > .filter-bar { position: sticky; top: var(--topbar-h, 0px); z-index: 6; background: var(--bg-card);
                                               border-radius: var(--radius) var(--radius) 0 0; }
  .pos-card:has(> .filter-bar) .table-scroll.fits { overflow: visible; }
  .pos-card:has(> .filter-bar) .table-scroll.fits > .pos-table > thead th { position: sticky; top: calc(var(--topbar-h, 0px) + var(--fb-h, 0px)); z-index: 5; }
  .pos-card:has(> .filter-bar) .pos-table thead tr:first-child th:first-child,
  .pos-card:has(> .filter-bar) .pos-table thead tr:first-child th:last-child { border-radius: 0; }
  .pos-card.is-stuck > .filter-bar { box-shadow: 0 6px 12px -10px rgba(15, 23, 42, .35); }
  .th-float { position: sticky; top: calc(var(--topbar-h, 0px) + var(--fb-h, 0px)); z-index: 5; overflow: hidden; }
  .th-float > table { table-layout: fixed; margin: 0; }
}

/* ── Settings › Printing: tab bar, profile bar, "this computer" chooser ── */
.pt-tabs { display: flex; gap: 4px; flex-wrap: wrap; padding: 4px; margin-bottom: 14px; border-radius: 12px; background: var(--bg-subtle); border: 1px solid var(--border); }
.pt-tabs a { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 9px; font-weight: 600; font-size: .88rem;
             color: var(--text-muted); text-decoration: none; }
.pt-tabs a:hover { color: var(--text-primary); }
.pt-tabs a.on { background: var(--bg-card); color: var(--text-primary); box-shadow: var(--shadow-sm); }
.pf-bar { margin-bottom: 14px; padding: 10px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-card); }
.pf-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pf-label { font-size: .76rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.pf-chips { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.pf-chip { display: inline-flex; align-items: center; gap: 5px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border);
           color: var(--text-primary); text-decoration: none; font-weight: 600; font-size: .86rem; background: var(--bg-card); }
.pf-chip small { font-weight: 500; color: var(--text-muted); font-size: .72rem; }
.pf-chip:hover { border-color: var(--accent); }
.pf-chip.on { border-color: var(--accent); background: var(--accent-dim); color: var(--green-text); }
.pf-more { position: relative; }
.pf-more > summary { list-style: none; cursor: pointer; }
.pf-more > summary::-webkit-details-marker { display: none; }
.pf-menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; width: 340px; padding: 12px; display: grid; gap: 10px;
           background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 30px rgba(15, 23, 42, .16); }
.pf-line { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 0; }
.pf-line form { margin: 0; }
.pf-line input[type=text] { flex: 1; min-width: 0; height: 34px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px;
                            background: var(--bg-card); color: var(--text-primary); font-size: .85rem; }
.pf-note { margin-top: 8px; font-size: .82rem; color: var(--text-muted); }
.pf-link { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 600; text-decoration: underline; cursor: pointer; }
.per-profile { margin-left: 6px; padding: 1px 8px; border-radius: 999px; font-size: .66rem; font-weight: 700; text-transform: uppercase;
               letter-spacing: .04em; vertical-align: 2px; background: var(--accent-blue-dim, #dbeafe); color: var(--blue-text); }
.pu-lead { color: var(--text-muted); font-size: .9rem; }
.pu-list { display: grid; gap: 8px; }
.pu-item { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; margin: 0; }
.pu-item:has(input:checked) { border-color: var(--accent); background: var(--accent-dim); }
.pu-item input { margin-top: 4px; }
.pu-item span { display: flex; flex-direction: column; gap: 2px; }
.pu-item small { color: var(--text-muted); font-size: .78rem; }
@media (max-width: 640px) { .pf-menu { width: min(340px, 92vw); } }
