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

body {
  font-family: 'IBM Plex Sans Arabic', 'Tajawal', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  direction: rtl;
  -webkit-tap-highlight-color: transparent
}

/* TOPBAR */
.topbar {
  background: linear-gradient(135deg, #005F88 0%, #0099CC 55%, #33BBEE 100%);
  color: #fff;
  padding: 0 28px;
  height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 3px 24px rgba(0, 100, 160, 0.28);
  position: sticky;
  top: 0;
  z-index: 100
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px
}

.topbar-logo {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  flex-shrink: 0
}

.topbar-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover
}

.topbar-title {
  font-size: 19px;
  font-weight: 700;
  font-family: 'Tajawal', sans-serif;
  letter-spacing: -0.3px
}

.topbar-sub {
  font-size: 11px;
  opacity: 0.75;
  font-weight: 400;
  margin-top: 1px
}

.topbar-nav {
  display: flex;
  gap: 6px
}

.nav-btn {
  padding: 8px 18px;
  border-radius: 8px;
  border: 1.5px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.10);
  color: #fff;
  font-family: 'IBM Plex Sans Arabic', sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 7px
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.20);
  border-color: rgba(255, 255, 255, 0.5)
}

.nav-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 2px 10px rgba(255, 140, 0, 0.4)
}

/* PAGES */
.page {
  display: none;
  animation: fadeIn 0.3s ease
}

.page.active {
  display: block
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px)
  }

  to {
    opacity: 1;
    transform: translateY(0)
  }
}

/* DASHBOARD */
.dashboard {
  padding: 26px 30px;
  max-width: 1360px;
  margin: 0 auto
}

.page-header {
  margin-bottom: 22px
}

.page-header h1 {
  font-size: 25px;
  font-weight: 800;
  font-family: 'Tajawal', sans-serif;
  color: var(--primary-dark)
}

.page-header p {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 4px
}

/* STATS */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 22px
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: transform 0.2s, box-shadow 0.2s
}

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

.stat-icon {
  width: 50px;
  height: 50px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0
}

.stat-icon.blue {
  background: #DBF0FA
}

.stat-icon.teal {
  background: #E0FAF6
}

.stat-icon.gold {
  background: #FEF6E4
}

.stat-icon.green {
  background: #E4FAF0
}

.stat-info {
  flex: 1
}

.stat-val {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
  font-family: 'Tajawal', sans-serif
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-top: 2px
}

/* TAB BAR */
.tab-bar {
  display: flex;
  background: var(--surface);
  padding: 6px;
  border-radius: 14px;
  border: 1px solid var(--border);
  gap: 6px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
  width: fit-content
}

.tab {
  padding: 10px 24px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: 'IBM Plex Sans Arabic', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap
}

.tab:hover {
  background: var(--surface2);
  color: var(--text)
}

.tab.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(0, 95, 136, 0.25)
}

/* CARDS */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  margin-bottom: 22px;
  overflow: hidden
}

.card-head {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fcfcfd
}

.card-head h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  font-family: 'Tajawal', sans-serif
}

.card-body {
  padding: 24px
}

/* GRIDS */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
  margin-bottom: 22px
}

.companies-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 18px;
  padding: 24px
}

/* COMPANY CARD */
.company-card {
  background: var(--surface);
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: all 0.25s;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column
}

.company-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-light)
}

.company-card-stripe {
  height: 5px;
  background: linear-gradient(90deg, var(--primary), var(--accent))
}

.company-card-body {
  padding: 18px;
  flex: 1
}

.company-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
  gap: 10px
}

.company-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--primary-dark);
  font-family: 'Tajawal', sans-serif
}

.company-rep-badge {
  background: var(--surface2);
  color: var(--text-muted);
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border);
  white-space: nowrap
}

.company-details {
  display: flex;
  flex-direction: column;
  gap: 8px
}

.company-detail-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted)
}

.company-detail-row a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500
}

.company-detail-row a:hover {
  text-decoration: underline
}

.d-icon {
  font-size: 14px;
  opacity: 0.8
}

.map-link {
  color: var(--accent-dark) !important;
  font-weight: 600 !important;
  font-size: 12px
}

.company-card-footer {
  padding: 12px 18px;
  background: #fcfcfd;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center
}

.company-footer-pts {
  font-size: 12px;
  color: var(--text)
}

.company-footer-date {
  font-size: 11px;
  color: var(--text-muted)
}

/* TABLE */
.wz-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  background: var(--surface);
  min-width: 600px
}

.wz-table th {
  text-align: right;
  padding: 14px 18px;
  background: #fcfcfd;
  border-bottom: 2px solid var(--border);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap
}

.wz-table td {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle
}

.wz-table tr:last-child td {
  border-bottom: none
}

.wz-table tr:hover td {
  background: #fcfcfd
}

/* BADGES */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap
}

.badge-blue {
  background: #DBF0FA;
  color: #005F88
}

.badge-teal {
  background: #E0FAF6;
  color: #00887A
}

.badge-gold {
  background: #FEF6E4;
  color: #B27B00
}

/* FINANCE */
.rep-fin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px
}

.rep-fin-card {
  background: var(--surface);
  border-radius: 14px;
  border: 1px solid var(--border);
  padding: 20px;
  cursor: pointer;
  transition: all 0.2s
}

.rep-fin-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
  transform: scale(1.02)
}

.rep-fin-name {
  font-size: 18px;
  font-weight: 800;
  color: var(--primary-dark);
  margin-bottom: 6px;
  font-family: 'Tajawal', sans-serif
}

.rep-fin-pts {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px
}

.rep-fin-amount {
  font-size: 24px;
  font-weight: 800;
  color: var(--accent-dark);
  font-family: 'Tajawal', sans-serif
}

.rep-fin-currency {
  font-size: 13px;
  font-weight: 600;
  margin-right: 4px
}

/* FORM */
.form-group {
  margin-bottom: 18px
}

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

.form-input,
.form-select {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-family: inherit;
  font-size: 16px; /* Better for mobile to prevent zoom */
  color: var(--text);
  transition: all 0.2s;
  outline: none;
  appearance: none
}

.form-input:focus,
.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 95, 136, 0.1)
}

.input-with-icon {
  position: relative
}

.input-with-icon .i-icon {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  pointer-events: none
}

.input-with-icon .form-input {
  padding-right: 42px
}

.lbl-optional {
  font-weight: 400;
  opacity: 0.6;
  font-size: 11px;
  margin-right: 4px
}

.gps-row {
  display: flex;
  gap: 8px
}

.btn-gps {
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  width: 48px;
  height: 48px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  transition: all 0.2s;
  flex-shrink: 0
}

.btn-gps:hover {
  background: var(--border);
  border-color: var(--text-muted)
}

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

.section-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 24px 0 16px
}

.section-divider span {
  font-size: 12px;
  font-weight: 800;
  color: var(--primary-dark);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap
}

.section-divider::after {
  content: '';
  flex: 1;
  height: 1.5px;
  background: linear-gradient(90deg, var(--border), transparent)
}

/* BUTTONS */
.btn {
  padding: 10px 22px;
  border-radius: var(--radius-sm);
  border: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  outline: none
}

.btn:active {
  transform: scale(0.98)
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 3px 10px rgba(0, 95, 136, 0.2)
}

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

.btn-accent {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 3px 12px rgba(255, 140, 0, 0.3)
}

.btn-accent:hover {
  background: var(--accent-dark)
}

.btn-danger {
  background: #FFF0F0;
  color: var(--danger);
  border: 1px solid #FFD5D5
}

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

.btn-warning {
  background: #FFF8E1;
  color: #e07800;
  border: 1px solid #FFE082
}

.btn-warning:hover {
  background: #e07800
}

.btn-full {
  width: 100%
}

.btn-sm {
  padding: 7px 14px;
  font-size: 13px
}

/* ALERT */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px
}

.alert-success {
  background: #E4FAF0;
  color: #0A7E52;
  border: 1px solid #9EE8C8
}

.alert-error {
  background: #FFF0F0;
  color: var(--danger);
  border: 1px solid #FFD5D5
}

.alert-info {
  background: #DBF0FA;
  color: var(--primary-dark);
  border: 1px solid #A8D8F0
}

/* LIST ITEM */
.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  margin-bottom: 8px;
  font-size: 14px;
  transition: box-shadow 0.15s
}

.list-item:hover {
  box-shadow: var(--shadow)
}

.list-item-name {
  font-weight: 600
}

/* REP PAGE */
.rep-page {
  min-height: calc(100vh - 66px);
  background: linear-gradient(160deg, #E8F6FF 0%, #E0F5F0 100%);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 32px 16px 48px
}

.rep-form-card {
  background: var(--surface);
  border-radius: 20px;
  box-shadow: 0 10px 60px rgba(0, 120, 180, 0.16);
  width: 100%;
  max-width: 580px;
  overflow: hidden;
  border: 1px solid var(--border)
}

.rep-form-header {
  background: linear-gradient(135deg, #005F88 0%, #0099CC 100%);
  padding: 28px 32px 44px;
  color: #fff;
  text-align: center;
  position: relative
}

.rep-form-header::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 30px;
  background: var(--surface);
  border-radius: 30px 30px 0 0
}

.rep-form-header h2 {
  font-size: 22px;
  font-weight: 800;
  font-family: 'Tajawal', sans-serif;
  margin-bottom: 4px
}

.rep-form-header p {
  font-size: 13px;
  opacity: 0.82
}

.rep-logo-badge {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
  margin: 0 auto 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center
}

.rep-logo-badge img {
  width: 100%;
  height: 100%;
  object-fit: cover
}

.rep-form-body {
  padding: 24px 32px 32px
}

/* DATETIME */
.datetime-display {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 14px;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between
}

.dt-text {
  font-weight: 600
}

.dt-date {
  font-size: 12px;
  color: var(--text-muted)
}

/* CHECKLIST */
.actions-check-list {
  max-height: 240px;
  overflow-y: auto;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm)
}

.action-check-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
  user-select: none
}

.action-check-item:last-child {
  border-bottom: none
}

.action-check-item:hover {
  background: var(--surface2)
}

.action-check-item input[type=checkbox] {
  width: 20px;
  height: 20px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0
}

.action-check-item label {
  font-size: 15px;
  cursor: pointer;
  flex: 1
}

.action-check-pts {
  font-size: 12px;
  color: var(--accent-dark);
  font-weight: 600
}

/* POINTS PREVIEW */
.points-preview {
  background: linear-gradient(135deg, #005F88 0%, #0099CC 60%, var(--accent) 100%);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px
}

.pp-label {
  font-size: 13px;
  opacity: 0.85
}

.pp-val {
  font-size: 24px;
  font-weight: 800;
  font-family: 'Tajawal', sans-serif
}

.pp-iqd {
  font-size: 13px;
  opacity: 0.85
}

/* EMPTY */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted)
}

.empty-state .es-icon {
  font-size: 40px;
  margin-bottom: 12px
}

.empty-state p {
  font-size: 14px
}

/* SUCCESS */
.success-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 999;
  align-items: center;
  justify-content: center
}

.success-overlay.show {
  display: flex;
  animation: fadeIn 0.25s ease
}

.success-box {
  background: var(--surface);
  border-radius: 20px;
  padding: 40px 32px;
  text-align: center;
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.2);
  max-width: 360px;
  width: 90%
}

.success-box .s-icon {
  font-size: 54px;
  margin-bottom: 16px
}

.success-box h3 {
  font-size: 22px;
  font-weight: 800;
  font-family: 'Tajawal', sans-serif;
  color: var(--success);
  margin-bottom: 8px
}

.success-box p {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 20px
}

/* LOGIN OVERLAY */
.login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column
}

.login-box {
  background: var(--surface);
  padding: 32px;
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 400px;
  border: 1px solid var(--border);
  text-align: center
}

.login-box h2 {
  font-size: 22px;
  font-weight: 800;
  font-family: 'Tajawal', sans-serif;
  margin-bottom: 24px;
  color: var(--primary-dark)
}

::-webkit-scrollbar {
  width: 6px
}

::-webkit-scrollbar-track {
  background: var(--bg)
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary-light)
}

/* RESPONSIVE DESIGN */
@media(max-width:768px) {
  .topbar {
    padding: 0 16px;
    height: 60px
  }

  .topbar-logo {
    width: 38px;
    height: 38px;
    border-radius: 10px
  }

  .topbar-title {
    font-size: 16px
  }

  .topbar-sub {
    font-size: 10px
  }

  .dashboard {
    padding: 16px
  }

  .page-header h1 {
    font-size: 20px
  }

  .stats-row {
    grid-template-columns: 1fr 1fr;
    gap: 10px
  }

  .stat-card {
    padding: 14px;
    gap: 10px
  }

  .stat-icon {
    width: 40px;
    height: 40px;
    font-size: 18px
  }

  .stat-val {
    font-size: 17px
  }

  .tab-bar {
    width: 100%;
    overflow-x: auto;
    border-radius: 10px;
    margin-bottom: 20px;
    -webkit-overflow-scrolling: touch
  }

  .tab {
    flex: 1;
    justify-content: center;
    padding: 10px 14px;
    font-size: 13px
  }

  .two-col {
    grid-template-columns: 1fr;
    gap: 16px
  }

  .companies-grid {
    grid-template-columns: 1fr;
    padding: 16px
  }

  .rep-form-body {
    padding: 20px 16px 24px
  }

  .rep-form-header {
    padding: 24px 20px 36px
  }

  .rep-page {
    padding: 16px 12px 32px
  }
}

@media(max-width:480px) {
  .stats-row {
    grid-template-columns: 1fr
  }

  .topbar-brand {
    gap: 8px
  }

  .topbar-sub {
    display: none
  }

  .card-head {
    padding: 14px 16px
  }

  .card-body {
    padding: 16px
  }

  .points-preview {
    flex-direction: column;
    text-align: center;
    gap: 10px
  }

  .points-preview div {
    text-align: center !important
  }

  .rep-fin-grid {
    grid-template-columns: 1fr
  }
}

/* UTILS */
.hide-on-mobile {
  @media(max-width: 600px) {
    display: none !important
  }
}
