:root {
  --bg-1: #f3f7fb;
  --bg-2: #dce8f7;
  --card: #ffffff;
  --text: #1d2d44;
  --muted: #5e748e;
  --primary: #0a7cff;
  --primary-dark: #045ac2;
  --danger: #c62828;
  --success: #2e7d32;
  --border: #d1dceb;
  --shadow: 0 14px 30px rgba(24, 58, 92, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Tahoma, "Segoe UI", sans-serif;
  color: var(--text);
  background: linear-gradient(130deg, var(--bg-1), var(--bg-2));
  min-height: 100vh;
}

.auth-page,
.dashboard-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.auth-card,
.dashboard-card {
  width: 100%;
  background: var(--card);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 24px;
  box-sizing: border-box;
}

.auth-header h1,
.dashboard-card h1 {
  margin: 0;
  font-size: 1.6rem;
}

.auth-header p,
.dashboard-card p {
  color: var(--muted);
  margin-top: 8px;
}

.role-switch {
  margin: 18px 0;
  background: #eef4fc;
  border: 1px solid var(--border);
  padding: 6px;
  border-radius: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.role-btn {
  border: none;
  padding: 10px 12px;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  color: var(--text);
  font-weight: 700;
}

.role-btn.active {
  background: #ffffff;
  color: var(--primary-dark);
  box-shadow: 0 4px 14px rgba(10, 124, 255, 0.18);
}

.login-form {
  display: grid;
  gap: 10px;
}

label {
  font-weight: 700;
  font-size: 0.95rem;
}

input {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  font-size: 1rem;
  outline: none;
}

input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(10, 124, 255, 0.16);
}

.submit-btn,
.logout-btn {
  margin-top: 6px;
  border: none;
  border-radius: 10px;
  padding: 12px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(90deg, var(--primary), #2d98ff);
}

.submit-btn:hover,
.logout-btn:hover {
  filter: brightness(0.96);
}

.form-message {
  min-height: 20px;
  margin: 0;
  font-size: 0.95rem;
}

.form-message.error {
  color: var(--danger);
}

.form-message.success {
  color: var(--success);
}

.auth-footer {
  margin-top: 14px;
  color: var(--muted);
  text-align: center;
}

.dashboard-meta {
  list-style: none;
  padding: 0;
  margin: 18px 0;
  display: grid;
  gap: 8px;
}

.dashboard-meta li {
  background: #f6f9ff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
}

.dashboard-shell {
  width: min(100%, 1400px);
  background: var(--card);
  border-radius: 18px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: 280px 1fr;
  overflow: hidden;
}

.dashboard-sidebar {
  background: linear-gradient(180deg, #f2f7ff, #e8f1ff);
  border-inline-end: 1px solid var(--border);
  padding: 22px;
  display: grid;
  align-content: start;
  gap: 14px;
}

.dashboard-sidebar h2 {
  margin: 0;
}

.dashboard-sidebar p {
  margin: 0;
}

.dashboard-tabs {
  margin-top: 8px;
  display: grid;
  gap: 8px;
}

.dashboard-tab {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font-weight: 700;
  cursor: pointer;
  text-align: right;
  text-decoration: none;
  display: block;
  width: 100%;
  font-family: inherit;
  font-size: inherit;
  box-sizing: border-box;
}

.dashboard-tab.active {
  border-color: #0a7cff;
  background: #0a7cff;
  color: #fff;
}

.dashboard-content {
  padding: 24px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.panel-header h1 {
  margin: 0;
}

.panel-header p {
  margin-top: 8px;
  color: var(--muted);
}

.stats-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
}

.stat-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: #f7fbff;
  display: grid;
  gap: 8px;
}

.stat-card span {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.9rem;
}

.stat-card strong {
  font-size: 1.6rem;
  line-height: 1;
}

.infographic-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.chart-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  padding: 14px;
}

.chart-card h3 {
  margin: 0 0 12px;
}

.donut-wrap {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 16px;
  align-items: center;
}

.donut-chart {
  width: 132px;
  height: 132px;
  border-radius: 50%;
  position: relative;
}

.donut-chart::after {
  content: '';
  position: absolute;
  inset: 20px;
  border-radius: 50%;
  background: #ffffff;
}

.donut-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
  color: var(--text);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  margin-inline-start: 6px;
}

.dot-received {
  background: #4ea8ff;
}

.dot-transit {
  background: #f6a623;
}

.dot-delivered {
  background: #3cb179;
}

.dot-delayed {
  background: #df4a4a;
}

.bars {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: 80px 1fr 46px;
  align-items: center;
  gap: 8px;
}

.bar-row span {
  color: var(--muted);
  font-weight: 700;
}

.bar-track {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: #edf2f9;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  transition: width 0.4s ease;
}

.fill-received {
  background: #4ea8ff;
}

.fill-transit {
  background: #f6a623;
}

.fill-delivered {
  background: #3cb179;
}

.fill-delayed {
  background: #df4a4a;
}

.placeholder-box {
  margin-top: 14px;
  border: 1px dashed #9db3ce;
  color: var(--muted);
  border-radius: 12px;
  padding: 24px;
  background: #f8fbff;
  text-align: center;
}

.filters-card {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 2px 10px #0a7cff11;
  padding: 18px 20px;
  margin-bottom: 18px;
}

.table-card {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  padding: 12px 12px 32px 12px;
  overflow: hidden;
}

.filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  align-items: end;
}

.filters-grid label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.85rem;
  color: #5e748e;
  font-weight: 600;
}

.filters-grid input[type='text'],
.filters-grid select,
.filters-grid input[type='date'] {
  padding: 8px 12px;
  border: 1.5px solid #d1dceb;
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  color: #1d2d44;
  background: #f8fafc;
  transition: border-color 0.15s, background 0.15s;
}

.filters-grid input[type='text']:focus,
.filters-grid select:focus,
.filters-grid input[type='date']:focus {
  outline: none;
  border-color: #0a7cff;
  background: #fff;
  box-shadow: none;
}

select,
input[type='date'] {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  font-size: 0.94rem;
  background: #fff;
  color: var(--text);
  outline: none;
}

select:focus,
input[type='date']:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(10, 124, 255, 0.16);
}

.filters-actions {
  display: flex;
  flex-direction: row;
  gap: 8px;
  align-items: flex-end;
  justify-content: flex-start;
}

.filters-actions .primary-btn,
.filters-actions .secondary-btn {
  flex: 1;
}

.primary-btn {
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #0a7cff 0%, #0056d6 100%);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 700;
  padding: 10px;
  cursor: pointer;
  letter-spacing: 0.03em;
  box-shadow: 0 3px 10px rgba(10, 124, 255, 0.28);
  transition: transform 0.15s, box-shadow 0.15s;
}

.primary-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(10, 124, 255, 0.38);
}

.primary-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(10, 124, 255, 0.22);
}

.secondary-btn {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f6f9ff;
  color: var(--text);
  font-weight: 700;
  padding: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.secondary-btn:hover {
  border-color: #9ab7db;
  background: #edf3fb;
}

.form-control {
  font-family: Tahoma, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--card);
  cursor: pointer;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px rgba(10, 124, 255, 0.1);
}

.shipments-mini-stats {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.mini-stat {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: #f8fbff;
  display: grid;
  gap: 8px;
}

.mini-stat span {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.9rem;
}

.mini-stat strong {
  font-size: 1.4rem;
}

.table-wrap {
  overflow-x: auto;
  width: 100%;
  -webkit-overflow-scrolling: touch;
  margin-top: 18px;
}

.shipments-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 700px; /* يجبر الـ scroll بدل التمدد */
  table-layout: fixed;
}

.shipments-table th,
.shipments-table td {
  text-align: right;
  padding: 10px 8px;
  border-bottom: 1px solid #e8eef8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* تحديد عرض كل عمود */
.shipments-table th:nth-child(1),
.shipments-table td:nth-child(1) { width: 40px; }   /* # */
.shipments-table th:nth-child(2),
.shipments-table td:nth-child(2) { width: 120px; }  /* الاسم */
.shipments-table th:nth-child(3),
.shipments-table td:nth-child(3) { width: 110px; }  /* الهاتف */
.shipments-table th:nth-child(4),
.shipments-table td:nth-child(4) { width: 100px; }  /* الرخصة */
.shipments-table th:nth-child(5),
.shipments-table td:nth-child(5) { width: 80px; }   /* المدينة */
.shipments-table th:nth-child(6),
.shipments-table td:nth-child(6) { width: 160px; }  /* البريد */
.shipments-table th:nth-child(7),
.shipments-table td:nth-child(7) { width: 70px; }   /* الحالة */
.shipments-table th:nth-child(8),
.shipments-table td:nth-child(8) { width: 120px; }  /* إجراءات */

.shipments-table th {
  color: var(--muted);
  font-size: 0.88rem;
  background: #f8fbff;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
}

.status-received {
  background: #4ea8ff;
}

.status-transit {
  background: #f6a623;
}

.status-delivered {
  background: #3cb179;
}

.status-delayed {
  background: #df4a4a;
}

.status-picked_up {
  background: #7c3aed;
}

.table-empty {
  margin: 10px 0 0;
  color: var(--muted);
  text-align: center;
}

.table-note {
  margin: 10px 0 0;
  color: var(--muted);
  text-align: center;
  min-height: 20px;
  font-weight: 700;
}

.table-note.success {
  color: var(--success);
}

.table-note.error {
  color: var(--danger);
}

.table-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.shipment-id-btn {
  background: none; border: none; cursor: pointer;
  color: #0a7cff; font-weight: 700; font-family: monospace;
  font-size: 0.82rem; padding: 0; text-decoration: underline dotted;
  transition: color .15s;
}
.shipment-id-btn:hover { color: #045ac2; }

.tiny-btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
}

.tiny-btn:hover {
  border-color: #9ab7db;
}

.perm-badge {
  display: inline-flex;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 700;
  background: #eef4fc;
  color: #35557a;
}

.perm-badge.on {
  background: #e8f8ef;
  color: #1c7a47;
}

.analytics-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.city-layout {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 18px;
  align-items: center;
}

.city-donut {
  width: 150px;
  height: 150px;
}

.city-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.city-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f9fbff;
  padding: 10px;
  display: grid;
  gap: 6px;
}

.city-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.city-title-row span {
  font-weight: 700;
}

.city-item small {
  color: var(--muted);
}

.city-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: #e8eef8;
  overflow: hidden;
}

.city-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
}

.full-width-card {
  width: 100%;
}

.chart-note {
  margin: -4px 0 10px;
  color: var(--muted);
}

.line-chart-wrap {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  background: #f9fcff;
}

.line-chart {
  width: 100%;
  height: 220px;
  display: block;
}

.line-area {
  fill: url(#lineArea);
  stroke: none;
}

.line-path {
  fill: none;
  stroke: #0a7cff;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.line-dot {
  fill: #ffffff;
  stroke: #0a7cff;
  stroke-width: 2;
}

.line-labels {
  margin-top: 8px;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  text-align: center;
}

.line-labels span {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.82rem;
  color: var(--muted);
  padding: 6px 4px;
  display: grid;
  gap: 2px;
}

.line-labels strong {
  color: var(--text);
  font-size: 0.92rem;
}

/* ======= نموذج إنشاء شحنة ======= */
.shipment-form,
.driver-form {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.form-section {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  background: #f9fbff;
}

.form-section legend {
  font-weight: 700;
  color: var(--primary-dark);
  padding: 0 6px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 10px;
}

.form-grid label {
  display: grid;
  gap: 6px;
}

.form-grid input,
.form-grid select {
  width: 100%;
}

/* ======= بوليصة الشحنة ======= */
.waybill-success {
  margin-top: 14px;
}

.waybill-box {
  border: 2px solid #3cb179;
  border-radius: 14px;
  background: #f4fdf8;
  padding: 20px;
  display: grid;
  gap: 8px;
}

.waybill-box h2 {
  margin: 0;
  color: var(--success);
}

.waybill-box hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 4px 0;
}

.waybill-box p {
  margin: 0;
}

.waybill-driver-assign {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.waybill-driver-assign label {
  font-weight: 700;
}

.assign-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.print-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  border-radius: 10px;
  padding: 11px 18px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(90deg, #2e7d32, #43a047);
}

.print-btn::before {
  content: '🖨';
  font-size: 1.1rem;
}

.print-btn:hover {
  filter: brightness(0.92);
}

.copy-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1.5px solid #0a7cff;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  color: #0a7cff;
  background: #e8f3ff;
}

.copy-link-btn:hover {
  background: #d0e8ff;
}

/* ======= أزرار إجراءات الجدول ======= */
.action-btn {
  border: none;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  margin-inline-end: 4px;
}

.edit-btn {
  background: #e8f3ff;
  color: var(--primary-dark);
}

.edit-btn:hover {
  background: #cce2ff;
}

.delete-btn {
  background: #fff0f0;
  color: var(--danger);
}

.delete-btn:hover {
  background: #ffd7d7;
}

/* ======= Mobile Topbar & Sidebar Drawer ======= */
.mobile-topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 11px 16px;
  background: linear-gradient(135deg, #f2f7ff, #e4effe);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  min-height: 52px;
  grid-column: 1 / -1;
}
.mobile-topbar-title {
  font-weight: 800;
  font-size: 0.97rem;
  color: var(--text);
}
.sidebar-toggle-btn {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 9px;
  padding: 7px 13px;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--primary);
  line-height: 1;
  transition: background 0.15s;
}
.sidebar-toggle-btn:hover { background: #e6f0ff; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 20, 50, 0.48);
  z-index: 98;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.open { display: block; }

.sidebar-close-btn {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--muted);
  font-family: inherit;
  font-weight: 700;
  align-self: flex-end;
  margin-bottom: 4px;
}
.sidebar-close-btn:hover { background: #f0f4f8; }

/* ======= Auth — Small Screen ======= */
@media (max-width: 500px) {
  .auth-card,
  .dashboard-card {
    padding: 18px;
    border-radius: 14px;
  }
  .auth-header h1,
  .dashboard-card h1 {
    font-size: 1.3rem;
  }
}

/* ======= Tablet & Mobile (≤ 1024px) ======= */
@media (max-width: 1024px) {
  .mobile-topbar     { display: flex; }
  .sidebar-close-btn { display: flex; }

  /* صفحة الداشبورد تملأ الشاشة بدون padding */
  .dashboard-page {
    padding: 0;
    display: block;
    min-height: 100vh;
  }

  /* الشِل يتحول لعمود واحد */
  .dashboard-shell {
    width: 100%;
    min-height: 100vh;
    border-radius: 0;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    overflow: visible;
  }

  /* الشريط الجانبي يصبح درج منزلق من اليمين */
  .dashboard-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 270px;
    max-width: 88vw;
    height: 100vh;
    z-index: 99;
    overflow-y: auto;
    transform: translateX(105%);
    transition: transform 0.24s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.24s ease;
    border-inline-end: none;
    border-bottom: none;
    box-shadow: none;
  }
  .dashboard-sidebar.open {
    transform: translateX(0);
    box-shadow: -6px 0 32px rgba(10, 30, 60, 0.2);
  }

  .dashboard-tabs { grid-template-columns: 1fr; }
  .dashboard-tab  { text-align: right; }

  .dashboard-content {
    padding: 16px;
    flex: 1;
  }

  /* إحصاءات */
  .stats-grid             { grid-template-columns: repeat(2, 1fr); }
  .shipments-mini-stats   { grid-template-columns: repeat(3, 1fr); }

  /* مخططات */
  .infographic-grid { grid-template-columns: 1fr; }
  .donut-wrap       { grid-template-columns: 1fr; justify-items: center; }
  .city-layout      { grid-template-columns: 1fr; justify-items: center; }
  .line-labels      { grid-template-columns: repeat(4, 1fr); }

  /* نماذج */
  .form-grid     { grid-template-columns: 1fr; }
  .filters-grid  { grid-template-columns: repeat(2, minmax(140px, 1fr)); }

  /* Modal */
  .modal-sections { grid-template-columns: 1fr; }
  .shipment-modal { max-width: 100%; margin: 0; border-radius: 16px 16px 0 0; }
  .shipment-modal-overlay { align-items: flex-end; padding: 0; }
}

/* ======= Mobile (≤ 640px) ======= */
@media (max-width: 640px) {
  .dashboard-content { padding: 10px; }

  .panel-header h1 { font-size: 1.2rem; }
  .panel-header p  { font-size: 0.84rem; margin-top: 4px; }

  .stats-grid { gap: 8px; }
  .stat-card  { padding: 10px 8px; }
  .stat-card strong { font-size: 1.25rem; }
  .stat-card span   { font-size: 0.82rem; }

  .shipments-mini-stats { gap: 6px; }
  .mini-stat { padding: 10px 8px; }
  .mini-stat strong { font-size: 1.1rem; }
  .mini-stat span   { font-size: 0.78rem; }

  .filters-grid { grid-template-columns: 1fr; }
  .filters-actions { flex-direction: row; }

  .table-card { padding: 6px 4px 18px; }

  .line-labels { grid-template-columns: repeat(3, 1fr); }

  .primary-btn, .secondary-btn {
    font-size: 0.85rem;
    padding: 10px 8px;
  }

  /* بوابة السائق */
  .portal-tabs {
    gap: 4px;
  }
  .portal-tab-btn {
    padding: 8px 14px;
    font-size: 0.88rem;
  }
}

/* ======= Small Mobile (≤ 420px) ======= */
@media (max-width: 420px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 6px; }
  .shipments-mini-stats { grid-template-columns: repeat(3, 1fr); gap: 4px; }
  .mini-stat { padding: 8px 6px; }
  .mini-stat strong { font-size: 1rem; }
  .line-labels { grid-template-columns: repeat(2, 1fr); }

  .portal-tab-btn { padding: 7px 10px; font-size: 0.82rem; }
}

/* ======= Modal تفاصيل الشحنة ======= */
.shipment-modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(10, 30, 60, 0.45);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  animation: fadeIn .18s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.shipment-modal {
  background: #fff; border-radius: 18px;
  box-shadow: 0 24px 60px rgba(10,30,80,.18);
  width: 100%; max-width: 620px;
  max-height: 90vh; overflow-y: auto;
  animation: slideUp .2s ease;
}
@keyframes slideUp { from { transform: translateY(24px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px 24px 16px;
  border-bottom: 1px solid #e8eef8;
  position: sticky; top: 0; background: #fff; z-index: 1;
}
.modal-header h2 { font-size: 1.1rem; color: #1d2d44; }
.modal-close-btn {
  background: #f0f4f8; border: none; border-radius: 50%;
  width: 34px; height: 34px; font-size: 1.1rem;
  cursor: pointer; color: #5e748e; transition: background .15s;
  display: flex; align-items: center; justify-content: center;
}
.modal-close-btn:hover { background: #e0e8f4; }

.modal-body { padding: 20px 24px 24px; }

.modal-status-row {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 20px; flex-wrap: wrap;
}
.modal-tracking-no { font-family: monospace; font-size: 1.15rem; font-weight: 900; letter-spacing: 1px; }
.modal-track-link {
  font-size: 0.82rem; color: #0a7cff; text-decoration: none; margin-right: auto;
  border: 1px solid #d1dceb; border-radius: 8px; padding: 4px 12px;
  transition: background .15s;
}
.modal-track-link:hover { background: #f0f7ff; }

.modal-sections {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px;
}
@media (max-width: 500px) { .modal-sections { grid-template-columns: 1fr; } }

.modal-section {
  background: #f8fafc; border-radius: 10px; padding: 14px 16px;
}
.modal-section h4 { font-size: 0.78rem; color: #5e748e; margin-bottom: 8px; border-bottom: 1px solid #e8eef8; padding-bottom: 6px; }
.modal-section p  { font-size: 0.88rem; margin: 3px 0; }
.modal-section strong { color: #1d2d44; }

/* تقرير السائقين */
.drivers-report-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin-top: 16px;
}
.driver-report-card {
  background: #fff; border: 1px solid #e8eef8; border-radius: 12px;
  padding: 16px; box-shadow: 0 2px 8px #0a7cff0a;
}
.driver-report-card h4 { font-size: 0.95rem; margin-bottom: 10px; color: #1d2d44; }
.driver-stat { display: flex; justify-content: space-between; font-size: 0.82rem; margin: 4px 0; color: #5e748e; }
.driver-stat strong { color: #1d2d44; }

/* إشعارات */
.notif-bell {
  position: relative; cursor: pointer; font-size: 1.3rem;
  background: none; border: none; padding: 4px;
}
.notif-badge {
  position: absolute; top: -2px; left: -2px;
  background: #df4a4a; color: #fff;
  border-radius: 50%; width: 18px; height: 18px;
  font-size: 0.65rem; font-weight: 900;
  display: flex; align-items: center; justify-content: center;
}
.notif-dropdown {
  position: absolute; top: calc(100% + 8px); left: 0;
  background: #fff; border: 1px solid #d1dceb;
  border-radius: 12px; box-shadow: 0 8px 32px rgba(10,30,80,.12);
  width: 300px; max-height: 360px; overflow-y: auto; z-index: 200;
  display: none;
}
.notif-dropdown.open { display: block; }
.notif-item {
  padding: 12px 16px; border-bottom: 1px solid #f0f4f8;
  font-size: 0.85rem; cursor: pointer; transition: background .12s;
}
.notif-item:hover { background: #f8fafc; }
.notif-item:last-child { border-bottom: none; }
.notif-item .notif-time { font-size: 0.75rem; color: #5e748e; margin-top: 3px; }
.notif-item.unread { background: #f0f7ff; }
.notif-empty { padding: 24px; text-align: center; color: #b0bec5; font-size: 0.9rem; }

/* ======= COD ======= */
.cod-badge {
  display: inline-flex; align-items: center; gap: 4px;
  background: #fff3e0; color: #e65100;
  border: 1.5px solid #ffb74d;
  border-radius: 20px; padding: 2px 8px;
  font-size: 0.75rem; font-weight: 700;
  margin-top: 3px;
}
.cod-badge.cod-collected {
  background: #e8f5e9; color: #2e7d32; border-color: #81c784;
}

/* ======= زر التقاط الصورة ======= */
.photo-capture-label {
  display: inline-flex; align-items: center; gap: 8px;
  background: #f0f7ff; border: 1.5px dashed #90c2ff;
  border-radius: 10px; padding: 10px 18px;
  cursor: pointer; font-size: 0.9rem; color: #0a7cff;
  font-weight: 600; transition: background .15s;
}
.photo-capture-label:hover { background: #e0f0ff; }

/* رابط صورة التسليم في الكارد */
.photo-thumb-link {
  display: inline-block; margin-top: 4px;
  font-size: 0.78rem; color: #0a7cff;
  text-decoration: none; font-weight: 600;
}
.photo-thumb-link:hover { text-decoration: underline; }

/* ======= بوابة السائق — كاردات الشحنات ======= */
#portalShipmentsContainer {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 0;
}

.portal-card {
  background: #fff;
  border: 1px solid #e3eaf4;
  border-radius: 14px;
  padding: 16px 18px;
  box-shadow: 0 2px 10px rgba(10,124,255,0.07);
  width: 100%;
  box-sizing: border-box;
}

.portal-card-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 5px 0;
  border-bottom: 1px solid #f3f6fb;
}
.portal-card-row:last-of-type { border-bottom: none; }

.portal-card-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: #8a9ab0;
  min-width: 72px;
  flex-shrink: 0;
  padding-top: 2px;
  text-align: right;
}

.portal-card-val {
  flex: 1;
  font-size: 0.9rem;
  color: #1d2d44;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  word-break: break-word;
}

.tracking-mono {
  font-family: monospace;
  font-size: 0.85rem;
  direction: ltr;
  text-align: left;
  word-break: break-all;
}

.portal-ref {
  display: block;
  font-size: 0.75rem;
  color: #0a7cff;
  margin-top: 2px;
  font-family: inherit;
  direction: rtl;
}

.portal-sub {
  font-size: 0.78rem;
  color: #5e748e;
}
.portal-sub.ltr { direction: ltr; text-align: left; }

.portal-card-action {
  display: flex;
  justify-content: flex-end;
  padding-top: 12px;
  margin-top: 4px;
  border-top: 1px solid #edf2f8;
}
