:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --primary: #1e40af;
  --primary-hover: #1e3a8a;
  --success: #059669;
  --success-hover: #047857;
  --warning: #d97706;
  --danger: #dc2626;
  --radius: 12px;
  --shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
}

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

body {
  font-family: 'Cairo', sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.6;
  direction: rtl;
}

.hidden {
  display: none !important;
}

.container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 18px;
}

/* شاشة تسجيل الدخول */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
}

.auth-card {
  background: var(--surface);
  width: 100%;
  max-width: 460px;
  padding: 36px 30px;
  border-radius: 16px;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.25);
  text-align: center;
}

.auth-logo {
  font-size: 46px;
  margin-bottom: 10px;
}

.auth-card h1 {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 6px;
}

.auth-subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 24px;
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: right;
}

.quick-login-box {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px dashed var(--border);
  font-size: 13px;
  color: var(--text-muted);
}

.quick-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

/* الشريط العلوي */
.topbar {
  background: #0f172a;
  color: #ffffff;
  padding: 14px 0;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

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

.brand-icon {
  font-size: 28px;
}

.brand h2 {
  font-size: 18px;
  font-weight: 700;
}

.db-badge {
  font-size: 12px;
  color: #93c5fd;
  display: block;
}

.user-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.current-user-pill {
  background: rgba(255, 255, 255, 0.1);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #10b981;
  display: inline-block;
}

/* المحتوى الرئيسي */
.main-content {
  padding-top: 24px;
  padding-bottom: 50px;
}

.approval-alert {
  background: #fffbeb;
  border: 1px solid #f59e0b;
  color: #92400e;
  padding: 14px 18px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

/* بطاقات الإحصائيات */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border-right: 5px solid var(--primary);
}

.stat-trailers {
  border-right-color: #2563eb;
}

.stat-payments {
  border-right-color: #059669;
}

.stat-balance {
  border-right-color: #7c3aed;
}

.stat-pending {
  border-right-color: #d97706;
}

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

.stat-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
}

.stat-icon {
  font-size: 24px;
}

.stat-value {
  font-size: 25px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 6px;
  direction: rtl;
}

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

/* الأقسام والنماذج */
.workspace-grid {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.panel {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding-bottom: 16px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.panel-header h3 {
  font-size: 19px;
  font-weight: 800;
}

.panel-desc {
  font-size: 13px;
  color: var(--text-muted);
}

.role-badge {
  font-size: 12px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 999px;
}

.badge-both {
  background: #dbeafe;
  color: #1e40af;
}

.badge-user1 {
  background: #d1fae5;
  color: #065f46;
}

.entry-form {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  margin-bottom: 20px;
}

.payment-entry-form {
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 13px;
  font-weight: 700;
  color: #334155;
}

.form-group input {
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-family: 'Cairo', sans-serif;
  font-size: 14px;
  background: #ffffff;
  transition: border-color 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary);
}

.currency-input {
  position: relative;
  display: flex;
  align-items: center;
}

.currency-input input {
  width: 100%;
  padding-left: 48px;
  font-weight: 700;
}

.currency-tag {
  position: absolute;
  left: 12px;
  font-size: 13px;
  font-weight: 800;
  color: var(--primary);
  pointer-events: none;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
}

.info-notice {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e3a8a;
  padding: 14px 16px;
  border-radius: 8px;
  margin-bottom: 18px;
  font-size: 14px;
}

/* أزرار */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 8px;
  font-family: 'Cairo', sans-serif;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all 0.15s ease;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-block {
  width: 100%;
}

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

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

.btn-success {
  background: var(--success);
  color: #ffffff;
}

.btn-success:hover {
  background: var(--success-hover);
}

.btn-warning {
  background: #f59e0b;
  color: #ffffff;
}

.btn-danger {
  background: var(--danger);
  color: #ffffff;
}

.btn-outline {
  background: transparent;
  border: 1px solid #cbd5e1;
  color: inherit;
}

.btn-outline:hover {
  background: rgba(148, 163, 184, 0.15);
}

.btn-danger-ghost {
  background: rgba(239, 68, 68, 0.18);
  color: #fecaca;
}

.btn-danger-ghost:hover {
  background: rgba(239, 68, 68, 0.32);
}

/* شريط الفلترة */
.filter-bar {
  margin-bottom: 14px;
}

.filter-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-tab {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #f8fafc;
  font-family: 'Cairo', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.filter-tab.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

/* الجداول */
.table-responsive {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th,
.data-table td {
  padding: 12px 10px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table th {
  background: #f8fafc;
  color: #475569;
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
}

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

.amount-cell {
  font-weight: 800;
  color: #0f172a;
  white-space: nowrap;
}

.empty-cell {
  text-align: center !important;
  padding: 28px !important;
  color: var(--text-muted);
}

/* شارات الحالة */
.status-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status-approved {
  background: #dcfce7;
  color: #166534;
}

.status-pending {
  background: #fef3c7;
  color: #92400e;
}

.status-rejected {
  background: #fee2e2;
  color: #991b1b;
}

.approval-btns {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.approval-btns .btn {
  white-space: nowrap;
  font-size: 12px;
  padding: 6px 10px;
}

.row-awaiting-approval {
  background-color: #fffbeb !important;
  border-right: 4px solid #f59e0b;
}

.row-awaiting-approval:hover {
  background-color: #fef3c7 !important;
}

@media (max-width: 768px) {
  .approval-btns {
    flex-direction: column;
    gap: 4px;
    min-width: 130px;
  }
  .approval-btns .btn {
    width: 100%;
    padding: 8px 10px;
    font-size: 13px;
  }
  .data-table th, .data-table td {
    padding: 10px 8px;
  }
}

/* نافذة معاينة الوصل */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal-content {
  background: var(--surface);
  border-radius: var(--radius);
  max-width: 650px;
  width: 100%;
  overflow: hidden;
}

.modal-header,
.modal-footer {
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.modal-footer {
  border-bottom: none;
  border-top: 1px solid var(--border);
}

.modal-body {
  padding: 16px;
  text-align: center;
  max-height: 70vh;
  overflow: auto;
}

.modal-body img {
  max-width: 100%;
  border-radius: 8px;
}

.btn-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
}

.alert {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
}

.alert-error {
  background: #fee2e2;
  color: #991b1b;
}

/* إشعار عائم */
.toast {
  position: fixed;
  bottom: 24px;
  left: 24px;
  background: #0f172a;
  color: #ffffff;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
  z-index: 200;
}