@font-face {
  font-family: 'Vazirmatn';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/vazirmatn-arabic.woff2') format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+FB50-FDFF, U+FE70-FEFC;
}
@font-face {
  font-family: 'Vazirmatn';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/vazirmatn-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+2000-206F;
}

:root,
[data-theme="light"] {
  --bg: #f1f5f9;
  --bg-accent: radial-gradient(circle at 12% 10%, rgba(14, 116, 144, 0.08), transparent 45%), radial-gradient(circle at 88% 8%, rgba(2, 132, 199, 0.07), transparent 40%);
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #e2e8f0;
  --text: #0f172a;
  --text-muted: #475569;
  --text-soft: #64748b;
  --border: #dbe3ee;
  --border-strong: #cbd5e1;
  --primary: #0e7490;
  --primary-hover: #0c627a;
  --primary-soft: rgba(14, 116, 144, 0.1);
  --accent: #0284c7;
  --success: #0f766e;
  --success-soft: rgba(15, 118, 110, 0.12);
  --warning: #b45309;
  --warning-soft: rgba(217, 119, 6, 0.13);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.11);
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 10px 28px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, 0.14);
  --radius: 14px;
  --radius-sm: 10px;
}

[data-theme="dark"] {
  --bg: #080e1a;
  --bg-accent: radial-gradient(circle at 15% 10%, rgba(56, 189, 248, 0.09), transparent 45%), radial-gradient(circle at 85% 5%, rgba(14, 116, 144, 0.12), transparent 40%);
  --surface: #111a2e;
  --surface-2: #17233b;
  --surface-3: #223250;
  --text: #f1f5f9;
  --text-muted: #cbd5e1;
  --text-soft: #94a3b8;
  --border: rgba(148, 163, 184, 0.18);
  --border-strong: rgba(148, 163, 184, 0.32);
  --primary: #0ea5e9;
  --primary-hover: #38bdf8;
  --primary-soft: rgba(14, 165, 233, 0.16);
  --accent: #38bdf8;
  --success: #34d399;
  --success-soft: rgba(16, 185, 129, 0.16);
  --warning: #fbbf24;
  --warning-soft: rgba(245, 158, 11, 0.16);
  --danger: #f87171;
  --danger-soft: rgba(239, 68, 68, 0.16);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 12px 30px rgba(0, 0, 0, 0.36);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.55);
}

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

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Vazirmatn', Tahoma, 'Segoe UI', sans-serif;
  background-color: var(--bg);
  background-image: var(--bg-accent);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
button, input, select, textarea { font-family: inherit; }

.hidden { display: none !important; }
.clickable { cursor: pointer; }
.ltr { direction: ltr; text-align: left; unicode-bidi: embed; }
.text-muted { color: var(--text-muted); }
.text-soft { color: var(--text-soft); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.fw-bold { font-weight: 700; }

/* Header / Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(10px);
}
.topbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-logo {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
}
.brand-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.25;
}
.brand-sub {
  font-size: 0.78rem;
  color: var(--text-soft);
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Live sync indicator */
.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--text-muted);
}
.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.live-dot.pulse {
  transform: scale(1.45);
  box-shadow: 0 0 0 5px var(--success-soft);
}

/* Layout Container */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}
.container-narrow {
  max-width: 980px;
  margin: 0 auto;
  padding: 20px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); transform: translateY(-1px); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { filter: brightness(1.08); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(1.08); }
.btn-warning { background: var(--warning); color: #fff; }
.btn-outline {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-outline:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--primary);
}
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-sm { padding: 6px 11px; font-size: 0.8rem; border-radius: 8px; }
.btn-lg { padding: 12px 22px; font-size: 0.96rem; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.card-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
}

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(205px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.kpi-label { font-size: 0.82rem; color: var(--text-soft); font-weight: 500; }
.kpi-value { font-size: 1.55rem; font-weight: 800; color: var(--text); line-height: 1.2; }
.kpi-accent { border-top: 3px solid var(--primary); }
.kpi-warning { border-top: 3px solid var(--warning); }
.kpi-success { border-top: 3px solid var(--success); }
.kpi-danger { border-top: 3px solid var(--danger); }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger  { background: var(--danger-soft);  color: var(--danger); }
.badge-primary { background: var(--primary-soft); color: var(--primary); }
.badge-muted   { background: var(--surface-3);    color: var(--text-muted); }

/* Tabs */
.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.tab-btn {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.16s ease;
}
.tab-btn:hover { background: var(--surface); color: var(--text); }
.tab-btn.active {
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 14px;
}
.col-12 { grid-column: span 12; }
.col-6  { grid-column: span 6; }
.col-4  { grid-column: span 4; }
.col-3  { grid-column: span 3; }

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field label {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text);
}
.req-star { color: var(--danger); margin-right: 3px; }
.input, select.input, textarea.input {
  width: 100%;
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.92rem;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
textarea.input { min-height: 82px; resize: vertical; }
.field-hint { font-size: 0.76rem; color: var(--text-soft); }

/* Non-refundable corporate notice matching attached paper form */
.tiva-notice-banner {
  background: linear-gradient(135deg, #c2410c, #ea580c);
  color: #ffffff;
  border-radius: var(--radius-sm);
  padding: 11px 16px;
  text-align: center;
  font-weight: 700;
  font-size: 0.94rem;
  letter-spacing: 0.1px;
  margin-bottom: 16px;
  box-shadow: 0 6px 16px rgba(194, 65, 12, 0.22);
}

/* Prepayment plan selector cards */
.plan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
}
.plan-card {
  position: relative;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  background: var(--surface-2);
  cursor: pointer;
  transition: all 0.18s ease;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.plan-card:hover { border-color: var(--primary); }
.plan-card.selected {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.plan-card-title { font-weight: 700; font-size: 0.92rem; color: var(--text); }
.plan-card-amount { font-weight: 800; font-size: 1.15rem; color: var(--primary); }
.plan-card-desc { font-size: 0.78rem; color: var(--text-soft); }

/* Camera / Timestamp Upload Box */
.upload-box {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color 0.2s ease;
}
.upload-box.has-verified { border-color: var(--success); background: var(--success-soft); }
.upload-box.has-failed { border-color: var(--danger); background: var(--danger-soft); }
.upload-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.upload-preview-wrap {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}
.upload-thumb {
  width: 112px;
  height: 84px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  cursor: zoom-in;
  background: var(--surface);
}
.ai-result-box {
  flex: 1;
  min-width: 210px;
  font-size: 0.82rem;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.ai-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}
thead th {
  background: var(--surface-2);
  color: var(--text-muted);
  font-weight: 700;
  text-align: right;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }

/* Mobile Request Cards (shown on small screens or marketer view) */
.req-cards-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.req-mobile-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.req-mobile-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.req-mobile-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* Filters bar */
.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
  align-items: flex-end;
}
.filters-bar .field { min-width: 155px; flex: 1; }

/* Permission switches */
.perm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 12px;
}
.perm-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.perm-item label { cursor: pointer; font-weight: 600; font-size: 0.87rem; }
.perm-desc { font-size: 0.77rem; color: var(--text-soft); margin-top: 2px; }
.switch {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  inset: 0;
  cursor: pointer;
  background: var(--border-strong);
  border-radius: 999px;
  transition: 0.2s;
}
.slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.2s;
}
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.65);
  backdrop-filter: blur(4px);
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-card {
  width: 100%;
  max-width: 820px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 22px;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.modal-close {
  border: none;
  background: var(--surface-2);
  color: var(--text);
  width: 34px;
  height: 34px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.86);
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.lightbox-card {
  position: relative;
  max-width: 92vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.lightbox-img {
  max-width: 100%;
  max-height: 80vh;
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
}
.lightbox-close {
  position: absolute;
  top: -14px;
  left: -14px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: #fff;
  color: #0f172a;
  font-weight: 800;
  cursor: pointer;
}
.lightbox-caption { color: #e2e8f0; font-size: 0.9rem; text-align: center; }

/* Toast Stack */
.toast-container {
  position: fixed;
  bottom: 22px;
  left: 22px;
  z-index: 140;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 380px;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  font-size: 0.86rem;
  font-weight: 600;
  opacity: 0;
  transform: translateY(12px);
  transition: all 0.22s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-badge {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 0.78rem;
  flex-shrink: 0;
}
.toast-success .toast-badge { background: var(--success); }
.toast-error .toast-badge   { background: var(--danger); }
.toast-warning .toast-badge { background: var(--warning); }
.toast-info .toast-badge    { background: var(--primary); }

/* Jalali Date Picker */
.jdp-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.45);
  z-index: 150;
}
.jdp-popup {
  z-index: 160;
  width: 310px;
  max-width: 94vw;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 14px;
  color: var(--text);
}
.jdp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.jdp-selects { display: flex; gap: 6px; flex: 1; }
.jdp-select {
  flex: 1;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 600;
}
.jdp-nav {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font-size: 1.1rem;
  cursor: pointer;
}
.jdp-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-soft);
  margin-bottom: 6px;
}
.jdp-weekdays .is-friday { color: var(--danger); }
.jdp-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.jdp-day, .jdp-empty {
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 0.85rem;
}
.jdp-day {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
}
.jdp-day:hover { background: var(--primary-soft); color: var(--primary); }
.jdp-day.is-friday { color: var(--danger); }
.jdp-day.is-today { border-color: var(--primary); color: var(--primary); }
.jdp-day.is-selected { background: var(--primary); color: #fff !important; }
.jdp-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.jdp-btn {
  padding: 5px 10px;
  border-radius: 7px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
}
.jdp-btn-today { border-color: var(--primary); color: var(--primary); }

/* Mobile PWA Bottom Bar (Marketer) */
.pwa-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 45;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 18px rgba(0, 0, 0, 0.08);
  padding: 6px 8px env(safe-area-inset-bottom, 6px);
}
.pwa-bottom-nav-inner {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.pwa-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 7px 4px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--text-soft);
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
}
.pwa-nav-item.active {
  background: var(--primary-soft);
  color: var(--primary);
}

/* Login Page */
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 470px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  padding: 28px;
}
.demo-box {
  margin-top: 18px;
  padding: 13px 15px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  font-size: 0.8rem;
}
.demo-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
}
.demo-row:last-child { border-bottom: none; }

/* Responsive */
@media (max-width: 900px) {
  .col-3, .col-4 { grid-column: span 6; }
}
@media (max-width: 640px) {
  .container, .container-narrow { padding: 12px; }
  .col-6, .col-4, .col-3 { grid-column: span 12; }
  .topbar-inner { padding: 10px 14px; }
  .brand-sub { display: none; }
  .has-pwa-nav { padding-bottom: 84px; }
  .pwa-bottom-nav { display: block; }
  .desktop-only-tabs { display: none; }
  .toast-container { left: 12px; right: 12px; bottom: 78px; max-width: none; }
}
