/* ==========================================================================
   Reyansh Clothing - Modern Retail POS & Stock Management Design System
   ========================================================================== */

:root {
  /* Color Palette */
  --bg-app: #f4f6fb;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #ffffff;
  --bg-subtle: #f8fafc;
  --border-color: #e2e8f0;
  --border-light: #edf2f7;

  /* Text Colors */
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-white: #ffffff;

  /* Accent Colors */
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-subtle: #eff6ff;
  --primary-light: #dbeafe;

  --success: #10b981;
  --success-hover: #059669;
  --success-subtle: #ecfdf5;
  --success-border: #a7f3d0;

  --warning: #f59e0b;
  --warning-subtle: #fffbeb;
  --warning-border: #fde68a;

  --danger: #ef4444;
  --danger-hover: #dc2626;
  --danger-subtle: #fef2f2;
  --danger-border: #fecaca;

  --indigo: #6366f1;
  --indigo-subtle: #eef2ff;

  --purple: #8b5cf6;
  --purple-subtle: #f5f3ff;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.1), 0 4px 6px -4px rgba(15, 23, 42, 0.08);
  --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, 0.12), 0 8px 10px -6px rgba(15, 23, 42, 0.08);

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Transitions */
  --trans-fast: 0.15s ease;
  --trans-base: 0.2s cubic-bezier(0.4, 0, 0.2, 1);

  /* Layout Constants */
  --header-height: 64px;
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

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

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ==========================================================================
   Header Navigation
   ========================================================================== */
.app-header {
  background: #0f172a;
  color: var(--text-white);
  height: 64px;
  padding: 0 1.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-shrink: 0; /* keep the brand at its natural size so the text never squeezes */
}

.brand-icon {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}

.brand-text h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #ffffff;
  line-height: 1.2;
  white-space: nowrap;
}

.brand-sub {
  font-size: 0.72rem;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
  white-space: nowrap;
}

.nav-tabs {
  display: flex;
  background: rgba(255, 255, 255, 0.08);
  padding: 4px;
  border-radius: var(--radius-lg);
  gap: 4px;
}

.nav-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 1.1rem;
  background: transparent;
  color: #cbd5e1;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--trans-fast);
  position: relative;
}

.nav-tab:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.06);
}

.nav-tab.active {
  background: #2563eb;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.35);
}

.badge-low-stock-count {
  background: #ef4444;
  color: white;
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  font-weight: 700;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.db-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: #a7f3d0;
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.76rem;
  font-weight: 600;
}

.db-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 6px #10b981;
  animation: pulseDot 2s infinite ease-in-out;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.live-clock {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.08);
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-sm);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* ==========================================================================
   Tab View System
   ========================================================================== */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.tab-view {
  display: none;
  flex: 1;
  padding: 1.5rem 1.75rem;
  animation: fadeIn 0.2s ease-in-out;
}

.tab-view.active {
  display: flex;
  flex-direction: column;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   TAB 1: POS Billing Layout
   ========================================================================== */
.pos-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 1.5rem;
  flex: 1;
  height: calc(100vh - var(--header-height) - 3rem);
  min-height: 0;
}

.pos-products-column {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  height: 100%;
  min-height: 0;
}

.pos-toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: var(--bg-surface);
  padding: 1rem 1.25rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.55rem 0.9rem;
  transition: var(--trans-fast);
}

.search-box:focus-within {
  border-color: var(--primary);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.search-box svg {
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-box input {
  border: none;
  outline: none;
  background: transparent;
  width: 100%;
  font-size: 0.92rem;
  color: var(--text-primary);
}

.clear-search-btn {
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 4px;
}

.clear-search-btn:hover {
  color: var(--text-primary);
}

.category-pills {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 2px;
}

.cat-pill {
  padding: 0.4rem 0.95rem;
  border-radius: var(--radius-full);
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: var(--trans-fast);
}

.cat-pill:hover {
  border-color: #cbd5e1;
  background: #f1f5f9;
}

.cat-pill.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: 0 2px 5px rgba(37, 99, 235, 0.25);
}

/* Products Grid */
.products-grid-container {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding-right: 4px;
}

.products-grid {
  display: grid;
  /* Comfortable card size — keeps cards from getting cramped; yields ~4 columns
     on a typical wide screen and never the tiny 5-up cards. */
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.1rem;
  align-content: start;
}

.product-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.1rem;
  box-shadow: var(--shadow-sm);
  transition: var(--trans-base);
  display: flex;
  flex-direction: column;
  /* Keep content top-aligned so shorter cards don't leave a gap mid-card */
  justify-content: flex-start;
}

.product-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: #cbd5e1;
}

.card-top {
  margin-bottom: 0.85rem;
}

.card-badges-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.cat-tag {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  background: var(--primary-subtle);
  color: var(--primary);
}

.stock-pill-total {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-subtle);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

.product-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: capitalize;
  line-height: 1.3;
}

.product-price {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.15rem;
  font-weight: 700;
  color: #059669;
  margin-top: 0.25rem;
}

.card-sizes-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 0.4rem;
}

.size-chips-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.size-chip-btn {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  padding: 0.35rem 0.5rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--trans-fast);
  text-align: center;
}

.size-chip-btn .size-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
}

.size-chip-btn .size-qty {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-secondary);
  line-height: 1.1;
  margin-top: 2px;
}

.size-chip-btn:hover:not(:disabled) {
  border-color: var(--primary);
  background: var(--primary-subtle);
  transform: translateY(-1px);
}

.size-chip-btn:active:not(:disabled) {
  transform: scale(0.96);
}

.size-chip-btn.low-stock {
  border-color: var(--warning-border);
  background: var(--warning-subtle);
}

.size-chip-btn.low-stock .size-qty {
  color: #b45309;
}

.size-chip-btn:disabled {
  background: #f1f5f9;
  border-color: #e2e8f0;
  opacity: 0.45;
  cursor: not-allowed;
}

.size-chip-btn:disabled .size-qty {
  color: #ef4444;
}

/* Size currently in the bill: highlighted orange with a count badge */
.size-chip-btn.in-cart {
  border-color: #f97316;
  background: #fff7ed;
  box-shadow: inset 0 0 0 1px #f97316;
}

.size-chip-btn.in-cart .size-name {
  color: #c2410c;
}

.size-chip-btn.in-cart .size-qty {
  color: #ea580c;
}

.size-chip-btn.in-cart:hover:not(:disabled) {
  border-color: #ea580c;
  background: #ffedd5;
}

.chip-cart-badge {
  position: absolute;
  top: -7px;
  right: -7px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f97316;
  color: #fff;
  border-radius: 9px;
  font-size: 0.64rem;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.28);
}

/* ==========================================================================
   Cart / Checkout Sidebar Panel
   ========================================================================== */
.pos-cart-column {
  height: auto;
  max-height: calc(100vh - var(--header-height) - 3rem);
  min-height: 0;
  align-self: start;
  position: sticky;
  top: calc(var(--header-height) + 1.5rem);
  /* The whole bill (items + totals + Generate Bill) scrolls together as one
     unit when it's taller than the viewport, so item quantities stay visible
     and you scroll down to the button — instead of the item list collapsing
     into an unusable inner sliver. */
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
}

.cart-panel {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  height: auto;
  min-height: 0;
  overflow: visible;
}

.cart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  background: #fafbfc;
  flex-shrink: 0;
}

.cart-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}

.cart-count-pill {
  background: var(--primary);
  color: white;
  font-size: 0.75rem;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  font-weight: 700;
}

.btn-text-danger {
  background: none;
  border: none;
  color: var(--danger);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: var(--trans-fast);
}

.btn-text-danger:hover {
  background: var(--danger-subtle);
}

/* Customer Input */
.cart-customer-section {
  padding: 0.75rem 1.25rem;
  background: #f8fafc;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.form-row-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.65rem;
}
@media (max-width: 560px) {
  .form-row-2 { grid-template-columns: 1fr; }
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.input-group label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.input-group input, .input-group select {
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  background: white;
  transition: var(--trans-fast);
}

.input-group input:focus, .input-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

/* Cart Items Container */
.cart-items-container {
  flex: 0 0 auto;
  overflow: visible;
  padding: 0.85rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-height: 0;
}

.cart-empty-state {
  margin: auto;
  text-align: center;
  padding: 2rem 1rem;
}

.empty-icon {
  font-size: 2.8rem;
  margin-bottom: 0.5rem;
  opacity: 0.8;
}

.empty-text {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.empty-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.cart-item-card {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.85rem;
  transition: var(--trans-fast);
}

.cart-item-card:hover {
  border-color: #cbd5e1;
  background: #ffffff;
}

.cart-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.cart-item-header .item-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: capitalize;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.cart-item-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.size-pill {
  background: #e2e8f0;
  color: #334155;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
}

.item-unit-price {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.cart-item-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 0.75rem;
  flex-wrap: wrap;
  padding-top: 0.5rem;
  margin-top: 0.15rem;
  border-top: 1px dashed var(--border-light);
}

.cart-item-tax-wrap {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
}

.item-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex: 0 0 auto;
  margin-left: auto;
}

.qty-control {
  display: inline-flex;
  align-items: center;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.btn-qty {
  width: 26px;
  height: 26px;
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-primary);
  transition: var(--trans-fast);
}

.btn-qty:hover {
  background: #f1f5f9;
}

.qty-display {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  font-weight: 700;
  min-width: 24px;
  text-align: center;
  padding: 0 4px;
}

.item-total-price {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-primary);
  min-width: 55px;
  text-align: right;
}

.btn-remove-item {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--trans-fast);
  flex-shrink: 0;
}

.btn-remove-item:hover {
  color: var(--danger);
  background: var(--danger-subtle);
}

/* Cart Footer & Calculations */
.cart-footer {
  border-top: 1px solid var(--border-color);
  padding: 0.85rem 1.25rem;
  background: #fafbfc;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  flex-shrink: 0;
}

.summary-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.sum-value {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  color: var(--text-primary);
}

.discount-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.discount-input {
  width: 90px;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  text-align: right;
}

.total-line {
  padding-top: 0.5rem;
  border-top: 1px dashed var(--border-color);
}

.total-label {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-primary);
}

.total-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.35rem;
  font-weight: 800;
  color: #059669;
}

/* Payment Mode */
.payment-methods-box {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.2rem;
}

.section-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
}

.payment-options {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.4rem;
}

.pay-option input {
  display: none;
}

.pay-btn {
  display: block;
  text-align: center;
  padding: 0.45rem 0.2rem;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--trans-fast);
}

.pay-option input:checked + .pay-btn {
  background: #0f172a;
  color: white;
  border-color: #0f172a;
}

/* Checkout Buttons */
.checkout-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: var(--trans-fast);
}

.btn-primary {
  background: #10b981;
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: #059669;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(16, 185, 129, 0.3);
}

.btn-checkout {
  padding: 0.8rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 700;
}

.btn-secondary {
  background: #e2e8f0;
  color: #334155;
}

.btn-secondary:hover:not(:disabled) {
  background: #cbd5e1;
}

.btn-outline {
  background: white;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.btn-outline:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: var(--text-primary);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  background: var(--danger-hover);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* ==========================================================================
   TAB 2 & 3: Stats & KPI Rows
   ========================================================================== */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
}

.stat-icon.bg-blue { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.stat-icon.bg-green { background: linear-gradient(135deg, #10b981, #059669); }
.stat-icon.bg-amber { background: linear-gradient(135deg, #f59e0b, #d97706); }
.stat-icon.bg-red { background: linear-gradient(135deg, #ef4444, #dc2626); }
.stat-icon.bg-purple { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.stat-icon.bg-indigo { background: linear-gradient(135deg, #6366f1, #4f46e5); }

.stat-content {
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.stat-number {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
}

.text-amber { color: #d97706; }
.text-red { color: #dc2626; }

/* Filter Bars */
.inventory-controls-bar, .sales-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.25rem;
  background: var(--bg-surface);
  padding: 1rem 1.25rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.inv-filters, .sales-date-filters {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
}

.select-dropdown {
  padding: 0.55rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  background: var(--bg-subtle);
  color: var(--text-primary);
  cursor: pointer;
  outline: none;
}

.select-dropdown:focus {
  border-color: var(--primary);
  background: white;
}

.checkbox-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.inv-actions, .sales-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.date-preset-btn {
  padding: 0.45rem 0.95rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--trans-fast);
}

.date-preset-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.date-picker-input {
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  background: white;
}

/* ==========================================================================
   Tables & Data Cards
   ========================================================================== */
.table-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.table-header-title {
  padding: 1rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  background: #fafbfc;
}

.table-header-title h3 {
  font-size: 1rem;
  font-weight: 700;
}

.records-badge {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
}

.table-responsive {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th {
  background: #f8fafc;
  padding: 0.85rem 1.25rem;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.data-table td {
  padding: 0.95rem 1.25rem;
  font-size: 0.88rem;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.data-table tbody tr:hover {
  background: #f8fafc;
}

.text-right {
  text-align: right;
}

/* Size Matrix Pills in Table */
.size-matrix-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.matrix-size-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.55rem;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
}

.matrix-size-pill .ms-size {
  font-weight: 700;
  color: #1e293b;
}

.matrix-size-pill .ms-count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  padding: 1px 5px;
  border-radius: 4px;
  background: white;
  border: 1px solid #cbd5e1;
}

.matrix-size-pill.ms-good .ms-count {
  background: #ecfdf5;
  color: #065f46;
  border-color: #a7f3d0;
}

.matrix-size-pill.ms-low .ms-count {
  background: #fffbeb;
  color: #92400e;
  border-color: #fde68a;
}

.matrix-size-pill.ms-zero .ms-count {
  background: #fef2f2;
  color: #991b1b;
  border-color: #fecaca;
}

.total-stock-badge {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-sm);
  background: #f8fafc;
  display: inline-block;
}

.table-actions {
  display: flex;
  gap: 0.4rem;
  justify-content: flex-end;
}

.btn-icon-action {
  background: white;
  border: 1px solid var(--border-color);
  padding: 0.4rem 0.65rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--trans-fast);
}

.btn-icon-action:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-subtle);
}

.btn-icon-action.danger:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: var(--danger-subtle);
}

.btn-icon-action.tax1-btn {
  color: #0284c7;
  background: #f0f9ff;
  border-color: #bae6fd;
}
.btn-icon-action.tax1-btn:hover {
  background: #0284c7;
  color: #ffffff;
  border-color: #0284c7;
}

.btn-icon-action.tax2-btn {
  color: #7c3aed;
  background: #f5f3ff;
  border-color: #ddd6fe;
}
.btn-icon-action.tax2-btn:hover {
  background: #7c3aed;
  color: #ffffff;
  border-color: #7c3aed;
}

/* ==========================================================================
   TAB 4: Settings View
   ========================================================================== */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr));
  gap: 1.5rem;
}

.settings-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.settings-card-header {
  margin-bottom: 1.25rem;
}

.settings-card-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.settings-card-header p {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-top: 0.2rem;
}

.settings-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.backup-actions-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.backup-action-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  gap: 1rem;
}

.backup-action-item h4 {
  font-size: 0.9rem;
  font-weight: 700;
}

.backup-action-item p {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 0.15rem;
}

.backup-action-item.danger-border {
  border-color: #fecaca;
  background: #fff5f5;
}

.file-input-label {
  cursor: pointer;
}

/* ==========================================================================
   Modals
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
}

.modal-card {
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalScale 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-receipt-preview {
  max-width: 900px;
  width: 95%;
}

@keyframes modalScale {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.15rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  background: #fafbfc;
}

.modal-title-group {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.modal-title-group h3 {
  font-size: 1.1rem;
  font-weight: 700;
}

.format-toggles {
  display: flex;
  background: #e2e8f0;
  padding: 2px;
  border-radius: var(--radius-md);
  gap: 2px;
}

.btn-toggle {
  background: none;
  border: none;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
}

.btn-toggle.active {
  background: white;
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}

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

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  background: #fafbfc;
}

.restock-sizes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
  max-height: 260px;
  overflow-y: auto;
  padding: 4px;
}

.restock-size-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.restock-size-card .rs-label {
  font-size: 0.8rem;
  font-weight: 700;
}

.restock-size-card .rs-current {
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.restock-size-card input {
  padding: 0.35rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  text-align: center;
}

/* ==========================================================================
   INVOICE / RECEIPT STYLES
   ========================================================================== */
/* Thermal 80mm Layout */
.receipt-thermal {
  width: 320px;
  margin: 0 auto;
  background: #ffffff;
  padding: 1.25rem 1rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  color: #000000;
  line-height: 1.4;
  border: 1px dashed #cbd5e1;
  box-shadow: var(--shadow-sm);
}

.receipt-thermal .r-center {
  text-align: center;
}

.receipt-thermal .r-logo {
  display: block;
  width: 62%;
  max-width: 150px;
  margin: 0 auto 6px;
  border-radius: 6px;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.receipt-thermal .r-store-name {
  font-size: 1.15rem;
  font-weight: 800;
  text-transform: uppercase;
  margin-bottom: 2px;
}

.receipt-thermal .r-address {
  font-size: 0.72rem;
  margin-bottom: 4px;
}

.receipt-thermal .r-divider {
  border-top: 1px dashed #000;
  margin: 0.65rem 0;
}

.receipt-thermal .r-meta-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
}

.receipt-thermal .r-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.5rem 0;
}

.receipt-thermal .r-table th {
  border-bottom: 1px dashed #000;
  border-top: 1px dashed #000;
  font-size: 0.75rem;
  padding: 4px 0;
  text-align: left;
}

.receipt-thermal .r-table td {
  padding: 4px 0;
  font-size: 0.75rem;
}

.receipt-thermal .r-table .t-right {
  text-align: right;
}

.receipt-thermal .r-totals {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 0.4rem;
}

.receipt-thermal .r-grand-total {
  font-size: 1rem;
  font-weight: 800;
  border-top: 1px dashed #000;
  border-bottom: 1px dashed #000;
  padding: 4px 0;
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
}

.receipt-thermal .r-footer {
  text-align: center;
  font-size: 0.7rem;
  margin-top: 0.85rem;
}

/* Standard A4/A5 Layout */
.receipt-a4 {
  background: #ffffff;
  padding: 1.75rem;
  border: 1px solid #e2e8f0;
  color: #1e293b;
  font-size: 0.88rem;
  line-height: 1.5;
}

.receipt-a4 .a4-header {
  display: flex;
  justify-content: space-between;
  border-bottom: 2px solid #0f172a;
  padding-bottom: 1rem;
  margin-bottom: 1.25rem;
}

.receipt-a4 .a4-logo {
  display: block;
  width: 180px;
  max-width: 60%;
  margin-bottom: 10px;
  border-radius: 8px;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.receipt-a4 .a4-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: #0f172a;
}

.receipt-a4 .a4-meta-box {
  text-align: right;
  font-size: 0.82rem;
}

.receipt-a4 .a4-cust-box {
  background: #f8fafc;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.25rem;
  display: flex;
  justify-content: space-between;
}

.receipt-a4 .a4-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.25rem;
}

.receipt-a4 .a4-table th {
  background: #f1f5f9;
  padding: 0.65rem 0.75rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  font-weight: 700;
  border: 1px solid #e2e8f0;
}

.receipt-a4 .a4-table td {
  padding: 0.65rem 0.75rem;
  border: 1px solid #e2e8f0;
  font-size: 0.85rem;
}

.receipt-a4 .a4-totals-box {
  width: 280px;
  margin-left: auto;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1.5rem;
}

.receipt-a4 .a4-grand-total {
  font-size: 1.15rem;
  font-weight: 800;
  color: #0f172a;
  border-top: 2px solid #0f172a;
  padding-top: 0.4rem;
  display: flex;
  justify-content: space-between;
}

.receipt-a4 .a4-footer {
  border-top: 1px solid #e2e8f0;
  padding-top: 1rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
  text-align: center;
}

/* ==========================================================================
   TAX INVOICE FORMAT 1 (PDF 1 - RASHMITA INFINITY INDUSTRIES)
   ========================================================================== */
.tax-invoice-f1 {
  background: #ffffff;
  padding: 0.85rem 1rem;
  color: #000000;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.76rem;
  line-height: 1.25;
  border: 1px solid #cbd5e1;
  max-width: 820px;
  margin: 0 auto;
  box-sizing: border-box;
}

.f1-top-pill {
  display: block;
  width: max-content;
  margin: 0 auto 5px;
  padding: 2px 16px;
  border: 1.5px solid #000000;
  border-radius: 4px;
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #000000;
}

.f1-header-grid {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2px;
}

.f1-logo-cell {
  flex: 0 0 auto;
  text-align: center;
}

.f1-company-cell {
  flex: 1;
  text-align: center;
}

.f1-company-title {
  font-family: Arial, Helvetica, sans-serif;
  font-weight: 900;
  font-size: 1.5rem;
  color: #0b1f7a;
  letter-spacing: 1px;
  line-height: 1.1;
}

.f1-company-subtitle {
  font-family: Arial, Helvetica, sans-serif;
  font-weight: 800;
  font-size: 1.15rem;
  color: #b87333;
  letter-spacing: 2px;
  line-height: 1.15;
}

.f1-company-meta-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.73rem;
  font-weight: 700;
  color: #000000;
  margin-top: 3px;
}

.f1-dashed-sep {
  border-top: 1.5px dashed #000000;
  margin: 4px 0;
}

.f1-invoice-meta-row {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  font-size: 0.78rem;
  margin-bottom: 4px;
}

.f1-main-box {
  border: 1.5px solid #000000;
}

.f1-bill-to-header {
  text-align: center;
  font-weight: 800;
  font-size: 0.78rem;
  padding: 2.5px;
  border-bottom: 1.5px solid #000000;
  letter-spacing: 1px;
  background: #f8fafc;
}

.f1-bill-to-table {
  width: 100%;
  border-collapse: collapse;
}

.f1-bill-to-table td {
  border-bottom: 1px solid #000000;
  padding: 2.5px 6px;
  font-size: 0.74rem;
}

.f1-bill-to-table td.f1-label {
  font-weight: 700;
  width: 25%;
  border-right: 1.5px solid #000000;
  background: #fafafa;
}

.f1-in-details-bar {
  background: #008080;
  color: #ffffff;
  text-align: center;
  font-weight: 700;
  padding: 3px;
  font-size: 0.76rem;
  border-bottom: 1.5px solid #000000;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.f1-items-table {
  width: 100%;
  border-collapse: collapse;
}

.f1-items-table th {
  background: #fde9d9;
  border: 1px solid #000000;
  padding: 3.5px 4px;
  font-size: 0.72rem;
  font-weight: 700;
  text-align: center;
  color: #000000;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.f1-items-table td {
  border: 1px solid #000000;
  padding: 3px 6px;
  font-size: 0.74rem;
  color: #000000;
}

.f1-items-table td.t-center { text-align: center; }
.f1-items-table td.t-right { text-align: right; }

.f1-calc-row td {
  font-weight: 700;
}

.f1-words-box {
  border-top: 1.5px solid #000000;
  border-bottom: 1.5px solid #000000;
  padding: 3.5px 6px;
  font-size: 0.74rem;
  font-weight: 700;
  background: #fbfbfb;
}

.f1-payable-bar {
  display: flex;
  border-bottom: 1.5px solid #000000;
  background: #fde9d9;
  font-weight: 800;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.f1-payable-label {
  flex: 1;
  text-align: right;
  padding: 3.5px 10px;
  border-right: 1.5px solid #000000;
  font-size: 0.78rem;
}

.f1-payable-val {
  width: 120px;
  text-align: right;
  padding: 3.5px 8px;
  font-size: 0.84rem;
}

.f1-bank-cert-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  border-bottom: 1.5px solid #000000;
}

.f1-bank-box {
  padding: 3.5px 5px;
  border-right: 1px solid #000000;
  font-size: 0.68rem;
  line-height: 1.25;
}

.f1-bank-header {
  background: #fde9d9;
  text-align: center;
  font-weight: 700;
  padding: 2px 0;
  margin: -3.5px -5px 3px -5px;
  border-bottom: 1px solid #000000;
  font-size: 0.7rem;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.f1-cert-box {
  padding: 4px 6px;
  font-size: 0.67rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.f1-notes-terms-grid {
  display: grid;
  grid-template-columns: 30% 70%;
  font-size: 0.67rem;
  line-height: 1.25;
}

.f1-notes-col {
  padding: 3.5px 5px;
  border-right: 1px solid #000000;
}

.f1-terms-col {
  padding: 3.5px 5px;
}

.f1-footer-note {
  text-align: center;
  font-size: 0.7rem;
  font-weight: 600;
  margin-top: 4px;
}

/* ==========================================================================
   TAX INVOICE FORMAT 2 (PDF 2 PAGE 1 - VIBRANT FULL COLOR GST E-INVOICE)
   ========================================================================== */
.tax-invoice-f2 {
  background: #ffffff;
  padding: 0.75rem 0.9rem;
  color: #0f172a;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.72rem;
  line-height: 1.2;
  border: 1.5px solid #1e3a8a;
  max-width: 860px;
  margin: 0 auto;
  box-sizing: border-box;
}

.f2-top-header-banner {
  background: linear-gradient(135deg, #1e3a8a 0%, #0284c7 100%);
  color: #ffffff;
  padding: 4px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: 3px 3px 0 0;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.f2-banner-title {
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

.f2-banner-sub {
  font-size: 0.68rem;
  font-weight: 500;
  opacity: 0.9;
  margin-left: 6px;
}

.f2-einvoice-badge {
  background: #f59e0b;
  color: #000000;
  font-weight: 800;
  font-size: 0.66rem;
  padding: 2px 7px;
  border-radius: 4px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.f2-irn-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f8fafc;
  padding: 3px 8px;
  border-left: 1.5px solid #1e3a8a;
  border-right: 1.5px solid #1e3a8a;
  border-bottom: 1.5px solid #1e3a8a;
  gap: 0.75rem;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.f2-irn-info {
  font-size: 0.66rem;
  font-family: 'JetBrains Mono', monospace;
  line-height: 1.3;
  color: #1e293b;
}

.f2-qr-wrap {
  flex: 0 0 auto;
  border: 1px solid #94a3b8;
  padding: 2px;
  background: #ffffff;
  border-radius: 3px;
}

.f2-party-transport-grid {
  display: grid;
  grid-template-columns: 50% 50%;
  border-left: 1.5px solid #1e3a8a;
  border-right: 1.5px solid #1e3a8a;
  border-bottom: 1.5px solid #1e3a8a;
}

.f2-party-col {
  border-right: 1.5px solid #1e3a8a;
}

.f2-seller-card {
  padding: 3.5px 7px;
  background: #f0f9ff;
  border-bottom: 1px solid #bae6fd;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.f2-seller-title {
  font-size: 0.85rem;
  font-weight: 800;
  color: #0369a1;
  margin-bottom: 1px;
}

.f2-consignee-card, .f2-buyer-card {
  padding: 3.5px 7px;
  border-bottom: 1px solid #cbd5e1;
}

.f2-buyer-card {
  border-bottom: none;
}

.f2-card-heading {
  font-size: 0.63rem;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  margin-bottom: 1px;
}

.f2-transport-table {
  width: 100%;
  border-collapse: collapse;
}

.f2-transport-table td {
  padding: 2px 5px;
  border-bottom: 1px solid #e2e8f0;
  border-right: 1px solid #e2e8f0;
  font-size: 0.67rem;
  line-height: 1.18;
  vertical-align: top;
}

.f2-transport-table td:nth-child(2n) {
  border-right: none;
}

.f2-transport-table tr:nth-child(even) td {
  background: #f8fafc;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.f2-goods-table {
  width: 100%;
  border-collapse: collapse;
  border-left: 1.5px solid #1e3a8a;
  border-right: 1.5px solid #1e3a8a;
  border-bottom: 1.5px solid #1e3a8a;
}

.f2-goods-table th {
  background: #1e3a8a;
  color: #ffffff;
  padding: 3.5px 3px;
  font-size: 0.64rem;
  font-weight: 700;
  text-transform: uppercase;
  border: 1px solid #1e3a8a;
  text-align: center;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.f2-goods-table td {
  border: 1px solid #cbd5e1;
  padding: 2.5px 5px;
  font-size: 0.7rem;
  color: #0f172a;
}

.f2-goods-table tbody tr:nth-child(even) {
  background: #f8fafc;
}

.f2-goods-table td.t-center { text-align: center; }
.f2-goods-table td.t-right { text-align: right; }

.f2-gst-pill {
  display: inline-block;
  background: #e0e7ff;
  color: #3730a3;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.66rem;
  font-weight: 700;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.f2-total-row td {
  background: #1e3a8a !important;
  color: #ffffff !important;
  font-weight: 800;
  font-size: 0.76rem;
  padding: 3.5px 6px;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.f2-amount-words-row {
  background: #f1f5f9;
  padding: 3.5px 7px;
  font-size: 0.68rem;
  border-left: 1.5px solid #1e3a8a;
  border-right: 1.5px solid #1e3a8a;
  border-bottom: 1.5px solid #1e3a8a;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.f2-hsn-table {
  width: 100%;
  border-collapse: collapse;
  border-left: 1.5px solid #1e3a8a;
  border-right: 1.5px solid #1e3a8a;
  border-bottom: 1.5px solid #1e3a8a;
}

.f2-hsn-table th {
  background: #0284c7;
  color: #ffffff;
  padding: 2.5px 4px;
  font-size: 0.63rem;
  font-weight: 700;
  border: 1px solid #0284c7;
  text-align: center;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.f2-hsn-table td {
  border: 1px solid #cbd5e1;
  padding: 2px 4px;
  font-size: 0.66rem;
  text-align: right;
}

.f2-hsn-table td:first-child {
  text-align: center;
  font-weight: 700;
}

.f2-hsn-table .f2-hsn-total-row td {
  background: #f0f9ff;
  font-weight: 700;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.f2-tax-words-row {
  background: #f8fafc;
  padding: 2.5px 7px;
  font-size: 0.66rem;
  border-left: 1.5px solid #1e3a8a;
  border-right: 1.5px solid #1e3a8a;
  border-bottom: 1.5px solid #1e3a8a;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.f2-bottom-grid {
  display: grid;
  grid-template-columns: 55% 45%;
  border-left: 1.5px solid #1e3a8a;
  border-right: 1.5px solid #1e3a8a;
  border-bottom: 1.5px solid #1e3a8a;
}

.f2-decl-bank-col {
  padding: 3.5px 7px;
  border-right: 1.5px solid #1e3a8a;
  font-size: 0.66rem;
  line-height: 1.18;
}

.f2-bank-details-card {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 3px;
  padding: 2.5px 5px;
  margin-top: 3px;
  font-size: 0.65rem;
  line-height: 1.2;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.f2-sig-col {
  padding: 3.5px 7px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: right;
  font-size: 0.66rem;
  line-height: 1.18;
}

.f2-jurisdiction-footer {
  text-align: center;
  font-size: 0.66rem;
  font-weight: 600;
  color: #475569;
  padding-top: 3px;
}

/* ==========================================================================
   TOAST NOTIFICATIONS
   ========================================================================== */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 300;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1.15rem;
  background: #0f172a;
  color: white;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.88rem;
  font-weight: 600;
  animation: slideInToast 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  transition: opacity 0.2s ease;
}

.toast.toast-success { background: #065f46; border-left: 4px solid #10b981; }
.toast.toast-error { background: #991b1b; border-left: 4px solid #ef4444; }
.toast.toast-info { background: #1e293b; border-left: 4px solid #3b82f6; }

@keyframes slideInToast {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   PRINT OPTIMIZED CSS
   ========================================================================== */
@media print {
  @page {
    size: A4 portrait;
    margin: 5mm 6mm !important;
  }

  /* Hide all app chrome */
  body, html {
    background: #ffffff !important;
    padding: 0 !important;
    margin: 0 !important;
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
  }

  .app-header,
  .nav-tabs,
  .app-main,
  .modal-backdrop:not(#billModal),
  .no-print,
  .modal-header,
  .modal-footer,
  .toast-container {
    display: none !important;
  }

  #billModal {
    position: static !important;
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    display: block !important;
    backdrop-filter: none !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    border: none !important;
    box-shadow: none !important;
  }

  .modal-card,
  .modal-receipt-preview {
    box-shadow: none !important;
    border: none !important;
    border-radius: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
    max-height: none !important;
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
  }

  .print-area {
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
    height: auto !important;
    min-height: 0 !important;
  }

  .receipt-thermal {
    width: 76mm !important;
    border: none !important;
    padding: 2mm !important;
    margin: 0 auto !important;
    box-shadow: none !important;
  }

  .receipt-a4 {
    border: none !important;
    padding: 0 !important;
    box-shadow: none !important;
  }

  .tax-invoice-f1,
  .tax-invoice-f2 {
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
    box-shadow: none !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    page-break-after: avoid !important;
    break-after: avoid !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .tax-invoice-f1 *,
  .tax-invoice-f2 * {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }
}

/* ==========================================================================
   ROLE RESTRICTIONS: TAX INVOICES ONLY ACCESSIBLE TO ADMIN / MASTER
   ========================================================================== */
body:not(.role-admin) #toggleTax1,
body:not(.role-admin) #toggleTax2,
body:not(.role-admin) .tax1-btn,
body:not(.role-admin) .tax2-btn,
body:not(.role-admin) .btn-sale-tax1,
body:not(.role-admin) .btn-sale-tax2 {
  display: none !important;
}

/* ==========================================================================
   Responsive Adaptations
   ========================================================================== */
/* Tablets & small laptops: POS becomes single column, cart drops below */
@media (max-width: 1024px) {
  .pos-layout {
    /* minmax(0, 1fr) lets the single column shrink to the viewport instead of
       growing to its widest child's intrinsic width (which caused overflow). */
    grid-template-columns: minmax(0, 1fr);
    height: auto;
  }

  .pos-products-column,
  .pos-cart-column,
  .cart-panel,
  .pos-toolbar,
  .products-grid-container {
    height: auto;
    min-width: 0;
  }

  .pos-cart-column {
    position: static;
    max-height: none;
    overflow: visible;
  }

  /* Allow the search field to shrink inside its flex row */
  .search-box input {
    min-width: 0;
  }

  .products-grid-container {
    overflow: visible;
  }

  /* Stacked layout: the whole bill flows down the page instead of being
     squeezed into a tiny inner scrollbar. All items are visible, and you
     scroll the page down to reach the totals and Generate Bill. */
  .cart-panel {
    max-height: none;
    height: auto;
    overflow: visible;
  }

  .cart-items-container {
    overflow: visible;
    max-height: none;
    min-height: 0;
  }
}

/* Tablets / large phones */
@media (max-width: 768px) {
  .app-header {
    height: auto;
    padding: 0.7rem 1rem;
    flex-wrap: wrap;
    gap: 0.6rem;
  }

  .header-right {
    gap: 0.5rem;
    flex-wrap: wrap;
  }

  /* Clock takes space and adds little on mobile */
  .live-clock {
    display: none;
  }

  .nav-tabs {
    order: 3;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .nav-tab {
    flex: 1 0 auto;
    justify-content: center;
    white-space: nowrap;
  }

  .tab-view {
    padding: 1rem;
  }

  /* Product cards: keep two per row on phones instead of one giant card */
  .products-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.75rem;
  }

  /* KPI / stat cards: two per row */
  .stats-row {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
  }

  .stat-card {
    padding: 0.9rem;
    gap: 0.7rem;
  }

  .stat-icon {
    width: 40px;
    height: 40px;
  }

  .stat-number {
    font-size: 1.2rem;
  }

  /* Filter bars stack vertically and fill width */
  .inventory-controls-bar,
  .sales-toolbar {
    flex-direction: column;
    align-items: stretch;
    padding: 0.9rem 1rem;
  }

  .inv-filters,
  .sales-date-filters,
  .inv-actions {
    width: 100%;
  }

  .inv-actions {
    flex-wrap: wrap;
  }

  .inv-filters .search-box,
  .inv-filters .select-dropdown {
    flex: 1 1 45%;
  }

  .inv-actions .btn {
    flex: 1 1 auto;
    justify-content: center;
  }

  /* Wide tables scroll horizontally rather than crushing columns */
  .data-table {
    min-width: 640px;
  }

  /* Modals fill more of the small screen */
  .modal-backdrop {
    padding: 0.5rem;
  }

  .modal-card {
    max-height: 94vh;
  }

  .modal-header {
    padding: 0.9rem 1rem;
  }

  .modal-title-group {
    gap: 0.6rem;
  }

  /* Prevent iOS auto-zoom when focusing inputs */
  input,
  select,
  textarea {
    font-size: 16px;
  }
}

/* Small phones */
@media (max-width: 480px) {
  .tab-view {
    padding: 0.75rem;
  }

  .brand-text h1 {
    font-size: 1rem;
  }

  .brand-sub,
  .db-status-pill {
    display: none;
  }

  .products-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.6rem;
  }

  .product-card {
    padding: 0.85rem;
  }

  .stat-number {
    font-size: 1.05rem;
  }

  .cart-panel {
    max-height: none;
  }

  .modal-card {
    max-width: 100%;
    border-radius: var(--radius-lg);
  }

  .format-toggles {
    flex-wrap: wrap;
  }

  /* Row action buttons wrap instead of overflowing */
  .table-actions {
    flex-wrap: wrap;
    gap: 0.35rem;
  }

  .login-wrapper {
    padding: 1rem;
  }

  .login-card {
    padding: 1.75rem 1.35rem;
  }
}

/* ==========================================================================
   Flexible 5% & 18% GST System Styles
   ========================================================================== */

/* POS Subbar & GST Slabs Filter */
.pos-filter-subbar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--border-color);
}

.filter-sub-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.gst-filter-pills {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.gst-pill {
  padding: 0.22rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--trans-fast);
}

.gst-pill:hover:not(.active) {
  background: var(--bg-subtle);
  border-color: #cbd5e1;
  color: var(--text-primary);
}

.gst-pill.active {
  background: #0f172a;
  color: #ffffff;
  border-color: #0f172a;
}

/* Cart Header Actions & GST Mode Toggle */
.cart-header-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-gst-mode {
  padding: 0.22rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid #cbd5e1;
  background: #f1f5f9;
  color: #334155;
  cursor: pointer;
  transition: var(--trans-fast);
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.btn-gst-mode:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
}

.btn-gst-mode.exclusive {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
}

/* Cart Tax Breakdown Box */
.tax-breakdown-box {
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.45rem 0.75rem;
  margin: 0.35rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.summary-line-mini {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.summary-line-mini.tax-highlight {
  font-weight: 700;
  color: #4338ca;
  border-top: 1px dashed #cbd5e1;
  padding-top: 0.25rem;
  margin-top: 0.2rem;
}

/* GST Badges on Product Cards & Tables */
.gst-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.12rem 0.42rem;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: -0.02em;
}

.gst-tag-5 {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.gst-tag-18 {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

.gst-tag-12 {
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #fde68a;
}

.gst-tag-0 {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
}

/* Category combobox: text input + clickable dropdown of existing categories */
.combobox {
  position: relative;
}

.combobox-input {
  width: 100%;
  padding-right: 2.4rem;
  background-image: none !important;
}

.combobox-toggle {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: 2.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  transition: var(--trans-fast);
}

.combobox-toggle:hover {
  color: var(--primary);
}

.combobox.open .combobox-toggle svg {
  transform: rotate(180deg);
}

.combobox-list {
  position: absolute;
  z-index: 60;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 220px;
  overflow-y: auto;
  margin: 0;
  padding: 0.3rem;
  list-style: none;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: none;
}

.combobox.open .combobox-list {
  display: block;
}

.combobox-option {
  padding: 0.5rem 0.65rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
}

.combobox-option:hover,
.combobox-option.is-highlight {
  background: var(--primary-subtle, #eef2ff);
  color: var(--primary);
}

.combobox-option.is-active {
  color: var(--primary);
  font-weight: 700;
}

.combobox-empty {
  padding: 0.55rem 0.65rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* Required-field marker on labels */
.req-star {
  color: var(--danger);
  font-weight: 700;
}

/* Bulk-select checkbox column in the sales table */
.col-check {
  width: 36px;
  text-align: center;
}

.col-check input {
  cursor: pointer;
  width: 16px;
  height: 16px;
}

/* Per-product stock value under the Total Available badge (master view) */
.stock-value-line {
  margin-top: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  font-weight: 700;
  color: #059669;
}

.stock-value-cost {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* Stock valuation grand-total row */
.valuation-total-row td {
  border-top: 2px solid var(--border-color);
  background: var(--bg-subtle);
  font-size: 0.95rem;
}

.valuation-card .records-badge {
  font-weight: 700;
}

/* In-Cart GST Rate Selector */
.cart-item-gst-select {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.45rem;
  border-radius: var(--radius-sm);
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #1e40af;
  cursor: pointer;
  outline: none;
  transition: var(--trans-fast);
}

.cart-item-gst-select:hover, .cart-item-gst-select:focus {
  border-color: var(--primary);
  background: #ffffff;
}

/* Modal GST Quick Picker */
.gst-quick-picker {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.4rem;
  margin-top: 0.35rem;
}

.btn-gst-pick {
  padding: 0.5rem 0.6rem;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-color);
  background: #ffffff;
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--trans-fast);
  text-align: center;
}

.btn-gst-pick:hover {
  border-color: var(--primary);
  background: var(--primary-subtle);
}

.btn-gst-pick.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
}

.gst-custom-input-wrap {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.5rem;
}

.custom-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.input-with-suffix {
  display: flex;
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding-right: 0.6rem;
}

.input-with-suffix:focus-within {
  border-color: var(--primary);
}

.gst-num-input {
  border: none !important;
  width: 75px !important;
  padding: 0.35rem 0.5rem !important;
  font-size: 0.85rem !important;
  outline: none !important;
}

.input-suffix {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
}

/* Batch GST Assignment Modal */
.batch-gst-options {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.batch-option-card {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  background: #ffffff;
  cursor: pointer;
  transition: var(--trans-fast);
}

.batch-option-card:hover {
  border-color: #93c5fd;
  background: #f8fafc;
}

.batch-option-card.active {
  border-color: var(--primary);
  background: #eff6ff;
}

.batch-option-card input[type="radio"] {
  margin-top: 0.25rem;
}

.boc-body {
  flex: 1;
  font-size: 0.88rem;
}

.boc-body p {
  margin-top: 0.2rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.boc-controls {
  margin-top: 0.5rem;
  display: flex;
  gap: 0.5rem;
}

/* Printable Receipts - Tax Tables */
.receipt-tax-box {
  margin: 6px 0;
  padding: 4px 0;
  border-top: 1px dashed #cbd5e1;
  border-bottom: 1px dashed #cbd5e1;
  font-size: 0.72rem;
}

.receipt-tax-row {
  display: flex;
  justify-content: space-between;
  padding: 1px 0;
}

/* ==========================================================================
   AUTHENTICATION & LOGIN SCREEN
   ========================================================================== */

.login-wrapper {
  position: fixed;
  inset: 0; /* fill the viewport without the 100vw scrollbar-overflow that shifted the card */
  z-index: 99999;
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #0f172a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  overflow-y: auto;
}

.login-container {
  width: 100%;
  max-width: 440px;
  animation: loginSlideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes loginSlideUp {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.login-card {
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(16px);
  border-radius: 18px;
  padding: 2.5rem 2.25rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-brand-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 1rem;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  color: #fff;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 25px -5px rgba(79, 70, 229, 0.45);
}

.login-title {
  font-size: 1.6rem;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.025em;
  margin-bottom: 0.35rem;
}

.login-subtitle {
  font-size: 0.88rem;
  color: #64748b;
  font-weight: 500;
}

.login-alert {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #dc2626;
  border-radius: 10px;
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: shake 0.3s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.login-form .form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.login-form label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #334155;
}

.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
}

/* Only the decorative leading icon (direct child) is positioned — NOT the eye
   icon inside the toggle button, which used to get pulled to the left. */
.input-with-icon > svg {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  pointer-events: none;
}

.input-with-icon input {
  width: 100%;
  padding: 0.85rem 2.8rem 0.85rem 2.8rem;
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  font-size: 0.95rem;
  color: #0f172a;
  transition: all 0.2s;
}

.input-with-icon input:focus {
  outline: none;
  background: #fff;
  border-color: #4f46e5;
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.12);
}

.btn-toggle-pw {
  position: absolute;
  right: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 0.35rem;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-toggle-pw:hover {
  color: #4f46e5;
  background: #eef2ff;
}

.btn-login-submit {
  width: 100%;
  padding: 0.95rem;
  background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  cursor: pointer;
  margin-top: 0.5rem;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.35);
  transition: all 0.2s;
}

.btn-login-submit:hover {
  background: linear-gradient(135deg, #4338ca 0%, #4f46e5 100%);
  box-shadow: 0 6px 20px rgba(79, 70, 229, 0.45);
  transform: translateY(-1px);
}

.btn-login-submit:active {
  transform: translateY(0);
}

.login-demo-hint {
  margin-top: 1.75rem;
  padding: 0.85rem 1rem;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
}

.hint-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: #475569;
}

.btn-quick-fill {
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  color: #4338ca;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-quick-fill:hover {
  background: #4f46e5;
  color: #fff;
}

.hint-content {
  font-size: 0.78rem;
  color: #64748b;
}

.hint-content code {
  font-family: 'JetBrains Mono', monospace;
  background: #e2e8f0;
  padding: 1px 5px;
  border-radius: 4px;
  color: #1e293b;
}

/* User pill & Logout button in header */
.user-pill {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #334155;
}

.btn-logout {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  background: #fff;
  border: 1px solid #fecaca;
  border-radius: 20px;
  color: #dc2626;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-logout:hover {
  background: #dc2626;
  color: #fff;
  border-color: #dc2626;
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.25);
}

/* ==========================================================================
   Colour Variants (colour + size stock)
   ========================================================================== */

/* Small round colour swatch used everywhere a colour is shown */
.color-dot {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 1px solid rgba(15, 23, 42, 0.25);
  flex-shrink: 0;
  vertical-align: middle;
}

/* POS card colour selector — tap a swatch to switch which colour's sizes show */
.color-swatch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.7rem;
}

.color-swatch {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.28rem 0.6rem 0.28rem 0.4rem;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-full);
  background: var(--bg-surface);
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--trans-fast);
}
.color-swatch .color-dot {
  width: 13px;
  height: 13px;
}
.color-swatch:hover { border-color: #cbd5e1; }
.color-swatch.active {
  border-color: var(--primary);
  background: var(--primary-subtle);
  color: var(--primary);
}

/* legacy stacked colour group (kept harmless) */
.color-variant-group {
  margin-top: 0.5rem;
}

.color-variant-group + .color-variant-group {
  margin-top: 0.6rem;
  padding-top: 0.55rem;
  border-top: 1px dashed var(--border-color);
}

.color-variant-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}

/* Cart line colour pill */
.size-pill.color-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

/* Inventory table: colour-grouped size matrix */
.variant-matrix-cell {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.matrix-color-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.matrix-color-label {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-secondary);
  min-width: 72px;
}

/* Restock modal: colour-grouped size cards */
.restock-color-group + .restock-color-group {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--border-color);
}

.restock-color-head {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

/* Colour-block variant builder (Add / Edit product) */
.vb-header {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.6rem;
}

.vb-count-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.vb-count-input {
  width: 72px;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  font-size: 0.9rem;
  text-align: center;
}

.variant-builder {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.variant-block {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  padding: 0.75rem;
}

.vb-block-top {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.vb-block-top .color-dot {
  width: 16px;
  height: 16px;
}

.vb-color-name {
  flex: 1;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: #fff;
  font-size: 0.9rem;
  font-weight: 600;
}

.vb-remove-block {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: #fff;
  color: #dc2626;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

.vb-remove-block:hover {
  background: #fef2f2;
  border-color: #fca5a5;
}

.vb-sizes-field {
  margin-bottom: 0.6rem;
}

.vb-sizes-field label,
.vb-qty-block > label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.vb-block-sizes {
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: #fff;
  font-size: 0.9rem;
}

/* Per-size quantity grid */
.vb-size-qtys {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.vb-sq {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 62px;
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.25rem;
}

.vb-sq-remove {
  position: absolute;
  top: -7px;
  right: -7px;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  font-size: 0.9rem;
  line-height: 1;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.28);
  transition: var(--trans-fast);
}

.vb-sq-remove:hover {
  transform: scale(1.12);
}

.vb-sq-size {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 0.2rem;
}

.vb-sq-qty {
  width: 100%;
  border: none;
  border-top: 1px solid var(--border-color);
  padding: 0.25rem 0.2rem 0;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 600;
  background: transparent;
  outline: none;
}

.vb-sq-empty {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
}

/* In edit mode we manage structure only, not per-cell stock: show the size
   chips (so each can be deleted with its × button) but hide the qty inputs and
   the "Quantity for each size" label — stock is changed via Restock. */
.variant-builder.edit-mode .vb-qty-block > label {
  display: none;
}

.variant-builder.edit-mode .vb-sq-qty {
  display: none;
}

.variant-builder.edit-mode .vb-sq {
  padding: 0.4rem 0.55rem;
}

.variant-builder.edit-mode .vb-sq-size {
  margin-bottom: 0;
}

.btn-add-color {
  margin-top: 0.6rem;
  font-size: 0.85rem;
  padding: 0.45rem 0.9rem;
}

/* Add-vs-Set stock mode toggle in the restock modal */
.stock-mode-toggle {
  display: flex;
  gap: 4px;
  background: #e2e8f0;
  padding: 3px;
  border-radius: var(--radius-md);
  margin-top: 0.25rem;
}

.stock-mode-btn {
  flex: 1;
  border: none;
  background: transparent;
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--trans-fast);
}

.stock-mode-btn.active {
  background: #ffffff;
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

/* Inline helper text under a form input */
.field-help {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.72rem;
  line-height: 1.4;
  color: var(--text-muted);
}

/* Product modal hint under the colour/size inputs */
.variant-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.65rem;
  margin-top: 0.25rem;
}

/* ==========================================================================
   Roles, Returns & User Management
   ========================================================================== */

/* Master-only elements are hidden for every role except admin */
body:not(.role-admin) .master-only { display: none !important; }

.master-badge {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #7c3aed;
  background: #f3e8ff;
  border-radius: var(--radius-full);
  padding: 1px 7px;
  margin-left: 0.35rem;
  vertical-align: middle;
}

.cost-line {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  margin-top: 2px;
}

/* Users list */
.users-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
}

.user-info { display: flex; flex-direction: column; }
.user-name { font-weight: 700; font-size: 0.9rem; }
.user-username { font-size: 0.75rem; color: var(--text-muted); }
.you-tag {
  font-size: 0.6rem; font-weight: 700; text-transform: uppercase;
  background: var(--primary-subtle); color: var(--primary);
  padding: 1px 6px; border-radius: var(--radius-full); margin-left: 0.35rem;
}
.user-actions { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.user-role-select { padding: 0.35rem 0.5rem; font-size: 0.8rem; }

.add-user-form {
  border-top: 1px dashed var(--border-color);
  padding-top: 0.9rem;
}
.add-user-title { font-size: 0.85rem; font-weight: 700; margin-bottom: 0.6rem; color: var(--text-secondary); }

/* Return / Refund modal */
.return-items-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0.75rem 0;
  max-height: 320px;
  overflow-y: auto;
}

.return-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
}
.return-item.is-done { opacity: 0.55; }

.return-item-pick { display: flex; align-items: flex-start; gap: 0.55rem; cursor: pointer; }
.return-item-pick input { margin-top: 3px; }
.ri-name { display: block; font-weight: 600; font-size: 0.88rem; }
.ri-meta { display: block; font-size: 0.72rem; color: var(--text-muted); }

.return-item-qty { display: flex; flex-direction: column; align-items: flex-end; gap: 0.2rem; flex-shrink: 0; }
.ri-max { font-size: 0.68rem; color: var(--text-muted); }
.return-item-qtyinput {
  width: 64px; text-align: center; padding: 0.35rem;
  border: 1px solid var(--border-color); border-radius: var(--radius-sm);
  font-size: 0.9rem; font-weight: 600;
}

.return-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius-md);
  font-weight: 700;
}
.return-summary span:last-child { font-family: 'JetBrains Mono', monospace; color: #dc2626; font-size: 1.1rem; }

/* Cancelled (voided) bills in the sales ledger */
.row-voided { background: #fef2f2; }
.row-voided td { color: var(--text-muted); }
.row-voided .size-pill { opacity: 0.6; }

.status-badge {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  margin-left: 0.4rem;
  vertical-align: middle;
}
.status-voided {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

/* ==========================================================================
   History / Search / Edit-bill / Stock-history
   ========================================================================== */

/* Search + filter bar (sales & activity) */
.sales-search-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.sales-search-box { flex: 1 1 280px; min-width: 0; }
.sales-range { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.sales-range label {
  display: inline-flex; align-items: center; gap: 0.35rem;
  font-size: 0.78rem; color: var(--text-secondary); font-weight: 600;
}
.date-picker-input {
  padding: 0.4rem 0.55rem; border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); background: var(--bg-subtle); font-size: 0.85rem;
}

/* Wider modal (edit bill) */
.modal-card.modal-wide { max-width: 640px; }

/* Edit bill items */
.edit-items-label { display:block; font-size:0.75rem; font-weight:700; color:var(--text-muted); margin: 0.5rem 0 0.35rem; }
.edit-bill-items { display: flex; flex-direction: column; gap: 0.45rem; }
.edit-bill-item {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.5rem 0.65rem; border: 1px solid var(--border-color);
  border-radius: var(--radius-md); background: var(--bg-subtle);
}
.ebi-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ebi-name { font-weight: 600; font-size: 0.85rem; text-transform: capitalize; }
.ebi-variant { font-size: 0.72rem; color: var(--text-muted); }
.ebi-field { display: inline-flex; align-items: center; gap: 2px; font-size: 0.8rem; color: var(--text-muted); }
.ebi-field input {
  width: 66px; padding: 0.35rem; text-align: center; font-weight: 600;
  border: 1px solid var(--border-color); border-radius: var(--radius-sm); background: #fff;
}
.ebi-line { width: 78px; text-align: right; font-family: 'JetBrains Mono', monospace; font-weight: 700; font-size: 0.85rem; }
.ebi-remove {
  width: 26px; height: 26px; flex-shrink: 0; border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); background: #fff; color: #dc2626; font-size: 1.05rem; cursor: pointer;
}
.ebi-remove:hover { background: #fef2f2; }

.edit-add-wrap { margin-top: 0.75rem; }
.edit-add-results { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.4rem; }
.edit-add-chip {
  border: 1px solid var(--border-color); background: #fff; border-radius: var(--radius-full);
  padding: 0.3rem 0.7rem; font-size: 0.78rem; cursor: pointer; transition: var(--trans-fast);
}
.edit-add-chip:hover:not(:disabled) { border-color: var(--primary); background: var(--primary-subtle); }
.edit-add-chip:disabled { opacity: 0.5; cursor: not-allowed; }

.edit-bill-total-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 1rem; padding: 0.75rem 1rem; background: var(--primary-subtle);
  border-radius: var(--radius-md); font-weight: 700;
}
.edit-bill-total-row span:last-child { font-family: 'JetBrains Mono', monospace; color: var(--primary); font-size: 1.1rem; }

/* Stock history list */
.stock-history-list { display: flex; flex-direction: column; gap: 0.4rem; max-height: 420px; overflow-y: auto; }
.sh-row {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  padding: 0.55rem 0.7rem; border: 1px solid var(--border-color); border-radius: var(--radius-md); background: var(--bg-surface);
}
.sh-left { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.sh-variant { font-weight: 700; font-size: 0.85rem; }
.sh-reason { font-size: 0.75rem; color: var(--text-secondary); }
.sh-meta { font-size: 0.68rem; color: var(--text-muted); }
.sh-right { display: flex; align-items: baseline; gap: 0.5rem; flex-shrink: 0; }
.sh-change { font-family: 'JetBrains Mono', monospace; font-weight: 800; font-size: 0.95rem; }
.sh-change.up { color: #059669; }
.sh-change.down { color: #dc2626; }
.sh-balance { font-size: 0.75rem; color: var(--text-muted); font-family: 'JetBrains Mono', monospace; }

/* ==========================================================================
   UI Polish (v9) — refinement pass, works on mobile & desktop
   ========================================================================== */

/* Slim, unobtrusive scrollbars everywhere */
* {
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 8px; }
*::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* Nav tabs: keep horizontal scroll on narrow screens but hide the ugly scrollbar */
.nav-tabs { scrollbar-width: none; }
.nav-tabs::-webkit-scrollbar { display: none; }

/* Cards lift gently on hover for a more tactile feel */
.stat-card, .product-card, .table-card, .settings-card {
  transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}
.stat-card:hover, .settings-card:hover {
  box-shadow: 0 10px 24px -12px rgba(15, 23, 42, 0.18);
}

/* Primary button: subtle gradient + lift */
.btn-primary {
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  border: none;
  box-shadow: 0 4px 12px -4px rgba(37, 99, 235, 0.5);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px -6px rgba(37, 99, 235, 0.55);
}
.btn-primary:active { transform: translateY(0); }

/* Row action buttons: rounder, clearer affordance */
.btn-icon-action {
  border-radius: var(--radius-md);
  transition: var(--trans-fast);
}
.btn-icon-action:hover {
  background: var(--primary-subtle);
  border-color: var(--primary);
  color: var(--primary);
}
.btn-icon-action.danger:hover {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #dc2626;
}

/* Smooth row hover */
.data-table tbody tr { transition: background 0.12s ease; }

/* Inputs: smoother focus ring */
.input-group input:focus, .input-group select:focus,
.search-box:focus-within, .select-dropdown:focus, .date-picker-input:focus {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* Modals: a touch more depth and a smoother entrance */
.modal-card {
  box-shadow: 0 30px 60px -20px rgba(15, 23, 42, 0.4);
}

/* Toast: cleaner */
.toast { box-shadow: 0 12px 28px -10px rgba(15, 23, 42, 0.35); }

/* ---- Header: drop the nav to its own row when it can't fit on one line ----
   The brand + 5 nav tabs + status pills need ~1600px; below that we put the
   nav on a centered second row so nothing squeezes or overflows. */
@media (max-width: 1600px) {
  :root {
    --header-height: 96px;
  }
  .app-header {
    flex-wrap: wrap;
    height: auto;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    row-gap: 0.5rem;
  }
  .header-brand { order: 1; }
  .header-right { order: 2; }
  .nav-tabs {
    order: 3;
    width: 100%;
    justify-content: center;
    overflow-x: auto;
  }
  /* Clock is decorative — drop it on the top row to keep it tidy */
  .live-clock { display: none; }
}

/* Two-column desktop POS (products + sticky cart side by side): keep it
   viewport-fitted so the cart's Generate Bill button stays in view and each
   column scrolls on its own. This must NOT apply once the layout stacks
   (<=1024px), or the cart items get crushed into a tiny internal scrollbar. */
@media (min-width: 1025px) and (max-width: 1600px) {
  .pos-layout {
    height: calc(100vh - var(--header-height) - 2.5rem);
    min-height: 0;
  }
  .pos-cart-column {
    max-height: calc(100vh - var(--header-height) - 2.5rem);
    top: calc(var(--header-height) + 1.25rem);
  }
  .products-grid-container {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
  }
}

/* ---- Mobile-specific finishing touches ---- */
@media (max-width: 768px) {
  /* Header: tighten and let the user pill/logout wrap neatly */
  .app-header { padding: 0.6rem 0.9rem; }
  .header-brand { gap: 0.6rem; }
  .brand-icon { width: 34px; height: 34px; }

  /* Nav tabs scroll as a neat pill strip */
  .nav-tabs {
    padding: 4px;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
  }
  .nav-tab { scroll-snap-align: start; }

  /* Give tables a hint they scroll sideways */
  .table-responsive {
    border-radius: var(--radius-md);
    -webkit-overflow-scrolling: touch;
  }

  /* Search/filter bars stack full width */
  .sales-search-bar { flex-direction: column; align-items: stretch; }
  .sales-search-bar .search-box,
  .sales-search-bar .select-dropdown { width: 100%; }
  .sales-range { justify-content: space-between; }
  .sales-range label { flex: 1; }
  .sales-range input { flex: 1; min-width: 0; }

  /* Modals nearly full-screen on phones */
  .modal-card, .modal-card.modal-wide { max-width: 100%; }

  /* Larger tap targets for row actions */
  .btn-icon-action { padding: 0.45rem 0.7rem; }
}

/* Very small phones */
@media (max-width: 400px) {
  .stat-card { padding: 0.8rem; gap: 0.6rem; }
  .stat-icon { width: 38px; height: 38px; }
  .stat-number { font-size: 1.05rem; }
  .tab-view { padding: 0.7rem; }
}
