@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700;800&display=swap');

/* ============================================================
   Daftar ERP — Modern POS & Accounting UI
   ============================================================ */

:root {
  --bg: #f8fafc;
  --bg-soft: #eef2f7;
  --surface: #ffffff;
  --sidebar: #0c1222;
  --sidebar-hover: #151d32;
  --sidebar-active: #1e3a5f;
  --primary: #3b82f6;
  --primary-light: #eff6ff;
  --primary-dark: #2563eb;
  --accent: #06b6d4;
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --purple: #8b5cf6;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.04);
  --shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.08);
  --shadow-card: 0 1px 3px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.04);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --font: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
  --header-h: auto;
  --sidebar-w: 272px;
  --page-header-h: 72px;
}

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

html { direction: rtl; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 50% at 100% -10%, rgba(59, 130, 246, 0.06), transparent),
    radial-gradient(ellipse 60% 40% at 0% 100%, rgba(6, 182, 212, 0.04), transparent);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  font-size: 14px;
}

/* إخفاء الصفحات الخاصة حتى تثبت جلسة الدخول */
body:not([data-auth="public"]):not(.auth-ok) {
  overflow: hidden;
}
body:not([data-auth="public"]):not(.auth-ok) .app-layout {
  visibility: hidden !important;
  pointer-events: none !important;
}
body:not([data-auth="public"]):not(.auth-ok)::after {
  content: "جاري التحقق من تسجيل الدخول…";
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8fafc;
  color: #475569;
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  z-index: 99999;
}

a { color: inherit; text-decoration: none; }

/* ── Layout ── */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #0c1222 0%, #111827 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  right: 0;
  top: 0;
  height: 100vh;
  border-left: 1px solid rgba(255,255,255,0.06);
  z-index: 200;
  transition: transform 0.25s ease;
}

.sidebar-brand {
  padding: 1.5rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  position: relative;
}

.sidebar-brand .logo-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sidebar-brand .logo-icon {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 800;
}

.sidebar-brand h1 { font-size: 1rem; font-weight: 700; letter-spacing: -0.02em; }
.sidebar-brand p { font-size: 0.7rem; color: #64748b; margin-top: 0.15rem; }

.sidebar-nav { flex: 1; padding: 1rem 0.75rem; overflow-y: auto; }

.nav-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #475569;
  padding: 0.5rem 0.75rem 0.35rem;
  margin-top: 0.5rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius-sm);
  color: #94a3b8;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 2px;
  transition: all 0.15s ease;
}

.nav-link:hover { background: var(--sidebar-hover); color: #e2e8f0; }

.nav-link.active {
  background: linear-gradient(90deg, rgba(37,99,235,0.25), transparent);
  color: #fff;
  border-right: 3px solid var(--primary);
}

.nav-icon {
  width: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.85;
}

.nav-icon .ico { width: 18px; height: 18px; }

/* ── أيقونات رسمية (SVG أحادية اللون) ── */
.ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.125em;
  height: 1.125em;
  flex-shrink: 0;
  vertical-align: -0.15em;
  color: inherit;
}

.ico svg {
  width: 100%;
  height: 100%;
  display: block;
}

.btn .ico,
.nav-link .ico,
.tab-btn .ico,
.quick-action-btn .ico {
  margin-left: 0.35em;
}

.sidebar-toggle .ico { width: 20px; height: 20px; }

.hub-icon .ico { width: 1.35rem; height: 1.35rem; }

.stat-icon .ico,
.rpt-kpi-icon .ico,
.module-card-icon .ico,
.sales-card-icon .ico,
.pill-icon .ico {
  width: 1.25rem;
  height: 1.25rem;
}

.empty-icon .ico,
.rpt-empty-icon .ico {
  width: 2.5rem;
  height: 2.5rem;
  opacity: 0.45;
  margin: 0 auto 0.5rem;
}

.rpt-product-thumb {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #f1f5f9;
  color: #64748b;
  font-size: 0.85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.session-chip .status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  margin-left: 0.35em;
  vertical-align: middle;
}

h3 .ico,
h4 .ico,
.section-head h3 .ico,
.cart-header .ico,
.hub-title .ico,
.rpt-type-pill .ico,
.tab-btn .ico {
  margin-left: 0.35em;
}

.search-icon .ico {
  width: 1rem;
  height: 1rem;
  opacity: 0.55;
}

.btn-icon .ico {
  width: 1rem;
  height: 1rem;
  margin: 0;
}

.sidebar-footer {
  padding: 1rem 0.75rem;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.main-content { flex: 1; display: flex; flex-direction: column; min-width: 0; padding-top: var(--page-header-h); margin-right: var(--sidebar-w); width: calc(100% - var(--sidebar-w)); }

.page-header {
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 1.75rem;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  position: fixed;
  top: 0;
  left: 0;
  right: var(--sidebar-w);
  z-index: 120;
  box-shadow: var(--shadow-sm);
}

.page-header-left {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  min-width: 0;
  flex: 1;
}

.page-header-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding-top: 0.1rem;
}

.page-header h2 {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
  line-height: 1.25;
  margin: 0;
}

.page-subtitle {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin: 0;
  font-weight: 500;
  line-height: 1.45;
  max-width: 520px;
}

.breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.3rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 0 0 0.15rem;
  line-height: 1.4;
}

.breadcrumb a {
  color: var(--text-secondary);
  font-weight: 500;
  transition: color 0.15s;
}

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

.breadcrumb-current {
  color: var(--primary-dark);
  font-weight: 600;
}

.breadcrumb-sep {
  opacity: 0.35;
  font-size: 0.85em;
  user-select: none;
}

.page-header-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-shrink: 0;
}

.sidebar-toggle {
  display: none;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  box-shadow: var(--shadow-sm);
}

.sidebar-toggle:hover {
  background: var(--bg-soft);
  border-color: #cbd5e1;
}

.sidebar-toggle[aria-expanded="true"] {
  background: var(--primary-light);
  border-color: #93c5fd;
}

.burger-box {
  width: 18px;
  height: 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.burger-box span {
  display: block;
  height: 2px;
  width: 100%;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.22s ease, opacity 0.18s ease, width 0.18s ease;
  transform-origin: center;
}

.sidebar-toggle[aria-expanded="true"] .burger-box span:nth-child(1) {
  transform: translateY(5px) rotate(45deg);
}

.sidebar-toggle[aria-expanded="true"] .burger-box span:nth-child(2) {
  opacity: 0;
  width: 0;
}

.sidebar-toggle[aria-expanded="true"] .burger-box span:nth-child(3) {
  transform: translateY(-5px) rotate(-45deg);
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 150;
  backdrop-filter: blur(3px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.sidebar-overlay.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

body.sidebar-open {
  overflow: hidden;
}

.sidebar-mobile-close {
  display: none;
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.sidebar-mobile-close:hover {
  background: rgba(255, 255, 255, 0.12);
}

.sidebar-mobile-close .ico {
  width: 18px;
  height: 18px;
}

.page-body { flex: 1; padding: 1.5rem 1.75rem; }

/* ── Status ── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-badge.connected { background: #d1fae5; color: #065f46; }
.status-badge.disconnected { background: #fee2e2; color: #991b1b; }
.status-badge.status-badge--draft { background: #fef3c7; color: #92400e; }

.history-actions {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

.history-actions .btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  min-height: 2rem;
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: 8px;
}

.history-actions .btn .icon,
.history-actions .btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.history-actions .btn-primary {
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.2);
}

.history-actions .btn-danger {
  background: #dc2626;
  border-color: #dc2626;
  color: #fff;
}

.history-actions .btn-danger:hover {
  background: #b91c1c;
  border-color: #b91c1c;
}

tr.row-cancelled td {
  opacity: 0.72;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

/* ── Setup banner ── */
.setup-banner {
  background: linear-gradient(135deg, #fffbeb, #fef3c7);
  border: 1px solid #fcd34d;
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}

.setup-banner h3 { color: #92400e; font-size: 0.95rem; font-weight: 700; }

/* ── Stats row ── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.35rem;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-light);
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  transition: box-shadow 0.2s, transform 0.2s;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 3px;
  background: var(--stat-accent, var(--primary));
  opacity: 0.85;
}

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

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: #f1f5f9;
  color: #475569;
  --stat-accent: var(--primary);
}

.stat-icon.blue,
.stat-icon.green,
.stat-icon.amber,
.stat-icon.purple {
  background: #f1f5f9;
  color: #475569;
  --stat-accent: var(--primary);
}

.stat-info .label { font-size: 0.8rem; color: var(--text-muted); font-weight: 500; }
.stat-info .value { font-size: 1.5rem; font-weight: 800; color: var(--text); line-height: 1.2; }
.stat-info .sub { font-size: 0.75rem; color: var(--text-secondary); margin-top: 0.15rem; }

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

.cards-grid--2 {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.dashboard-group {
  margin-bottom: 1.75rem;
}

.dashboard-group-head {
  margin-bottom: 1rem;
}

.dashboard-group-head h3 {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 0.2rem;
}

.dashboard-group-head p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.module-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.35rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  display: block;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.module-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 3px;
  background: var(--card-accent, var(--primary));
  opacity: 0;
  transition: opacity 0.2s;
}

.module-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-3px);
  border-color: transparent;
}

.module-card:hover::before { opacity: 1; }

.module-card-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.85rem;
  background: #f1f5f9;
  color: #475569;
  --card-accent: var(--primary);
}

.icon-emerald,
.icon-blue,
.icon-indigo,
.icon-amber,
.icon-rose,
.icon-slate {
  background: #f1f5f9;
  color: #475569;
  --card-accent: var(--primary);
}

.module-card h3 { font-size: 0.95rem; font-weight: 700; margin-bottom: 0.3rem; }
.module-card p { font-size: 0.78rem; color: var(--text-muted); line-height: 1.5; }

/* ── Classic hub (inspired by old app) ── */
.hub-panel {
  background: linear-gradient(145deg, #1e3a8a 0%, #1e40af 40%, #172554 100%);
  border-radius: var(--radius);
  padding: 2rem;
  margin-bottom: 1.5rem;
  position: relative;
  overflow: hidden;
}

.hub-panel::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 28px 28px;
  pointer-events: none;
}

.hub-title {
  text-align: center;
  color: #fbbf24;
  font-weight: 800;
  font-size: 1.1rem;
  margin-bottom: 1.5rem;
  position: relative;
  z-index: 1;
}

.hub-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.85rem;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.hub-btn {
  background: rgba(255,255,255,0.95);
  border: none;
  border-radius: var(--radius-sm);
  padding: 1.1rem 0.5rem;
  font-family: var(--font);
  font-weight: 700;
  font-size: 0.9rem;
  color: #1e293b;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.hub-btn:hover {
  background: #fff;
  transform: scale(1.03);
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

.hub-btn.center { grid-column: 2; }

/* ── Panel / Card ── */
.panel {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  overflow: hidden;
}

.panel-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(to left, #f8fafc, #fff);
}

.panel-header h3 {
  font-size: 0.95rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.panel-body { padding: 1.25rem; }

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  overflow-x: auto;
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 0 0.5rem;
}

.tab-btn {
  padding: 0.85rem 1.1rem;
  border: none;
  background: none;
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
}

.tab-btn:hover { color: var(--primary); }

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Forms ── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

.currency-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.85rem;
  padding: 0.5rem 0.75rem;
  background: var(--primary-light);
  border-radius: var(--radius-xs);
  border-right: 3px solid var(--primary);
}

.currency-input:focus {
  border-color: var(--primary);
  background: #fafbff;
}

/* ── Invoice line dual currency inputs ── */
.line-dual-input {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 100px;
}

.line-dual-input .form-control {
  padding: 0.35rem 0.5rem;
  font-size: 0.78rem;
  min-width: 0;
}

.line-dual-input .line-price-usd,
.line-dual-input .line-total-usd {
  border-right: 2px solid #3b82f6;
}

.line-dual-input .line-price-iqd,
.line-dual-input .line-total-iqd {
  border-right: 2px solid #10b981;
}

.data-table .line-dual-input .form-control::placeholder {
  font-size: 0.7rem;
  opacity: 0.6;
}

.form-grid-2 {
  grid-template-columns: repeat(2, 1fr);
}
.form-grid-3 { grid-template-columns: repeat(3, 1fr); }

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

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

.form-group label .req { color: var(--danger); }

.form-control {
  width: 100%;
  padding: 0.6rem 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.875rem;
  color: var(--text);
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
  direction: rtl;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.form-control:read-only,
.form-control[readonly] {
  background: #f8fafc;
  color: var(--text-secondary);
}

.form-control.lg { padding: 0.75rem 1rem; font-size: 1rem; }

textarea.form-control { min-height: 80px; resize: vertical; }

/* ── Custom Select ── */
.custom-select {
  position: relative;
  width: 100%;
}

.custom-select-native {
  position: absolute !important;
  opacity: 0 !important;
  pointer-events: none !important;
  width: 0 !important;
  height: 0 !important;
  overflow: hidden !important;
}

.custom-select-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.6rem 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  font-family: var(--font);
  font-size: 0.875rem;
  color: var(--text);
  cursor: pointer;
  text-align: right;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  direction: rtl;
}

.custom-select-trigger:hover {
  border-color: #cbd5e1;
  background: #fcfdff;
}

.custom-select.is-open .custom-select-trigger,
.custom-select-trigger:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.custom-select-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-select-chevron {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  border-radius: 6px;
  background: var(--bg-soft);
  position: relative;
  transition: transform 0.2s ease, background 0.15s;
}

.custom-select-chevron::before {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--text-secondary);
}

.custom-select.is-open .custom-select-chevron {
  transform: rotate(180deg);
  background: var(--primary-light);
}

.custom-select.is-disabled .custom-select-trigger {
  opacity: 0.65;
  cursor: not-allowed;
  background: #f8fafc;
}

.custom-select-dropdown {
  position: fixed;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  overflow-y: auto;
  padding: 0.35rem;
  opacity: 0;
  transform: translateY(-8px) scale(0.98);
  transform-origin: top right;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.custom-select.is-open .custom-select-dropdown {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.custom-select-dropdown.has-search {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}

.custom-select-search-wrap {
  flex-shrink: 0;
  padding: 0.4rem 0.45rem 0.35rem;
  border-bottom: 1px solid var(--border-light);
  background: var(--surface);
}

.custom-select-search {
  width: 100%;
  padding: 0.45rem 0.65rem;
  border: 1.5px solid var(--border);
  border-radius: calc(var(--radius-sm) - 2px);
  background: #fff;
  font-family: var(--font);
  font-size: 0.8rem;
  color: var(--text);
  direction: rtl;
}

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

.custom-select-options {
  overflow-y: auto;
  padding: 0.35rem;
  flex: 1;
  min-height: 0;
}

.custom-select-empty {
  padding: 0.65rem 0.75rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.custom-select-option {
  display: block;
  width: 100%;
  text-align: right;
  border: none;
  background: transparent;
  font-family: var(--font);
  font-size: 0.875rem;
  color: var(--text);
  padding: 0.55rem 0.75rem;
  border-radius: calc(var(--radius-sm) - 2px);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.custom-select-option:hover:not(:disabled) {
  background: var(--bg-soft);
}

.custom-select-option.is-selected {
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 600;
}

.custom-select-option:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23475569' d='M1 1.5 6 6.5 11 1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 0.85rem center;
  padding-left: 2rem;
}

.form-hint {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 0.8rem;
  color: #92400e;
  margin: 0.75rem 0;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.6rem 1.25rem;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

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

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); box-shadow: 0 4px 12px rgba(37,99,235,0.35); }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #059669; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #dc2626; }

.btn-purple { background: var(--purple); color: #fff; }
.btn-purple:hover:not(:disabled) { background: #7c3aed; }

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

.btn-outline:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }

.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.8rem; }
.btn-block { width: 100%; }

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
}

/* ── Invoice form (sales / purchases) ── */
.invoice-layout { display: flex; flex-direction: column; gap: 1rem; }

.invoice-header-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.85rem;
}

.invoice-meta-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
  padding: 1rem 1.25rem;
  background: linear-gradient(to left, #eff6ff, #f8fafc);
  border-bottom: 1px solid var(--border);
}

.exchange-badge {
  background: linear-gradient(135deg, #ede9fe, #ddd6fe);
  border: 1px solid #c4b5fd;
  border-radius: var(--radius-sm);
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: #5b21b6;
}

/* ── Data table ── */
.table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.data-table thead {
  background: linear-gradient(to left, #f1f5f9, #e2e8f0);
}

.data-table th {
  padding: 0.75rem 0.85rem;
  text-align: right;
  font-weight: 700;
  color: var(--text-secondary);
  font-size: 0.78rem;
  white-space: nowrap;
  border-bottom: 2px solid var(--border);
}

.data-table td {
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

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

.data-table .form-control {
  padding: 0.4rem 0.6rem;
  font-size: 0.82rem;
  min-width: 70px;
}

.data-table tfoot td {
  font-weight: 700;
  background: #f8fafc;
  padding: 0.75rem 0.85rem;
}

/* ── Invoice footer totals ── */
.invoice-footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 1.25rem;
  padding: 1.25rem;
  background: linear-gradient(to left, #f8fafc, #f1f5f9);
  border-top: 2px solid var(--border);
}

.totals-box {
  min-width: 260px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.totals-row {
  display: flex;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.875rem;
}

.totals-row.grand {
  background: linear-gradient(to left, #1e40af, #2563eb);
  color: #fff;
  font-weight: 800;
  font-size: 1rem;
  border: none;
}

.totals-row .form-control {
  width: 100px;
  text-align: left;
  direction: ltr;
  padding: 0.3rem 0.5rem;
}

/* ── Totals panel (modern) ── */
.totals-panel {
  min-width: 300px;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.totals-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: linear-gradient(to left, #eff6ff, #f8fafc);
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
}

.totals-currency-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  padding: 0.2rem 0.55rem;
  background: var(--primary);
  color: #fff;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 800;
  direction: ltr;
}

.totals-panel-body {
  padding: 0.5rem 0;
}

.totals-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border-light);
}

.totals-line:last-child {
  border-bottom: none;
}

.totals-line-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.totals-line-value {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text);
  direction: ltr;
  font-variant-numeric: tabular-nums;
  text-align: left;
  min-width: 80px;
}

.totals-line-value--balance {
  color: #059669;
  background: #ecfdf5;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-xs);
  font-size: 0.95rem;
}

.totals-line--input {
  background: #fafbff;
}

.totals-input {
  width: 110px;
  padding: 0.45rem 0.65rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xs);
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 700;
  text-align: left;
  direction: ltr;
  color: var(--text);
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.totals-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.totals-line--grand {
  margin-top: 0.25rem;
  padding: 0.85rem 1rem;
  background: linear-gradient(135deg, #1e40af 0%, #2563eb 100%);
  border-bottom: none;
}

.totals-line--grand .totals-line-label {
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.9rem;
  font-weight: 700;
}

.totals-line-value--grand {
  color: #fff;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.totals-line--balance {
  background: linear-gradient(to left, #f0fdf4, #fff);
}

/* ── POS ── */
.pos-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 1rem;
  height: calc(100vh - var(--header-h) - 3rem);
}

.pos-layout--v2 {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 380px);
  gap: 1rem;
  height: calc(100vh - var(--header-h) - 2.5rem);
  min-height: 560px;
}

.pos-shell {
  animation: posFadeIn 0.35s ease;
}

@keyframes posFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.pos-menu {
  background: #fff;
  border: 1px solid #e8edf3;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.pos-menu-toolbar {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid #eef2f6;
  flex-wrap: wrap;
}

.pos-menu-title {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 800;
  font-size: 0.95rem;
  color: #0f172a;
  white-space: nowrap;
}

.pos-menu-title-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: #f1f5f9;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #334155;
}

.pos-menu-title-icon .ico,
.pos-menu-title-icon svg {
  width: 15px;
  height: 15px;
}

.pos-cat-scroll {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  overflow-x: auto;
  flex: 1;
  min-width: 0;
  padding: 0.1rem 0;
  scrollbar-width: thin;
}

.pos-cat-pill {
  flex: 0 0 auto;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #475569;
  border-radius: 10px;
  padding: 0.45rem 0.85rem;
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

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

.pos-cat-pill.active {
  background: #152033;
  border-color: #152033;
  color: #fff;
}

.pos-menu-tools {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-inline-start: auto;
}

.pos-icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #334155;
  border-radius: 10px;
  padding: 0.45rem 0.75rem;
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.pos-icon-btn:hover {
  background: #f8fafc;
}

.pos-icon-btn .ico,
.pos-icon-btn svg {
  width: 14px;
  height: 14px;
}

.pos-search {
  position: relative;
  min-width: 180px;
}

.pos-search input {
  width: 100%;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 0.5rem 2.2rem 0.5rem 0.85rem;
  font-family: var(--font);
  font-size: 0.82rem;
  background: #fff;
}

.pos-search input:focus {
  outline: none;
  border-color: #94a3b8;
  box-shadow: 0 0 0 3px rgba(21, 32, 51, 0.08);
}

.pos-search-icon {
  position: absolute;
  right: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  pointer-events: none;
}

.pos-search-icon .ico,
.pos-search-icon svg {
  width: 14px;
  height: 14px;
}

.pos-currency-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid #eef2f6;
  background: #fafbfc;
  flex-wrap: wrap;
}

.pos-products {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pos-toolbar {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(to left, #f8fafc, #fff);
}

.search-box { position: relative; }

.search-box input {
  width: 100%;
  padding: 0.75rem 2.75rem 0.75rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.9rem;
  background: #fff;
}

.search-box input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

.search-box .search-icon {
  position: absolute;
  right: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1rem;
}

.currency-tabs { display: flex; gap: 0.5rem; align-items: center; }

.currency-tab {
  padding: 0.4rem 0.95rem;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 600;
  transition: all 0.15s;
}

.currency-tab.active {
  background: #152033;
  border-color: #152033;
  color: #fff;
}

.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: 0.75rem;
  padding: 1rem;
  overflow-y: auto;
  flex: 1;
  align-content: start;
}

.products-grid--v2 {
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 0.9rem;
  padding: 1rem;
  background: #f7f9fb;
  flex: 1;
}

.pos-empty-grid {
  grid-column: 1 / -1;
  text-align: center;
  color: #94a3b8;
  padding: 3rem 1rem;
  font-size: 0.9rem;
}

.pos-product-card {
  background: #fff;
  border: 1px solid #e8edf3;
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.pos-product-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

.pos-product-card.is-unavailable {
  opacity: 0.78;
}

.pos-product-media {
  position: relative;
  aspect-ratio: 4 / 3;
  background: linear-gradient(145deg, #e2e8f0, #f8fafc 55%, #dbeafe);
}

.pos-product-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.pos-product-thumb.is-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
  font-weight: 800;
  color: #64748b;
  letter-spacing: -0.03em;
}

.pos-stock-badge {
  position: absolute;
  top: 0.55rem;
  left: 0.55rem;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: rgba(255, 255, 255, 0.94);
  border-radius: 999px;
  padding: 0.22rem 0.55rem;
  font-size: 0.68rem;
  font-weight: 800;
  color: #0f172a;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

.pos-stock-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #94a3b8;
}

.pos-stock-badge.is-available .pos-stock-dot { background: #16a34a; }
.pos-stock-badge.is-unavailable { color: #991b1b; }
.pos-stock-badge.is-unavailable .pos-stock-dot { background: #dc2626; }

.pos-product-body {
  padding: 0.75rem 0.8rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
}

.pos-product-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.pos-product-name {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.pos-product-price {
  font-size: 0.88rem;
  font-weight: 800;
  color: #0f172a;
  white-space: nowrap;
  direction: ltr;
}

.pos-product-code {
  font-size: 0.72rem;
  color: #94a3b8;
  margin-bottom: 0.25rem;
}

.pos-card-btn {
  width: 100%;
  margin-top: auto;
  border: none;
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
  background: #152033;
  color: #fff;
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.15s, transform 0.12s;
}

.pos-card-btn:hover {
  background: #0f172a;
}

.pos-card-btn:active {
  transform: scale(0.98);
}

.pos-card-btn.is-more {
  background: #fff;
  color: #152033;
  border: 1.5px solid #152033;
}

.pos-card-btn.is-more:hover {
  background: #f8fafc;
}

.pos-card-btn.is-disabled,
.pos-card-btn:disabled {
  background: #e2e8f0;
  color: #94a3b8;
  cursor: not-allowed;
  border: none;
}

.product-card {
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 0.85rem;
  text-align: right;
  cursor: pointer;
  transition: all 0.15s;
  background: #fff;
  font-family: var(--font);
}

.product-card:hover {
  border-color: var(--primary);
  background: #eff6ff;
  box-shadow: 0 4px 12px rgba(37,99,235,0.12);
  transform: translateY(-1px);
}

.product-card .name { font-weight: 700; font-size: 0.85rem; color: var(--text); }
.product-card .code { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.2rem; }
.product-card .price { font-size: 0.95rem; font-weight: 800; color: var(--primary); margin-top: 0.45rem; }
.product-card .stock { font-size: 0.7rem; color: var(--text-muted); margin-top: 0.2rem; }

.pos-cart,
.pos-order {
  background: #fff;
  border-radius: 16px;
  border: 1px solid #e8edf3;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.pos-order-head {
  padding: 1.05rem 1.15rem 0.85rem;
  border-bottom: 1px solid #eef2f6;
}

.pos-order-head h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  color: #0f172a;
}

.pos-order-id {
  margin: 0.2rem 0 0;
  font-size: 0.82rem;
  color: #64748b;
  font-weight: 600;
  direction: ltr;
  text-align: right;
}

.pos-order-customer {
  padding: 0.85rem 1.15rem;
  border-bottom: 1px solid #eef2f6;
}

.pos-order-customer label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: #64748b;
  margin-bottom: 0.35rem;
}

.cart-header {
  padding: 1rem 1.15rem;
  font-weight: 700;
  font-size: 0.95rem;
  background: linear-gradient(to left, #1e40af, #2563eb);
  color: #fff;
}

.cart-items,
.pos-order-items {
  flex: 1;
  overflow-y: auto;
  padding: 0.85rem 1rem;
  background: #fff;
}

.cart-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
  padding: 2.5rem 1rem;
}

.pos-cart-line {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: 0.65rem;
  align-items: start;
  padding: 0.7rem 0;
  border-bottom: 1px solid #f1f5f9;
}

.pos-cart-thumb {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  background: linear-gradient(145deg, #e2e8f0, #f8fafc);
  object-fit: cover;
  display: block;
  overflow: hidden;
}

.pos-cart-thumb.is-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #64748b;
  font-size: 1.1rem;
}

.pos-cart-title {
  font-size: 0.86rem;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.35;
}

.pos-cart-title span {
  color: #64748b;
  font-weight: 700;
}

.pos-cart-meta {
  font-size: 0.72rem;
  color: #94a3b8;
  margin-top: 0.15rem;
}

.pos-cart-price {
  margin-top: 0.35rem;
  font-size: 0.84rem;
  font-weight: 800;
  color: #0f172a;
  direction: ltr;
  text-align: right;
}

.pos-cart-actions {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.pos-line-btn {
  width: 28px;
  height: 28px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
  color: #334155;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  line-height: 1;
}

.pos-line-btn:hover { background: #f8fafc; }
.pos-line-btn.is-danger { color: #dc2626; }
.pos-line-btn .ico,
.pos-line-btn svg { width: 13px; height: 13px; }

.cart-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #f8fafc;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 0.65rem;
  margin-bottom: 0.5rem;
}

.cart-line-info { flex: 1; min-width: 0; }
.cart-line-info .name { font-size: 0.85rem; font-weight: 600; }
.cart-line-info .calc { font-size: 0.75rem; color: var(--text-muted); }

.qty-btn {
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition: background 0.1s;
}

.qty-btn:hover { background: var(--border-light); }

.cart-footer,
.pos-order-footer {
  border-top: 1px solid #eef2f6;
  padding: 0.9rem 1.15rem 1.15rem;
  background: #fff;
}

.pos-totals {
  margin-bottom: 0.75rem;
}

.cart-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.875rem;
  margin-bottom: 0.45rem;
  color: #475569;
}

.cart-row--discount {
  color: #16a34a;
  font-weight: 700;
}

.cart-row.total {
  font-weight: 800;
  font-size: 1.05rem;
  margin-top: 0.5rem;
  padding-top: 0.65rem;
  border-top: 1px dashed #e2e8f0;
  color: #0f172a;
}

.pos-order-fields .form-group {
  margin-bottom: 0.65rem;
}

.pos-order-fields label {
  font-size: 0.75rem;
  font-weight: 700;
  color: #64748b;
}

.payment-tabs { display: flex; gap: 0.5rem; margin: 0.35rem 0 0; }

.payment-tab {
  flex: 1;
  padding: 0.55rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 600;
  transition: all 0.15s;
}

.payment-tab.active.cash { background: var(--success); border-color: var(--success); color: #fff; }
.payment-tab.active.credit { background: #152033; border-color: #152033; color: #fff; }

.pos-confirm-btn {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.95rem 1rem;
  border: none;
  border-radius: 12px;
  background: #152033;
  color: #fff;
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.15s, transform 0.12s;
}

.pos-confirm-btn:hover {
  background: #0f172a;
}

.pos-confirm-btn:active {
  transform: scale(0.985);
}

.pos-confirm-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ── Reports ── */
.reports-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.75rem;
}

.report-card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 1rem 1.15rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  transition: all 0.15s;
  cursor: pointer;
}

.report-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
  transform: translateX(-2px);
}

.report-card .r-icon {
  width: 40px;
  height: 40px;
  background: var(--primary-light);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.report-card .r-title { font-size: 0.875rem; font-weight: 600; }

/* ── Messages ── */
.message {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  margin: 0.75rem 0;
  font-weight: 500;
}

.message.error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.message.success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }

/* ── Settings sub-nav ── */
.settings-subnav {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.65rem;
  margin-bottom: 1.25rem;
}

.settings-chip {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}

.settings-chip:hover, .settings-chip.active {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary-dark);
}

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

.form-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
}

.form-card h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

/* ── Balance display ── */
.balance-display {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.balance-chip {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  font-size: 0.82rem;
}

.balance-chip .lbl { color: var(--text-muted); font-size: 0.72rem; }
.balance-chip .val { font-weight: 800; color: #166534; direction: ltr; text-align: left; }

/* ── Cashbox balance panel ── */
.form-group--sub-link {
  grid-column: span 1;
}

.sub-accounts-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.4rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary);
  transition: color 0.15s;
}

.sub-accounts-link:hover { color: var(--primary-dark); text-decoration: underline; }

.balance-panel {
  margin: 1.25rem 0;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.balance-panel-head {
  padding: 0.65rem 1rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
  background: rgba(255,255,255,0.7);
  border-bottom: 1px solid var(--border);
}

.balance-panel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.balance-stat {
  padding: 1rem 1.15rem;
  border-left: 1px solid var(--border);
}

.balance-stat:first-child { border-left: none; }

.balance-stat-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.balance-stat--prev .balance-stat-title { color: #64748b; }
.balance-stat--remain .balance-stat-title { color: var(--primary-dark); }

.balance-stat-rows {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.balance-stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0.75rem;
  background: #fff;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-light);
}

.balance-stat-lbl {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.balance-stat-val {
  font-size: 1.05rem;
  font-weight: 800;
  direction: ltr;
  font-variant-numeric: tabular-nums;
}

.balance-stat--prev .balance-stat-val { color: #475569; }
.balance-stat--remain .balance-stat-val { color: #1d4ed8; }

.balance-iqd-pair {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  justify-content: flex-end;
  font-size: 0.92rem !important;
}

.iqd-before {
  color: #64748b;
  font-weight: 700;
  font-size: 0.92em;
  opacity: 0.95;
}

.iqd-arrow {
  color: var(--text-muted);
  font-size: 0.75em;
  opacity: 0.7;
}

.iqd-after {
  color: inherit;
  font-weight: 800;
}

.balance-iqd-legend {
  margin: 0.15rem 0 0;
  font-size: 0.65rem;
  color: var(--text-muted);
  font-weight: 500;
}

.balance-panel-grid--3 {
  grid-template-columns: 1fr 1fr 0.85fr;
}

.balance-stat--status {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  min-height: 100%;
}

.payment-status-wrap {
  padding: 0.5rem;
}

.payment-status {
  display: inline-block;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 800;
}

.payment-status--paid {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #86efac;
}

.payment-status--unpaid {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fcd34d;
}

.settlement-section {
  margin-bottom: 1.25rem;
}

.settlement-pills .type-pill.active {
  background: #dbeafe;
  border-color: var(--primary);
  color: var(--primary-dark);
}

.settlement-pills .type-pill.active[data-value="none"] {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #475569;
}

.currency-pills .type-pill.active {
  background: #ecfdf5;
  border-color: #10b981;
  color: #047857;
}

.amount-negative-hint:focus {
  border-color: var(--primary);
}

.field-hint {
  margin: 0.35rem 0 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.field-optional {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
}

.partial-amount-wrap {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.list-toolbar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.list-toolbar .form-control--compact {
  min-width: 140px;
}

@media (max-width: 768px) {
  .balance-panel-grid--3 { grid-template-columns: 1fr; }
}

/* ── Page hero & quick actions ── */
.page-hero {
  background: linear-gradient(135deg, #1e40af 0%, #2563eb 45%, #0ea5e9 100%);
  border-radius: var(--radius);
  padding: 1.75rem 2rem;
  color: #fff;
  margin-bottom: 1.5rem;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.page-hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 90% 10%, rgba(255,255,255,0.15), transparent 40%),
    linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: auto, 24px 24px, 24px 24px;
  pointer-events: none;
}

.page-hero-inner { position: relative; z-index: 1; }

.page-hero h3 {
  font-size: 1.35rem;
  font-weight: 800;
  margin-bottom: 0.35rem;
}

.page-hero p {
  font-size: 0.875rem;
  opacity: 0.9;
  max-width: 520px;
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1.25rem;
}

.quick-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 1rem;
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 999px;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  transition: all 0.15s;
  backdrop-filter: blur(4px);
}

.quick-action-btn:hover {
  background: rgba(255,255,255,0.95);
  color: var(--primary-dark);
  transform: translateY(-1px);
}

/* ── Section cards (invoice / forms) ── */
.section-card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.section-card + .section-card { margin-top: 1rem; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.25rem;
  background: linear-gradient(to left, #f8fafc, #fff);
  border-bottom: 1px solid var(--border);
}

.section-head h3 {
  font-size: 0.9rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text);
}

.section-head .badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  background: var(--primary-light);
  color: var(--primary-dark);
}

.section-body { padding: 1.25rem; }

/* ── Invoice meta improved ── */
.invoice-meta-bar {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  align-items: end;
  padding: 1.25rem;
  background: linear-gradient(135deg, #eff6ff 0%, #f8fafc 100%);
  border-bottom: 1px solid var(--border);
}

.invoice-meta-bar .exchange-badge {
  grid-column: span 1;
  align-self: center;
  text-align: center;
}

/* ── Type pills (cashbox / payment) ── */
.type-pills {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.type-pill {
  flex: 1;
  min-width: 100px;
  padding: 0.75rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 700;
  text-align: center;
  transition: all 0.15s;
  color: var(--text-secondary);
}

.type-pill:hover { border-color: var(--primary); color: var(--primary); }

.type-pill.active.payment { background: #fce7f3; border-color: #f9a8d4; color: #9d174d; }
.type-pill.active.receipt { background: #d1fae5; border-color: #6ee7b7; color: #047857; }
.type-pill.active.transfer { background: #ede9fe; border-color: #c4b5fd; color: #6d28d9; }

.history-type {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.history-type--payment { background: #fce7f3; border-color: #f9a8d4; color: #9d174d; }
.history-type--receipt { background: #d1fae5; border-color: #6ee7b7; color: #047857; }
.history-type--transfer { background: #ede9fe; border-color: #c4b5fd; color: #6d28d9; }

.history-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-light);
}

.history-page-info {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 7rem;
  text-align: center;
}

.history-page-btn {
  min-width: 5.5rem;
}

.history-page-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ── Sidebar footer info ── */
.sidebar-info {
  padding: 0.85rem 1rem;
  margin: 0 0.75rem 0.75rem;
  background: rgba(255,255,255,0.06);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  color: #94a3b8;
}

.sidebar-info .info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.25rem 0;
}

.sidebar-info .info-val {
  color: #e2e8f0;
  font-weight: 700;
  direction: ltr;
}

/* ── POS session bar ── */
.pos-session-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.85rem 1.15rem;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1rem;
}

.pos-session-bar .session-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--success-light);
  color: #065f46;
}

.pos-session-bar .session-chip.offline {
  background: var(--warning-light);
  color: #92400e;
}

/* ── Settings exchange card ── */
.exchange-card {
  max-width: 420px;
  margin: 2rem auto;
  text-align: center;
  padding: 2rem;
  background: linear-gradient(135deg, #eff6ff, #f0fdf4);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.exchange-card .exchange-value {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--primary-dark);
  margin: 1rem 0;
  direction: ltr;
}

.exchange-card .exchange-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  opacity: 0.6;
}

.empty-state p { font-size: 0.875rem; }

/* ── Action bar sticky ── */
.sticky-actions {
  position: sticky;
  bottom: 0;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
  padding: 1rem 1.25rem;
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
  z-index: 10;
  box-shadow: 0 -4px 12px rgba(15,23,42,0.04);
}

/* ── Hub panel refresh ── */
.hub-panel {
  background: linear-gradient(145deg, #1e3a8a 0%, #1d4ed8 50%, #172554 100%);
  border-radius: var(--radius);
  padding: 2rem;
  margin-bottom: 1.5rem;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.hub-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.85rem;
  max-width: 520px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.hub-btn {
  background: rgba(255,255,255,0.96);
  border: none;
  border-radius: var(--radius-sm);
  padding: 1.15rem 0.5rem;
  font-family: var(--font);
  font-weight: 700;
  font-size: 0.88rem;
  color: #1e293b;
  cursor: pointer;
  transition: all 0.18s;
  text-align: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.12);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}

.hub-btn .hub-icon { display: inline-flex; align-items: center; justify-content: center; }

.hub-btn:hover {
  background: #fff;
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
}

/* ── Module cards refresh ── */
.module-card {
  box-shadow: var(--shadow-card);
}

.panel {
  box-shadow: var(--shadow-card);
}

.pos-products, .pos-cart {
  box-shadow: var(--shadow-card);
}

/* ── Table toolbar ── */
.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}

.cashbox-panel,
.purchases-panel { display: none; }
.cashbox-panel.active,
.purchases-panel.active { display: block; }

.sales-panel { display: none; }
.sales-panel.active { display: block; }

.cashbox-tabs { background: var(--surface); }

/* ── Responsive ── */
@media (max-width: 1024px) {
  .pos-layout,
  .pos-layout--v2 { grid-template-columns: 1fr; height: auto; }
  .pos-order { min-height: 420px; }
  .sidebar-toggle { display: inline-flex; }
  .sidebar-mobile-close { display: inline-flex; }
  .page-header { right: 0; }
  .main-content { margin-right: 0; width: 100%; }
  .sidebar {
    position: fixed;
    right: 0;
    top: 0;
    transform: translateX(100%);
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.18);
  }
  .sidebar.open { transform: translateX(0); }
}

@media (max-width: 640px) {
  .page-body { padding: 1rem; }
  .page-header {
    padding: 0.75rem 1rem;
    flex-wrap: wrap;
    align-items: flex-start;
  }
  .page-header h2 { font-size: 1.15rem; }
  .page-subtitle { font-size: 0.78rem; }
  .page-header-actions { width: 100%; justify-content: flex-end; }
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
  .invoice-footer { flex-direction: column; }
  .invoice-meta-bar { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .page-hero { padding: 1.25rem; }
  .quick-actions { flex-direction: column; }
}

/* ── Auth (login / signup) ── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.auth-wrap { width: 100%; max-width: 420px; }

.auth-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 2rem 1.75rem;
  border: 1px solid var(--border-light);
}

.auth-brand { text-align: center; margin-bottom: 1.5rem; }

.auth-logo {
  width: 56px;
  height: 56px;
  margin: 0 auto 0.75rem;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  font-size: 1.75rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-brand h1 { font-size: 1.35rem; font-weight: 800; }
.auth-brand p { color: var(--text-muted); font-size: 0.875rem; margin-top: 0.25rem; }

.auth-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  background: var(--bg-soft);
  padding: 0.35rem;
  border-radius: var(--radius-sm);
}

.auth-tab {
  flex: 1;
  border: none;
  background: transparent;
  padding: 0.6rem;
  border-radius: var(--radius-xs);
  font-family: var(--font);
  font-weight: 600;
  cursor: pointer;
  color: var(--text-secondary);
}

.auth-tab.active {
  background: var(--surface);
  color: var(--primary-dark);
  box-shadow: var(--shadow-sm);
}

.auth-form .form-group { margin-bottom: 1rem; }
.auth-hint { font-size: 0.78rem; color: var(--text-muted); text-align: center; margin-top: 0.75rem; }
.auth-footer-note { text-align: center; margin-top: 1rem; font-size: 0.8rem; }

.sidebar-user-link { margin-top: 0.25rem; }
.sidebar-logout-btn {
  width: 100%;
  text-align: right;
  border: none;
  background: none;
  cursor: pointer;
  font-family: var(--font);
  font-size: inherit;
  color: inherit;
  padding: 0.65rem 1rem;
  border-radius: var(--radius-xs);
}
.sidebar-logout-btn:hover { background: var(--sidebar-hover); }

/* ── Account page ── */
.account-card {
  max-width: 480px;
  padding: 2rem;
  text-align: center;
}

.account-avatar {
  width: 72px;
  height: 72px;
  margin: 0 auto 1rem;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary-dark);
  font-size: 2rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

.account-card h3 { font-size: 1.35rem; margin-bottom: 0.25rem; }
.account-role { color: var(--text-muted); margin-bottom: 1.5rem; }

.account-details {
  text-align: right;
  margin-bottom: 1.5rem;
}

.account-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border-light);
}

.account-row dt { color: var(--text-muted); font-size: 0.875rem; }
.account-row dd { font-weight: 600; word-break: break-all; }
.account-id { font-size: 0.75rem; font-family: monospace; direction: ltr; text-align: left; }

.account-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border: none;
}
.btn-danger:hover { filter: brightness(0.95); }

/* ── Invoice summary (مخلص الفاتورة — عرض أفقي) ── */
.invoice-summary-wrap {
  margin: 1.25rem 0 0;
  padding-top: 1.25rem;
  border-top: 2px solid var(--border);
}

.invoice-summary-head {
  margin-bottom: 0.85rem;
  border-radius: var(--radius-sm);
}

.invoice-summary-head-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.badge-soft {
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 700;
}

.invoice-summary-bar {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.summary-col {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.85rem 1rem;
  border-left: 1px solid var(--border-light);
  min-height: 96px;
}

.summary-col:first-child {
  border-left: none;
}

.summary-col-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: none;
  white-space: nowrap;
}

.summary-col-values {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  direction: ltr;
  text-align: left;
}

.summary-col-values span {
  font-size: 0.95rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  line-height: 1.3;
}

.summary-col-sub {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  direction: ltr;
  text-align: left;
}

.summary-col-sub--grand {
  color: var(--primary-dark);
  font-weight: 700;
}

.summary-col-single {
  font-size: 1.1rem;
  font-weight: 800;
  color: #059669;
  direction: ltr;
  text-align: left;
  font-variant-numeric: tabular-nums;
}

.summary-col--input {
  background: #fafbff;
}

.summary-col--highlight {
  background: linear-gradient(to bottom, #eff6ff, #fff);
}

.summary-col--accent {
  background: linear-gradient(to bottom, #ecfdf5, #fff);
}

.summary-col--accent .summary-col-values span {
  color: #059669;
}

.summary-col--balance {
  background: linear-gradient(to bottom, #f0fdf4, #fff);
}

.summary-input {
  width: 100%;
  max-width: 120px;
  padding: 0.5rem 0.65rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xs);
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 700;
  text-align: left;
  direction: ltr;
  color: var(--text);
  background: #fff;
}

.summary-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.sales-paid-dual {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  width: 100%;
  max-width: 130px;
}

.sales-paid-dual .summary-input {
  max-width: 100%;
}

#sales-paid-locked-label {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
}

#sales-settlement-wrap .field-hint {
  margin-top: 0.45rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* display:flex على .form-group يتجاوز [hidden] — إجبار الإخفاء عند نقد */
#sales-settlement-wrap[hidden],
#sales-settlement-wrap.is-cash-hidden {
  display: none !important;
}

.invoice-footer--meta {
  margin-top: 0.75rem;
  padding-top: 0;
  border-top: none;
}

@media (max-width: 1100px) {
  .invoice-summary-bar {
    grid-template-columns: repeat(3, 1fr);
  }
  .summary-col:nth-child(3n + 1) {
    border-left: none;
  }
  .summary-col {
    border-bottom: 1px solid var(--border-light);
  }
}

@media (max-width: 640px) {
  .invoice-summary-bar {
    grid-template-columns: repeat(2, 1fr);
  }
  .summary-col:nth-child(odd) {
    border-left: none;
  }
}

/* ── Sales page (redesign) ── */
.page-body--sales {
  padding-bottom: 2rem;
}

.sales-invoice {
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow: hidden;
  border-radius: var(--radius);
}

.sales-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 1.35rem 1.5rem;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 55%, #0ea5e9 100%);
  color: #fff;
}

.sales-hero-main {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
}

.sales-hero-tag {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.85;
  background: rgba(255,255,255,0.15);
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
}

.sales-hero-number {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0;
  direction: ltr;
}

.sales-hero .badge-soft {
  background: rgba(255,255,255,0.2);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.25);
}

.sales-hero-meta {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
}

.sales-hero-field label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  opacity: 0.85;
  margin-bottom: 0.3rem;
}

.sales-hero-field .form-control {
  background: rgba(255,255,255,0.95);
  border: none;
  min-width: 150px;
}

.sales-exchange-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  backdrop-filter: blur(4px);
}

.sales-exchange-pill strong {
  font-size: 1rem;
  direction: ltr;
}

.sales-grid-2 {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 0;
  border-bottom: 1px solid var(--border);
}

.sales-card {
  padding: 1.25rem 1.5rem;
  border-left: 1px solid var(--border-light);
}

.sales-card:first-child {
  border-left: none;
}

.sales-card-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.sales-card-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-light);
  border-radius: 8px;
  font-size: 1rem;
}

.sales-card-head h4 {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text);
  margin: 0;
}

.sales-inline-fields {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.sales-notes {
  margin-top: 0.75rem;
  margin-bottom: 0;
}

.sales-card--balance {
  background: linear-gradient(to bottom, #f0fdf4, #fff);
}

.sales-balance-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.sales-balance-item {
  background: #fff;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  box-shadow: var(--shadow-sm);
}

.sales-balance-currency {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  margin-bottom: 0.25rem;
}

.sales-balance-val {
  display: block;
  font-size: 1.35rem;
  font-weight: 800;
  color: #166534;
  direction: ltr;
  text-align: left;
  font-variant-numeric: tabular-nums;
}

.sales-stock-hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  background: rgba(255,255,255,0.8);
  border: 1px dashed #86efac;
  border-radius: var(--radius-xs);
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.sales-stock-hint strong {
  color: var(--text);
  direction: ltr;
}

.sales-lines-section {
  padding: 1.25rem 1.5rem;
  background: #fff;
}

.sales-lines-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.sales-lines-head h4 {
  font-size: 0.95rem;
  font-weight: 800;
  margin: 0 0 0.15rem;
}

.sales-lines-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 0;
}

.sales-table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.sales-lines-table thead {
  background: linear-gradient(to left, #f1f5f9, #e2e8f0);
}

.sales-lines-table th.col-qty { width: 118px; }
.sales-lines-table th.col-action { width: 48px; }
.sales-lines-table .line-qty-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 88px;
}
.sales-lines-table .line-qty-wrap .line-qty {
  min-width: 0;
  font-size: 0.85rem;
  padding: 0.35rem 0.5rem;
}
.sales-lines-table .line-stock-avail {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted, #64748b);
  white-space: nowrap;
  line-height: 1.2;
}
.sales-lines-table .line-stock-avail.is-low {
  color: #b45309;
}
.sales-lines-table .line-stock-avail.is-zero {
  color: #dc2626;
}
.sales-lines-table .line-dual-input {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 100px;
}

.sales-lines-table .line-dual-input .form-control {
  min-width: 0;
  font-size: 0.78rem;
  padding: 0.35rem 0.5rem;
}

.sales-invoice .invoice-summary-wrap {
  margin: 0;
  padding: 1.25rem 1.5rem 1.5rem;
  border-top: 1px solid var(--border);
  background: linear-gradient(to bottom, #f8fafc, #fff);
}

.sales-invoice .invoice-summary-head {
  margin-bottom: 0.85rem;
  padding: 0;
  background: none;
  border: none;
}

.sales-invoice .invoice-summary-head h4 {
  font-size: 0.95rem;
  font-weight: 800;
  margin: 0;
}

.sales-invoice .invoice-summary-bar {
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.06);
}

.sales-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 1rem 1.5rem 1.35rem;
  background: #fff;
  border-top: 1px solid var(--border);
}

.sales-actions .message {
  flex: 1;
  min-width: 200px;
  margin: 0;
}

.btn-lg {
  padding: 0.7rem 1.5rem;
  font-size: 0.95rem;
  font-weight: 700;
}

@media (max-width: 960px) {
  .sales-grid-2 {
    grid-template-columns: 1fr;
  }
  .sales-card {
    border-left: none;
    border-bottom: 1px solid var(--border-light);
  }
  .sales-inline-fields {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .sales-hero {
    padding: 1rem;
  }
  .sales-hero-number {
    font-size: 1.4rem;
  }
  .sales-lines-section,
  .sales-invoice .invoice-summary-wrap,
  .sales-actions {
    padding-right: 1rem;
    padding-left: 1rem;
  }
}

/* ── Page layout utilities ── */
.page-tabs,
.cashbox-tabs.page-tabs {
  margin-bottom: 1rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}

.page-section {
  margin-bottom: 1.25rem;
}

.form-control--compact {
  max-width: 240px;
  padding: 0.45rem 0.75rem;
  font-size: 0.82rem;
}

.form-actions--flat {
  border-top: none;
  padding-top: 0;
  margin-top: 0.5rem;
}

.page-body--pos {
  padding-bottom: 0.5rem;
}

.pos-tabs-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.pos-panel {
  display: none;
}

.pos-panel.active {
  display: block;
}

.pos-history-filters {
  margin-bottom: 1.25rem;
  align-items: end;
}

.pos-history-filter-actions {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}

.pos-session-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.pos-rate-label {
  margin-right: auto;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.pos-cart-customer {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.pos-discount-field,
.pos-paid-field {
  margin: 0.5rem 0;
}

.pos-discount-field label,
.pos-paid-field label {
  font-size: 0.78rem;
}

.pos-complete-btn {
  margin-top: 0.5rem;
  padding: 0.85rem;
}

.exchange-badge--header {
  font-size: 0.78rem;
}

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

.item-image-upload {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.85rem 1rem;
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  background: #f8fafc;
}

.item-image-preview {
  width: 96px;
  height: 96px;
  border-radius: 12px;
  overflow: hidden;
  background: #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.item-image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.item-image-placeholder {
  font-size: 0.72rem;
  color: #94a3b8;
  text-align: center;
  padding: 0.35rem;
}

.item-image-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.item-image-hint {
  width: 100%;
  margin: 0.15rem 0 0;
  font-size: 0.75rem;
  color: #94a3b8;
}

.pos-product-thumb,
.pos-cart-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.pos-product-media .pos-product-thumb {
  width: 100%;
  height: 100%;
}

.pos-product-thumb.is-fallback,
.pos-cart-thumb.is-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
  font-weight: 800;
  color: #64748b;
  letter-spacing: -0.03em;
  background: linear-gradient(145deg, #e2e8f0, #f8fafc 55%, #dbeafe);
}

.pos-cart-thumb {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  overflow: hidden;
  background: linear-gradient(145deg, #e2e8f0, #f8fafc);
  flex-shrink: 0;
}

.pos-cart-thumb.is-fallback {
  font-size: 1.1rem;
}

.account-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  justify-content: center;
}

/* ── فريق العمل ── */
.team-org-banner .panel-body {
  padding: 1rem 1.25rem;
}

.team-org-banner p {
  margin: 0 0 0.35rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.team-org-name {
  font-weight: 700;
  color: var(--primary);
}

.team-tabs {
  margin-bottom: 1rem;
}

.team-tab-panel[hidden] {
  display: none !important;
}

.team-invite-box {
  margin-top: 1rem;
  padding: 1rem;
  background: #f8fafc;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
}

.team-invite-link-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.permissions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.5rem;
  margin: 1rem 0;
}

.perm-check-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  background: #f8fafc;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.82rem;
  transition: border-color 0.15s;
}

.perm-check-label:hover {
  border-color: var(--primary);
}

.perm-check-label input {
  flex-shrink: 0;
}

.team-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: flex-start;
}

.btn-danger-text {
  color: var(--danger);
  border-color: #fecaca;
}

.btn-danger-text:hover {
  background: #fef2f2;
  border-color: var(--danger);
  color: #b91c1c;
}

/* ── نافذة منبثقة (تأكيد / خطأ) ── */
.app-modal-root {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.app-modal-root[hidden] {
  display: none !important;
}

.app-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.app-modal-root.open .app-modal-backdrop {
  opacity: 1;
}

.app-modal {
  position: relative;
  z-index: 1;
  width: min(100%, 420px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 24px 48px rgba(15, 23, 42, 0.18);
  padding: 1.75rem 1.5rem 1.5rem;
  text-align: center;
  transform: scale(0.92) translateY(12px);
  opacity: 0;
  transition: transform 0.22s ease, opacity 0.22s ease;
}

.app-modal-root.open .app-modal {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.app-modal-close {
  position: absolute;
  top: 0.85rem;
  left: 0.85rem;
  width: 2rem;
  height: 2rem;
  border: none;
  background: #f1f5f9;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  transition: background 0.15s, color 0.15s;
}

.app-modal-close:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.app-modal-close .ico {
  width: 1rem;
  height: 1rem;
}

.app-modal-icon {
  width: 3.5rem;
  height: 3.5rem;
  margin: 0 auto 1rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-modal-icon .ico {
  width: 1.65rem;
  height: 1.65rem;
}

.app-modal-icon--warn {
  background: #fef3c7;
  color: #d97706;
}

.app-modal-icon--danger,
.app-modal-icon--error {
  background: #fee2e2;
  color: #dc2626;
}

.app-modal-icon--success {
  background: #dcfce7;
  color: #16a34a;
}

.app-modal-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: #0f172a;
  margin: 0 0 0.5rem;
}

.app-modal-message {
  font-size: 0.9rem;
  color: #64748b;
  line-height: 1.65;
  margin: 0 0 1.35rem;
  white-space: pre-line;
}

.app-modal-actions {
  display: flex;
  gap: 0.65rem;
  justify-content: center;
  flex-wrap: wrap;
}

.app-modal-actions .btn {
  min-width: 7rem;
  padding: 0.65rem 1.25rem;
}

.btn-danger {
  background: #dc2626;
  border-color: #dc2626;
  color: #fff;
}

.btn-danger:hover {
  background: #b91c1c;
  border-color: #b91c1c;
}

body.modal-open {
  overflow: hidden;
}

/* ============================================================
   إخفاء أشرطة التمرير + أزرار الأرقام — كل الصفحات
   التمرير يبقى يعمل بالعجلة / اللمس
   ============================================================ */

html,
body,
* {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar,
*::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
  background: transparent;
}

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

input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}
