:root {
  --primary: #155e9b;
  --primary-light: #3b93cf;
  --primary-dark: #0e4478;
  --secondary: #0d9488;
  --secondary-light: #14b8a6;
  --secondary-dark: #0f766e;
  --danger: #dc2626;
  --warning: #d97706;
  --bg: #eef3f8;
  --bg-card: #ffffff;
  --text: #12304a;
  --text-secondary: #5b7286;
  --border: #dce6ee;
  --sidebar-bg: linear-gradient(170deg, #0b3a63 0%, #0e4c7d 45%, #155e9b 75%, #1a76ad 100%);
  --shadow: 0 1px 3px rgba(15,45,75,0.07), 0 1px 2px rgba(15,45,75,0.04);
  --shadow-lg: 0 12px 28px -8px rgba(21,94,155,0.18), 0 4px 10px -3px rgba(15,45,75,0.06);
  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --sidebar-w: 270px;
}

::selection { background: rgba(21,94,155,0.25); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #a9c8de; border-radius: 6px; border: 2px solid #eef3f8; }
::-webkit-scrollbar-thumb:hover { background: var(--primary-light); }

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

body {
  font-family: 'Inter', 'Cairo', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: linear-gradient(180deg, #f7fafc 0%, #eef3f8 45%, #f1f6fa 100%);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

[dir="rtl"] body { direction: rtl; }
[dir="ltr"] body { direction: ltr; }

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #e2f0f8 0%, #cfe3f0 30%, #a9c8de 60%, #7fb6d4 100%);
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  top: -200px;
  right: -200px;
}

.login-page::after {
  content: '';
  position: absolute;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  background: rgba(13,148,136,0.06);
  bottom: -100px;
  left: -100px;
}

.login-container {
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 24px;
  box-shadow: 0 20px 50px -20px rgba(11,58,99,0.22);
  padding: 40px;
  width: 100%;
  max-width: 420px;
  border: 1px solid rgba(255,255,255,0.5);
  position: relative;
  z-index: 1;
}

.login-logo {
  text-align: center;
  margin-bottom: 30px;
}

.login-logo-img {
  width: 80px;
  height: auto;
  margin-bottom: 12px;
  filter: drop-shadow(0 4px 8px rgba(21,94,155,0.2));
}

.login-logo h1 {
  color: var(--primary-dark);
  font-size: 22px;
  font-weight: 800;
  margin-top: 8px;
}

.form-group {
  margin-bottom: 16px;
}

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

.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  transition: all 0.25s ease;
  background: white;
  color: var(--text);
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(21, 94, 155, 0.1);
}

.radio-card.active { border-color:var(--primary) !important; background:linear-gradient(135deg, rgba(21,94,155,0.06), rgba(13,148,136,0.06)); }
.radio-card:hover { border-color:var(--primary-light) !important; transform:translateY(-1px); }

.btn {
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  position: relative;
  overflow: hidden;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 3px 10px rgba(21,94,155,0.18);
}

.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 5px 16px rgba(21,94,155,0.25); transform: translateY(-1px); }

.btn-secondary {
  background: var(--secondary);
  color: white;
  box-shadow: 0 3px 10px rgba(13,148,136,0.18);
}

.btn-secondary:hover { background: var(--secondary-dark); box-shadow: 0 5px 16px rgba(13,148,136,0.25); transform: translateY(-1px); }

.btn-danger {
  background: var(--danger);
  color: white;
  box-shadow: 0 3px 10px rgba(220,38,38,0.18);
}

.btn-danger:hover { background: #b91c1c; box-shadow: 0 5px 16px rgba(220,38,38,0.25); transform: translateY(-1px); }

.btn-outline {
  background: transparent;
  border: 2px solid var(--primary);
  color: var(--primary);
}

.btn-outline:hover { background: var(--primary); color: white; border-color: var(--primary); }

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

.btn-block { width: 100%; justify-content: center; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: white;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  z-index: 100;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 4px 0 24px rgba(11,58,99,0.10);
}

[dir="ltr"] .sidebar { left: 0; }
[dir="rtl"] .sidebar { right: 0; }

.sidebar-header {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  position: relative;
}

.sidebar-collapse-btn {
  position: absolute;
  left: 50%;
  bottom: -13px;
  transform: translateX(-50%);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: var(--primary-dark);
  color: white;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
  transition: background 0.2s, transform 0.2s;
  z-index: 2;
}

.sidebar-collapse-btn:hover {
  background: var(--secondary-dark);
  transform: translateX(-50%) scale(1.12);
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 10, 40, 0.5);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 90;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

@media (min-width: 769px) { .sidebar-backdrop { display: none; } }
@media (max-width: 768px) { .sidebar-collapse-btn { display: none; } }

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

.logo-img {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  object-fit: contain;
  background: rgba(255,255,255,0.15);
  padding: 6px;
  backdrop-filter: blur(4px);
}

.sidebar-title-group h2 {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
}

.sidebar-title-group p {
  font-size: 11px;
  opacity: 0.7;
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 20px 10px 12px;
  overflow-y: auto;
}

.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.25); border-color: transparent; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: rgba(255,255,255,0.75);
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  background: none;
  width: 100%;
  text-align: start;
  font-size: 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 2px;
}

[dir="rtl"] .nav-item { text-align: right; }
[dir="ltr"] .nav-item { text-align: left; }

.nav-item:hover { background: rgba(255,255,255,0.12); color: white; }

.nav-item.active {
  background: rgba(255,255,255,0.18);
  color: white;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

[dir="ltr"] .nav-item.active { box-shadow: inset 4px 0 0 0 var(--secondary-light), 0 2px 8px rgba(0,0,0,0.1); }
[dir="rtl"] .nav-item.active { box-shadow: inset -4px 0 0 0 var(--secondary-light), 0 2px 8px rgba(0,0,0,0.1); }

.nav-item:focus-visible { outline: 2px solid rgba(255,255,255,0.55); outline-offset: -2px; }

.nav-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.sidebar-footer .user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.sidebar-footer .user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--secondary), var(--secondary-light));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  box-shadow: 0 2px 8px rgba(13,148,136,0.3);
}

.sidebar-footer .user-name {
  font-size: 13px;
  font-weight: 600;
}

.sidebar-footer .user-role {
  font-size: 11px;
  opacity: 0.7;
}

.main-content {
  flex: 1;
  min-width: 0;
  transition: margin-right 0.3s cubic-bezier(0.4, 0, 0.2, 1), margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[dir="rtl"] .layout.sidebar-pinned .main-content { margin-right: var(--sidebar-w); }
[dir="ltr"] .layout.sidebar-pinned .main-content { margin-left: var(--sidebar-w); }

@media (min-width: 769px) {
  .sidebar { transform: translateX(-100%); }
  [dir="rtl"] .sidebar { transform: translateX(100%); }
  .sidebar.visible { transform: translateX(0); }
  [dir="rtl"] .sidebar.visible { box-shadow: -12px 0 40px rgba(20, 10, 50, 0.28); }
  [dir="ltr"] .sidebar.visible { box-shadow: 12px 0 40px rgba(20, 10, 50, 0.28); }
}

.topbar {
  background: rgba(255,255,255,0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(229,231,235,0.5);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  color: var(--primary);
}

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

.bell-container { position:relative; }
.bell-btn { position:relative; font-size:20px; background:none; border:none; cursor:pointer; padding:6px 10px; border-radius:var(--radius-sm); transition:all .2s; }
.bell-btn:hover { background:var(--bg); }
.bell-badge { position:absolute; top:-2px; right:-2px; background:var(--danger); color:white; font-size:10px; font-weight:700; min-width:18px; height:18px; border-radius:9px; display:flex; align-items:center; justify-content:center; padding:0 4px; pointer-events:none; }
[dir="rtl"] .bell-badge { right:auto; left:-2px; }
.bell-dropdown { position:absolute; top:100%; right:0; min-width:320px; max-height:400px; overflow-y:auto; background:rgba(255,255,255,0.95); backdrop-filter:blur(20px); border-radius:16px; box-shadow:0 10px 40px rgba(0,0,0,0.15); z-index:500; border:1px solid rgba(229,231,235,0.5); margin-top:6px; }
[dir="rtl"] .bell-dropdown { right:auto; left:0; }
.bell-header { padding:14px 18px; font-weight:700; border-bottom:1px solid var(--border); background:linear-gradient(135deg, rgba(21,94,155,0.04), rgba(13,148,136,0.04)); border-radius:16px 16px 0 0; position:sticky; top:0; z-index:1; font-size:14px; }
.bell-item { padding:14px 18px; border-bottom:1px solid #f3f4f6; cursor:pointer; transition:all .2s; }
.bell-item:hover { background:var(--bg); }
.bell-item:last-child { border-bottom:none; }

.page-content {
  padding: 28px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  transition: all 0.3s ease;
  border: 1px solid rgba(229,231,235,0.3);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  opacity: 0.6;
}

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

.stat-card .stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin-bottom: 14px;
  background: linear-gradient(135deg, rgba(21,94,155,0.08), rgba(13,148,136,0.08));
}

.stat-card .stat-value {
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
  color: var(--primary-dark);
}

.stat-card .stat-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
  font-weight: 500;
}

.card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 1px solid rgba(229,231,235,0.3);
  transition: all 0.3s ease;
}

.card:hover { box-shadow: 0 4px 14px rgba(15,45,75,0.08); }

.card-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: linear-gradient(135deg, rgba(21,94,155,0.02), rgba(13,148,136,0.02));
}

.card-header h3 {
  font-size: 16px;
  font-weight: 700;
}

.card-body { padding: 20px; }

.table-container {
  /* ارتفاع محدد حتى يبقى شريط التمرير الأفقي ظاهراً دون الحاجة للنزول إلى نهاية الجدول */
  overflow: auto;
  max-height: calc(100vh - 280px);
  min-height: 160px;
  overscroll-behavior: contain;
}

.table-container::-webkit-scrollbar-thumb { background: #a9c8de; }

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  background: #f4f8fb;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

table th, table td {
  padding: 14px 18px;
  text-align: start;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

[dir="rtl"] table th, [dir="rtl"] table td { text-align: right; }
[dir="ltr"] table th, [dir="ltr"] table td { text-align: left; }

table th {
  background: #f4f8fb;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
  position: sticky;
  top: 0;
}

table tbody tr {
  transition: all 0.2s ease;
}

table tbody tr:hover { background: #eef6fb; }

table tbody tr:last-child td { border-bottom: none; }

td.text-truncate { max-width:200px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; cursor:default; }
td.text-truncate:hover { overflow:visible; white-space:normal; word-break:break-word; position:relative; background:white; box-shadow:0 2px 8px rgba(0,0,0,0.1); border-radius:4px; z-index:1; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.badge-active { background: linear-gradient(135deg, #d1fae5, #a7f3d0); color: #065f46; }
.badge-stopped { background: linear-gradient(135deg, #fee2e2, #fecaca); color: #991b1b; }
.badge-expired { background: linear-gradient(135deg, #fef3c7, #fde68a); color: #92400e; }
.badge-admin { background: linear-gradient(135deg, #e2f0f8, #cfe3f0); color: #0e4478; }
.badge-editor { background: linear-gradient(135deg, #dbeafe, #bfdbfe); color: #1e40af; }
.badge-viewer { background: #f3f4f6; color: #374151; }
.badge-super { background: linear-gradient(135deg, #155e9b, #0d9488); color: white; }

.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
  backdrop-filter: blur(4px);
}

.modal {
  background: white;
  border-radius: var(--radius);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 60px -15px rgba(0,0,0,0.2);
  animation: modalIn 0.25s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, rgba(21,94,155,0.03), rgba(13,148,136,0.03));
}

.modal-header h3 { font-size: 16px; font-weight: 700; }

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 4px 8px;
  border-radius: 8px;
  transition: all 0.2s;
}

.modal-close:hover { background: var(--bg); color: var(--text); }

.modal-body { padding: 22px; }

.modal-footer {
  padding: 16px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-bar input {
  padding: 10px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  min-width: 260px;
  transition: all 0.25s ease;
}

.search-bar input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(21,94,155,0.1);
}

.lang-toggle {
  display: flex;
  background: #f3f4f6;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.lang-toggle button {
  padding: 7px 16px;
  border: none;
  background: transparent;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-secondary);
}

.lang-toggle button.active {
  background: var(--primary);
  color: white;
}

.alert {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 13px;
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.alert-success { background: linear-gradient(135deg, #d1fae5, #a7f3d0); color: #065f46; border: 1px solid rgba(13,148,136,0.2); }
.alert-error { background: linear-gradient(135deg, #fee2e2, #fecaca); color: #991b1b; border: 1px solid rgba(239,68,68,0.2); }
.alert-warning { background: linear-gradient(135deg, #fef3c7, #fde68a); color: #92400e; border: 1px solid rgba(245,158,11,0.2); }
.alert-info { background: linear-gradient(135deg, #dbeafe, #bfdbfe); color: #1e40af; border: 1px solid rgba(59,130,246,0.2); }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}

.empty-state .icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

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

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
}

.tab {
  padding: 10px 20px;
  border: none;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
  border-radius: var(--radius-xs) var(--radius-xs) 0 0;
}

.tab:hover { color: var(--primary); background: rgba(21,94,155,0.04); }

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.text-muted { color: var(--text-secondary); }
.text-center { text-align: center; }
.font-bold { font-weight: 700; }
.w-full { width: 100%; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.order-number-group {
  display: flex;
  align-items: flex-end;
  gap: 0;
  margin-bottom: 16px;
}

.order-number-group .order-num-input {
  flex: 0 0 80px;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  background: white;
  color: var(--text);
  transition: all 0.2s;
}

.order-number-group .order-num-divider {
  padding: 10px 12px;
  background: var(--primary);
  color: white;
  font-size: 18px;
  font-weight: 800;
  display: flex;
  align-items: center;
  border-top: 2px solid var(--primary);
  border-bottom: 2px solid var(--primary);
  user-select: none;
}

.order-number-group .order-year-input {
  flex: 0 0 100px;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  background: white;
  color: var(--text);
  transition: all 0.2s;
}

.order-number-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(21, 94, 155, 0.1);
}

.order-number-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}

.order-number-row {
  display: flex;
  align-items: flex-end;
  gap: 16px;
}

.order-number-row .order-number-group {
  flex: 0 0 auto;
}

.order-number-row .form-group {
  flex: 1;
}

@media (max-width: 768px) {
  .sidebar {
    width: 280px;
    transform: translateX(-100%);
  }
  [dir="rtl"] .sidebar { transform: translateX(100%); }
  .sidebar.open { transform: translateX(0); }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .search-bar input { min-width: 150px; }
  .modal { max-width: 95vw; }
  .page-content { padding: 16px; }
  .topbar { padding: 12px 16px; }
}

.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 28px;
}

@media (max-width: 900px) {
  .charts-grid { grid-template-columns: 1fr; }
}

.chart-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  border: 1px solid rgba(229,231,235,0.3);
  transition: all 0.3s ease;
}

.chart-card:hover { box-shadow: var(--shadow-lg); }

.chart-card h4 {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text);
}

.progress-bar {
  height: 8px;
  background: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
  margin-top: 6px;
}

.progress-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  transition: width 0.3s ease;
}

.stop-info {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border: 1px solid rgba(245,158,11,0.2);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-top: 12px;
}

.stop-info h4 {
  color: #92400e;
  font-size: 13px;
  margin-bottom: 8px;
}

.stop-info p {
  font-size: 12px;
  color: #92400e;
  margin: 2px 0;
}

.sidebar-toggle {
  background: white;
  border: 1px solid var(--border);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  color: var(--text);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex: 0 0 auto;
}

.sidebar-toggle:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  box-shadow: 0 3px 10px rgba(21,94,155,0.25);
}

@media (max-width: 768px) {
  .login-container { padding: 28px 24px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .stat-card { padding: 16px; }
  .stat-card .stat-value { font-size: 22px; }
  .doc-grid-responsive { grid-template-columns: 1fr !important; }
}

.card:hover { box-shadow: 0 4px 14px rgba(15,45,75,0.08); }

.badge-expired { background: #fee2e2; color: #dc2626; padding: 2px 10px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.badge-active { background: #d1fae5; color: #065f46; padding: 2px 10px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.badge-stopped { background: #fef3c7; color: #d97706; padding: 2px 10px; border-radius: 12px; font-size: 11px; font-weight: 600; }

.form-control {
  padding: 8px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
}
.form-control:focus { border-color: #155e9b; box-shadow: 0 0 0 2px rgba(21,94,155,0.1); }

.flex { display: flex; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.text-center { text-align: center; }
.mb-4 { margin-bottom: 16px; }
.mt-2 { margin-top: 8px; }
.text-xs { font-size: 12px; }
.text-muted { color: #6b7280; }
.text-sm { font-size: 14px; }
.font-bold { font-weight: 700; }
.w-full { width: 100%; }

/* ====== تحسينات الهاتف ====== */
@media (max-width: 768px) {
  .modal { max-width: 95vw; max-height: 92vh; margin: 4vh auto; overflow-y: auto; }
  .modal-body > div[style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
  .table-container { overflow: auto; max-height: calc(100vh - 220px); -webkit-overflow-scrolling: touch; }
  .table-container table { min-width: 680px; }
  .topbar { flex-wrap: wrap; gap: 8px; }
  .topbar-actions { flex-wrap: wrap; gap: 8px; }
  .card-header { flex-wrap: wrap; gap: 8px; }
  .public-order { font-size: 12px; }
}

/* ====== الطباعة (بطاقة QR / الصفحة العامة) ====== */
@media print {
  body * { visibility: hidden; }
  .print-area, .print-area * { visibility: visible; }
  .print-area { position: fixed; top: 35%; left: 50%; transform: translate(-50%, -50%); box-shadow: none; }
}

