/* ============================================================
   SS POS — design tokens ported from the prototypes.
   Three templates (Warmth / Midnight / Slate) × eight accents.
   ============================================================ */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

.tpl-warm {
  --desk-bg: #8A9575; --app-bg: #EEEBDB; --surface: #FFFFFF; --panel-bg: #FFFFFF;
  --rail-bg: #213026; --rail-border: #213026; --rail-icon: #8CA091; --rail-title: #EFF3EA;
  --ink: #25301F; --sub: #7E8674; --line: #E9E6D7;
  --card-bg: #FFFFFF; --card-border: #EAE7D8; --tile-bg: #F4F2E7;
  --radius: 18px; --radius-sm: 12px;
  --font: 'Poppins', system-ui, sans-serif;
  --shadow: 0 30px 80px -30px rgba(30,40,20,.45);
  --soft-alpha: 0.12; --switch-off: #D7D3C4;
}
.tpl-midnight {
  --desk-bg: #0E1116; --app-bg: #191D23; --surface: #20262E; --panel-bg: #15191F;
  --rail-bg: #15191F; --rail-border: #2A3038; --rail-icon: #5A636C; --rail-title: #E8EAED;
  --ink: #E8EAED; --sub: #8A929B; --line: #2A3038;
  --card-bg: #20262E; --card-border: #2E353E; --tile-bg: #262C34;
  --radius: 16px; --radius-sm: 11px;
  --font: 'Geist', system-ui, sans-serif;
  --shadow: 0 30px 80px -30px rgba(0,0,0,.6);
  --soft-alpha: 0.2; --switch-off: #3A424C;
}
.tpl-slate {
  --desk-bg: #DBDBD5; --app-bg: #F6F6F3; --surface: #FFFFFF; --panel-bg: #FFFFFF;
  --rail-bg: #FFFFFF; --rail-border: #E7E7E0; --rail-icon: #8A8F86; --rail-title: #16181C;
  --ink: #16181C; --sub: #8A8F86; --line: #E7E7E0;
  --card-bg: #FFFFFF; --card-border: #E7E7E0; --tile-bg: #F4F4EF;
  --radius: 9px; --radius-sm: 6px;
  --font: 'IBM Plex Sans', system-ui, sans-serif;
  --shadow: 0 30px 80px -34px rgba(30,30,20,.32);
  --soft-alpha: 0.12; --switch-off: #D7D3C4;
}
.app-root {
  --accent: rgb(var(--accent-rgb));
  --accent-soft: rgba(var(--accent-rgb), var(--soft-alpha));
  font-family: var(--font); color: var(--ink);
}

/* desk + app card */
.desk { min-height: 100vh; padding: 24px; background: var(--desk-bg); }
.app-card {
  max-width: 1560px; margin: 0 auto; height: calc(100vh - 48px); min-height: 720px;
  background: var(--app-bg); border-radius: 24px; overflow: hidden;
  display: flex; position: relative; box-shadow: var(--shadow);
}

/* base elements */
button { transition: transform .1s ease, background .15s ease, border-color .15s ease, color .15s ease, opacity .15s ease; font-family: inherit; cursor: pointer; }
button:active { transform: scale(.97); }
input, select, textarea { font-family: inherit; }
input:focus, select:focus, textarea:focus { outline: none; }
a { text-decoration: none; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: rgba(130,130,130,.32); border-radius: 20px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0 } to { transform: none; opacity: 1 } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) } to { opacity: 1; transform: none } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px) } to { opacity: 1; transform: none } }
@keyframes growUp { from { transform: scaleY(0) } to { transform: scaleY(1) } }
@keyframes shake { 0%,100% { transform: translateX(0) } 20% { transform: translateX(-8px) } 40% { transform: translateX(8px) } 60% { transform: translateX(-5px) } 80% { transform: translateX(5px) } }

/* sidebar rail */
.rail {
  width: 74px; height: 100%; flex-shrink: 0; background: var(--rail-bg); border-right: 1px solid var(--rail-border);
  display: flex; flex-direction: column; padding: 18px 12px; gap: 5px; overflow: hidden;
  transition: width .22s cubic-bezier(.3,.8,.3,1);
}
.rail.expanded { width: 212px; }
.rail-item {
  display: flex; align-items: center; gap: 13px; height: 46px; padding: 0 11px;
  border-radius: 13px; cursor: pointer; border: none; background: transparent;
  color: var(--rail-icon); font-family: inherit; font-weight: 600; font-size: 14px;
  transition: background .15s ease, color .15s ease; white-space: nowrap; width: 100%;
}
.rail-item.active { background: var(--accent-soft); color: var(--accent); }
.rail-item.centered { justify-content: center; }
.rail-item .icon { width: 24px; height: 24px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }

/* buttons */
.btn { border: none; border-radius: var(--radius-sm); font-weight: 600; font-size: 13px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.btn-accent { background: var(--accent); color: var(--accent-text); }
.btn-outline { background: var(--surface); border: 1px solid var(--line); color: var(--ink); }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--sub); }
.btn-plain { background: none; border: none; color: var(--sub); }
.btn-link { background: none; border: none; color: var(--accent); font-weight: 600; cursor: pointer; padding: 0; }
.btn-danger { background: rgba(194,56,91,.12); border: 1px solid rgba(194,56,91,.3); color: #C2385B; }
.btn-ink { background: var(--ink); color: var(--app-bg); border: none; }
.h42 { height: 42px; padding: 0 15px; }
.h46 { height: 46px; padding: 0 18px; }
.h50 { height: 50px; padding: 0 26px; font-size: 15px; }

/* pills & chips */
.chip { padding: 9px 15px; border-radius: var(--radius-sm); font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap; background: var(--surface); color: var(--sub); border: 1px solid var(--line); }
.chip.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.seg-wrap { display: flex; gap: 4px; padding: 4px; border-radius: var(--radius); background: var(--tile-bg); }
.seg { padding: 8px 14px; border-radius: 9px; font-size: 12px; font-weight: 600; cursor: pointer; border: none; white-space: nowrap; background: transparent; color: var(--sub); }
.seg.on { background: var(--accent); color: var(--accent-text); }

.badge { padding: 4px 10px; border-radius: 7px; font-size: 11px; font-weight: 700; display: inline-block; }
.badge-good { background: rgba(30,107,60,.13); color: #2E9E5B; }
.badge-warn { background: rgba(201,140,40,.16); color: #B07E1E; }
.badge-bad { background: rgba(194,56,91,.13); color: #C2385B; }
.badge-info { background: rgba(38,71,230,.13); color: #5B78F0; }
.badge-muted { background: var(--tile-bg); color: var(--sub); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }

/* cards */
.card { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: var(--radius); }
.card-pad { padding: 18px; }
.tile { background: var(--tile-bg); border-radius: var(--radius-sm); }

/* inputs */
.field-label { font-size: 12px; font-weight: 600; color: var(--ink); margin-bottom: 7px; }
.input {
  width: 100%; height: 46px; padding: 0 14px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: var(--surface); font-size: 14px; color: var(--ink);
}
.input.err { border-color: #C2385B; }

/* ---- select2 skin ----
   select2 ships a Bootstrap-ish look that ignores our tokens entirely. These
   rules make its generated markup match .input (height, radius, colours) and,
   importantly, follow the theme — its default white panels are unreadable on the
   dark templates. Selectors are select2's own class names, hence the verbosity. */
.select2-container { width: 100% !important; }
.select2-container--default .select2-selection--single {
  height: 46px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface);
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
  line-height: 44px; padding-left: 14px; padding-right: 34px; color: var(--ink); font-size: 14px;
}
.select2-container--default .select2-selection--single .select2-selection__placeholder { color: var(--sub); }
.select2-container--default .select2-selection--single .select2-selection__arrow { height: 44px; right: 8px; }
.select2-container--default .select2-selection--single .select2-selection__clear {
  color: var(--sub); margin-right: 6px; font-weight: 700;
}
.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--open .select2-selection--single { border-color: var(--accent); }
/* The fallbacks matter: this panel is re-parented at runtime, and if it ever
   lands outside the .tpl-* scope again these vars resolve to nothing and it
   renders transparent with unreadable text floating over the page. */
.select2-dropdown {
  background: var(--surface, #FFFFFF); border: 1px solid var(--line, #E3E3DC);
  border-radius: var(--radius-sm, 12px); overflow: hidden;
  box-shadow: 0 12px 32px rgba(0,0,0,.18);
}
.select2-container--default .select2-search--dropdown .select2-search__field {
  height: 40px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--app-bg); color: var(--ink); font-size: 14px;
}
.select2-container--default .select2-results__option { color: var(--ink); font-size: 14px; padding: 9px 12px; }
.select2-container--default .select2-results__option--highlighted[aria-selected],
.select2-container--default .select2-results__option--highlighted[data-selected] {
  background: var(--accent); color: #fff;
}
.select2-container--default .select2-results__option[aria-selected=true],
.select2-container--default .select2-results__option[data-selected=true] {
  background: var(--accent-soft); color: var(--ink);
}
.select2-results__option--load-more,
.select2-results__message { color: var(--sub); font-size: 13px; }
/* The dropdown is appended to <body>, so it sits outside any modal stacking
   context — it must out-rank the modal or it renders behind it. */
.select2-container--open { z-index: 4000; }
.input-tile { background: var(--tile-bg); }
select.input { cursor: pointer; }
.err-text { font-size: 12px; font-weight: 600; color: #C2385B; }

/* toggle switch */
.switch { width: 46px; height: 28px; flex-shrink: 0; border-radius: 20px; border: none; cursor: pointer; position: relative; transition: background .18s ease; background: var(--switch-off); padding: 0; }
.switch.on { background: var(--accent); }
.switch .knob { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: left .18s ease; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.switch.on .knob { left: 21px; }

/* modal + drawer */
.overlay { position: absolute; inset: 0; background: rgba(15,20,15,.4); animation: fadeIn .18s ease; z-index: 42; display: flex; align-items: center; justify-content: center; padding: 26px; }
.modal { max-width: 100%; max-height: 100%; display: flex; flex-direction: column; background: var(--surface); border-radius: 18px; box-shadow: 0 40px 90px -30px rgba(0,0,0,.5); animation: pop .24s cubic-bezier(.2,.8,.2,1); overflow: hidden; }
.modal-head { padding: 20px 24px 16px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.modal-title { font-weight: 700; font-size: 18px; color: var(--ink); }
.modal-sub { font-size: 12px; color: var(--sub); margin-top: 2px; }
.icon-btn { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--ink); cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; padding: 0; }
.drawer-veil { position: absolute; inset: 0; background: rgba(15,20,15,.4); animation: fadeIn .18s ease; z-index: 40; }
.drawer { position: absolute; top: 0; right: 0; bottom: 0; background: var(--surface); box-shadow: -24px 0 60px -30px rgba(0,0,0,.4); display: flex; flex-direction: column; animation: slideIn .24s cubic-bezier(.2,.8,.2,1); z-index: 41; }

/* toast */
.toast { position: absolute; left: 50%; bottom: 26px; transform: translateX(-50%); background: var(--ink); color: var(--app-bg); padding: 12px 22px; border-radius: 12px; font-weight: 600; font-size: 14px; box-shadow: 0 14px 40px rgba(0,0,0,.28); animation: pop .25s ease; z-index: 45; white-space: nowrap; }

/* tables */
.tbl-head { display: grid; gap: 12px; padding: 12px 20px; background: var(--tile-bg); font-size: 11px; font-weight: 700; letter-spacing: .04em; color: var(--sub); }
.tbl-row { display: grid; gap: 12px; padding: 13px 20px; border-top: 1px solid var(--line); align-items: center; }

/* avatars */
.avatar { border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 600; flex-shrink: 0; background: var(--accent-soft); color: var(--accent); }

/* page headers */
.page-title { font-weight: 700; font-size: 22px; color: var(--ink); }
.page-sub { font-weight: 500; font-size: 13px; color: var(--sub); margin-top: 3px; }

/* misc text */
.ink { color: var(--ink); } .sub { color: var(--sub); } .accent-text { color: var(--accent); }
.mono { font-family: ui-monospace, monospace; }

/* pinpad */
.pin-key { width: 62px; height: 62px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-size: 22px; font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.pin-key.alt { font-size: 16px; color: var(--sub); background: transparent; }
.pin-dot { width: 14px; height: 14px; border-radius: 50%; transition: background .12s ease; background: transparent; border: 2px solid var(--line); }
.pin-dot.on { background: var(--accent); border-color: var(--accent); }

/* POS scan bar — matches the .input look, stretches across the toolbar */
.scan-bar { display: flex; align-items: center; gap: 10px; height: 48px; padding: 0 8px 0 16px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); min-width: 280px; flex: 1 1 auto; transition: border-color .15s ease, box-shadow .15s ease; }
.scan-bar:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.scan-bar input { flex: 1; min-width: 0; border: none; outline: none; background: transparent; color: var(--ink); font-size: 14px; }

/* POS mobile cart bar — hidden on desktop, where the cart lives in the side
   panel. On small screens the panel becomes a bottom sheet this bar toggles. */
.pos-cart-fab { display: none; }

/* trial banner */
.trial-banner { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 9px 18px; background: var(--accent); color: var(--accent-text); font-size: 13px; }
.trial-banner .btn.btn-accent { background: rgba(255,255,255,.18); color: inherit; border: 1px solid rgba(255,255,255,.35); }

/* receipt printing — only the receipt paper is visible on print */
@media print {
    body * { visibility: hidden !important; }
    .receipt-paper, .receipt-paper * { visibility: visible !important; }
    .receipt-paper { position: fixed !important; left: 0; top: 0; width: 100%; border: none !important; border-radius: 0 !important; }
}

/* ============================================================
   Layout utilities — use these instead of new inline styles.
   ============================================================ */
.row { display: flex; align-items: center; }
.stack { display: flex; flex-direction: column; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.gap-1 { gap: 6px; } .gap-2 { gap: 10px; } .gap-3 { gap: 14px; } .gap-4 { gap: 18px; }
.t-11 { font-size: 11px; } .t-12 { font-size: 12px; } .t-13 { font-size: 13px; } .t-14 { font-size: 14px; }
.w-600 { font-weight: 600; } .w-700 { font-weight: 700; }
.muted { color: var(--sub); }
.w-full { width: 100%; }

/* stat card grids (dashboard/staff/customers/inventory headers) */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }

/* ============================================================
   Responsive breakpoints — tablet ≤1100px, mobile ≤768px.
   ============================================================ */

@media (max-width: 1100px) {
  .rail, .rail.expanded { width: 74px; }
  .rail .rail-head, .rail .rail-item span:not(.icon) { display: none; }
  .rail-item { justify-content: center; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .pos-panel { width: 340px !important; }
}

@media (max-width: 768px) {
  .desk { padding: 0; }
  .app-card {
    max-width: none; height: auto; min-height: 100vh; border-radius: 0;
    flex-direction: column; padding-bottom: 66px;
  }

  /* rail becomes a fixed bottom navigation bar */
  .rail, .rail.expanded {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: 100%;
    height: 64px; flex-direction: row; align-items: center; gap: 2px;
    padding: 6px 8px; border-right: none; border-top: 1px solid var(--rail-border);
    overflow-x: auto; overflow-y: hidden; z-index: 60;
  }
  .rail-item { width: auto; height: 50px; padding: 0 13px; flex-shrink: 0; }
  .rail .rail-tail { margin-top: 0; margin-left: auto; flex-direction: row; }

  /* POS side panels stack under the main column */
  .pos-panel {
    width: 100% !important; max-height: none;
    border-left: none !important; border-top: 1px solid var(--line);
  }
  .main-col { min-height: 55vh; }

  /* The cart panel becomes a bottom sheet the cashier pulls up, so the
     product grid gets the full screen and Charge is always one tap away. */
  .pos-sheet {
    position: fixed !important; left: 0; right: 0; bottom: 64px; top: auto;
    width: 100% !important; max-height: 82vh; overflow-y: auto;
    border-top: none !important; border-radius: 20px 20px 0 0;
    box-shadow: 0 -24px 60px -22px rgba(0,0,0,.5);
    transform: translateY(calc(100% + 64px));
    transition: transform .28s cubic-bezier(.2,.8,.2,1); z-index: 62;
  }
  .pos-sheet.open { transform: none; }
  .pos-sheet-veil {
    position: fixed; left: 0; right: 0; top: 0; bottom: 64px;
    background: rgba(15,20,15,.42); z-index: 61; animation: fadeIn .18s ease;
  }

  .pos-cart-fab {
    display: flex; align-items: center; gap: 12px;
    position: fixed; left: 12px; right: 12px; bottom: 76px; z-index: 58;
    height: 54px; padding: 0 18px; border: none; border-radius: 14px;
    background: var(--accent); color: var(--accent-text);
    font-family: inherit; font-weight: 600; font-size: 14px;
    box-shadow: 0 14px 34px -10px rgba(0,0,0,.5);
  }
  .pos-cart-fab-icon { position: relative; display: flex; align-items: center; }
  .pos-cart-fab-count {
    position: absolute; top: -9px; right: -11px; min-width: 18px; height: 18px;
    padding: 0 5px; border-radius: 10px; background: var(--accent-text);
    color: var(--accent); font-size: 11px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
  }

  /* tables scroll horizontally instead of squishing */
  .card:has(.tbl-head) { overflow-x: auto !important; }
  .tbl-head, .tbl-row { min-width: 640px; }

  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .drawer { width: 100% !important; }
  .overlay { padding: 10px; }
  .modal { width: 100% !important; }
  .toast { white-space: normal; width: calc(100% - 40px); text-align: center; }
}

@media (max-width: 520px) {
  .stat-grid { grid-template-columns: 1fr; }
  .pin-key { width: 56px; height: 56px; }
  /* Staff picker on the lock/login screen: one card per row so nothing clips. */
  .unlock-grid { grid-template-columns: 1fr !important; }
}

/* auth screens (login / onboarding): brand panel drops on small screens */
@media (max-width: 900px) {
  .auth-brand { display: none !important; }
  .auth-card { min-height: auto !important; width: 100% !important; }
  .auth-desk { padding: 14px !important; }
}

/* ---- guided product tour ---- */
/* Four masks dim + block everything except a hole over the highlighted target;
   an accent ring frames the hole, and (on interactive steps) pulses. */
.tour-mask { position: fixed; background: rgba(10,14,10,.55); z-index: 9000; pointer-events: auto; animation: fadeIn .2s ease; }
.tour-mask-clear { background: transparent; }   /* info steps: block the hole too, invisibly */
.tour-ring {
  position: fixed; z-index: 9001; border-radius: 12px; pointer-events: none;
  border: 2px solid var(--accent); box-shadow: 0 0 0 5px rgba(var(--accent-rgb), .22);
  transition: top .22s ease, left .22s ease, width .22s ease, height .22s ease;
}
.tour-ring.live { animation: tourPulse 1.6s ease-in-out infinite; }
@keyframes tourPulse {
  0%, 100% { box-shadow: 0 0 0 5px rgba(var(--accent-rgb), .22); }
  50%      { box-shadow: 0 0 0 9px rgba(var(--accent-rgb), .10); }
}
.tour-card {
  position: fixed; z-index: 9002; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: 0 40px 90px -30px rgba(0,0,0,.5);
  padding: 18px 18px 16px; animation: pop .22s cubic-bezier(.2,.8,.2,1);
  transition: top .2s ease, left .2s ease;
}
.tour-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.tour-step-count { font-size: 11px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: var(--accent); }
.tour-x { display: flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 8px; color: var(--sub); background: transparent; border: none; cursor: pointer; }
.tour-x:hover { background: var(--app-bg); color: var(--ink); }
.tour-title { font-weight: 700; font-size: 17px; color: var(--ink); margin-bottom: 6px; }
.tour-body { font-size: 13px; line-height: 1.5; color: var(--sub); }
.tour-dots { display: flex; gap: 6px; margin: 16px 0 14px; }
.tour-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--line); transition: all .2s ease; }
.tour-dot.on { width: 18px; border-radius: 3px; background: var(--accent); }
.tour-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tour-nav { display: flex; align-items: center; gap: 8px; }
.tour-skip { font-size: 12px; font-weight: 600; color: var(--sub); background: transparent; border: none; cursor: pointer; padding: 8px 4px; }
.tour-skip:hover { color: var(--ink); }
/* Interactive step: nudge the user to act, with a low-key escape hatch. */
.tour-do { font-size: 12px; font-weight: 700; color: var(--accent); animation: tourNudge 1.2s ease-in-out infinite; }
@keyframes tourNudge { 0%,100% { opacity: .6; } 50% { opacity: 1; } }
.tour-skip-step { font-size: 12px; font-weight: 600; color: var(--sub); background: transparent; border: none; cursor: pointer; padding: 8px 6px; border-radius: 8px; }
.tour-skip-step:hover { color: var(--ink); background: var(--app-bg); }

@media (max-width: 560px) {
  .tour-card { width: calc(100vw - 24px) !important; left: 12px !important; }
}
