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

:root {
  --blue: #1a569d;
  --blue-light: #e8f0fa;
  --green: #22a06b;
  --green-light: #e6f7ef;
  --orange: #e07b00;
  --orange-light: #fff4e5;
  --purple: #7c3aed;
  --purple-light: #f3eeff;
  --red: #d9534f;
  --red-light: #fdecea;
  --gray-50: #f5f7f9;
  --gray-100: #eef1f4;
  --gray-200: #dde2e8;
  --gray-400: #9aa3ad;
  --gray-600: #5c6670;
  --gray-800: #1e293b;
  --phone-w: 375px;
  --phone-h: 780px;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,.10);
}

body {
  font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
  background: #e8eaed;
  color: var(--gray-800);
  direction: rtl;
  line-height: 1.4;
}

/* ── Gallery page ── */
.gallery {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

.gallery-header {
  text-align: center;
  margin-bottom: 48px;
}

.gallery-header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.gallery-header p {
  color: var(--gray-600);
  font-size: .95rem;
}

.screen-block {
  margin-bottom: 56px;
}

.screen-label {
  text-align: center;
  font-size: .9rem;
  color: var(--gray-600);
  margin-bottom: 16px;
  font-weight: 600;
}

/* ── Phone frame ── */
.phone {
  width: var(--phone-w);
  height: var(--phone-h);
  margin: 0 auto;
  background: #fff;
  border-radius: 36px;
  box-shadow: var(--shadow), 0 0 0 8px #1a1a1a, 0 0 0 10px #333;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

.phone-notch {
  height: 28px;
  background: #fff;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.phone-notch::after {
  content: '';
  width: 80px;
  height: 6px;
  background: #ddd;
  border-radius: 3px;
}

.phone-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--gray-50);
  -webkit-overflow-scrolling: touch;
}

.phone-body.no-scroll { overflow: hidden; }

/* ── App header ── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid var(--gray-100);
}

.app-header h2 {
  font-size: 1.05rem;
  font-weight: 700;
}

.app-header .greeting {
  font-size: .95rem;
  font-weight: 600;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--blue-light);
  border: 2px solid var(--blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 700;
  color: var(--blue);
  flex-shrink: 0;
}

.avatar-lg {
  width: 48px;
  height: 48px;
  font-size: .85rem;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: .82rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  white-space: nowrap;
}

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

.btn-outline {
  background: #fff;
  color: var(--gray-800);
  border: 1px solid var(--gray-200);
}

.btn-full {
  width: 100%;
  justify-content: center;
  padding: 13px;
  border-radius: var(--radius);
  font-size: .9rem;
}

.btn-sm {
  padding: 5px 10px;
  font-size: .75rem;
}

/* ── Bottom nav ── */
.bottom-nav {
  display: flex;
  background: #fff;
  border-top: 1px solid var(--gray-100);
  padding: 6px 0 10px;
  flex-shrink: 0;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: .65rem;
  color: var(--gray-400);
  text-decoration: none;
  padding: 4px 0;
}

.nav-item.active { color: var(--blue); font-weight: 700; }

.nav-icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

/* ── Stat cards ── */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 12px 16px;
}

.stat-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 14px;
  border: 1px solid var(--gray-100);
}

.stat-card .label {
  font-size: .78rem;
  color: var(--gray-600);
  margin-bottom: 4px;
}

.stat-card .value {
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 4px;
}

.stat-card .sub {
  font-size: .72rem;
  color: var(--gray-400);
}

.value-green { color: var(--green); }
.value-orange { color: var(--orange); }
.value-blue { color: var(--blue); }

/* ── Section ── */
.section {
  padding: 12px 16px;
}

.section-title {
  font-size: .88rem;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--gray-800);
}

/* ── Pipeline pills ── */
.pipeline {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.pipeline::-webkit-scrollbar { display: none; }

.pipeline-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 20px;
  font-size: .78rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

.pill-blue { background: var(--blue-light); color: var(--blue); }
.pill-orange { background: var(--orange-light); color: var(--orange); }
.pill-purple { background: var(--purple-light); color: var(--purple); }
.pill-green { background: var(--green-light); color: var(--green); }

/* ── Task rows ── */
.task-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 8px;
  border: 1px solid var(--gray-100);
}

.task-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.task-dot.red { background: var(--red); }
.task-dot.gray { background: var(--gray-200); }

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

.task-info .name {
  font-size: .85rem;
  font-weight: 600;
}

.task-info .time {
  font-size: .72rem;
  color: var(--gray-400);
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 10px;
  font-size: .68rem;
  font-weight: 700;
}

.badge-red { background: var(--red-light); color: var(--red); }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }
.badge-blue { background: var(--blue-light); color: var(--blue); }
.badge-orange { background: var(--orange-light); color: var(--orange); }
.badge-green { background: var(--green-light); color: var(--green); }
.badge-purple { background: var(--purple-light); color: var(--purple); }
.badge-teal { background: #e0f7f4; color: #00897b; }

/* ── Search & filters ── */
.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin: 0 16px 10px;
  font-size: .85rem;
  color: var(--gray-400);
}

.filter-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0 16px 12px;
  scrollbar-width: none;
}

.filter-chips::-webkit-scrollbar { display: none; }

.chip {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: .78rem;
  font-weight: 600;
  border: 1px solid var(--gray-200);
  background: #fff;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
}

.chip.active {
  background: var(--blue-light);
  border-color: var(--blue);
  color: var(--blue);
}

/* ── Lead card ── */
.lead-card {
  background: #fff;
  border-radius: var(--radius);
  margin: 0 16px 12px;
  padding: 14px;
  border: 1px solid var(--gray-100);
}

.lead-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.lead-name {
  font-size: .95rem;
  font-weight: 700;
}

.status-banner {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: .72rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.banner-red { background: var(--red-light); color: var(--red); }
.banner-orange { background: var(--orange-light); color: var(--orange); }

.lead-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: .72rem;
  color: var(--gray-600);
  margin-bottom: 12px;
}

.lead-meta span { display: flex; align-items: center; gap: 3px; }

.lead-actions {
  display: flex;
  justify-content: space-around;
  border-top: 1px solid var(--gray-100);
  padding-top: 10px;
}

.action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: .65rem;
  color: var(--gray-600);
  cursor: pointer;
}

.action-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .9rem;
}

.icon-green { background: var(--green-light); color: var(--green); }
.icon-purple { background: var(--purple-light); color: var(--purple); }
.icon-orange { background: var(--orange-light); color: var(--orange); }
.icon-blue { background: var(--blue-light); color: var(--blue); }

/* ── Customer card ── */
.customer-header {
  background: #fff;
  padding: 16px;
  border-bottom: 1px solid var(--gray-100);
}

.customer-top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.customer-name {
  font-size: 1.1rem;
  font-weight: 700;
}

.customer-id {
  font-size: .78rem;
  color: var(--gray-600);
}

.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.info-item .info-label {
  font-size: .68rem;
  color: var(--gray-400);
}

.info-item .info-value {
  font-size: .82rem;
  font-weight: 600;
}

.quick-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.quick-actions .btn { flex: 1; min-width: calc(50% - 4px); justify-content: center; font-size: .75rem; padding: 8px 6px; }

/* ── Table ── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .78rem;
}

.data-table th {
  text-align: right;
  padding: 8px 10px;
  color: var(--gray-400);
  font-weight: 600;
  border-bottom: 1px solid var(--gray-100);
}

.data-table td {
  padding: 10px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: top;
}

.data-table .product-name { font-weight: 600; }
.data-table .product-sub { font-size: .7rem; color: var(--gray-400); }

/* ── Timeline ── */
.timeline { position: relative; padding-right: 20px; }

.timeline-item {
  position: relative;
  padding-bottom: 16px;
  padding-right: 16px;
}

.timeline-item::before {
  content: '';
  position: absolute;
  right: -1px;
  top: 8px;
  bottom: -8px;
  width: 2px;
  background: var(--gray-200);
}

.timeline-item:last-child::before { display: none; }

.timeline-dot {
  position: absolute;
  right: -6px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid #fff;
}

.dot-blue { background: var(--blue); }
.dot-purple { background: var(--purple); }
.dot-green { background: var(--green); }

.timeline-title { font-size: .82rem; font-weight: 700; }
.timeline-desc { font-size: .75rem; color: var(--gray-600); margin: 2px 0; }
.timeline-time { font-size: .68rem; color: var(--gray-400); }

/* ── Modal overlay ── */
.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: flex-end;
  z-index: 10;
}

.modal-sheet {
  background: #fff;
  border-radius: 20px 20px 0 0;
  width: 100%;
  padding: 20px 16px 24px;
  max-height: 85%;
  overflow-y: auto;
}

.modal-handle {
  width: 40px;
  height: 4px;
  background: var(--gray-200);
  border-radius: 2px;
  margin: 0 auto 16px;
}

.modal-customer {
  text-align: center;
  margin-bottom: 16px;
}

.modal-customer h3 { font-size: 1rem; font-weight: 700; }
.modal-customer p { font-size: .85rem; color: var(--gray-600); }

.modal-question {
  font-size: .9rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 14px;
}

.outcome-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  background: #fff;
  font-size: .85rem;
  font-weight: 600;
  margin-bottom: 8px;
  cursor: pointer;
  text-align: right;
}

.outcome-btn .icon { font-size: 1.1rem; }

.outcome-btn.selected {
  border-color: var(--blue);
  background: var(--blue-light);
  color: var(--blue);
}

textarea.note-input {
  width: 100%;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: .82rem;
  font-family: inherit;
  resize: none;
  height: 70px;
  margin: 10px 0;
  direction: rtl;
}

/* ── Tasks page ── */
.task-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 14px;
  margin: 0 16px 10px;
  border: 1px solid var(--gray-100);
  display: flex;
  gap: 12px;
  align-items: flex-start;
  border-right: 3px solid transparent;
}

.task-card.overdue { border-right-color: var(--red); }

.task-check {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--gray-200);
  flex-shrink: 0;
  margin-top: 2px;
}

.task-card-body { flex: 1; }
.task-card-title { font-size: .88rem; font-weight: 700; }
.task-card-sub { font-size: .75rem; color: var(--gray-600); margin: 2px 0; }
.task-card-time { font-size: .72rem; color: var(--red); display: flex; align-items: center; gap: 4px; }
.task-card-time.normal { color: var(--gray-400); }

.group-header {
  padding: 8px 16px 6px;
  font-size: .82rem;
  font-weight: 700;
  color: var(--gray-600);
}

/* ── Inventory ── */
.inventory-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 0 16px 8px;
  border: 1px solid var(--gray-100);
}

.inventory-info .inv-name { font-size: .88rem; font-weight: 700; }
.inventory-info .inv-sku { font-size: .72rem; color: var(--gray-400); }

.stock-count {
  font-size: 1.4rem;
  font-weight: 800;
  min-width: 40px;
  text-align: center;
}

.stock-count.low { color: var(--red); }
.stock-count.ok { color: var(--green); }
.stock-count.infinity { color: var(--blue); font-size: 1.2rem; }

.inventory-legend {
  text-align: center;
  font-size: .72rem;
  color: var(--gray-400);
  padding: 8px 16px 16px;
}

/* ── Quote ── */
.quote-customer {
  background: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--gray-100);
}

.product-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  background: #fff;
  border-radius: var(--radius);
  padding: 14px;
  margin: 0 16px 8px;
  border: 1px solid var(--gray-100);
}

.product-info .prod-name { font-size: .88rem; font-weight: 700; }
.product-info .prod-desc { font-size: .72rem; color: var(--gray-400); }
.product-price { font-size: .9rem; font-weight: 700; color: var(--blue); white-space: nowrap; }

.form-section {
  background: #fff;
  margin: 0 16px 8px;
  border-radius: var(--radius);
  padding: 14px;
  border: 1px solid var(--gray-100);
}

.form-section label {
  display: block;
  font-size: .78rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--gray-600);
}

.form-section input {
  width: 100%;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: .85rem;
  font-family: inherit;
  direction: rtl;
}

.summary-box {
  background: #fff;
  margin: 0 16px 8px;
  border-radius: var(--radius);
  padding: 14px;
  border: 1px solid var(--gray-100);
}

.summary-row {
  display: flex;
  justify-content: space-between;
  font-size: .82rem;
  padding: 5px 0;
}

.summary-row.total {
  border-top: 1px solid var(--gray-100);
  margin-top: 6px;
  padding-top: 10px;
  font-weight: 800;
  font-size: .95rem;
}

.discount-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0;
}

.discount-row input {
  width: 60px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  font-size: .82rem;
  text-align: center;
}

.btn-whatsapp {
  background: #25d366;
  color: #fff;
  margin: 12px 16px 20px;
}

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

.page-pad { padding-bottom: 8px; }

/* ── Language switcher ── */
.lang-switcher {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 32px;
}

.lang-btn {
  padding: 8px 18px;
  border-radius: 20px;
  border: 1px solid var(--gray-200);
  background: #fff;
  font-size: .82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
  color: inherit;
  display: inline-block;
}

.lang-btn.active {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}

/* ── LTR overrides ── */
html[dir="ltr"] body { direction: ltr; }

html[dir="ltr"] .data-table th,
html[dir="ltr"] .data-table td { text-align: left; }

html[dir="ltr"] .timeline {
  padding-right: 0;
  padding-left: 20px;
}

html[dir="ltr"] .timeline-item {
  padding-right: 0;
  padding-left: 16px;
}

html[dir="ltr"] .timeline-item::before {
  right: auto;
  left: -1px;
}

html[dir="ltr"] .timeline-dot {
  right: auto;
  left: -6px;
}

html[dir="ltr"] .task-card.overdue {
  border-right-color: transparent;
  border-left: 3px solid var(--red);
}

html[dir="ltr"] .outcome-btn { text-align: left; }

html[dir="ltr"] textarea.note-input,
html[dir="ltr"] .form-section input { direction: ltr; text-align: left; }

html[dir="ltr"] .form-section label,
html[dir="ltr"] .info-item .info-label { text-align: left; }

html[dir="ltr"] .modal-customer { text-align: center; }

html[dir="ltr"] .lead-meta span,
html[dir="ltr"] .summary-row { flex-direction: row; }

html[dir="ltr"] .search-bar { flex-direction: row; }

html[dir="ltr"] .app-header .header-actions { flex-direction: row; }
