:root {
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-soft: #f8fbff;
  --text: #0f172a;
  --muted: #5b6475;
  --line: #e3e8f2;
  --primary: #0f766e;
  --primary-soft: #dff4f1;
  --warning: #b45309;
  --danger: #b91c1c;
  --success: #047857;
  --sidebar: #111827;
  --sidebar-line: #1f2937;
  --radius-lg: 18px;
  --radius-md: 12px;
  --shadow: 0 10px 28px rgba(15, 23, 42, 0.06);
}

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

html,
body {
  height: 100%;
}

body {
  font-family: "Manrope", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 10%, #dff4f1 0, transparent 28%),
    radial-gradient(circle at 90% 5%, #e7f0ff 0, transparent 35%),
    var(--bg);
  display: flex;
  overflow: hidden;
}

.app {
  width: 100%;
  display: flex;
  min-height: 100vh;
}

.is-hidden {
  display: none !important;
}

.login-view {
  width: 100%;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-card {
  width: min(460px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 20px;
}

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

.login-card p {
  color: var(--muted);
  margin-bottom: 14px;
  font-size: 14px;
}

.login-remember {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #334155;
  font-weight: 600;
}

.section-spacer {
  margin: 12px 0;
}

.select-compact {
  max-width: 200px;
}

.hidden-input {
  display: none;
}

.insights-grid {
  margin: 12px 0;
}

.kpi-grid-spaced {
  margin-bottom: 16px;
}

.kpi-success {
  background: #f0fdf4;
}

.kpi-danger {
  background: #fef2f2;
}

.form-section {
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
}

.form-section-muted {
  background: #f8fafc;
}

.form-section-success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
}

.form-section-warning {
  background: #fffbeb;
  border: 1px solid #fde68a;
}

.form-section-danger {
  background: #fef2f2;
  border: 1px solid #fecaca;
}

.form-section-title {
  font-weight: 600;
  margin-bottom: 8px;
}

.form-help {
  font-size: 11px;
  color: #64748b;
  margin-top: 4px;
}

.input-surface {
  background: #ffffff;
  color: #1e293b;
  border: 1px solid #cbd5e1;
  padding: 8px;
  border-radius: 6px;
  font-size: 14px;
  width: 100%;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  cursor: pointer;
}

.checkbox-input {
  width: auto;
}

.inline-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.align-end {
  align-items: flex-end;
}

.mt-8 {
  margin-top: 8px;
}

.mt-12 {
  margin-top: 12px;
}

.form-description {
  margin-bottom: 16px;
  color: #4b5563;
}

.form-note-success {
  color: #059669;
  font-size: 0.9em;
  margin-bottom: 16px;
}

.form-note-danger {
  color: #dc2626;
  font-size: 0.9em;
  margin-bottom: 16px;
}

.alert-compact {
  padding: 10px;
  font-size: 13px;
}

.chip-list {
  max-height: 150px;
  overflow-y: auto;
}

.chip-list-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-chip {
  background: #e2e8f0;
  padding: 4px 8px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.tag-remove-btn {
  border: 0;
  background: transparent;
  cursor: pointer;
  color: #ef4444;
  font-weight: bold;
}

.details-table {
  width: 100%;
  margin-top: 12px;
  font-size: 13px;
}

.details-empty {
  margin-top: 12px;
  color: #64748b;
}

.grid-gap-12 {
  gap: 12px;
}

.grid-gap-10 {
  gap: 10px;
}

.hidden-block {
  display: none;
}

.text-slate-800 {
  color: #1e293b;
}

.text-green-700 {
  color: #166534;
}

.text-amber-700 {
  color: #92400e;
}

.text-red-800 {
  color: #991b1b;
}

.field.light,
.select.light,
.textarea.light {
  color: #0f172a;
  background: #fff;
  border-color: var(--line);
}

.sidebar {
  width: 288px;
  flex-shrink: 0;
  background: var(--sidebar);
  color: #d1d5db;
  border-right: 1px solid var(--sidebar-line);
  display: flex;
  flex-direction: column;
  z-index: 20;
  transition: transform 0.25s ease;
}

.brand {
  padding: 24px 20px;
  border-bottom: 1px solid var(--sidebar-line);
}

.brand h1 {
  color: #f8fafc;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.2px;
}

.brand p {
  margin-top: 4px;
  font-size: 12px;
  color: #9ca3af;
}

.nav {
  padding: 14px;
  display: grid;
  gap: 8px;
  overflow-y: auto;
}

.nav-btn {
  border: 0;
  background: transparent;
  color: #9ca3af;
  text-align: left;
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.nav-btn:hover {
  background: #1f2937;
  color: #e5e7eb;
}

.nav-btn.active {
  background: linear-gradient(135deg, #115e59, #0f766e);
  color: #f0fdfa;
  box-shadow: 0 8px 20px rgba(15, 118, 110, 0.35);
}

.nav-divider {
  height: 1px;
  background: #374151;
  margin: 16px 12px 8px 12px;
}

.sidebar-footer {
  padding: 0 14px 14px;
  display: grid;
  gap: 8px;
}

.nav-btn.nav-btn-danger {
  color: #f87171;
  font-weight: 600;
  margin-top: 8px;
}

.nav-btn.nav-btn-danger:hover {
  background: #7f1d1d;
  color: #fecaca;
}

.auth-panel {
  margin: auto 14px 14px;
  background: #0b1220;
  border: 1px solid #1f2937;
  border-radius: var(--radius-md);
  padding: 12px;
  display: grid;
  gap: 8px;
}

.auth-panel h2 {
  font-size: 12px;
  color: #e5e7eb;
  font-weight: 700;
  margin-bottom: 2px;
}

.label {
  font-size: 11px;
  color: #94a3b8;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.sep {
  border: 0;
  border-top: 1px solid #1f2937;
  margin: 6px 0;
}

.field,
.select,
.textarea {
  width: 100%;
  border-radius: 9px;
  border: 1px solid #334155;
  padding: 9px 10px;
  font-size: 13px;
  color: #e2e8f0;
  background: #111827;
  outline: none;
}

.textarea {
  min-height: 90px;
  resize: vertical;
}

.field:focus,
.select:focus,
.textarea:focus {
  border-color: #14b8a6;
}

.searchable-select {
  position: relative;
  width: 100%;
}

.searchable-select-native {
  position: absolute !important;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  width: 100%;
  height: 100%;
}

.searchable-select-input {
  padding-right: 34px;
  background-image:
    linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% - 2px),
    calc(100% - 13px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.searchable-select.is-open .searchable-select-input {
  border-color: #14b8a6;
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.12);
}

.searchable-select-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 35;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  max-height: 240px;
  overflow: auto;
  display: none;
}

.searchable-select.is-open .searchable-select-dropdown {
  display: block;
}

.searchable-select-list {
  padding: 6px;
  display: grid;
  gap: 4px;
}

.searchable-select-option,
.searchable-select-empty {
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: 9px 10px;
  text-align: left;
  font-size: 13px;
  background: transparent;
  color: var(--text);
}

.searchable-select-option {
  cursor: pointer;
}

.searchable-select-option:hover,
.searchable-select-option.is-selected {
  background: var(--primary-soft);
  color: var(--primary);
}

.searchable-select-option:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.searchable-select-empty {
  color: var(--muted);
}

.btn {
  border: 0;
  border-radius: 9px;
  padding: 9px 11px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.btn-primary {
  color: #ecfeff;
  background: #0f766e;
}

.btn-tiny {
  font-size: 11px;
  padding: 2px 8px;
  line-height: 1.5;
}

.btn-subtle {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--line);
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

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

.menu-toggle {
  display: none;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.title-block h2 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.2px;
}

.title-block p {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.chip {
  border-radius: 999px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  font-size: 12px;
  background: #fff;
  color: #1e293b;
  font-weight: 700;
}

.chip-button {
  cursor: pointer;
}

.health-popover {
  position: absolute;
  right: 18px;
  top: 58px;
  width: min(420px, calc(100vw - 36px));
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 10px;
  z-index: 20;
}

.api-route-popover {
  position: absolute;
  right: 18px;
  top: 58px;
  width: min(460px, calc(100vw - 36px));
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 10px;
  z-index: 20;
}

.health-popover h4 {
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 8px;
}

.api-route-popover h4 {
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 8px;
}

.health-popover-controls {
  margin-bottom: 8px;
}

.api-route-base {
  font-size: 12px;
  color: #334155;
  margin-bottom: 8px;
  padding: 7px 8px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fbff;
  word-break: break-all;
}

.health-popover-body {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: #334155;
  max-height: 220px;
  overflow: auto;
}

.api-route-popover-body {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: #334155;
  max-height: 220px;
  overflow: auto;
}

.health-popover-row {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 7px 8px;
  display: grid;
  gap: 2px;
}

.api-route-popover-row {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 7px 8px;
  display: grid;
  gap: 2px;
}

.health-popover-row strong {
  font-size: 12px;
}

.api-route-popover-row strong {
  font-size: 12px;
}

.content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: grid;
  gap: 16px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 14px;
  box-shadow: var(--shadow);
}

.kpi small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.kpi strong {
  display: block;
  margin-top: 6px;
  font-size: 22px;
  font-weight: 800;
}

.kpi span {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.card-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 12px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.card-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.card-head h3 {
  flex-shrink: 0;
  font-size: 14px;
  font-weight: 800;
}

.card-head .controls {
  width: 50%;
  justify-content: flex-end;
  display: inline-flex;
  flex-wrap: wrap;
}

.card-body {
  padding: 12px 14px;
  display: grid;
  gap: 10px;
}

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

.controls .label {
  align-self: center;
  line-height: 1;
  white-space: nowrap;
}

.controls .field,
.controls .select,
.controls .textarea {
  color: #0f172a;
  background: #fff;
  border-color: var(--line);
  min-width: 150px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 700px;
}

th,
td {
  text-align: left;
  padding: 10px;
  border-bottom: 1px solid #edf2f7;
  font-size: 13px;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fbff;
  color: #475569;
  font-weight: 800;
}

.status {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 11px;
  font-weight: 800;
  border: 1px solid transparent;
}

.status.pending {
  background: #fff7ed;
  color: var(--warning);
  border-color: #fed7aa;
}

.status.dispatched {
  background: #eff6ff;
  color: #2563eb;
  border-color: #bfdbfe;
}

.status.delivered {
  background: #ecfdf5;
  color: var(--success);
  border-color: #a7f3d0;
}

.status.error {
  background: #fef2f2;
  color: var(--danger);
  border-color: #fecaca;
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.alert {
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: 13px;
  border: 1px solid;
}

.alert.info {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
}

.alert.warn {
  background: #fff7ed;
  color: #9a3412;
  border-color: #fdba74;
}

.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  z-index: 10;
}

.overlay.show {
  display: block;
}

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(15, 23, 42, 0.55);
  padding: 24px;
}

.modal-overlay.show {
  display: grid;
  place-items: center;
}

#idleModal {
  z-index: 40;
}

.modal {
  width: min(760px, 100%);
  max-height: 90vh;
  background: #fff;
  border-radius: 16px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
}

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

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.form-grid .full {
  grid-column: 1 / -1;
}

.loading {
  color: #334155;
  font-weight: 700;
  font-size: 13px;
}

.loading.is-refreshing::after {
  content: " Refreshing...";
  color: var(--primary);
  animation: refreshPulse 1.2s ease-in-out infinite;
}

@keyframes refreshPulse {
  0% { opacity: 0.45; }
  50% { opacity: 1; }
  100% { opacity: 0.45; }
}

.table-pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.toast-stack {
  position: fixed;
  right: 14px;
  top: 14px;
  z-index: 60;
  display: grid;
  gap: 8px;
  max-width: min(360px, calc(100vw - 28px));
}

.toast {
  border: 1px solid;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 700;
  box-shadow: var(--shadow);
  transform: translateY(0);
  opacity: 1;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.info {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
}

.toast.warn {
  background: #fff7ed;
  color: #9a3412;
  border-color: #fdba74;
}

.toast.hide {
  opacity: 0;
  transform: translateY(6px);
}

@media (max-width: 1200px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .card-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 992px) {
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .menu-toggle {
    display: inline-block;
  }

  .topbar-toggle {
    display: none;
    width: 38px;
    height: 38px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--primary);
  }
}

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

  .topbar {
    padding: 10px 12px;
    flex-wrap: wrap;
  }

  .topbar-left {
    flex: 1;
    min-width: 150px;
  }

  .topbar-actions {
    display: none;
  }

  .topbar-actions.visible {
    display: flex;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(6px);
    border-bottom: 1px solid var(--line);
    padding: 12px;
    gap: 8px;
    z-index: 100;
  }

  #appLogoutBtn {
    display: inline-flex !important;
  }

  .topbar-actions.visible .chip,
  .topbar-actions.visible .btn {
    width: 100%;
    text-align: center;
  }

  .topbar-toggle {
    display: flex !important;
  }

  .content {
    padding: 12px;
  }

  .title-block h2 {
    font-size: 18px;
  }

  .controls .field,
  .controls .select,
  .controls .btn,
  .controls .textarea {
    width: 100%;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .modal-overlay {
    padding: 12px;
  }
}

@media (max-width: 576px) {
  .title-block p {
    display: none;
  }

  .chip {
    width: 100%;
    text-align: center;
  }

  .topbar-actions.visible {
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
  }
}

/* Invoice Modal Styles */
.invoice-modal {
  width: min(800px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  background: #fff;
  border-radius: 16px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

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

.invoice-modal .modal-body {
  padding: 14px;
}

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

.invoice-container {
  font-family: Arial, sans-serif;
}

.invoice-header {
  margin-bottom: 20px;
  border-bottom: 2px solid #333;
  padding-bottom: 10px;
}

.invoice-header h2 {
  margin: 0 0 10px 0;
  color: #333;
}

.invoice-header p {
  margin: 5px 0;
  font-size: 14px;
}

.invoice-container h3 {
  margin: 20px 0 10px 0;
  border-bottom: 1px solid #ccc;
  padding-bottom: 5px;
  font-size: 16px;
}

.invoice-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
  font-size: 13px;
}

.invoice-table th,
.invoice-table td {
  border: 1px solid #ddd;
  padding: 8px;
  text-align: left;
}

.invoice-table th {
  background-color: #f5f5f5;
  font-weight: bold;
}

.invoice-table tfoot td {
  font-weight: bold;
  background-color: #f9f9f9;
}

.invoice-table th:nth-child(4),
.invoice-table td:nth-child(4) {
  text-align: center;
  white-space: nowrap;
}

.invoice-table th:nth-child(5),
.invoice-table td:nth-child(5),
.invoice-table th:nth-child(6),
.invoice-table td:nth-child(6) {
  text-align: right;
  white-space: nowrap;
}

.invoice-summary {
  margin-top: 20px;
  padding: 15px;
  background-color: #f9f9f9;
  border-radius: 5px;
}

.invoice-summary .summary-row {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
}

.invoice-summary .balance-due {
  font-size: 1.2em;
  font-weight: bold;
  border-top: 2px solid #333;
  margin-top: 10px;
  padding-top: 10px;
  color: #b91c1c;
}

.invoice-footer {
  margin-top: 30px;
  text-align: center;
  color: #666;
  font-size: 0.9em;
}

/* Order Invoice Modal Styles */
.invoice-party-details {
  display: flex;
  justify-content: space-between;
  margin-bottom: 20px;
  padding: 15px;
  background-color: #f9f9f9;
  border-radius: 8px;
}

.invoice-party-details .party-info,
.invoice-party-details .order-info {
  width: 48%;
}

.invoice-party-details h4 {
  margin: 0 0 10px 0;
  font-size: 14px;
}

.invoice-party-details p {
  margin: 3px 0;
  font-size: 13px;
}

.invoice-totals {
  margin-top: 20px;
  padding: 15px;
  background-color: #f9f9f9;
  border-radius: 5px;
  max-width: 300px;
  margin-left: auto;
}

.invoice-totals .total-row {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
}

.invoice-totals .grand-total {
  font-size: 1.2em;
  font-weight: bold;
  border-top: 2px solid #333;
  margin-top: 10px;
  padding-top: 10px;
  color: #b91c1c;
}

.invoice-notes {
  margin-top: 20px;
  padding: 10px;
  background-color: #fff7ed;
  border-radius: 5px;
}

/* Party Pricing Modal Styles */
.pricing-modal {
  width: min(700px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  background: #fff;
  border-radius: 16px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

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

.pricing-modal .modal-body {
  padding: 14px;
}

.pricing-container {
  font-family: Arial, sans-serif;
}

.pricing-header {
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid #e2e8f0;
}

.pricing-header h3 {
  margin: 0 0 8px 0;
  color: #1e293b;
  font-size: 18px;
}

.pricing-header p {
  margin: 0;
  color: #64748b;
  font-size: 13px;
}

.pricing-form {
  margin-bottom: 20px;
  padding: 15px;
  background-color: #f8fafc;
  border-radius: 8px;
}

.pricing-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  align-items: end;
}

.global-modal-footer {
  display: none;
  gap: 10px;
  justify-content: flex-end;
  padding: 12px 16px;
  border-top: 1px solid #e5e7eb;
}

.global-modal-footer.is-open {
  display: flex;
}

.form-note {
  margin-bottom: 16px;
  font-size: 0.9em;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.checkbox-label {
  font-weight: 500;
}

.delivery-features {
  margin: 8px 0 8px 20px;
  line-height: 1.6;
}

.zone-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 12px;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 8px 12px;
  background: #f8fafc;
}

.zone-grid .checkbox-row {
  margin-bottom: 2px;
}

.zone-select-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 6px;
}

.zone-search {
  margin-bottom: 6px;
}

.zone-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 18px;
  padding: 0 5px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  background: #3b82f6;
  border-radius: 9px;
  vertical-align: middle;
}

.zone-count {
  font-size: 11px;
  color: #64748b;
  margin-left: auto;
  align-self: center;
}

.text-left {
  text-align: left;
}

.text-right {
  text-align: right;
}

.col-w-5 { width: 5%; }
.col-w-6 { width: 6%; }
.col-w-8 { width: 8%; }
.col-w-10 { width: 10%; }
.col-w-12 { width: 12%; }
.col-w-13 { width: 13%; }
.col-w-14 { width: 14%; }
.col-w-15 { width: 15%; }
.col-w-41 { width: 41%; }

.pricing-list h4 {
  margin: 0 0 12px 0;
  color: #1e293b;
  font-size: 14px;
}

.pricing-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.pricing-table th,
.pricing-table td {
  border: 1px solid #e2e8f0;
  padding: 10px;
  text-align: left;
}

.pricing-table th {
  background-color: #f1f5f9;
  font-weight: bold;
  color: #475569;
}

.pricing-table td {
  color: #334155;
}

.no-pricing {
  padding: 20px;
  text-align: center;
  color: #64748b;
  background-color: #f8fafc;
  border-radius: 8px;
  font-size: 13px;
}

/* Dropdown Styles */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dropdown-arrow {
  font-size: 10px;
  transition: transform 0.2s ease;
}

.dropdown.open .dropdown-arrow {
  transform: rotate(180deg);
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 50;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  min-width: 200px;
  padding: 6px;
  display: none;
  margin-top: 4px;
}

.dropdown.open .dropdown-menu {
  display: block;
}

.dropdown-item {
  display: block;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  background: transparent;
  text-align: left;
  font-size: 13px;
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
}

.dropdown-item:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.dropdown-divider {
  height: 1px;
  background: var(--line);
  margin: 6px 0;
}

/* Ensure dropdowns are visible on mobile - prevent clipping by overflow containers */
.searchable-select-dropdown,
.dropdown-menu {
  z-index: 1000 !important;
}

/* On mobile, position dropdowns in viewport center to avoid clipping */
@media (max-width: 768px) {
  .searchable-select-dropdown.is-open,
  .dropdown-menu.is-open {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-height: 50vh;
    max-width: 90vw;
  }

  /* Reset filter controls width on mobile for full width */
   .card-head .controls {
     width: 100%;
     justify-content: flex-start;
   }
}

/* Loading Screen Styles */
.loading-screen {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-content {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
}

.loading-content p {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  margin: 0;
}

.spinner-lg {
  width: 48px;
  height: 48px;
  border: 3px solid var(--line);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

.spinner-sm {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--line);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Deployment Wizard ──────────────────────────────────────────── */

.step-indicator {
  display: flex;
  gap: 0;
  margin-bottom: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.step-dot {
  flex: 1;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  background: var(--surface);
  color: var(--muted);
  border-right: 1px solid var(--line);
  cursor: default;
}

.step-dot:last-child {
  border-right: none;
}

.step-dot.active {
  background: var(--primary);
  color: #fff;
}

.log-output {
  background: #1e293b;
  color: #e2e8f0;
  font-family: 'Menlo', 'Consolas', monospace;
  font-size: 12px;
  line-height: 1.5;
  padding: 12px;
  border-radius: var(--radius-md);
  max-height: 400px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  margin-top: 8px;
}

.input-group {
  display: flex;
  gap: 8px;
  align-items: center;
}

.alert.error {
  background: #fef2f2;
  color: #991b1b;
  border-color: #fca5a5;
}

.dispatch-return-form .order-return-section {
  margin-bottom: 20px;
  padding: 12px;
  background: var(--surface-soft);
  border-radius: var(--radius-md);
}

.dispatch-return-form .order-return-header {
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.dispatch-return-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.dispatch-return-table th,
.dispatch-return-table td {
  padding: 6px 8px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

.dispatch-return-table th {
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.dispatch-return-table .return-qty-input {
  width: 80px;
}

/* Route Planner */
.rp-layout {
  display: flex;
  gap: 16px;
  min-height: 520px;
}

.rp-map-wrap {
  flex: 1;
  position: relative;
  min-height: 500px;
}

.rp-map {
  height: 100%;
  min-height: 500px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  z-index: 1;
}

.rp-map-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rp-map-controls .btn {
  font-size: 12px;
  padding: 6px 12px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  background: var(--surface);
  border: 1px solid var(--line);
}

.rp-route-info {
  position: absolute;
  bottom: 12px;
  left: 12px;
  right: 12px;
  z-index: 1000;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  display: flex;
  gap: 20px;
  font-size: 13px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.rp-route-info span {
  color: var(--text);
  font-weight: 500;
}

.rp-stops-panel {
  width: 300px;
  min-width: 260px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.rp-stops-panel h4 {
  margin: 0;
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 600;
  border-bottom: 1px solid var(--line);
  color: var(--text);
}

.rp-stops-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  max-height: 550px;
}

.rp-stop-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.15s;
  border-radius: var(--radius-md);
}

.rp-stop-item:hover {
  background: var(--primary-soft);
}

.rp-stop-item-warn {
  background: #fff8e1;
}
.rp-stop-item-warn:hover {
  background: #fff3c4;
}

.rp-stop-badge-warn {
  font-size: 10px;
  color: #e65100;
  background: #fff3e0;
  padding: 1px 6px;
  border-radius: 3px;
  font-weight: 600;
  margin-left: 4px;
}

.rp-stop-num-badge {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.rp-stop-details {
  flex: 1;
  min-width: 0;
}

.rp-stop-details strong {
  display: block;
  font-size: 13px;
  color: var(--text);
  line-height: 1.3;
}

.rp-stop-meta {
  display: block;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rp-plan-btn {
  font-size: 12px !important;
  padding: 4px 12px !important;
}

.rp-plan-btn.active {
  background: var(--primary) !important;
  color: #fff !important;
  border-color: var(--primary) !important;
}

/* Fullscreen */
.rp-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 0;
}

.rp-fullscreen .rp-stops-panel {
  display: none;
}

.rp-fullscreen .rp-map-wrap {
  flex: 1;
  min-height: 100vh;
}

.rp-fullscreen .rp-map {
  min-height: 100vh;
  border-radius: 0;
}

.rp-body-fullscreen {
  overflow: hidden;
}

/* Supplier marker */
.rp-supplier-icon {
  background: none !important;
  border: none !important;
}

.rp-supplier-dot {
  width: 20px;
  height: 20px;
  background: #3b82f6;
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(59,130,246,0.5);
}

/* Stop marker */
.rp-stop-icon {
  background: none !important;
  border: none !important;
}

.rp-stop-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

/* Settings mode toggle */
.settings-mode-btn.active {
  background: var(--primary) !important;
  color: #fff !important;
  border-color: var(--primary) !important;
}

/* Warehouse marker */
.rp-warehouse-icon {
  background: none !important;
  border: none !important;
}

.rp-warehouse-marker {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #f59e0b;
  border: 3px solid #fff;
  box-shadow: 0 2px 10px rgba(245,158,11,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
}

/* Warehouse stop item */
.rp-stop-item-warehouse {
  background: #fffbeb;
  border: 1px solid #fde68a;
  cursor: default;
}

.rp-stop-num-badge-wh {
  background: #f59e0b !important;
  font-size: 14px;
}

/* Simulation controls */
.rp-sim-controls {
  border-top: 1px solid var(--line);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--surface);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.rp-sim-header {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.rp-sim-progress-bar {
  width: 100%;
  height: 6px;
  background: var(--line);
  border-radius: 3px;
  overflow: hidden;
}

.rp-sim-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #0d9488);
  border-radius: 3px;
  transition: width 0.4s ease;
}

.rp-sim-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.rp-sim-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.rp-sim-btn {
  font-size: 11px !important;
  padding: 5px 10px !important;
  flex: 1;
  text-align: center;
}

.rp-sim-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Highlighted stop */
.rp-stop-highlighted {
  z-index: 10000 !important;
}

.rp-stop-num-highlighted {
  width: 36px;
  height: 36px;
  background: #3b82f6 !important;
  border: 3px solid #93c5fd;
  box-shadow: 0 0 20px rgba(59,130,246,0.6);
  font-size: 14px;
  animation: rpPulse 1.5s ease-in-out infinite;
}

/* Alternative route label on map */
.rp-alt-route-label {
  background: none !important;
  border: none !important;
}

.rp-alt-route-pill {
  background: rgba(255,255,255,0.9);
  border: 1px solid #94a3b8;
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 700;
  color: #475569;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
  white-space: nowrap;
}

.rp-alt-route-pill:hover {
  background: #fff;
  border-color: #3b82f6;
  color: #3b82f6;
}

/* Alt route toggle buttons in route info */
.rp-alt-route-btn.active {
  background: var(--primary) !important;
  color: #fff !important;
  border-color: var(--primary) !important;
}

@keyframes rpPulse {
  0%, 100% { box-shadow: 0 0 10px rgba(59,130,246,0.4); }
  50% { box-shadow: 0 0 24px rgba(59,130,246,0.8); }
}

@media (max-width: 768px) {
  .rp-layout {
    flex-direction: column;
  }
  .rp-stops-panel {
    width: 100%;
    min-width: unset;
  }
  .rp-stops-list {
    max-height: 200px;
  }
}
