/* =========================================================================
   BrewBooks POS & Ledger — MiaTech-Inspired Multi-Theme + Layout System
   ========================================================================= */

/* Theme 1 (Default): MiaPastel (ดึงชุดสีจาก MiaTechCatalog) */
:root,
body[data-theme="MiaPastel"] {
  --bg: #eaf6ff;
  --surface: #ffffff;
  --surface-2: #e3f2ff;
  --sidebar: linear-gradient(165deg, #2b7de0 0%, #5c54e8 100%);
  --sidebar-solid: #3b82f6;
  --sidebar-hover: rgba(255, 255, 255, 0.14);
  --sidebar-active: rgba(255, 255, 255, 0.24);
  --sidebar-text: #eef6ff;
  --border: #bfdefa;
  --text: #1e2b42;
  --text-muted: #4a6282;
  --primary: #257fd4;
  --primary-bright: #4ea8f5;
  --primary-soft: rgba(78, 168, 245, 0.16);
  --accent: #ec6fa5;
  --emerald: #10b981;
  --emerald-soft: #d1fae5;
  --rose: #e54b65;
  --rose-soft: #ffe4e8;
  --blue: #2563eb;
  --blue-soft: #dbeafe;
  --purple: #7c3aed;
  --purple-soft: #ede9fe;
  --radius: 16px;
  --radius-sm: 11px;
  --shadow: 0 3px 12px rgba(30, 43, 66, 0.07);
  --shadow-lg: 0 14px 36px rgba(15, 23, 42, 0.2);
}

/* Theme 2: CafeWarm (คาเฟ่เอสเพรสโซ่) */
body[data-theme="CafeWarm"] {
  --bg: #f6f2ec;
  --surface: #ffffff;
  --surface-2: #faf8f5;
  --sidebar: linear-gradient(165deg, #261a16 0%, #442b22 100%);
  --sidebar-solid: #261a16;
  --sidebar-hover: rgba(255, 255, 255, 0.1);
  --sidebar-active: #d97706;
  --sidebar-text: #f5ece4;
  --border: #e7dfd5;
  --text: #1f1714;
  --text-muted: #6e625b;
  --primary: #b45309;
  --primary-bright: #d97706;
  --primary-soft: #fef3c7;
  --accent: #d97706;
  --emerald: #059669;
  --emerald-soft: #d1fae5;
  --rose: #dc2626;
  --rose-soft: #fee2e2;
}

/* Theme 3: SakuraPink */
body[data-theme="SakuraPink"] {
  --bg: #fff0f6;
  --surface: #ffffff;
  --surface-2: #fce3ef;
  --sidebar: linear-gradient(165deg, #ec5c9e 0%, #a855f7 100%);
  --sidebar-solid: #ec5c9e;
  --sidebar-hover: rgba(255, 255, 255, 0.16);
  --sidebar-active: rgba(255, 255, 255, 0.28);
  --sidebar-text: #fff5fa;
  --border: #f5beda;
  --text: #3a1c33;
  --text-muted: #784a6c;
  --primary: #c9387d;
  --primary-bright: #ec5c9e;
  --primary-soft: rgba(236, 92, 158, 0.16);
  --accent: #8b5cf6;
  --emerald: #10b981;
  --emerald-soft: #d1fae5;
  --rose: #e11d48;
  --rose-soft: #ffe4e6;
}

/* Theme 4: LavenderDream */
body[data-theme="LavenderDream"] {
  --bg: #f4f0ff;
  --surface: #ffffff;
  --surface-2: #eae2ff;
  --sidebar: linear-gradient(165deg, #7c3aed 0%, #ec6fa5 100%);
  --sidebar-solid: #7c3aed;
  --sidebar-hover: rgba(255, 255, 255, 0.16);
  --sidebar-active: rgba(255, 255, 255, 0.26);
  --sidebar-text: #f7f4ff;
  --border: #d0c2fa;
  --text: #261e45;
  --text-muted: #5e5287;
  --primary: #6d28d9;
  --primary-bright: #8b5cf6;
  --primary-soft: rgba(139, 92, 246, 0.16);
  --accent: #ec6fa5;
}

/* Theme 5: MintCream */
body[data-theme="MintCream"] {
  --bg: #ecfdf5;
  --surface: #ffffff;
  --surface-2: #d6faeb;
  --sidebar: linear-gradient(165deg, #059669 0%, #0ea5e9 100%);
  --sidebar-solid: #059669;
  --sidebar-hover: rgba(255, 255, 255, 0.16);
  --sidebar-active: rgba(255, 255, 255, 0.26);
  --sidebar-text: #ecfdf5;
  --border: #a7f3d0;
  --text: #143a2e;
  --text-muted: #3e6e5e;
  --primary: #059669;
  --primary-bright: #10b981;
  --primary-soft: rgba(16, 185, 129, 0.16);
  --accent: #0ea5e9;
}

/* Theme 6: DarkModern */
body[data-theme="DarkModern"] {
  --bg: #0f121c;
  --surface: #181c2a;
  --surface-2: #232940;
  --sidebar: linear-gradient(165deg, #1b1846 0%, #2d2675 100%);
  --sidebar-solid: #1e1b4b;
  --sidebar-hover: rgba(255, 255, 255, 0.12);
  --sidebar-active: #725cff;
  --sidebar-text: #f1f5f9;
  --border: #313a56;
  --text: #f8fafc;
  --text-muted: #a6b4cc;
  --primary: #8b7bff;
  --primary-bright: #725cff;
  --primary-soft: rgba(114, 92, 255, 0.24);
  --accent: #ec6fa5;
  --emerald: #22c55e;
  --emerald-soft: rgba(34, 197, 94, 0.18);
  --rose: #f87171;
  --rose-soft: rgba(239, 68, 68, 0.2);
  --blue: #60a5fa;
  --blue-soft: rgba(59, 130, 246, 0.2);
  --purple: #c084fc;
  --purple-soft: rgba(168, 85, 247, 0.2);
  --shadow: 0 3px 14px rgba(0, 0, 0, 0.4);
}

/* Theme 7: SevenService (ธีม 7-Eleven) */
body[data-theme="SevenService"] {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #e6f4ee;
  --sidebar: linear-gradient(165deg, #006640 0%, #004d30 100%);
  --sidebar-solid: #006640;
  --sidebar-hover: rgba(255, 255, 255, 0.12);
  --sidebar-active: #f97316;
  --sidebar-text: #f0fdf4;
  --border: #cbd5e1;
  --text: #0f172a;
  --text-muted: #475569;
  --primary: #006640;
  --primary-bright: #007a4d;
  --primary-soft: rgba(0, 122, 77, 0.14);
  --accent: #f97316;
}

/* Layout Style Modifiers */
body[data-round="classic"] {
  --radius: 8px;
  --radius-sm: 6px;
}

body[data-font="large"] {
  font-size: 16px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  font-family: 'Sarabun', 'Prompt', 'Noto Sans Thai', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  transition: background 0.2s, color 0.2s;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

/* Shell */
.app-shell {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  padding-top: env(safe-area-inset-top, 0px);
}

.sidebar {
  width: 240px;
  background: var(--sidebar);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  padding: 16px 12px;
  gap: 14px;
  box-shadow: 2px 0 16px rgba(0, 0, 0, 0.1);
}

/* Top-Nav Mode (สไตล์ MiaTechCatalog) */
body[data-nav-layout="top"] .app-shell {
  flex-direction: column;
}
body[data-nav-layout="top"] .sidebar {
  width: 100%;
  height: auto;
  flex-direction: row;
  align-items: center;
  padding: 10px 16px;
  gap: 14px;
  flex-wrap: wrap;
}
body[data-nav-layout="top"] .nav-list {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 6px;
}
body[data-nav-layout="top"] .nav-item {
  padding: 8px 13px;
  font-size: 13.5px;
}
body[data-nav-layout="top"] .sidebar-footer {
  border-top: none;
  padding-top: 0;
}
body[data-nav-layout="top"] .shift-pill {
  width: auto;
  padding: 7px 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 6px;
}

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.2);
  display: grid;
  place-items: center;
  font-size: 21px;
  flex-shrink: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.brand-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand-name {
  font-weight: 800;
  font-size: 15.5px;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-sub {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.78);
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, 0.86);
  font-weight: 600;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}

.nav-item.hidden-feat {
  display: none !important;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: #fff;
}

.nav-item.active {
  background: var(--sidebar-active);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.16);
}

.nav-icon {
  font-size: 18px;
  width: 22px;
  text-align: center;
}

.sidebar-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.16);
  padding-top: 12px;
}

.shift-pill {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.12);
  text-align: left;
  transition: background 0.15s;
}

.shift-pill:hover {
  background: rgba(255, 255, 255, 0.2);
}

.shift-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.3);
  flex-shrink: 0;
}

.shift-dot.closed {
  background: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.3);
}

.shift-pill-title {
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}

.shift-pill-sub {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.82);
}

/* Main Area */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.topbar {
  height: 58px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
}

.topbar-left {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
}

.page-title {
  font-size: 17.5px;
  font-weight: 800;
  white-space: nowrap;
}

.live-clock {
  font-size: 12px;
  color: var(--text-muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.content-host {
  flex: 1;
  overflow: auto;
  padding: 16px 20px;
}

.content-host.pos-mode {
  padding: 12px 16px;
  overflow: hidden;
}

/* Common Controls */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 15px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  transition: transform 0.08s, background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.btn:active { transform: scale(0.97); }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: calc(var(--radius-sm) - 2px); }
.btn-lg { padding: 13px 20px; font-size: 15.5px; }
.btn-block { width: 100%; }

.btn-primary {
  background: var(--primary-bright);
  color: #fff;
}
.btn-primary:hover { background: var(--primary); }

.btn-emerald {
  background: var(--emerald);
  color: #fff;
}
.btn-emerald:hover { filter: brightness(0.92); }

.btn-rose {
  background: var(--rose);
  color: #fff;
}
.btn-rose:hover { filter: brightness(0.92); }

.btn-blue {
  background: var(--blue);
  color: #fff;
}
.btn-blue:hover { filter: brightness(0.92); }

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

.btn-outline {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { background: var(--surface-2); border-color: var(--primary-bright); }

.input, .select, .textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary-bright);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.badge-green { background: var(--emerald-soft); color: #065f46; }
.badge-red { background: var(--rose-soft); color: #991b1b; }
.badge-amber { background: var(--primary-soft); color: var(--primary); }
.badge-blue { background: var(--blue-soft); color: #1e40af; }
.badge-purple { background: var(--purple-soft); color: #5b21b6; }
.badge-gray { background: var(--surface-2); color: var(--text-muted); }

body[data-theme="DarkModern"] .badge-green { color: #86efac; }
body[data-theme="DarkModern"] .badge-red { color: #fca5a5; }
body[data-theme="DarkModern"] .badge-blue { color: #93c5fd; }
body[data-theme="DarkModern"] .badge-purple { color: #d8b4fe; }

/* Theme Swatches & Segmented Controls & iOS Switches (MiaTech Style) */
.swatches {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 8px;
}

.swatch {
  padding: 11px 10px;
  border-radius: var(--radius-sm);
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  text-align: center;
  border: 3px solid transparent;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.14);
  transition: transform 0.12s, border-color 0.15s;
}

.swatch:hover { transform: translateY(-1px); }
.swatch.active {
  border-color: var(--text);
  box-shadow: 0 0 0 3px var(--primary-soft), 0 6px 14px rgba(0, 0, 0, 0.18);
}

.ui-pref-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 9px 0;
  border-bottom: 1px dashed var(--border);
}

.ui-pref-lbl {
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
}

.ui-seg-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.ui-seg-btn {
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
  font-size: 12.5px;
  transition: all 0.14s;
}

.ui-seg-btn.active {
  background: var(--primary-bright);
  border-color: var(--primary-bright);
  color: #fff;
}

.feature-toggle-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.feature-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  cursor: pointer;
}

.feature-toggle-title {
  font-weight: 700;
  font-size: 13.5px;
}

.feature-toggle-desc {
  font-size: 12px;
  color: var(--text-muted);
}

.ios-switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
  flex-shrink: 0;
}

.ios-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.ios-slider {
  position: absolute;
  inset: 0;
  background: #cbd5e1;
  border-radius: 999px;
  transition: background 0.2s;
}

.ios-slider::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s;
}

.ios-switch input:checked + .ios-slider {
  background: var(--emerald);
}

.ios-switch input:checked + .ios-slider::before {
  transform: translateX(20px);
}

/* ===================== POS LAYOUT ===================== */
.pos-layout {
  display: grid;
  grid-template-columns: 1fr 390px;
  gap: 14px;
  height: 100%;
  min-height: 0;
}

.pos-left {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overflow: hidden;
}

.table-strip {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 2px;
  flex-shrink: 0;
}

.table-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  transition: all 0.15s;
}

.table-chip.active {
  background: var(--sidebar-solid);
  color: #fff;
  border-color: var(--sidebar-solid);
}

.pos-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.pos-search {
  flex: 1;
  min-width: 180px;
}

.cat-pills {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  flex-shrink: 0;
}

.cat-pill {
  padding: 7px 13px;
  border-radius: 999px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
}

.cat-pill.active {
  background: var(--primary-bright);
  color: #fff;
  border-color: var(--primary-bright);
}

.product-grid {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(156px, 1fr));
  gap: 10px;
  align-content: start;
  padding-right: 4px;
}

/* POS Grid Density Variants */
body[data-pos-grid="compact"] .product-grid {
  grid-template-columns: repeat(auto-fill, minmax(126px, 1fr));
  gap: 8px;
}
body[data-pos-grid="compact"] .product-card {
  padding: 9px;
}
body[data-pos-grid="compact"] .product-emoji {
  width: 34px;
  height: 34px;
  font-size: 18px;
}

body[data-pos-grid="list"] .product-grid {
  grid-template-columns: 1fr;
  gap: 6px;
}
body[data-pos-grid="list"] .product-card {
  flex-direction: row;
  align-items: center;
  padding: 9px 12px;
  gap: 12px;
}
body[data-pos-grid="list"] .product-meta {
  margin-top: 0;
  margin-left: auto;
  gap: 10px;
}

.product-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  transition: transform 0.1s, border-color 0.15s, box-shadow 0.15s;
  position: relative;
}

.product-card:hover {
  border-color: var(--primary-bright);
  box-shadow: 0 6px 18px var(--primary-soft);
  transform: translateY(-1px);
}

.product-card.out-of-stock {
  opacity: 0.48;
  pointer-events: none;
}

.product-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 6px;
}

.product-emoji {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  font-size: 22px;
  flex-shrink: 0;
  overflow: hidden;
}

.product-photo {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: calc(var(--radius-sm) - 1px);
  object-fit: cover;
  background: var(--surface-2);
  display: block;
}

body[data-pos-grid="list"] .product-photo {
  width: 48px;
  height: 48px;
  aspect-ratio: 1 / 1;
  flex-shrink: 0;
}

.menu-thumb {
  width: 40px;
  height: 40px;
  border-radius: 9px;
  object-fit: cover;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.product-stock-tag {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-weight: 700;
}

.product-stock-tag.low {
  background: var(--rose-soft);
  color: var(--rose);
}

.product-name {
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  line-height: 1.3;
}

.product-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
}

.product-price {
  font-weight: 800;
  font-size: 15.5px;
  color: var(--primary);
}

.product-mod-hint {
  font-size: 11px;
  color: var(--text-muted);
}

/* POS Cart Panel */
.pos-cart {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.cart-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-2);
}

.cart-table-title {
  font-weight: 800;
  font-size: 15px;
}

.cart-items {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cart-empty {
  margin: auto;
  text-align: center;
  color: var(--text-muted);
  padding: 24px 12px;
}

.cart-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cart-item-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.cart-item-name {
  font-weight: 700;
  font-size: 13.5px;
}

.cart-item-mods {
  font-size: 11.5px;
  color: var(--text-muted);
}

.cart-item-total {
  font-weight: 800;
  color: var(--text);
  white-space: nowrap;
}

.qty-stepper {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.qty-btn {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-weight: 700;
  display: grid;
  place-items: center;
}

.qty-btn:hover { border-color: var(--primary-bright); }

.cart-footer {
  border-top: 1px solid var(--border);
  padding: 12px 14px;
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.discount-bar {
  display: flex;
  gap: 6px;
  align-items: center;
}

.summary-lines {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
}

.summary-line {
  display: flex;
  justify-content: space-between;
  color: var(--text-muted);
}

.summary-line.grand {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  padding-top: 6px;
  margin-top: 2px;
  border-top: 1px dashed var(--border);
}

/* ===================== KPI & TABLES ===================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.kpi-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.kpi-value {
  font-size: 23px;
  font-weight: 800;
  margin-top: 6px;
}

.kpi-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 3px;
}

.text-green { color: var(--emerald); }
.text-red { color: var(--rose); }
.text-amber { color: var(--primary); }
.text-blue { color: var(--blue); }

.wallet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.wallet-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
}

.wallet-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 22px;
  background: var(--surface-2);
}

.toolbar-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.toolbar-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.data-table th {
  text-align: left;
  padding: 10px 12px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 700;
  white-space: nowrap;
}

.data-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tr:hover td {
  background: var(--surface-2);
}

.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Charts Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 14px;
  margin-bottom: 16px;
}

.section-heading {
  font-size: 15px;
  font-weight: 800;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pnl-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
}

.pnl-row.bold {
  font-weight: 800;
  font-size: 15px;
  border-bottom: 2px solid var(--border);
}

.bar-track {
  height: 8px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 5px;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
}

/* Sub-tabs inside Menu / Settings */
.subtabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.subtab {
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  font-weight: 700;
  font-size: 13px;
}

.subtab.active {
  background: var(--primary-bright);
  border-color: var(--primary-bright);
  color: #fff;
}

/* ===================== MODALS ===================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 34, 0.56);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
}

.modal-backdrop.hidden { display: none; }

.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 2px);
  width: 100%;
  max-width: 540px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: popIn 0.14s ease-out;
}

.modal-card.wide { max-width: 720px; }

@keyframes popIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface-2);
}

.modal-title {
  font-size: 16px;
  font-weight: 800;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 18px;
  color: var(--text-muted);
}

.modal-close:hover { background: var(--primary-soft); color: var(--text); }

.modal-body {
  padding: 16px 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-field.full { grid-column: 1 / -1; }

.form-label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-muted);
}

/* Modifier Pills */
.mod-group-title {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 6px;
  color: var(--text);
}

.mod-options {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.mod-opt {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  font-weight: 700;
  transition: all 0.12s;
}

.mod-opt.selected {
  border-color: var(--primary-bright);
  background: var(--primary-soft);
  color: var(--primary);
}

/* Checkout Payment Tabs */
.pay-methods {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.pay-tab {
  padding: 10px 6px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surface);
  text-align: center;
  font-weight: 700;
  font-size: 12.5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.pay-tab.active {
  border-color: var(--emerald);
  background: var(--emerald-soft);
  color: #065f46;
}

body[data-theme="DarkModern"] .pay-tab.active {
  color: #86efac;
}

.quick-bills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.qr-box {
  background: #fff;
  border: 2px solid #1e3a8a;
  border-radius: 14px;
  padding: 14px;
  text-align: center;
  max-width: 280px;
  margin: 0 auto;
  color: #111;
}

.qr-banner {
  background: #113566;
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 8px;
  margin-bottom: 10px;
}

/* Receipt Preview */
.receipt-paper {
  background: #fff;
  border: 1px dashed #b5aaa0;
  border-radius: 10px;
  padding: 16px;
  max-width: 310px;
  margin: 0 auto;
  font-family: 'Consolas', 'Courier New', 'Segoe UI', monospace;
  font-size: 12.5px;
  color: #111;
}

.receipt-center { text-align: center; }
.receipt-hr { border: none; border-top: 1px dashed #999; margin: 8px 0; }
.receipt-row { display: flex; justify-content: space-between; gap: 8px; margin: 3px 0; }

/* Toast */
.toast-container {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1200;
}

.toast {
  background: var(--sidebar-solid);
  color: #fff;
  padding: 11px 16px;
  border-radius: 11px;
  box-shadow: var(--shadow-lg);
  font-weight: 700;
  font-size: 13.5px;
  animation: popIn 0.15s ease-out;
}

.toast.success { background: #059669; }
.toast.error { background: #dc2626; }

/* Print Styles (Thermal 80mm Receipt) */
.print-only { display: none; }

@media print {
  body * { visibility: hidden; }
  #printArea, #printArea * { visibility: visible; }
  #printArea {
    display: block !important;
    position: fixed;
    left: 0;
    top: 0;
    width: 78mm;
    padding: 4mm;
    background: #fff;
    color: #000;
    font-family: 'Courier New', monospace;
    font-size: 12px;
  }
}

/* Responsive (Tablet & Mobile) */
@media (max-width: 960px) {
  .pos-layout {
    grid-template-columns: 1fr 320px;
  }
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 780px) {
  .app-shell,
  body[data-nav-layout="top"] .app-shell {
    flex-direction: column;
  }
  .sidebar,
  body[data-nav-layout="top"] .sidebar {
    order: 2;
    width: 100%;
    height: calc(64px + env(safe-area-inset-bottom, 0px));
    flex-direction: row;
    padding: 4px 6px calc(4px + env(safe-area-inset-bottom, 0px));
    gap: 2px;
    flex-wrap: nowrap;
  }
  .brand, .sidebar-footer { display: none; }
  .nav-list,
  body[data-nav-layout="top"] .nav-list {
    flex-direction: row;
    justify-content: space-around;
    width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
  }
  .nav-item,
  body[data-nav-layout="top"] .nav-item {
    flex-direction: column;
    padding: 6px 4px;
    gap: 2px;
    font-size: 10.5px;
    flex: 1;
    min-width: 56px;
    align-items: center;
  }
  .nav-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 68px;
  }
  .content-host.pos-mode {
    overflow-y: auto;
  }
  .pos-layout {
    grid-template-columns: 1fr;
    height: auto;
  }
  .pos-cart {
    min-height: 360px;
  }
  .topbar-actions .btn {
    padding: 6px 9px;
    font-size: 12px;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .pay-methods {
    grid-template-columns: repeat(2, 1fr);
  }
}
