:root {
  --brand-green: #4E8A2C;
  --brand-green-dark: #3B6B20;
  --brand-green-soft: #F3F8F1;
  --brand-orange: #E07014;
  --brand-orange-soft: #FFF4EB;
  --bg: #F6F8F5;
  --card: #FFFFFF;
  --text: #111827;
  --muted: #6B7280;
  --border: #E5ECE4;
  --danger: #DC2626;
  --danger-soft: #FEF2F2;
  --info: #2563EB;
  --info-soft: #EFF6FF;
  --radius: 16px;
  --shadow: 0 6px 20px rgba(17, 24, 39, 0.06);
}

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

body {
  font-family: 'Cairo', -apple-system, BlinkMacSystemFont, 'Segoe UI', Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

/* ─── LOGIN SCREEN ─── */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at top right, #EAF5E4 0%, #F7F8F7 55%, #FFF4EB 100%);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 32px;
  box-shadow: 0 20px 50px rgba(17, 24, 39, 0.08);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 26px;
}

.login-brand h1 {
  font-size: 22px;
  font-weight: 900;
  color: var(--text);
}

.login-brand p {
  font-size: 13px;
  color: var(--muted);
}

.brand-badge {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--brand-green), var(--brand-orange));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  flex-shrink: 0;
  box-shadow: 0 8px 18px rgba(78, 138, 44, 0.22);
}

.brand-badge.small {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  font-size: 20px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

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

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: #FAFBF9;
  transition: border-color 0.15s, background 0.15s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--brand-green);
  background: #FFFFFF;
}

.alert-error {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid #FECACA;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 700;
}

.login-footer-note {
  margin-top: 20px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

.login-footer-note code {
  background: var(--brand-green-soft);
  color: var(--brand-green-dark);
  padding: 2px 6px;
  border-radius: 6px;
  font-weight: 700;
}

/* ─── BUTTONS ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 12px;
  padding: 10px 16px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s, background 0.15s, opacity 0.15s;
}

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

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

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 7px 12px;
  font-size: 12.5px;
  border-radius: 10px;
}

.btn-xs {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 8px;
}

.btn-primary {
  background: var(--brand-green);
  color: #FFFFFF;
}

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

.btn-orange {
  background: var(--brand-orange);
  color: #FFFFFF;
}

.btn-orange:hover {
  background: #C7600E;
}

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

.btn-danger:hover {
  background: #B91C1C;
}

.btn-soft {
  background: var(--brand-green-soft);
  color: var(--brand-green-dark);
  border: 1px solid #DCEAD6;
}

.btn-soft:hover {
  background: #E5F1DF;
}

.btn-outline {
  background: #FFFFFF;
  color: #374151;
  border: 1px solid var(--border);
}

.btn-outline:hover {
  background: #F9FAFB;
}

.btn-link {
  background: transparent;
  color: var(--brand-green);
  padding: 4px 8px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #FFFFFF;
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ─── APP SHELL ─── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 268px;
  background: var(--card);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
  z-index: 50;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px 18px;
  border-bottom: 1px solid var(--border);
}

.brand-text {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.brand-text strong {
  font-size: 16px;
  font-weight: 900;
}

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

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 16px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 12px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: #374151;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  text-align: right;
  transition: background 0.15s, color 0.15s;
}

.nav-item:hover {
  background: var(--brand-green-soft);
}

.nav-item.active {
  background: var(--brand-green);
  color: #FFFFFF;
}

.nav-icon {
  font-size: 17px;
}

.nav-badge {
  margin-right: auto;
  background: var(--danger);
  color: #FFFFFF;
  font-size: 11px;
  font-weight: 800;
  padding: 1px 7px;
  border-radius: 99px;
}

.nav-badge.orange {
  background: var(--brand-orange);
}

.nav-item.active .nav-badge {
  background: rgba(255, 255, 255, 0.25);
  color: #FFFFFF;
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.admin-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 12px;
  background: var(--brand-green-soft);
}

.admin-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--brand-green);
  color: #FFFFFF;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
}

.admin-meta {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.admin-meta strong {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-meta span {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── MAIN AREA & TOPBAR ─── */
.main-area {
  flex: 1;
  min-width: 0;
  padding: 20px 24px 36px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

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

.topbar h2 {
  font-size: 22px;
  font-weight: 900;
}

.page-subtitle {
  font-size: 13px;
  color: var(--muted);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ECFDF5;
  color: #065F46;
  border: 1px solid #A7F3D0;
  border-radius: 99px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 700;
}

.scope-pill {
  background: var(--brand-orange-soft);
  color: #B45309;
  border: 1px solid #FED7AA;
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.gov-select {
  padding: 7px 12px;
  border-radius: 10px;
  border: 1.5px solid var(--brand-green);
  background: #FFFFFF;
  color: var(--brand-green-dark);
  font-family: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.locked-gov-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--brand-orange-soft);
  color: #C2410C;
  border: 1px solid #FDBA74;
  border-radius: 99px;
  padding: 5px 13px;
  font-size: 12.5px;
  font-weight: 800;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10B981;
  animation: pulseDot 1.6s infinite;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(1.25); }
}

.view-section {
  display: none;
}

.view-section.active {
  display: block;
}

/* ─── KPI CARDS ─── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.kpi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow);
}

.kpi-card.clickable {
  cursor: pointer;
  transition: transform 0.12s, border-color 0.15s;
}

.kpi-card.clickable:hover {
  transform: translateY(-2px);
  border-color: var(--brand-green);
}

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

.kpi-icon.green { background: #EAF5E4; }
.kpi-icon.orange { background: #FFF1E6; }
.kpi-icon.amber { background: #FEF3C7; }
.kpi-icon.blue { background: #EFF6FF; }
.kpi-icon.emerald { background: #ECFDF5; }

.kpi-label {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 600;
}

.kpi-value {
  font-size: 22px;
  font-weight: 900;
  color: var(--text);
}

/* ─── PANELS ─── */
.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-head h3 {
  font-size: 16px;
  font-weight: 800;
}

.muted-tag,
.muted-small {
  font-size: 12px;
  color: var(--muted);
}

/* ─── PIPELINE FUNNEL ─── */
.pipeline-grid {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.pipe-step {
  flex: 1;
  min-width: 120px;
  background: var(--brand-green-soft);
  border: 1px solid #DCEAD6;
  border-radius: 14px;
  padding: 14px 12px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.12s;
}

.pipe-step:hover {
  border-color: var(--brand-green);
  transform: translateY(-2px);
}

.pipe-step.done {
  background: #ECFDF5;
  border-color: #A7F3D0;
}

.pipe-count {
  display: block;
  font-size: 24px;
  font-weight: 900;
  color: var(--text);
}

.pipe-label {
  font-size: 12.5px;
  font-weight: 700;
  color: #374151;
}

.pipe-arrow {
  color: #9CA3AF;
  font-weight: 900;
  font-size: 18px;
}

.two-col-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.stack-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mini-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #FAFBF9;
}

.mini-row-info strong {
  display: block;
  font-size: 14px;
}

.mini-row-info span {
  font-size: 12px;
  color: var(--muted);
}

/* ─── TOOLBAR & FILTERS ─── */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

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

.filter-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  background: var(--brand-green-soft);
  padding: 5px;
  border-radius: 14px;
}

.filter-tab {
  border: none;
  background: transparent;
  color: #374151;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 7px 14px;
  border-radius: 10px;
  cursor: pointer;
}

.filter-tab.active {
  background: #FFFFFF;
  color: var(--brand-green-dark);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.search-input {
  min-width: 240px;
  padding: 9px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #FFFFFF;
  font-family: inherit;
  font-size: 13.5px;
}

.search-input:focus {
  outline: none;
  border-color: var(--brand-green);
}

.checkbox-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

/* ─── TABLES ─── */
.table-panel {
  padding: 0;
  overflow: hidden;
}

.table-wrap {
  overflow-x: auto;
}

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

.data-table th {
  background: var(--brand-green-soft);
  color: #374151;
  text-align: right;
  font-weight: 800;
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 13px 14px;
  border-bottom: 1px solid #F1F5F0;
  vertical-align: middle;
}

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

.entity-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.entity-thumb {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  object-fit: cover;
  background: var(--brand-green-soft);
  border: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.actions-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* ─── BADGES ─── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 800;
  white-space: nowrap;
}

.badge-green { background: #ECFDF5; color: #065F46; }
.badge-orange { background: #FFF4EB; color: #C2410C; }
.badge-amber { background: #FEF3C7; color: #92400E; }
.badge-red { background: #FEF2F2; color: #B91C1C; }
.badge-blue { background: #EFF6FF; color: #1D4ED8; }
.badge-gray { background: #F3F4F6; color: #4B5563; }

/* ─── ORDERS WORKSPACE & STEPPER ─── */
.orders-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(340px, 0.95fr);
  gap: 18px;
  align-items: start;
}

.orders-cards-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.order-card {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  transition: border-color 0.15s;
}

.order-card.selected {
  border-color: var(--brand-green);
  box-shadow: 0 8px 24px rgba(78, 138, 44, 0.14);
}

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

.order-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
  font-size: 12.5px;
  color: #374151;
  background: #FAFBF9;
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 12px;
}

/* 5-Step Lifecycle Bar */
.lifecycle-bar {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  margin: 10px 0 12px;
}

.life-step {
  text-align: center;
  padding: 6px 4px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  background: #F3F4F6;
  color: #9CA3AF;
}

.life-step.done {
  background: var(--brand-green-soft);
  color: var(--brand-green-dark);
}

.life-step.current {
  background: var(--brand-orange);
  color: #FFFFFF;
}

.life-step.cancelled {
  background: var(--danger-soft);
  color: var(--danger);
}

.order-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

/* ─── TRACKING MAP PANEL ─── */
.tracking-panel {
  position: sticky;
  top: 16px;
}

.tracking-map {
  width: 100%;
  height: 310px;
  border-radius: 14px;
  border: 1px solid var(--border);
  overflow: hidden;
  z-index: 1;
}

.map-legend {
  display: flex;
  align-items: center;
  justify-content: space-around;
  margin: 10px 0;
  font-size: 12px;
  font-weight: 700;
  color: #374151;
  background: var(--brand-green-soft);
  padding: 7px;
  border-radius: 10px;
}

.selected-order-box {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  margin-top: 8px;
  font-size: 13px;
}

.order-items-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 8px 0 12px;
}

.order-items-list li {
  display: flex;
  justify-content: space-between;
  background: #FAFBF9;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12.5px;
}

.assign-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.assign-row select {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  font-size: 13px;
}

/* ─── SETTINGS ─── */
.settings-panel {
  max-width: 780px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.settings-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-start;
  margin-top: 6px;
}

/* ─── EMPTY & MODALS ─── */
.empty-box,
.empty-cell {
  text-align: center;
  padding: 28px 16px;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 600;
}

.empty-box.compact {
  padding: 14px 10px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 39, 0.55);
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 460px;
  background: var(--card);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
}

.image-modal-card {
  max-width: 680px;
}

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

.modal-body {
  padding: 18px;
}

.modal-body.centered {
  display: flex;
  justify-content: center;
  background: #111827;
}

.modal-body img {
  max-width: 100%;
  max-height: 70vh;
  border-radius: 10px;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
}

/* ─── TOASTS ─── */
.toast-container {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: #111827;
  color: #FFFFFF;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.toast.success { background: var(--brand-green-dark); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--brand-orange); }

/* ─── RESPONSIVE ─── */
.mobile-only {
  display: none;
}

@media (max-width: 1024px) {
  .orders-workspace {
    grid-template-columns: 1fr;
  }
  .tracking-panel {
    position: static;
  }
}

@media (max-width: 820px) {
  .mobile-only {
    display: inline-flex;
  }
  .sidebar {
    position: fixed;
    right: -280px;
    top: 0;
    transition: right 0.22s ease;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.16);
  }
  .sidebar.open {
    right: 0;
  }
  .main-area {
    padding: 16px;
  }
}
