@import url("ui-system.css");

:root {
  --primary: #2563EB;
  --primary-dark: #1D4ED8;
  --primary-light: #3B82F6;
  --primary-glow: rgba(37, 99, 235, 0.18);
  --bg-dark: #0F172A;
  --bg-surface: #1E293B;
  --bg-page: #F8FAFC;
  --border: #E2E8F0;
  --border-strong: #CBD5E1;
  --text: #0F172A;
  --text-muted: #64748B;
  --white: #ffffff;
  --green: #10B981;
  --green-dark: #059669;
  --red: #EF4444;
  --red-dark: #DC2626;
  --amber: #F59E0B;
  --radius: 16px;
  --radius-sm: 14px;
  --radius-lg: 18px;
  --shadow-soft: 0 4px 24px rgba(15, 23, 42, 0.06);
  --shadow-card: 0 8px 32px rgba(15, 23, 42, 0.08);
  --shadow-modal: 0 24px 64px rgba(15, 23, 42, 0.18);
  --glass-bg: rgba(255, 255, 255, 0.78);
  --glass-border: rgba(255, 255, 255, 0.45);
  --transition: 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  --topbar-h: 60px;
  --nav-h: 48px;

  /* legacy aliases */
  --blue: var(--primary);
  --blue-dark: var(--primary-dark);
  --gray-50: var(--bg-page);
  --gray-100: #F1F5F9;
  --gray-200: var(--border);
  --gray-500: var(--text-muted);
  --gray-800: var(--bg-surface);
  --shadow: var(--shadow-soft);
  --surface-2: #F1F5F9;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-page);
  color: var(--text);
  min-width: 1180px;
  -webkit-font-smoothing: antialiased;
}

body.login-page {
  background:
    radial-gradient(ellipse 80% 60% at 20% 10%, rgba(37, 99, 235, 0.35), transparent),
    radial-gradient(ellipse 60% 50% at 80% 90%, rgba(30, 41, 59, 0.5), transparent),
    linear-gradient(145deg, var(--bg-dark) 0%, #1a2744 45%, var(--bg-surface) 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

body.receipt-page {
  background: var(--white);
  min-width: auto;
}

a {
  color: var(--primary);
  transition: color var(--transition);
}

a:hover { color: var(--primary-dark); }

/* ── Shell ── */
.pos-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 100vh;
  background: var(--bg-page);
}

.pos-shell.pos-mode .pos-main { padding: 0; }

.pos-topbar {
  height: var(--topbar-h);
  background: linear-gradient(135deg, var(--bg-dark) 0%, var(--bg-surface) 100%);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.15);
}

.pos-brand {
  font-weight: 800;
  font-size: 1.2rem;
  letter-spacing: 0.06em;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.pos-brand::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 12px var(--primary-glow);
}

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

.pos-datetime {
  text-align: right;
  font-size: 0.8rem;
  line-height: 1.4;
  opacity: 0.9;
  font-variant-numeric: tabular-nums;
}

.pos-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  font-size: 0.85rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.pos-user-role {
  opacity: 0.8;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(37, 99, 235, 0.35);
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
}

.pos-topbar-link {
  color: var(--white);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.82rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-sm);
  transition: background var(--transition), border-color var(--transition);
}

.pos-topbar-link:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.35);
}

.btn-logout {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #FECACA;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  transition: background var(--transition), transform var(--transition);
}

.btn-logout:hover {
  background: rgba(239, 68, 68, 0.28);
  transform: translateY(-1px);
}

.pos-nav {
  height: var(--nav-h);
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  padding: 0 1rem;
  gap: 0.15rem;
  flex-shrink: 0;
  box-shadow: var(--shadow-soft);
}

.pos-nav a {
  display: flex;
  align-items: center;
  padding: 0 1.1rem;
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.88rem;
  border-bottom: 3px solid transparent;
  transition: color var(--transition), background var(--transition), border-color var(--transition);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.pos-nav a:hover {
  color: var(--primary);
  background: rgba(37, 99, 235, 0.06);
}

.pos-nav a.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: rgba(37, 99, 235, 0.08);
}

.pos-main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pos-main.page-scroll {
  overflow: auto;
  padding: 1.5rem;
}

/* ── POS Layout ── */
.pos-sale-layout {
  flex: 1;
  display: grid;
  grid-template-columns: 290px 1fr 320px;
  grid-template-rows: minmax(0, 1fr);
  min-height: 0;
  height: 100%;
  gap: 0;
}

#page-content:has(.pos-sale-layout) {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pos-col-left,
.pos-col-center,
.pos-col-right {
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--white);
  border-right: 1px solid var(--border);
}

.pos-col-right { border-right: none; }

.pos-col-left {
  padding: 1rem;
  gap: 0.65rem;
  background: var(--bg-page);
}

.pos-col-left-scroll {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  height: 100%;
}

.product-catalog-panel {
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  min-height: 0;
  gap: 0.55rem;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem;
  box-shadow: var(--shadow-soft);
}

.product-catalog-panel .product-list {
  flex: 0 0 auto;
  height: auto;
  min-height: 0;
  max-height: 320px;
  overflow-y: auto;
  overflow-x: hidden;
  border: none;
  border-radius: var(--radius-sm);
}

.product-search-input { flex-shrink: 0; }

.product-search-input::-webkit-search-cancel-button,
.product-search-input::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
  display: none;
}

.pos-receipt-tools {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.85rem;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.pos-col-center {
  border-right: 1px solid var(--border);
  background: var(--white);
}

.pos-col-right {
  padding: 1rem;
  gap: 0.65rem;
  overflow: hidden;
  background: linear-gradient(180deg, #FAFBFC 0%, var(--white) 100%);
}

.pos-col-right > .field-label,
.pos-col-right > .field-input,
.pos-col-right > .debt-customer-block,
.pos-col-right > .pay-actions,
.pos-col-right > .hint-keys {
  flex-shrink: 0;
}

.pos-col-right .right-payment-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-top: 0.35rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
  overflow: visible;
}

.right-payment-totals {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 1rem;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.right-cash-box {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  width: 100%;
  flex-shrink: 0;
  background: linear-gradient(135deg, #ECFDF5 0%, #F0FDF4 100%);
  border: 1px solid #A7F3D0;
  border-left: 4px solid var(--green);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.85rem;
  margin: 0.15rem 0 0;
  box-sizing: border-box;
}

.right-payment-divider {
  flex-shrink: 0;
  border-top: 1px dashed var(--border);
  margin: 0.35rem 0 0.15rem;
}

.right-cash-box .cash-badge-label,
.cash-badge-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.right-cash-box .cash-badge-amount,
.cash-badge-amount {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--green-dark);
  line-height: 1.2;
  margin-top: 0.15rem;
  font-variant-numeric: tabular-nums;
}

.right-payment-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.right-payment-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.right-payment-value {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.right-payment-total-main .right-payment-value {
  font-size: clamp(1.5rem, 2.2vw, 2rem);
  color: var(--primary);
}

.right-payment-input {
  font-size: 1.05rem;
  padding: 0.7rem 0.85rem;
  font-weight: 700;
}

/* ── Form elements ── */
.field-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field-input,
.field-select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  background: var(--white);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.field-input:focus,
.field-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.field-input-lg {
  font-size: 1.15rem;
  padding: 0.8rem 0.9rem;
  font-weight: 600;
}

/* ── Product list ── */
.product-list {
  flex: 0 0 auto;
  height: auto;
  min-height: 0;
  max-height: 300px;
  overflow-y: auto;
  overflow-x: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-page);
}

.product-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
}

.product-row:hover {
  background: rgba(37, 99, 235, 0.06);
}

.product-row:active { transform: scale(0.995); }

.product-row-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.product-row-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.product-row-price {
  color: var(--primary);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.product-list-empty,
.empty-state {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.empty-state-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  opacity: 0.4;
}

.product-list-more {
  padding: 0.65rem;
  text-align: center;
}

.cash-badge {
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-left: 4px solid var(--green);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
}

/* ── Cart ── */
.pos-col-center {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.cart-table-wrap {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
}

.cart-table-wrap::-webkit-scrollbar { width: 8px; }
.cart-table-wrap::-webkit-scrollbar-track { background: transparent; }
.cart-table-wrap::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.35);
  border-radius: 999px;
}
.cart-table-wrap::-webkit-scrollbar-thumb:hover { background: rgba(100, 116, 139, 0.55); }

.page-scroll-panel {
  max-height: calc(100vh - 220px);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}

.low-stock-section + .low-stock-section { margin-top: 1.25rem; }

.low-stock-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  align-items: stretch;
  min-height: calc(100vh - 220px);
}

.low-stock-column {
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.low-stock-column-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.low-stock-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.low-stock-scroll {
  flex: 1;
  min-height: 240px;
  max-height: calc(100vh - 260px);
  overflow-y: auto;
  overflow-x: hidden;
}

@media (max-width: 960px) {
  .low-stock-grid {
    grid-template-columns: 1fr;
    min-height: auto;
  }
  .low-stock-scroll {
    max-height: 360px;
  }
}

.pos-payment-modal .modal-card {
  width: min(420px, 92vw);
  border-radius: 16px;
  padding: 1.25rem 1.35rem;
}

.pos-payment-card h3 {
  text-align: center;
  letter-spacing: 0.04em;
  margin-bottom: 1rem;
}

.payment-type-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.payment-choice {
  min-height: 88px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.payment-choice:hover {
  border-color: #2563eb;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.12);
}

.admin-auth-card {
  width: min(420px, 92vw);
}

.low-stock-section-title {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  font-weight: 700;
}

.btn-pay-return {
  border-color: #f59e0b;
  color: #b45309;
}

.return-modal-card {
  width: min(760px, 96vw);
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.return-items-scroll {
  flex: 1;
  min-height: 180px;
  max-height: 340px;
  overflow: auto;
  overscroll-behavior: contain;
  margin-top: 0.5rem;
}

.cart-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.cart-table thead th {
  position: sticky;
  top: 0;
  background: var(--bg-page);
  border-bottom: 2px solid var(--border);
  padding: 0.75rem 0.65rem;
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: 0.04em;
  z-index: 1;
}

.cart-table tbody td {
  padding: 0.65rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.cart-table tbody tr {
  transition: background var(--transition);
}

.cart-table tbody tr:hover { background: rgba(37, 99, 235, 0.03); }

.cart-table input[type=number] {
  width: 56px;
  padding: 0.35rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-align: center;
}

.cart-table .col-amount {
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
  color: var(--primary);
}

.btn-remove {
  background: var(--red);
  color: var(--white);
  border: none;
  border-radius: var(--radius-sm);
  width: 30px;
  height: 30px;
  cursor: pointer;
  font-weight: 700;
  transition: background var(--transition), transform var(--transition);
}

.btn-remove:hover {
  background: var(--red-dark);
  transform: scale(1.05);
}

.qty-control {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.qty-control button {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  background: var(--white);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 700;
  transition: background var(--transition), border-color var(--transition);
}

.qty-control button:hover {
  background: var(--bg-page);
  border-color: var(--primary);
  color: var(--primary);
}

/* ── Payment buttons ── */
.pay-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  width: 100%;
}

.pay-actions-primary {
  grid-template-columns: 1fr 1.15fr;
  align-items: stretch;
}

.pay-actions-full {
  grid-column: 1 / -1;
}

.btn-pay-settle {
  grid-column: 2;
  grid-row: 1;
}

#btnCard {
  grid-column: 1;
  grid-row: 1;
}

.pay-actions .btn-pay-type,
.pay-actions .btn-quick-pay {
  min-width: 0;
  width: 100%;
  padding: 0.6rem 0.4rem;
  font-size: clamp(0.72rem, 1.6vw, 0.88rem);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-pay-type {
  border: 2px solid var(--border);
  background: var(--white);
  border-radius: var(--radius-sm);
  font-weight: 700;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 2.85rem;
  transition: border-color var(--transition), background var(--transition), transform var(--transition);
}

.btn-pay-type:hover:not(:disabled) {
  border-color: var(--primary-light);
  transform: translateY(-1px);
}

.btn-pay-type.active {
  border-color: var(--primary);
  background: rgba(37, 99, 235, 0.1);
  color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.btn-quick-pay,
.btn-pay-settle {
  background: linear-gradient(135deg, var(--green) 0%, var(--green-dark) 100%);
  color: var(--white);
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 800;
  cursor: pointer;
  min-height: 2.85rem;
  transition: transform var(--transition), box-shadow var(--transition);
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
}

.btn-quick-pay:hover,
.btn-pay-settle:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.35);
}

.pay-btn-label { display: block; }

.pay-btn-badge {
  display: block;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-top: 2px;
  opacity: 0.85;
}

.footer-given {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.btn-cancel-pay {
  background: linear-gradient(135deg, var(--red) 0%, var(--red-dark) 100%);
  color: var(--white);
  border: none;
  padding: 0.9rem 1rem;
  font-size: 0.95rem;
  font-weight: 800;
  border-radius: var(--radius-sm);
  cursor: pointer;
  letter-spacing: 0.04em;
  transition: transform var(--transition), box-shadow var(--transition);
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.25);
}

.btn-cancel-pay-block {
  width: 100%;
  flex-shrink: 0;
  margin-top: auto;
}

.btn-cancel-pay:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.3);
}

.btn-finish-pay {
  background: linear-gradient(135deg, var(--green) 0%, var(--green-dark) 100%);
  color: var(--white);
  border: none;
  padding: 0.9rem 2rem;
  font-size: 1.05rem;
  font-weight: 800;
  border-radius: var(--radius-sm);
  cursor: pointer;
  min-width: 160px;
}

.btn-finish-pay:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-pay-settle.btn-pay-blocked,
.btn-pay-settle:disabled {
  background: #94A3B8 !important;
  border-color: #94A3B8 !important;
  cursor: not-allowed !important;
  opacity: 0.85;
  box-shadow: none !important;
  transform: none !important;
}

.btn-pay-main {
  width: 100%;
  margin-top: 8px;
  padding: 14px;
  font-size: 1.1rem;
  font-weight: 800;
  border: none;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--green) 0%, var(--green-dark) 100%);
  color: #fff;
  cursor: pointer;
}

.btn-pay-disabled,
.btn-pay-type:disabled {
  background: #F1F5F9 !important;
  color: #94A3B8 !important;
  border-color: var(--border) !important;
  cursor: not-allowed !important;
  pointer-events: none;
  box-shadow: none !important;
}

/* ── Page cards & tables ── */
.page-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  margin-bottom: 1.25rem;
  transition: box-shadow var(--transition);
}

.page-card:hover { box-shadow: 0 12px 40px rgba(15, 23, 42, 0.1); }

.page-card.border-warning { border-left: 4px solid var(--amber); }

.page-card-body { padding: 1.5rem; }

.page-card-flush .page-card-body { padding: 0; }

.page-title {
  margin: 0 0 1.25rem;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}

.page-title-dynamic { margin: 0 0 1.25rem; }

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

@media (min-width: 1100px) {
  .stat-row { grid-template-columns: repeat(6, 1fr); }
}

.stat-box {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  border-left: 4px solid var(--primary);
  box-shadow: var(--shadow-soft);
  transition: transform var(--transition), box-shadow var(--transition);
}

.stat-box:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card);
}

.stat-box.success { border-left-color: var(--green); }
.stat-box.warning { border-left-color: var(--amber); }
.stat-box.danger { border-left-color: var(--red); }

.stat-box-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.stat-box-value {
  font-size: 1.5rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

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

.data-table thead th {
  background: var(--bg-page);
  padding: 0.85rem 1.1rem;
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
}

.data-table tbody td {
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background var(--transition);
}

.data-table tbody tr:hover { background: rgba(37, 99, 235, 0.04); }

.data-table th.sortable {
  cursor: pointer;
  user-select: none;
}

.data-table th.sortable:hover { color: var(--primary); }

.table-scroll { overflow-x: auto; overflow-y: auto; max-height: calc(100vh - 220px); overscroll-behavior: contain; }

.cash-log-table { width: 100%; }

.cash-log-table th,
.cash-log-table td {
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

/* ── Buttons ── */
.btn-tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.55rem 1rem;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
}

.btn-tool:hover { transform: translateY(-1px); }

.btn-tool:active,
.btn-tool.is-pressed,
.btn-pay-type:active,
.btn-pay-type.is-pressed,
.pos-nav-link.is-pressed {
  transform: translateY(1px);
  opacity: 0.92;
  transition: transform 0.05s ease, opacity 0.05s ease;
}

.btn-tool-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: var(--white);
  border: none;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-tool-primary:hover {
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.35);
  color: var(--white);
}

.btn-tool-success {
  background: linear-gradient(135deg, var(--green) 0%, var(--green-dark) 100%);
  color: var(--white);
  border: none;
}

.btn-tool-danger {
  background: linear-gradient(135deg, var(--red) 0%, var(--red-dark) 100%);
  color: var(--white);
  border: none;
}

.btn-tool-outline {
  background: var(--white);
  border-color: var(--border);
  color: var(--text);
}

.btn-tool-outline:hover {
  background: var(--bg-page);
  border-color: var(--primary-light);
  color: var(--primary);
}

.btn-tool-warning {
  background: linear-gradient(135deg, var(--amber) 0%, #D97706 100%);
  color: var(--white);
  border: none;
}

.btn-tool-sm { padding: 0.38rem 0.7rem; font-size: 0.78rem; }

/* Bootstrap-compat utilities */
.d-flex { display: flex; }
.d-flex.align-items-end { align-items: flex-end; }
.gap-2 { gap: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mb-3 { margin-bottom: 1rem; }
.nowrap { white-space: nowrap; }
.small { font-size: 0.82rem; }
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1.25rem;
}
.toolbar .field-input { flex: 1; min-width: 180px; }
.badge {
  display: inline-block;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}
.bg-secondary { background: var(--bg-surface); color: var(--white); }
.btn-sm { padding: 0.35rem 0.65rem; font-size: 0.8rem; }
.btn { display: inline-flex; align-items: center; border-radius: var(--radius-sm); cursor: pointer; font-weight: 600; }
.btn-outline-primary { background: var(--white); border: 1px solid var(--primary); color: var(--primary); }
.me-1 { margin-right: 0.25rem; }
.col-md-3, .col-md-4, .col-md-6, .col-md-8, .col-md-12 { min-width: 0; }

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1.25rem;
}

.filter-bar .field-input,
.filter-bar .field-select {
  width: auto;
  min-width: 150px;
}

.muted { color: var(--text-muted); font-size: 0.875rem; }
.text-center { text-align: center; }

.badge-status {
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}

.badge-active { background: #FEE2E2; color: var(--red-dark); }
.badge-paid, .badge-cash { background: #D1FAE5; color: var(--green-dark); }
.badge-debt { background: #FEE2E2; color: var(--red-dark); }

.stock-ok { color: var(--green-dark); font-weight: 600; }
.stock-low { color: var(--amber); font-weight: 600; }
.stock-out { color: var(--red); font-weight: 600; }
.stock-zero { color: var(--red); font-weight: 700; }
.stock-one { color: #EA580C; font-weight: 700; }

/* ── Dashboard cards ── */
.quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.25rem;
}

.quick-card {
  display: block;
  padding: 1.65rem 1.25rem;
  text-align: center;
  text-decoration: none;
  color: inherit;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  font-weight: 700;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}

.quick-card:hover {
  border-color: var(--primary);
  transform: translateY(-3px);
  box-shadow: var(--shadow-card);
}

.quick-card small {
  display: block;
  margin-top: 0.4rem;
  font-weight: 400;
  color: var(--text-muted);
}

.report-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.report-stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.25rem 1.15rem;
  min-height: 110px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  justify-content: center;
  border: 1px solid var(--border);
  transition: transform var(--transition);
}

.report-stat-card:hover { transform: translateY(-2px); }

.report-stat-card.orange { border-left: 4px solid var(--amber); }
.report-stat-card.red { border-left: 4px solid var(--red); }
.report-stat-card.green { border-left: 4px solid var(--green); }

.report-stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.report-stat-value {
  font-size: 1.45rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.cash-action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
}

.cash-action-block {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  align-items: end;
}

.form-grid .span-2 { grid-column: span 2; }

/* Products — barcode button below input (input grid position unchanged) */
.product-barcode-field {
  min-width: 0;
}

.product-barcode-slot {
  position: relative;
  width: 100%;
}

.product-barcode-slot > .field-input {
  width: 100%;
}

.product-barcode-slot > .btn-barcode-generate {
  position: absolute;
  left: 0;
  right: 0;
  width: 100%;
  top: calc(100% + 0.5rem);
}

.form-grid-has-barcode {
  overflow: visible;
  padding-bottom: calc(2.5rem + 0.5rem);
}

.btn-barcode-generate {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  min-height: 2.5rem;
}

.btn-barcode-generate:focus-visible {
  outline: 2px solid var(--primary-light);
  outline-offset: 2px;
}

.btn-barcode-generate:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-barcode-generate:active:not(:disabled) {
  transform: translateY(0);
  filter: brightness(0.95);
}

.btn-barcode-generate-icon {
  font-size: 1rem;
  line-height: 1;
}

.btn-barcode-generate-spinner {
  display: none;
  width: 1rem;
  height: 1rem;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: barcodeBtnSpin 0.7s linear infinite;
}

.btn-barcode-generate.is-loading .btn-barcode-generate-spinner {
  display: inline-block;
}

.btn-barcode-generate.is-loading .btn-barcode-generate-icon {
  display: none;
}

@keyframes barcodeBtnSpin {
  to { transform: rotate(360deg); }
}

@media (max-width: 480px) {
  .product-barcode-field {
    grid-column: 1 / -1;
  }
}

/* ── Login ── */
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--glass-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 2.75rem 2.5rem;
  box-shadow: var(--shadow-modal);
}

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

.login-logo h1 {
  margin: 0;
  color: var(--white);
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.login-logo p {
  margin: 0.5rem 0 0;
  color: rgba(255, 255, 255, 0.65);
  font-size: 0.9rem;
}

body.login-page .field-label { color: rgba(255, 255, 255, 0.7); }

body.login-page .field-input {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(255, 255, 255, 0.3);
}

.login-actions { margin-top: 1.5rem; }

.login-actions .btn-tool {
  width: 100%;
  padding: 0.95rem;
  font-size: 1rem;
  border-radius: var(--radius-sm);
}

/* ── Modals ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: fadeIn 0.2s ease;
}

.modal-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  width: min(440px, 92vw);
  box-shadow: var(--shadow-modal);
  border: 1px solid var(--border);
  animation: slideUp 0.25s ease;
}

.modal-card h3 {
  margin: 0 0 1.25rem;
  font-size: 1.15rem;
  font-weight: 800;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

/* ── Toast ── */
#toast-container {
  position: fixed;
  top: calc(var(--topbar-h) + 12px);
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  min-width: 240px;
  max-width: 380px;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-card);
  font-weight: 600;
  font-size: 0.92rem;
  opacity: 0;
  transform: translateX(24px);
  transition: opacity 0.35s ease, transform 0.35s ease;
  pointer-events: auto;
  backdrop-filter: blur(12px);
}

.toast-show { opacity: 1; transform: translateX(0); }

.toast-success {
  background: rgba(209, 250, 229, 0.95);
  color: #065F46;
  border: 1px solid #6EE7B7;
}

.toast-error {
  background: rgba(254, 226, 226, 0.95);
  color: #991B1B;
  border: 1px solid #FCA5A5;
  white-space: pre-line;
}

.toast-info {
  background: rgba(219, 234, 254, 0.95);
  color: #1E40AF;
  border: 1px solid #93C5FD;
}

/* ── Banners ── */
.cash-session-banner {
  background: #FFFBEB;
  border: 1px solid #FDE68A;
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin-bottom: 1.25rem;
  color: #92400E;
}

.cash-recovery-banner {
  background: #FEF2F2;
  border: 1px solid #FECACA;
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin-bottom: 1.25rem;
  color: #991B1B;
}

.cash-recovery-modal {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.cash-recovery-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
}

.cash-recovery-dialog {
  position: relative;
  z-index: 1;
  max-width: 480px;
  width: 100%;
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-modal);
}

.cash-recovery-dialog h2 {
  font-size: 1.15rem;
  margin: 0 0 0.5rem;
  color: var(--red-dark);
}

.cash-recovery-meta {
  font-size: 0.9rem;
  line-height: 1.55;
  margin-top: 0.75rem;
}

.cash-recovery-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

.debt-customer-block {
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.hint-keys {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 0.4rem;
  padding: 0.35rem 0.5rem;
  background: var(--bg-page);
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border);
}

.alert-note {
  background: #FFFBEB;
  border: 1px solid #FDE68A;
  border-radius: var(--radius-sm);
  padding: 0.85rem 1.1rem;
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
}

.chart-wrap { position: relative; height: 280px; }
.section-hidden { display: none !important; }

/* ── System info ── */
.system-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem 1.5rem;
}

.system-info-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.system-info-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  padding: 0.65rem 0.85rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  user-select: text;
}

.system-info-locked {
  margin-top: 1.5rem;
  padding: 0.9rem 1.1rem;
  border-radius: var(--radius-sm);
  background: #ECFDF5;
  border: 1px solid #A7F3D0;
  color: var(--green-dark);
  font-weight: 600;
  text-align: center;
  font-size: 0.88rem;
}

/* ── Loading & Skeleton ── */
#page-loading {
  position: fixed;
  inset: 0;
  z-index: 10040;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(4px);
}

#page-loading.is-active { display: flex; }

.page-loading-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 2rem 2.5rem;
  box-shadow: var(--shadow-modal);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.page-loading-text {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.skeleton {
  background: linear-gradient(90deg, #F1F5F9 25%, #E2E8F0 50%, #F1F5F9 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 8px;
}

.skeleton-cell {
  height: 16px;
  width: 80%;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Responsive ── */
@media (max-width: 1400px) {
  .pos-sale-layout { grid-template-columns: 260px 1fr 290px; }
}

@media (max-width: 1280px) {
  body { min-width: 1024px; }
  .pos-sale-layout { grid-template-columns: 240px 1fr 270px; }
}

@media (max-width: 1100px) {
  .pos-sale-layout { grid-template-columns: 220px 1fr 250px; }
  .pos-col-left, .pos-col-right { padding: 0.75rem; }
}

/* Legacy pages — pre-UI-modernization restore (Avans, Çek Arxivi, Hesabat, Məhsullar) */
#page-content.ui-legacy {
  display: block;
  gap: 0;
}

#page-content.ui-legacy .page-title {
  margin: 0 0 1.25rem;
  font-size: 1.5rem;
  font-weight: 800;
}

#page-content.ui-legacy .ui-page-subtitle {
  display: none;
}

#page-content.ui-legacy .page-card {
  background: var(--white);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}

#page-content.ui-legacy .toolbar {
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

#page-content.ui-legacy .table-scroll {
  border: none;
  border-radius: 0;
  overflow-x: auto;
}

#page-content.ui-legacy .data-table {
  border-collapse: collapse;
}

#page-content.ui-legacy .data-table thead th {
  position: static;
  background: var(--bg-page);
  padding: 0.85rem 1.1rem;
}

#page-content.ui-legacy .data-table tbody td {
  padding: 0.85rem 1.1rem;
}

#page-content.ui-legacy .data-table tbody tr:nth-child(even) {
  background: transparent;
}

#page-content.ui-legacy .data-table tbody tr:hover {
  background: rgba(37, 99, 235, 0.04);
}

#page-content.ui-legacy .report-stat-card {
  background: var(--white);
  backdrop-filter: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 1.25rem 1.15rem;
  min-height: 110px;
}

#page-content.ui-legacy .field-input,
#page-content.ui-legacy .field-select {
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
  font-size: 0.95rem;
}

#page-content.ui-legacy .field-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

@media print {
  .pos-topbar, .pos-nav, .no-print, .btn-logout, #page-loading, #toast-container { display: none !important; }
  .pos-main.page-scroll { padding: 0; }
  body { background: white; }
}

/* Theme engine — dark mode */
html[data-theme="dark"] {
  color-scheme: dark;
}

html[data-theme="dark"] body {
  background: #0f172a;
  color: #e2e8f0;
}

html[data-theme="dark"] .pos-topbar,
html[data-theme="dark"] .pos-nav,
html[data-theme="dark"] .page-card,
html[data-theme="dark"] .ui-card,
html[data-theme="dark"] .settings-panel,
html[data-theme="dark"] .settings-sidebar,
html[data-theme="dark"] .settings-card,
html[data-theme="dark"] .modal-card,
html[data-theme="dark"] .login-card {
  background: rgba(30, 41, 59, 0.92);
  border-color: #334155;
  color: #e2e8f0;
}

html[data-theme="dark"] .field-input,
html[data-theme="dark"] .field-select,
html[data-theme="dark"] textarea {
  background: #1e293b;
  border-color: #475569;
  color: #f8fafc;
}

html[data-theme="dark"] .data-table th {
  background: #1e293b;
  color: #cbd5e1;
}

html[data-theme="dark"] .data-table td {
  border-color: #334155;
}

html[data-theme="dark"] .muted,
html[data-theme="dark"] .settings-page-subtitle,
html[data-theme="dark"] .settings-status-label {
  color: #94a3b8;
}

html[data-theme="dark"] .settings-nav-btn {
  background: #1e293b;
  color: #cbd5e1;
}

html[data-theme="dark"] .settings-nav-btn:hover {
  background: var(--ui-hover-bg);
  color: var(--ui-hover-text);
}

html[data-theme="dark"] .settings-nav-btn.active {
  background: var(--ui-active-bg);
  color: #fff;
}

html[data-theme="dark"] .btn-tool-outline {
  border-color: #475569;
  color: #e2e8f0;
}

html[data-font-size="small"] { font-size: 14px; }
html[data-font-size="medium"] { font-size: 16px; }
html[data-font-size="large"] { font-size: 18px; }

.pos-brand-row { display: flex; align-items: center; gap: 10px; }
.btn-page-refresh {
  width: 36px; height: 36px; border-radius: 10px; border: 1px solid rgba(255,255,255,.25);
  background: rgba(255,255,255,.12); color: #fff; font-size: 18px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; transition: transform .2s, background .2s;
}
.btn-page-refresh:hover { background: rgba(255,255,255,.22); }
.btn-page-refresh.is-refreshing { animation: spin-refresh .8s linear infinite; }
@keyframes spin-refresh { to { transform: rotate(360deg); } }

.customer-action-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.customer-card { margin-top: 8px; }
.customer-card-inner {
  background: rgba(255,255,255,.72); border: 1px solid rgba(15,23,42,.08); border-radius: 12px;
  padding: 10px 12px; backdrop-filter: blur(8px);
}
.customer-card-title { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: #64748b; margin-bottom: 6px; }
.customer-card-row { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; margin: 4px 0; }
.customer-modal { width: min(420px, 94vw); }
.customer-picker-modal { width: min(480px, 94vw); }
.customer-picker-list { max-height: 320px; overflow: auto; display: flex; flex-direction: column; gap: 6px; }
.customer-picker-item {
  text-align: left; border: 1px solid rgba(15,23,42,.1); border-radius: 10px; padding: 10px 12px;
  background: rgba(255,255,255,.8); cursor: pointer;
}
.customer-picker-item:hover { border-color: #3b82f6; background: #eff6ff; }
.customer-picker-item strong { display: block; }
.link-btn { background: none; border: none; color: #2563eb; cursor: pointer; font-weight: 600; padding: 0; }
.customer-profile-modal { width: min(720px, 96vw); max-height: 90vh; overflow: auto; }
.customer-profile-summary { margin-bottom: 12px; }
.customer-profile-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.customer-profile-content { max-height: 360px; overflow: auto; }
.customer-profile-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px;
}
.customer-profile-stat {
  background: rgba(255,255,255,.72); border: 1px solid rgba(15,23,42,.08); border-radius: 10px; padding: 8px 10px;
}
.customer-profile-stat span { display: block; font-size: 11px; color: #64748b; text-transform: uppercase; letter-spacing: .03em; }
.customer-profile-stat strong { display: block; margin-top: 4px; font-size: 14px; }

.pay-debt-modal {
  width: min(920px, 96vw);
  max-height: 92vh;
  overflow: auto;
  padding: 1.25rem 1.5rem 1.5rem;
}
.pay-debt-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 1rem;
}
.pay-debt-modal-header h3 { margin: 0; }
.modal-close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: #64748b;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
}
.modal-close-btn:hover { background: #f1f5f9; color: #0f172a; }
.pay-debt-customer-info {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  padding: 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  margin-bottom: 1rem;
}
.pay-debt-info-item span {
  display: block;
  font-size: 11px;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.pay-debt-info-item strong { display: block; margin-top: 4px; font-size: 14px; }
.pay-debt-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 1rem;
}
.pay-debt-panel {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px;
  background: #fff;
}
.pay-debt-panel-title {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 700;
}
.pay-debt-panel-right {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  text-align: center;
  background: linear-gradient(180deg, #f0fdf4 0%, #fff 100%);
}
.pay-debt-full-amount {
  font-size: 1.75rem;
  font-weight: 800;
  color: #dc2626;
  margin: 0 0 12px;
}
.pay-debt-full-btn {
  min-height: 52px;
  font-size: 1.05rem;
  font-weight: 700;
}
.pay-debt-history-title {
  margin: 0 0 8px;
  font-size: 14px;
}
.pay-debt-history-wrap { max-height: 220px; }
.pay-amount-input { font-size: 1.1rem; font-weight: 600; }
html[data-theme="dark"] .pay-debt-customer-info { background: #1e293b; border-color: #334155; }
html[data-theme="dark"] .pay-debt-panel { background: #0f172a; border-color: #334155; }
html[data-theme="dark"] .pay-debt-panel-right { background: linear-gradient(180deg, #14532d22 0%, #0f172a 100%); }
html[data-theme="dark"] .modal-close-btn:hover { background: #334155; color: #f8fafc; }

@media (max-width: 720px) {
  .pay-debt-split { grid-template-columns: 1fr; }
}
.text-danger { color: #dc2626; }

.cash-log-table-wrap { max-height: calc(100vh - 260px); overflow: auto; }
.data-table-sticky thead th { position: sticky; top: 0; z-index: 2; background: #f8fafc; }
.label-qty-group { display: flex; flex-direction: column; gap: 4px; }
.label-qty-input { width: 72px; min-width: 72px; }
.label-print-cell { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

html[data-theme="dark"] .customer-card-inner { background: rgba(30,41,59,.85); border-color: #334155; }
html[data-theme="dark"] .customer-picker-item { background: #1e293b; border-color: #334155; color: #e2e8f0; }
html[data-theme="dark"] .data-table-sticky thead th { background: #1e293b; }

.pos-main:has(.customers-page-root) {
  overflow: hidden;
}
.customers-page-root {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 72px);
}
.customers-table-card { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.customers-table-card .page-card-body { padding: 0; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.customers-table-viewport {
  flex: 1;
  min-height: 240px;
  max-height: none;
  overflow-y: auto;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.customers-virtual-table { margin: 0; }
.customers-virtual-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #f8fafc;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.08);
}
.customers-filter-group { display: flex; flex-wrap: wrap; gap: 6px; }

.btn-add-customer {
  height: 44px;
  min-height: 44px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 11px;
  line-height: 1.2;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn-add-customer:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.35);
}

.th-sort-btn {
  background: none; border: none; padding: 0; font: inherit; font-weight: 600;
  color: inherit; cursor: pointer; display: inline-flex; align-items: center; gap: 4px;
}
.th-sort-btn:hover { color: #2563eb; }
.sort-ind { font-size: 10px; opacity: 0.85; }
.customers-vrow td { vertical-align: middle; }
.badge-muted { font-size: 10px; padding: 2px 6px; border-radius: 6px; background: #e2e8f0; color: #475569; }
html[data-theme="dark"] .customers-virtual-table thead th { background: #1e293b; }
html[data-theme="dark"] .badge-muted { background: #334155; color: #cbd5e1; }

.debts-scroll {
  max-height: calc(100vh - 220px);
  overflow-y: auto;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.debts-virtual-table { margin: 0; }
.debts-virtual-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #f8fafc;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.08);
}
html[data-theme="dark"] .debts-virtual-table thead th { background: #1e293b; }

/* Legacy alias — products use .products-table-viewport in crm-pages.css */
.products-scroll,
.products-table-viewport {
  flex: 1;
  min-height: 200px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.products-virtual-table { margin: 0; }
.products-virtual-table thead th,
.products-data-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #f8fafc;
  box-shadow: none;
}
html[data-theme="dark"] .products-virtual-table thead th,
html[data-theme="dark"] .products-data-table thead th { background: #0f172a; }

.pos-main:has(.cash-log-page-root) {
  overflow: hidden;
}
.cash-log-page-root {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 72px);
}
.cash-log-table-card { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.cash-log-table-card .page-card-body { padding: 0; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.cash-log-table-viewport {
  flex: 1;
  min-height: 240px;
  max-height: none;
  overflow-y: auto;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.cash-log-virtual-table { margin: 0; min-width: 1100px; }
.cash-log-virtual-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #f8fafc;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.08);
}
.cash-log-range-group,
.cash-log-filter-wrap { display: flex; flex-wrap: wrap; gap: 6px; }
.cash-log-vrow td { vertical-align: middle; white-space: nowrap; }
.cash-log-vrow td:nth-child(10) { white-space: normal; min-width: 140px; }
html[data-theme="dark"] .cash-log-virtual-table thead th { background: #1e293b; }

@media print {
  .pos-topbar, .pos-nav, .no-print, .btn-page-refresh { display: none !important; }
  .pos-main { overflow: visible !important; padding: 0 !important; }
  .cash-log-table-viewport { max-height: none !important; overflow: visible !important; }
  .cash-log-virtual-table thead th { position: static; }
}

/* ── Payment flow modals ── */
.pos-payment-modal {
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 1200;
}

.pos-payment-card {
  width: min(520px, 94vw);
  max-height: min(90vh, 720px);
  overflow: auto;
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 48px rgba(15, 23, 42, 0.18);
}

.pos-payment-card h3 {
  text-align: center;
  margin-bottom: 1.25rem;
  font-size: 1.15rem;
}

.payment-type-choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.payment-choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 110px;
  padding: 1rem 0.75rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  cursor: pointer;
  font-weight: 800;
  font-size: 0.95rem;
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.payment-choice:hover,
.payment-choice:focus-visible {
  transform: translateY(-2px);
  outline: none;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}

.payment-choice-cash {
  border-color: rgba(16, 185, 129, 0.45);
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.08) 0%, var(--white) 100%);
}

.payment-choice-cash:hover,
.payment-choice-cash:focus-visible {
  border-color: var(--green);
}

.payment-choice-debt {
  border-color: rgba(245, 158, 11, 0.45);
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.1) 0%, var(--white) 100%);
}

.payment-choice-debt:hover,
.payment-choice-debt:focus-visible {
  border-color: var(--orange, #f59e0b);
}

.payment-choice-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.pos-payment-cancel {
  width: 100%;
}

.debt-pay-actions {
  display: grid;
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.debt-pay-choice {
  width: 100%;
  justify-content: center;
  min-height: 2.75rem;
}

.debt-payment-selected {
  margin-bottom: 1rem;
}

.debt-pay-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.debt-pay-footer .btn-tool-primary {
  flex: 1 1 180px;
}

/* ── Nisyə satış modal (premium redesign) ── */
.debt-sale-modal {
  backdrop-filter: blur(2px);
}

.debt-sale-card {
  width: min(460px, 94vw);
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(37, 99, 235, 0.12);
  animation: debtSaleModalIn 0.22s ease-out;
}

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

.debt-sale-header {
  padding: 1.1rem 1.25rem 0.85rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.08) 0%, rgba(255, 255, 255, 0) 100%);
}

.debt-sale-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: 0.06em;
  text-align: center;
}

.debt-sale-title-icon {
  font-size: 1.15rem;
  line-height: 1;
}

.debt-sale-subtitle {
  margin: 0.35rem 0 0;
  text-align: center;
  font-size: 0.78rem;
  color: var(--muted, #64748b);
  line-height: 1.35;
}

.debt-sale-body {
  padding: 1rem 1.25rem 0.5rem;
}

.debt-sale-field-label {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--muted, #64748b);
  margin-bottom: 0.45rem;
}

.debt-customer-selector {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 0.65rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius, 12px);
  background: var(--white);
  cursor: pointer;
  text-align: left;
  transition: border-color var(--transition, 0.15s ease), box-shadow var(--transition, 0.15s ease), transform var(--transition, 0.15s ease);
}

.debt-customer-selector:hover,
.debt-customer-selector:focus-visible {
  border-color: rgba(37, 99, 235, 0.45);
  box-shadow: 0 0 0 3px var(--primary-glow);
  outline: none;
  transform: translateY(-1px);
}

.debt-customer-selector.is-selected {
  border-color: rgba(16, 185, 129, 0.45);
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.06) 0%, var(--white) 100%);
}

.debt-customer-selector-icon {
  width: 2.25rem;
  height: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.08);
  font-size: 1rem;
}

.debt-customer-selector.is-selected .debt-customer-selector-icon {
  background: rgba(16, 185, 129, 0.12);
}

.debt-customer-selector-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.debt-customer-selector-kicker {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--muted, #64748b);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.debt-customer-selector-value {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text, #0f172a);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.debt-customer-selector-meta {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--orange, #f59e0b);
  white-space: nowrap;
}

.debt-customer-selector.is-selected .debt-customer-selector-meta::after {
  content: " ✓";
  color: var(--green, #10b981);
}

.debt-customer-selector-chevron {
  font-size: 1.25rem;
  line-height: 1;
  color: var(--muted, #94a3b8);
  font-weight: 300;
}

.debt-new-customer-btn {
  margin-top: 0.65rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.85rem;
  border: 1px dashed rgba(37, 99, 235, 0.35);
  border-radius: var(--radius, 10px);
  background: rgba(37, 99, 235, 0.04);
  color: var(--primary);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--transition, 0.15s ease), border-color var(--transition, 0.15s ease);
}

.debt-new-customer-btn:hover,
.debt-new-customer-btn:focus-visible {
  background: rgba(37, 99, 235, 0.08);
  border-color: var(--primary-light);
  outline: none;
}

.debt-new-customer-icon {
  font-size: 1rem;
  line-height: 1;
  font-weight: 700;
}

.debt-customer-summary {
  margin-top: 0.85rem;
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: var(--radius, 12px);
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.07) 0%, rgba(255, 255, 255, 0.95) 100%);
  padding: 0.85rem 0.95rem;
}

.debt-customer-summary-inner {
  display: grid;
  gap: 0.35rem;
}

.debt-customer-summary-label {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--orange, #f59e0b);
}

.debt-customer-summary-name {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text, #0f172a);
  line-height: 1.25;
  word-break: break-word;
}

.debt-customer-summary-phone {
  font-size: 0.82rem;
  color: var(--muted, #64748b);
}

.debt-customer-summary-debt {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.25rem;
  padding-top: 0.55rem;
  border-top: 1px dashed rgba(15, 23, 42, 0.12);
}

.debt-customer-summary-debt span {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted, #64748b);
}

.debt-customer-summary-debt strong {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--danger, #dc2626);
}

.debt-sale-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.85rem 1.25rem 1.1rem;
  border-top: 1px solid var(--border);
  background: rgba(248, 250, 252, 0.85);
}

.debt-sale-cancel-btn {
  flex: 0 0 auto;
  min-width: 6.5rem;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted, #64748b);
  font-weight: 700;
}

.debt-sale-cancel-btn:hover,
.debt-sale-cancel-btn:focus-visible {
  background: rgba(15, 23, 42, 0.04);
  border-color: rgba(15, 23, 42, 0.18);
  outline: none;
}

.debt-sale-complete-btn {
  flex: 1 1 auto;
  min-height: 2.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-weight: 800;
  box-shadow: 0 8px 20px var(--primary-glow);
}

.debt-sale-complete-btn:disabled {
  opacity: 0.55;
  box-shadow: none;
  cursor: not-allowed;
}

.debt-sale-complete-icon {
  font-size: 0.95rem;
  line-height: 1;
}

@media (max-width: 520px) {
  .debt-sale-footer {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .debt-sale-cancel-btn,
  .debt-sale-complete-btn {
    width: 100%;
    min-width: 0;
  }

  .debt-customer-selector-meta {
    display: none;
  }
}

.customer-picker-table .customer-picker-row {
  cursor: pointer;
}

.customer-picker-table .customer-picker-row:hover,
.customer-picker-table .customer-picker-row:focus {
  background: rgba(37, 99, 235, 0.08);
  outline: none;
}

@media (max-width: 520px) {
  .payment-type-choices {
    grid-template-columns: 1fr;
  }
  .btn-pay-settle,
  #btnCard {
    grid-column: auto;
    grid-row: auto;
  }
}
