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

:root {
  --primary: #2563EB;
  --primary-dark: #1D4ED8;
  --primary-light: #DBEAFE;
  --primary-lighter: #EFF6FF;
  --bg: #F1F5F9;
  --card-bg: #FFFFFF;
  --text: #0F172A;
  --text-secondary: #64748B;
  --text-tertiary: #94A3B8;
  --border: #E2E8F0;
  --border-light: #F1F5F4;
  --warning: #F59E0B;
  --warning-bg: #FFFBEB;
  --danger: #EF4444;
  --danger-bg: #FEF2F2;
  --success: #22C55E;
  --success-bg: #F0FDF4;
  --badge-red: #EF4444;
  --badge-yellow: #F59E0B;
  --badge-green: #22C55E;
  --badge-purple: #8B5CF6;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
  --radius: 12px;
  --radius-card: 16px;
  --radius-xl: 20px;
  --radius-2xl: 20px;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Kufi Arabic", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 120px;
}

/* ========== SPLASH / AUTH-STYLE ========== */
.splash {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.6s, transform 0.6s;
}

.splash.fade-out {
  opacity: 0;
  transform: scale(1.03);
  pointer-events: none;
}

.splash-content {
  text-align: center;
  padding: 40px 32px;
  max-width: 400px;
  width: 100%;
}

.splash-brand-text {
  margin-bottom: 32px;
}

.splash-44x {
  font-size: 52px;
  font-weight: 800;
  color: #1E3A5F;
  letter-spacing: -2px;
  display: block;
  line-height: 1;
}

.splash-desc {
  font-size: 16px;
  color: var(--text-secondary);
  margin-top: 10px;
  font-weight: 500;
}

.splash-spinner {
  display: inline-block;
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 16px;
}

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

.splash-loading-text {
  font-size: 14px;
  color: var(--text-tertiary);
}

/* ========== APP SHELL ========== */
.app {
  min-height: 100vh;
}

/* ========== TOP HEADER ========== */
.top-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: #FFFFFF;
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.brand-44x {
  font-size: 22px;
  font-weight: 800;
  color: #1E3A5F;
  letter-spacing: -1px;
}

.brand-sub {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-tagline {
  text-align: center;
  font-size: 12px;
  color: var(--text-tertiary);
}

.header-date-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.date-pill {
  direction: ltr;
  unicode-bidi: plaintext;
  text-align: center;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.5px;
  padding: 8px 16px;
  border: 1.5px solid var(--border);
  border-radius: 100px;
  background: var(--card-bg);
  color: var(--text);
  width: 150px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.date-pill:focus {
  outline: none;
  border-color: var(--primary);
}

.new-session-btn {
  padding: 8px 14px;
  border: 1.5px solid var(--danger);
  border-radius: 100px;
  background: transparent;
  color: var(--danger);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s, color 0.2s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.new-session-btn:active {
  background: var(--danger-bg);
}

/* ========== BRANCH SECTION ========== */
.branch-section {
  padding: 16px 16px 8px;
}

.section-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.label-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
}

.branch-select {
  width: 100%;
  padding: 14px 16px;
  font-size: 16px;
  font-family: inherit;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  color: var(--text);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 14px center;
  padding-left: 40px;
  cursor: pointer;
  transition: border-color 0.2s;
}

.branch-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* ========== SEARCH BAR ========== */
.search-section {
  padding: 4px 16px 12px;
}

.search-box {
  position: relative;
}

.search-box input {
  width: 100%;
  padding: 12px 44px 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  background: var(--card-bg);
  font-size: 15px;
  color: var(--text);
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-shadow: var(--shadow-sm);
}

.search-box input::placeholder {
  color: var(--text-tertiary);
}

.search-box input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.search-icon {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  color: var(--text-tertiary);
  pointer-events: none;
}

/* ========== SECTION ========== */
.section {
  margin: 12px 16px;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 4px 10px;
  margin-bottom: 2px;
}

.section-header h2 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}

.section-count {
  font-size: 12px;
  color: var(--text-tertiary);
  background: var(--border-light);
  padding: 2px 10px;
  border-radius: 100px;
  font-weight: 600;
}

/* ========== PRODUCT CARDS (MONDAY.COM STYLE) ========== */
.product-card {
  background: var(--card-bg);
  border-radius: var(--radius-card);
  padding: 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s;
  border: 1px solid var(--border-light);
}

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

.product-card.manual-review {
  border-color: var(--warning);
  background: linear-gradient(135deg, var(--card-bg) 0%, var(--warning-bg) 100%);
}

.product-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.product-info {
  flex: 1;
  min-width: 0;
}

.product-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
}

.product-name-en {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 400;
  display: block;
  margin-top: 2px;
}

.product-name .badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 10px;
  font-weight: 600;
  margin-right: 6px;
  vertical-align: middle;
  background: var(--warning-bg);
  color: var(--warning);
}

.product-name .badge.badge-approved {
  background: var(--success-bg);
  color: var(--success);
}

.product-calculation {
  text-align: left;
  direction: ltr;
  flex-shrink: 0;
  background: var(--primary-lighter);
  padding: 6px 14px;
  border-radius: var(--radius);
  min-width: 80px;
}

.calc-value {
  font-size: 20px;
  font-weight: 800;
  color: var(--primary);
  display: block;
  line-height: 1;
}

.calc-unit {
  font-size: 10px;
  color: var(--text-tertiary);
  display: block;
  text-align: center;
  margin-top: 1px;
}

/* ========== UNIT SEGMENTED BUTTONS ========== */
.unit-segment {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.unit-btn {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 100px;
  background: var(--card-bg);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

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

/* ========== ENTRY ROWS (multi-unit) ========== */
.entry-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.entry-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border-radius: 14px;
  padding: 8px 8px 8px 12px;
}

.entry-row .qty-input {
  flex: 1;
  min-width: 0;
  font-size: 20px;
  font-weight: 700;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: var(--card-bg);
  text-align: center;
  min-height: 48px;
  color: var(--text);
  font-family: inherit;
  transition: border-color 0.2s, background 0.2s;
}

.entry-row .qty-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.unit-select {
  padding: 10px 36px 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  color: var(--text);
  background: var(--card-bg);
  cursor: pointer;
  min-width: 100px;
  min-height: 48px;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 12px center;
  background-size: 12px;
  transition: border-color 0.2s;
}

.unit-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.delete-row-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: var(--border-light);
  color: var(--text-secondary);
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, color 0.2s;
  -webkit-tap-highlight-color: transparent;
  line-height: 1;
}

.delete-row-btn:active {
  background: var(--border);
  color: var(--text);
}

.add-row-btn {
  width: 100%;
  padding: 12px;
  border: 2px dashed var(--primary);
  border-radius: 14px;
  background: var(--primary-lighter);
  color: var(--primary);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.add-row-btn:active {
  background: var(--primary-light);
  border-color: var(--primary-dark);
}

.card-total-line {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  padding: 6px 0 2px;
  border-top: 1px solid var(--border-light);
  margin-top: 6px;
}

.card-total-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.card-total-value {
  font-size: 16px;
  font-weight: 800;
  color: var(--primary);
  direction: ltr;
}

.row-error {
  color: var(--danger);
  font-size: 12px;
  font-weight: 500;
  padding: 6px 12px;
  background: var(--danger-bg);
  border-radius: 10px;
  display: none;
  margin: 4px 12px 0;
}

.row-error.visible {
  display: block;
}

/* ========== QUANTITY INPUT ========== */
.input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.qty-input {
  flex: 1;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  background: var(--bg);
  text-align: center;
  font-family: inherit;
  transition: border-color 0.2s, background 0.2s;
  min-height: 44px;
}

.qty-input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--card-bg);
}

.qty-input::placeholder {
  color: var(--text-tertiary);
  font-weight: 400;
  font-size: 15px;
}

.input-error {
  border-color: var(--danger) !important;
  background: var(--danger-bg) !important;
}

.error-msg {
  color: var(--danger);
  font-size: 12px;
  font-weight: 500;
  padding: 6px 12px;
  background: var(--danger-bg);
  border-radius: var(--radius);
  display: none;
  margin-bottom: 2px;
}

.error-msg.visible {
  display: block;
}

/* ========== EMPTY STATE ========== */
.empty-state,
.loading-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.empty-state .icon,
.loading-state .icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.empty-state p,
.loading-state p {
  font-size: 15px;
}

/* ========== LAN INFO BAR ========== */
.lan-bar {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 2px 0 4px;
  font-size: 11px;
  color: var(--text-tertiary);
}

.lan-item strong {
  color: var(--text);
  font-weight: 600;
}

/* ========== VERSION BAR ========== */
.version-bar {
  text-align: center;
  padding: 4px 0 2px;
}

.version-label {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 500;
}

/* ========== FOOTER ========== */
.app-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  box-shadow: 0 -4px 12px rgba(0,0,0,0.04);
}

.summary-bar {
  display: flex;
  justify-content: space-around;
  align-items: center;
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--text-secondary);
}

.summary-bar .stat {
  display: flex;
  align-items: center;
  gap: 4px;
}

.summary-bar .stat strong {
  color: var(--text);
  font-weight: 700;
}

.summary-bar .stat.warning-text strong {
  color: var(--warning);
}

.export-btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--radius-2xl);
  background: var(--primary);
  color: white;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  box-shadow: 0 4px 12px rgba(37,99,235,0.25);
}

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

.export-btn:hover {
  background: var(--primary-dark);
}

.export-btn:disabled {
  background: var(--border);
  color: var(--text-tertiary);
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.7;
}

/* ========== FAB ========== */
.fab {
  position: fixed;
  bottom: 100px;
  left: 20px;
  z-index: 90;
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-size: 28px;
  font-weight: 300;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(37,99,235,0.35);
  transition: transform 0.2s, box-shadow 0.2s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  line-height: 1;
}

.fab:active {
  transform: scale(0.92);
  box-shadow: 0 2px 8px rgba(37,99,235,0.25);
}

/* ========== MODAL ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(15, 23, 42, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--card-bg);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: var(--shadow-lg);
  transform: translateY(24px);
  transition: transform 0.25s;
}

.modal-overlay.open .modal {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-header h2 {
  font-size: 19px;
  font-weight: 700;
}

.modal-close {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: var(--border-light);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  -webkit-tap-highlight-color: transparent;
  transition: background 0.2s;
}

.modal-close:active {
  background: var(--border);
}

.modal-summary-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}

.stat-card {
  padding: 14px;
  border-radius: var(--radius);
  background: var(--bg);
  text-align: center;
}

.stat-card .num {
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
  display: block;
}

.stat-card .label {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.stat-card.danger .num {
  color: var(--danger);
}

.stat-card.warning .num {
  color: var(--warning);
}

.modal-manual-list {
  margin-bottom: 20px;
}

.modal-manual-list h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--warning);
}

.modal-manual-list ul {
  list-style: none;
  padding: 0;
}

.modal-manual-list li {
  padding: 6px 10px;
  font-size: 13px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-light);
}

.modal-export-info {
  margin-bottom: 16px;
  padding: 12px;
  background: var(--bg);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.export-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}

.info-label {
  color: var(--text-secondary);
  font-weight: 500;
}

.info-value {
  color: var(--text);
  font-weight: 600;
  direction: ltr;
  text-align: right;
}

.filename-value {
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  background: var(--card-bg);
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  direction: ltr;
  text-align: left;
  word-break: break-all;
  max-width: 100%;
}

/* ========== REVIEW SECTION ========== */
.review-section {
  margin-bottom: 16px;
}

.review-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.review-section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.review-empty {
  font-size: 13px;
  color: var(--text-tertiary);
  padding: 12px;
  text-align: center;
}

.review-change-item {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 8px;
  border-right: 4px solid var(--warning);
}

.review-change-item.is-zero {
  border-right-color: var(--danger);
}

.review-change-item.is-new {
  border-right-color: var(--primary);
}

.review-item-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.review-item-compare {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
  direction: ltr;
  text-align: left;
}

.review-item-compare .old {
  color: var(--text-secondary);
}

.review-item-compare .new {
  color: var(--text);
  font-weight: 600;
}

.review-item-warning {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 100px;
}

.review-item-warning.warn-surge {
  background: var(--warning-bg);
  color: #D97706;
}

.review-item-warning.warn-zero {
  background: var(--danger-bg);
  color: var(--danger);
}

.review-item-warning.warn-new {
  background: var(--primary-lighter);
  color: var(--primary);
}

.modal-actions {
  display: flex;
  gap: 10px;
}

.modal-actions button {
  flex: 1;
  padding: 14px;
  border: none;
  border-radius: var(--radius-2xl);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.2s;
}

.btn-cancel {
  background: var(--border-light);
  color: var(--text);
}

.btn-cancel:active {
  background: var(--border);
}

.btn-confirm {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 12px rgba(37,99,235,0.25);
}

.btn-confirm:active {
  background: var(--primary-dark);
}

.btn-confirm:disabled {
  background: var(--border);
  color: var(--text-tertiary);
  box-shadow: none;
  cursor: not-allowed;
}

/* ========== ADD PRODUCT FORM ========== */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: var(--card-bg);
  transition: border-color 0.2s;
}

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

.form-group select {
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 12px center;
  padding-left: 36px;
}

.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
}

.form-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

.form-check label {
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
}

.unit-options-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-light);
}

.unit-options-section h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.unit-option-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.unit-option-row input[type="text"] {
  flex: 2;
  min-width: 70px;
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
}

.unit-option-row input[type="number"] {
  flex: 1;
  min-width: 60px;
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
}

.unit-option-row input:focus {
  outline: none;
  border-color: var(--primary);
}

.unit-option-check {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.unit-option-check input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.add-unit-btn {
  padding: 8px 16px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  background: none;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.2s, color 0.2s;
}

.add-unit-btn:active {
  border-color: var(--primary);
  color: var(--primary);
}

.form-error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 12px;
  display: none;
}

.form-error.visible {
  display: block;
}

/* ========== WIZARD INFO BAR ========== */
.wizard-info {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: var(--primary-lighter);
  border-bottom: 1px solid var(--primary-light);
  font-size: 13px;
  direction: rtl;
}

.wizard-info-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.wizard-info-label {
  color: var(--text-secondary);
  font-weight: 500;
}

.wizard-info-value {
  color: var(--primary);
  font-weight: 700;
  direction: ltr;
  text-align: right;
}

.wizard-info-divider {
  width: 1px;
  height: 16px;
  background: var(--primary-light);
}

/* ========== WIZARD BAR ========== */
.wizard-bar {
  padding: 4px 8px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.wizard-bar::-webkit-scrollbar {
  display: none;
}

.wizard-steps {
  display: flex;
  gap: 4px;
  min-width: max-content;
  padding: 4px 0;
}

.wizard-tab {
  padding: 10px 14px;
  border: none;
  border-radius: 100px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s, color 0.2s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  flex-shrink: 0;
}

.wizard-tab:active {
  background: var(--border-light);
}

.wizard-tab.active {
  background: var(--primary);
  color: #FFFFFF;
  font-weight: 600;
}

/* ========== WIZARD NAVIGATION ========== */
.wizard-nav {
  display: flex;
  gap: 10px;
  padding: 12px 16px 20px;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  margin-top: 8px;
  position: sticky;
  bottom: 0;
  z-index: 10;
}

.wizard-nav-btn {
  flex: 1;
  padding: 14px 20px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-2xl);
  background: var(--card-bg);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.wizard-nav-btn:active {
  background: var(--bg);
}

.wizard-nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.wizard-nav-next {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(37,99,235,0.25);
}

.wizard-nav-next:active {
  background: var(--primary-dark);
}

.wizard-save-btn {
  flex-shrink: 0;
  padding: 14px 16px;
  border: 1px dashed var(--text-tertiary);
  border-radius: var(--radius-2xl);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.wizard-save-btn:active {
  border-color: var(--primary);
  color: var(--primary);
}

/* ========== REVIEW SCREEN ========== */
.review-screen {
  padding: 16px;
}

.review-screen h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
  text-align: center;
}

.review-card {
  background: var(--card-bg);
  border-radius: var(--radius-card);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
}

.review-card h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.review-card h3 .count-badge {
  background: var(--primary-lighter);
  color: var(--primary);
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 100px;
  font-weight: 600;
}

.review-card.warning-card h3 .count-badge {
  background: var(--warning-bg);
  color: var(--warning);
}

.review-card.danger-card h3 .count-badge {
  background: var(--danger-bg);
  color: var(--danger);
}

.review-card.success-card h3 .count-badge {
  background: var(--success-bg);
  color: var(--success);
}

.review-product-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
}

.review-product-item:last-child {
  border-bottom: none;
}

.review-product-name {
  font-weight: 600;
  color: var(--text);
}

.review-product-sku {
  font-size: 11px;
  color: var(--text-tertiary);
  font-family: monospace;
}

.review-product-detail {
  font-size: 12px;
  color: var(--text-secondary);
  direction: ltr;
  text-align: left;
}

.review-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

.review-stat-card {
  padding: 16px;
  border-radius: var(--radius);
  background: var(--bg);
  text-align: center;
}

.review-stat-number {
  font-size: 28px;
  font-weight: 800;
  color: var(--primary);
  display: block;
  line-height: 1;
}

.review-stat-label {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.review-filename {
  text-align: center;
  padding: 12px;
  background: var(--primary-lighter);
  border-radius: var(--radius);
  margin-top: 12px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  color: var(--primary);
  direction: ltr;
  word-break: break-all;
}

/* ========== REVIEW SUMMARY ========== */
.review-summary-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.review-summary-stat {
  flex: 1;
  background: var(--card-bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 12px 8px;
  text-align: center;
  font-size: 12px;
  color: var(--text-secondary);
}

.review-summary-stat strong {
  display: block;
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  margin-top: 4px;
}

.review-summary-stat.success strong {
  color: var(--success);
}

.review-summary-stat.danger strong {
  color: var(--danger);
}

.review-blocker {
  background: var(--danger-bg);
  border: 1px solid var(--danger);
  border-radius: var(--radius-card);
  padding: 16px;
  margin-bottom: 16px;
}

.review-blocker-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--danger);
  margin-bottom: 10px;
}

.review-missing-list {
  margin-top: 8px;
}

.review-missing-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.review-missing-list ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.review-missing-list li {
  padding: 6px 12px;
  font-size: 13px;
  color: var(--text);
  border-bottom: 1px solid var(--border-light);
}

.review-missing-list li:last-child {
  border-bottom: none;
}

/* ========== WIZARD ERROR ========== */
.wizard-error {
  text-align: center;
  padding: 12px 16px;
  margin: 8px 16px 0;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius);
  border: 1px solid var(--danger);
}

.wizard-error.hidden {
  display: none !important;
}

/* ========== MISSING INPUT HIGHLIGHT ========== */
.product-card.missing-highlight {
  border-color: var(--danger) !important;
  background: linear-gradient(135deg, var(--danger-bg) 0%, #fff5f5 100%) !important;
  animation: pulse-warning 1.5s ease-in-out infinite;
}

@keyframes pulse-warning {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.3); }
  50% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
}

.section-completion-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 4px;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.section-completion-bar .completion-count {
  font-weight: 700;
  color: var(--text);
}

.section-completion-bar .completion-count.done {
  color: var(--success);
}

/* ========== TOAST ========== */
.toast {
  position: fixed;
  bottom: 120px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  padding: 14px 24px;
  border-radius: var(--radius-2xl);
  background: var(--text);
  color: white;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  transition: opacity 0.3s, transform 0.3s;
  white-space: nowrap;
  direction: rtl;
}

.toast.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(12px);
  pointer-events: none;
}

/* ========== UPDATE BANNER ========== */
.update-banner {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 250;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px 10px 20px;
  border-radius: var(--radius-2xl);
  background: var(--text);
  color: white;
  box-shadow: var(--shadow-lg);
  transition: opacity 0.3s, transform 0.3s;
  direction: rtl;
  white-space: nowrap;
}

.update-banner.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(16px);
  pointer-events: none;
}

.update-banner-text {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}

.update-banner-btn {
  padding: 8px 18px;
  border: none;
  border-radius: 100px;
  background: var(--primary);
  color: white;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}

.update-banner-btn:active {
  background: var(--primary-dark);
}

/* ========== RESPONSIVE ========== */
@media (min-width: 768px) {
  .section {
    margin: 16px auto;
    max-width: 720px;
  }

  .top-header {
    padding-left: max(24px, env(safe-area-inset-left));
    padding-right: max(24px, env(safe-area-inset-right));
  }

  .app-footer {
    padding-left: max(24px, env(safe-area-inset-left));
    padding-right: max(24px, env(safe-area-inset-right));
  }

  .branch-section {
    padding-left: max(24px, env(safe-area-inset-left));
    padding-right: max(24px, env(safe-area-inset-right));
  }

  .search-section {
    padding-left: max(24px, env(safe-area-inset-left));
    padding-right: max(24px, env(safe-area-inset-right));
  }

  .product-card {
    padding: 18px;
  }
}

@media (min-width: 1024px) {
  .section {
    max-width: 800px;
  }
}

/* ========== UTILITY ========== */
.hidden {
  display: none !important;
}
