: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-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  opacity: 0.95;
}

.nav-section {
  border: 0;
  background: transparent;
  color: #9ca3af;
  text-align: left;
  border-radius: 10px;
  padding: 12px 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  transition: all 0.15s ease;
}

.nav-section::after {
  content: "›";
  font-size: 16px;
  line-height: 1;
  color: #4b5563;
  margin-left: auto;
  transition: transform 0.15s ease;
}

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

.nav-section:hover::after {
  color: #9ca3af;
}

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

.nav-section.active::after {
  color: #f0fdfa;
}

.nav-btn-home {
  border: 0;
  background: transparent;
  color: #e5e7eb;
  text-align: left;
  border-radius: 10px;
  padding: 12px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-btn-home .nav-icon {
  color: #34d399;
}

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

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

.nav-btn-home.active .nav-icon {
  color: #f0fdfa;
}

.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 {
  z-index: 10000 !important;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  max-height: 240px;
  overflow: auto;
  display: none;
}

.searchable-select-portal .searchable-select-dropdown {
  display: block;
}

.searchable-select-portal {
  position: fixed;
  z-index: 10000 !important;
  display: none;
  pointer-events: auto;
}

.searchable-select-portal.is-positioned {
  display: block;
}

.searchable-select-portal .searchable-select-dropdown {
  display: block;
  position: static;
  border: none;
  box-shadow: none;
  background: transparent;
  max-height: none;
  overflow: visible;
}

.searchable-select-portal .searchable-select-list {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  max-height: 240px;
  overflow: auto;
  padding: 6px;
}

.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 {
  background: var(--primary);
  color: #f0fdfa;
  border: 1px solid transparent;
}

.btn-success {
  background: #047857;
  color: #f0fdfa;
  border: 1px solid transparent;
}

.btn-success:hover {
  background: #065f46;
}

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

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

.btn-notif-mute {
  font-size: 15px;
  padding: 4px 8px;
}

.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;
}

.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;
}

.controls .date-picker-wrap {
  width: 100%;
  min-width: 150px;
}

/* --- Filter bar (desktop): compact controls in one row, matching the user guide --- */
/* Only bars grouped by filter-grouping.js get the full-width bar treatment;
   compact card bars (dashboard, releases, deployment) keep the default layout. */
@media (min-width: 769px) {
  .card-head > .controls.has-filter-groups {
    flex: 1 1 100%;
    width: auto;
    max-width: 100%;
    display: flex;
    justify-content: flex-start;
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: 8px 10px;
    gap: 8px;
  }

  /* Related filters are clustered into groups; the actions group aligns right. */
  .card-head > .controls.has-filter-groups .filter-group {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
  }

  .card-head > .controls.has-filter-groups .filter-group--right {
    margin-left: auto;
  }

  .card-head > .controls.has-filter-groups .filter-group + .filter-group {
    border-left: 1px solid var(--line);
    padding-left: 12px;
  }

  .card-head > .controls.has-filter-groups .label {
    font-size: 11px;
    font-weight: 700;
    align-self: center;
  }

  .card-head > .controls.has-filter-groups .field,
  .card-head > .controls.has-filter-groups .select,
  .card-head > .controls.has-filter-groups .searchable-select,
  .card-head > .controls.has-filter-groups .date-picker-wrap {
    width: auto;
    min-width: 0;
  }

  .card-head > .controls.has-filter-groups .select,
  .card-head > .controls.has-filter-groups .field {
    font-size: 12.5px;
    padding: 6px 10px;
    border-radius: 8px;
    min-height: 32px;
  }

  .card-head > .controls.has-filter-groups .select {
    min-width: 120px;
  }

  .card-head > .controls.has-filter-groups .field[type="text"] {
    min-width: 150px;
  }

  .card-head > .controls.has-filter-groups .field[type="date"] {
    min-width: 135px;
  }

  .card-head > .controls.has-filter-groups .field[type="number"] {
    min-width: 100px;
  }

  .card-head > .controls.has-filter-groups .btn,
  .card-head > .controls.has-filter-groups .dropdown-toggle {
    font-size: 12px;
    padding: 7px 12px;
    border-radius: 8px;
  }

  .card-head > .controls.has-filter-groups .inline-check {
    font-size: 12px;
    white-space: nowrap;
  }

  .card-head > .controls.has-filter-groups .searchable-select-input,
  .card-head > .controls.has-filter-groups .date-picker-display {
    font-size: 12.5px;
    padding: 6px 30px 6px 10px;
    border-radius: 8px;
    min-height: 32px;
  }

  .card-head > .controls.has-filter-groups .searchable-select-input {
    padding-right: 28px;
  }

  .card-head > .controls.has-filter-groups .date-picker-toggle {
    padding: 6px;
  }
}

/* --- Content toolbar (desktop): buttons that act on the panel content sit at
     the top of the content area, separate from the filter bar --- */
.content-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.content-toolbar .btn,
.content-toolbar .dropdown-toggle {
  font-size: 12px;
  padding: 7px 12px;
  border-radius: 8px;
}

.content-toolbar #partyCsvImportSection {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.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;
}

.status.muted {
  background: #f3f4f6;
  color: #6b7280;
  border-color: #e5e7eb;
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.section-intro {
  margin: 0 0 16px;
  color: var(--text-secondary, #666);
  font-size: 14px;
}

.section-view.has-tabs {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.section-tabs {
  display: flex;
  align-items: flex-end;
  height: 48px;
  box-sizing: border-box;
  padding: 0 10px;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}

.section-tabs::-webkit-scrollbar {
  display: none;
}

.section-tab {
  flex: 0 0 auto;
  width: 150px;
  height: 48px;
  box-sizing: border-box;
  border: 1px solid transparent;
  border-radius: 10px 10px 0 0;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.2px;
  text-align: left;
  padding: 0 16px;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.section-tab:hover {
  color: var(--primary);
  background: var(--primary-soft);
}

.section-tab.active {
  background: var(--surface);
  color: var(--primary);
  border-color: var(--line);
  border-bottom: 3px solid var(--primary);
  font-weight: 800;
}

.section-view.has-tabs .section-view-body .panel.active > .card:first-child {
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.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.success {
  background: #ecfdf5;
  color: #047857;
  border-color: #a7f3d0;
}

.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;
  }

  .form-grid > * {
    min-width: 0;
  }

  .form-grid .searchable-select {
    min-width: 0;
    max-width: 100%;
  }

  .form-grid .searchable-select-input {
    width: 100%;
    box-sizing: border-box;
    min-width: 0;
  }

  .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 above all containers */
.searchable-select-dropdown,
.dropdown-menu {
  z-index: 10000 !important;
}

/* On mobile, ensure dropdowns stay within viewport */
@media (max-width: 768px) {
  /* 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);
}

/* Toggle switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 22px;
  flex-shrink: 0;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-slider {
  position: absolute;
  inset: 0;
  background: #ccc;
  border-radius: 22px;
  cursor: pointer;
  transition: background 0.2s;
}
.toggle-slider::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 2px;
  bottom: 2px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}
.toggle-switch input:checked + .toggle-slider {
  background: var(--primary, #2563eb);
}
.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

/* 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;
  }
}

/* ── Admin Hub ── */
.admin-hub {
  display: grid;
  gap: 16px;
}

/* ── Company filter dropdown dark theme ── */
#dashCompanyFilter,
#orderCompanyFilter,
#roundCompanyFilter,
#productCompanyFilter,
#receiptCompanyFilter,
#companyPaymentCompanyFilter,
#ledgerCompanyFilter,
#reportCompanyFilter,
#plCompanyFilter {
  background: var(--sidebar);
  color: #f1f5f9;
  border-color: var(--sidebar-line);
  font-weight: 600;
}

.hub-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.stat-unit {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px;
  text-align: center;
}

.stat-unit strong {
  display: block;
  font-size: 24px;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.2;
}

.stat-unit small {
  display: block;
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-top: 4px;
}

/* Activity feed */
.activity-feed {
  display: grid;
  gap: 8px;
}

.activity-item {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 8px;
  align-items: start;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  font-size: 13px;
}

.activity-icon {
  font-size: 16px;
  line-height: 1.4;
  text-align: center;
}

.activity-text {
  color: var(--text);
  line-height: 1.4;
}

.activity-meta {
  grid-column: 1 / -1;
  font-size: 11px;
  color: var(--muted);
}

@media (max-width: 768px) {
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

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

.round-action-flow {
  display: inline-flex;
  align-items: center;
  gap: 0;
  flex-wrap: nowrap;
  overflow-x: auto;
  max-width: 100%;
}

.round-action-flow .btn {
  border-radius: 0;
  white-space: nowrap;
  position: relative;
  padding: 8px 14px;
  font-size: 12px;
  flex-shrink: 0;
}

.round-action-flow .btn:first-child {
  border-radius: 9px 0 0 9px;
}

.round-action-flow .btn:last-child {
  border-radius: 0 9px 9px 0;
}

.round-action-flow .flow-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 34px;
  background: var(--surface-soft, #f1f5f9);
  color: var(--text-muted, #94a3b8);
  font-size: 11px;
  flex-shrink: 0;
  border-top: 1px solid var(--line, #e2e8f0);
  border-bottom: 1px solid var(--line, #e2e8f0);
}

.round-action-flow .btn:disabled {
  background: #047857;
  color: #d1fae5;
  border-color: transparent;
  cursor: default;
  opacity: 1;
  text-decoration: line-through;
}

.round-action-flow .btn:disabled + .flow-arrow {
  background: #d1fae5;
  color: #047857;
  border-color: #047857;
}

.round-action-flow .flow-arrow.active {
  background: #d1fae5;
  color: #047857;
  border-color: #047857;
}

@media (max-width: 640px) {
  .round-action-flow {
    flex-wrap: wrap;
    gap: 0;
  }

  .round-action-flow .btn {
    font-size: 11px;
    padding: 7px 10px;
  }

  .round-action-flow .flow-arrow {
    width: 100%;
    height: 18px;
    border-top: none;
    border-bottom: none;
    border-left: 1px solid var(--line, #e2e8f0);
    border-right: 1px solid var(--line, #e2e8f0);
    transform: rotate(90deg);
  }

  .round-action-flow .btn:first-child {
    border-radius: 9px 9px 0 0;
  }

  .round-action-flow .btn:last-child {
    border-radius: 0 0 9px 9px;
  }
}

.round-action-chips {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.row-actions-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.row-actions-quick {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.row-actions-quick:hover {
  background: #eef2f9;
  border-color: #cbd5e1;
  color: var(--text);
}

.row-actions-quick:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.row-actions {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.row-actions-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.row-actions-toggle:hover,
.row-actions.is-open .row-actions-toggle {
  background: #eef2f9;
  border-color: #cbd5e1;
  color: var(--text);
}

.row-actions-toggle:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.row-actions-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 60;
  min-width: 150px;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  display: none;
}

.row-actions.is-open .row-actions-menu {
  display: block;
}

.row-actions-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  background: transparent;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}

.row-actions-item:hover {
  background: #f1f5fb;
}

.row-actions-item--danger {
  color: #dc2626;
}

.row-actions-item--danger:hover {
  background: #fef2f2;
}

.row-actions-icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  opacity: 0.85;
}

@media (max-width: 768px) {
  .row-actions-toggle {
    width: 34px;
    height: 34px;
  }

  .row-actions-quick {
    padding: 5px 8px;
  }

  .row-actions-quick .row-actions-icon {
    display: none;
  }

  .controls {
    gap: 4px;
  }
}

@media (max-width: 480px) {
  .row-actions-toggle {
    width: 32px;
    height: 32px;
  }
}

.pwa-offline-chip {
  background: #fef2f2 !important;
  color: #dc2626 !important;
  border: 1px solid #fecaca !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 4px !important;
  font-weight: 600 !important;
}

.pwa-offline-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #dc2626;
  display: inline-block;
  animation: pwa-pulse 1.5s ease-in-out infinite;
}

@keyframes pwa-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.pwa-pending-chip {
  background: #fffbeb !important;
  color: #d97706 !important;
  border: 1px solid #fde68a !important;
  font-weight: 600 !important;
  cursor: help !important;
}

.pwa-offline-chip.is-hidden,
.pwa-pending-chip.is-hidden {
  display: none !important;
}

/* --- Graphical date picker --- */
.date-picker-wrap {
  position: relative;
  display: inline-block;
  min-width: 150px;
}

.date-picker-native {
  position: absolute !important;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
  border: 0;
  padding: 0;
  margin: 0;
}

.date-picker-display {
  width: 100%;
  border-radius: 9px;
  border: 1px solid var(--line);
  padding: 9px 34px 9px 10px;
  font-size: 13px;
  color: #0f172a;
  background: #fff;
  outline: none;
  cursor: pointer;
  font-family: inherit;
}

.date-picker-display::placeholder {
  color: #94a3b8;
}

.date-picker-display:focus {
  border-color: #14b8a6;
}

.date-picker-toggle {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: 0;
  color: #64748b;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border-radius: 6px;
}

.date-picker-toggle:hover {
  color: #14b8a6;
}

.date-picker-popup {
  position: fixed;
  z-index: 1200;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  padding: 10px;
  font-size: 13px;
  color: var(--text);
  user-select: none;
  min-width: 264px;
}

.date-picker-popup .dp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.date-picker-popup .dp-title {
  font-weight: 800;
}

.date-picker-popup .dp-nav {
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.date-picker-popup .dp-nav:hover {
  border-color: #14b8a6;
  color: #14b8a6;
}

.date-picker-popup .dp-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  color: #64748b;
  font-weight: 700;
  font-size: 11px;
  margin-bottom: 4px;
}

.date-picker-popup .dp-weekdays span {
  padding: 4px 0;
}

.date-picker-popup .dp-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.date-picker-popup .dp-empty {
  padding: 7px 0;
}

.date-picker-popup .dp-day {
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 7px 0;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
}

.date-picker-popup .dp-day:hover {
  background: #f1f5f9;
}

.date-picker-popup .dp-day.is-today {
  box-shadow: inset 0 0 0 1px #14b8a6;
  color: #14b8a6;
  font-weight: 700;
}

.date-picker-popup .dp-day.is-selected {
  background: #14b8a6;
  color: #fff;
  font-weight: 700;
}

.date-picker-popup .dp-day:disabled {
  color: #cbd5e1;
  cursor: not-allowed;
}

.date-picker-popup .dp-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.date-picker-popup .dp-datetime {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #475569;
  min-width: 0;
}

.date-picker-popup .dp-date-label {
  font-weight: 700;
  white-space: nowrap;
}

.date-picker-popup .dp-time-wrap {
  display: flex;
  align-items: center;
  gap: 3px;
}

.date-picker-popup .dp-time-wrap select {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 4px 2px;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
}

.date-picker-popup .dp-time-wrap select:focus {
  border-color: #14b8a6;
  outline: none;
}

.date-picker-popup .dp-colon {
  font-weight: 700;
  color: var(--text);
}

.date-picker-popup .dp-ampm {
  display: flex;
  gap: 2px;
}

.date-picker-popup .dp-ampm-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 8px;
  padding: 4px 8px;
  cursor: pointer;
  font-weight: 700;
  font-size: 12px;
  font-family: inherit;
  line-height: 1.2;
}

.date-picker-popup .dp-ampm-btn.is-active {
  background: #14b8a6;
  border-color: #14b8a6;
  color: #fff;
}

.date-picker-popup .dp-ampm-btn:not(.is-active):hover {
  border-color: #14b8a6;
  color: #14b8a6;
}

.date-picker-popup .dp-actions {
  display: flex;
  gap: 6px;
}

.date-picker-popup .dp-today {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  font-weight: 700;
  font-size: 12px;
  font-family: inherit;
}

.date-picker-popup .dp-today:hover {
  border-color: #14b8a6;
  color: #14b8a6;
}

.date-picker-popup .dp-done {
  border: 1px solid #14b8a6;
  background: #14b8a6;
  color: #fff;
  border-radius: 8px;
  padding: 6px 14px;
  cursor: pointer;
  font-weight: 700;
  font-size: 12px;
  font-family: inherit;
}

.date-picker-popup .dp-done:hover {
  background: #0d9488;
  border-color: #0d9488;
}

/* --- Mobile-friendly filter controls --- */
.filter-toggle {
  display: none;
}

.filter-toggle-arrow {
  font-size: 9px;
  transition: transform 0.2s ease;
}

.filter-toggle.is-open .filter-toggle-arrow {
  transform: rotate(180deg);
}

@media (max-width: 768px) {
  .card-head {
    flex-direction: column;
    align-items: stretch;
  }

  .card-head > .controls {
    width: 100%;
    justify-content: flex-start;
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  /* Tablets: two columns fit comfortably; phones stay single column. */
  @media (min-width: 577px) {
    .card-head > .controls {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }
  }

  /* Grouped filter bars: each cluster becomes its own stacked row,
     single column on phones, two columns on tablets. */
  .card-head > .controls .filter-group {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    border-left: 0;
    padding-left: 0;
  }

  @media (min-width: 577px) {
    .card-head > .controls .filter-group {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }
  }

  .card-head > .controls.is-collapsed {
    display: none;
  }

  /* Content toolbar: always visible (not collapsed with filters), wraps into
     a 2-column button grid on phones. */
  .content-toolbar {
    justify-content: flex-start;
  }

  .content-toolbar .btn,
  .content-toolbar .dropdown {
    flex: 1 1 calc(50% - 4px);
    min-height: 40px;
  }

  .content-toolbar .dropdown-toggle {
    width: 100%;
    min-height: 40px;
    justify-content: space-between;
  }

  .content-toolbar #partyCsvImportSection {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
  }

  .card-head .controls .label {
    width: 100%;
    white-space: normal;
  }

  .card-head .controls .field,
  .card-head .controls .select,
  .card-head .controls .btn,
  .card-head .controls .textarea,
  .card-head .controls .searchable-select,
  .card-head .controls .dropdown,
  .card-head .controls .date-picker-wrap {
    width: 100%;
    min-width: 0;
  }

  .card-head .controls .dropdown-toggle,
  .card-head .controls .btn {
    min-height: 40px;
  }

  .card-head .controls .dropdown-toggle {
    justify-content: space-between;
  }

  .filter-toggle {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 40px;
  }

  .date-picker-wrap {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .date-picker-display {
    min-height: 40px;
  }

  .searchable-select-input {
    min-height: 40px;
  }
}

@media (max-width: 480px) {
  .date-picker-popup {
    max-width: calc(100vw - 16px);
  }
}

/* ── Big Units builder (product form) ─────────────────────────────────── */
.big-unit-card {
  position: relative;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 6px 8px;
  margin-bottom: 8px;
  background: #f8fafc;
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 6px 4px;
  transition: border-color .15s ease, background .15s ease;
}

.big-unit-card:hover {
  border-color: #cbd5e1;
}

.big-unit-badges {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.big-unit-primary {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  color: #92400e;
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: 999px;
  padding: 2px 6px;
}

.big-unit-conversion {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 5px;
  flex: 0 1 auto;
  min-width: 0;
}

.unit-mode-block {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
}

.unit-eq {
  color: #475569;
  white-space: nowrap;
}

.unit-mode-block .field,
.unit-mode-block .select {
  margin: 0;
}

.big-unit-conversion > .unit-name-input {
  width: 82px;
  flex: 0 1 auto;
  min-width: 52px;
  padding: 6px 8px;
}

.unit-mode-block .unit-pieces-input,
.unit-mode-block .unit-relation-qty {
  width: 70px;
  flex-shrink: 1;
  min-width: 36px;
}

.unit-relation-select {
  width: auto;
  max-width: 58px;
  min-width: 44px;
  flex-shrink: 0;
  padding: 6px 5px;
  font-size: 12px;
}

.unit-mode-toggle {
  display: inline-flex;
  flex-shrink: 0;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #f1f5f9;
  padding: 2px;
  gap: 2px;
}

.unit-mode-btn {
  border: 0;
  background: transparent;
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  line-height: 1;
  padding: 3px 5px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s ease, color .15s ease;
}

.unit-mode-btn.is-active {
  background: #fff;
  color: #1e293b;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .12);
}

.big-unit-actions {
  display: inline-flex;
  gap: 4px;
  flex-shrink: 0;
  margin-left: auto;
}

.big-unit-actions .btn {
  padding: 2px 4px;
  font-size: 13px;
  line-height: 1.4;
}

.big-unit-result {
  flex-basis: auto;
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  color: #0f766e;
  background: #f0fdfa;
  border: 1px solid #99f6e4;
  border-radius: 999px;
  padding: 2px 5px;
  white-space: nowrap;
}

.big-unit-error {
  position: absolute;
  top: calc(100% + 6px);
  left: 12px;
  right: 12px;
  font-size: 12px;
  color: #b91c1c;
}

.big-unit-invalid {
  border-color: #fca5a5;
  background: #fef2f2;
  margin-bottom: 28px;
}

.unit-mode-label {
  display: none;
}

.big-unit-add-btn {
  margin-top: 4px;
  width: 100%;
  border: 1px dashed #cbd5e1;
  background: transparent;
  color: #475569;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: border-color .15s ease, color .15s ease, background .15s ease;
}

.big-unit-add-btn:hover {
  border-color: var(--primary, #2563eb);
  color: var(--primary, #2563eb);
  background: #eff6ff;
}

.big-unit-preview {
  margin-top: 8px;
  font-size: 12px;
  color: #1e293b;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  word-break: break-word;
}

.bu-preview-label {
  font-weight: 700;
  color: #1e40af;
  white-space: nowrap;
}

.bu-preview-chain {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.bu-arrow {
  color: #64748b;
}

.bu-chip {
  display: inline-flex;
  align-items: center;
  background: #fff;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  padding: 2px 8px;
  font-weight: 600;
  color: #1e40af;
  white-space: nowrap;
}

.bu-chip-primary {
  color: #92400e;
  border-color: #fcd34d;
  background: #fef3c7;
}

.bu-preview-badges {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}

.big-unit-error-summary {
  margin-top: 8px;
  font-size: 12px;
  color: #991b1b;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 6px;
  padding: 6px 10px;
}

@media (max-width: 768px) {
  .modal {
    width: 100%;
    max-height: 100vh;
    border-radius: 12px;
  }

  .modal-overlay {
    padding: 8px;
  }

  .modal-body {
    padding: 12px;
    overflow-x: hidden;
  }

  .modal-head {
    padding: 10px 12px;
  }

  .modal-head h3 {
    font-size: 15px;
  }

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

  .form-help {
    font-size: 12px;
  }

  .discount-tiers-row {
    flex-direction: column;
  }

  .discount-tiers-row .field {
    width: 100% !important;
  }

  .big-unit-card {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto auto;
    gap: 6px 8px;
    padding: 10px;
  }

  .big-unit-badges {
    grid-row: 1;
    grid-column: 1;
    align-self: center;
  }

  .big-unit-primary {
    font-size: 11px;
    padding: 2px 8px;
  }

  .big-unit-actions {
    grid-row: 1;
    grid-column: 2;
    display: flex;
    align-items: center;
    gap: 3px;
    justify-self: end;
  }

  .big-unit-actions .btn {
    padding: 5px 8px;
    font-size: 15px;
    min-width: 32px;
  }

  .big-unit-conversion {
    grid-row: 2;
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    align-items: center;
    gap: 4px;
    min-width: 0;
  }

  .big-unit-conversion > .unit-name-input {
    width: 100%;
    min-width: 0;
    padding: 7px 8px;
    font-size: 14px;
  }

  .big-unit-conversion > span.unit-eq:first-of-type {
    grid-column: 1;
    font-size: 13px;
    flex-shrink: 0;
  }

  .big-unit-conversion > span.unit-eq:not(:first-of-type) {
    grid-column: 3;
    font-size: 13px;
    flex-shrink: 0;
  }

  .unit-mode-block {
    grid-column: 4;
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
  }

  .unit-mode-block .unit-pieces-input,
  .unit-mode-block .unit-relation-qty {
    width: 50px;
    flex-shrink: 0;
    min-width: 0;
    padding: 7px 4px;
    font-size: 14px;
    text-align: center;
  }

  .unit-relation-block {
    gap: 3px;
    min-width: 0;
  }

  .unit-relation-block .searchable-select {
    width: 88px;
    min-width: 0;
  }

  .unit-relation-block .searchable-select-input {
    width: 88px;
    min-width: 0;
    padding: 7px 24px 7px 6px;
    font-size: 13px;
  }

  .unit-mode-toggle {
    grid-row: 3;
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 2px;
  }

  .unit-mode-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    white-space: nowrap;
  }

  .unit-mode-btn {
    flex: 1;
    text-align: center;
    padding: 7px 12px;
    font-size: 12px;
    font-weight: 700;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
    color: #475569;
  }

  .unit-mode-btn.is-active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: 0 2px 6px rgba(15, 118, 110, 0.3);
  }

  .big-unit-result {
    grid-row: 3;
    grid-column: 1;
    font-size: 12px;
    align-self: center;
  }

  .big-unit-error {
    grid-row: 4;
    grid-column: 1 / -1;
    font-size: 11px;
    position: static;
  }

  .big-unit-preview {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding: 8px;
  }

  .big-unit-error-summary {
    font-size: 12px;
    padding: 6px 8px;
  }

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

/* ── Reports hub ─────────────────────────────────────────────── */

#panel-reports .report-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin: 12px 0;
}

#panel-reports .report-summary .kpi {
  margin: 0;
}

.report-filter-hint {
  color: var(--muted);
  font-size: 12px;
}

.report-filter-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 12px;
  font-size: 13px;
  color: var(--muted);
}

.report-filter-control .select,
.report-filter-control .field {
  width: auto;
  min-width: 130px;
}

.report-filter-control .report-days-input {
  min-width: 80px;
  max-width: 90px;
}

.report-subtitle {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface, #fff);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.report-table-wrap {
  max-height: 68vh;
  overflow: auto;
}

.report-table-wrap table {
  min-width: 640px;
}

.report-table-wrap tfoot th {
  border-top: 2px solid var(--line);
}

.report-table-wrap tbody tr:nth-child(even) {
  background: rgba(0, 0, 0, 0.02);
}

.report-chart-wrap {
  margin: 14px 0;
  padding: 14px;
  background: var(--surface, #fff);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  height: 320px;
  position: relative;
}

.report-chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

.report-chart-note {
  margin: 0;
  padding: 8px 12px;
  background: var(--surface-muted, #f5f6f8);
  border-radius: var(--radius-sm, 6px);
  font-size: 0.85rem;
  color: var(--text-muted, #666);
}

body.printing-report #reportsChartWrap {
  display: none !important;
}

/* ── Print: report output only ───────────────────────────────── */

body.printing-report #sidebar,
body.printing-report .topbar,
body.printing-report .section-tabs,
body.printing-report .content-toolbar {
  display: none !important;
}

body.printing-report .content {
  padding: 0;
  overflow: visible;
}

body.printing-report .main,
body.printing-report .content,
body.printing-report .section-view,
body.printing-report .section-view-body {
  margin: 0;
  padding: 0;
}

body.printing-report .panel {
  display: none !important;
}

body.printing-report #panel-reports {
  display: block !important;
}

body.printing-report #panel-reports .card {
  border: 0;
  box-shadow: none;
}

body.printing-report #panel-reports .card-head {
  display: none;
}

body.printing-report #panel-reports .card-body {
  padding: 0;
}

body.printing-report #panel-reports .report-table-wrap {
  max-height: none;
  overflow: visible;
  border: 0;
}

body.printing-report #panel-reports .report-table-wrap table {
  min-width: 0;
}

body.printing-report #reportsSummary {
  margin-bottom: 14px;
}

body.printing-report #reportsState:not(:empty) {
  display: none;
}

@media print {
  body {
    background: #fff;
  }
}

.confirm-step .confirm-summary {
  margin: 0.5rem 0 1rem;
}

.confirm-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 7px 2px;
  border-bottom: 1px solid rgba(127, 127, 127, 0.15);
  font-size: 0.95rem;
}

.confirm-row:last-child {
  border-bottom: none;
}

.confirm-label {
  opacity: 0.65;
}

.confirm-value {
  font-weight: 600;
  text-align: right;
}

.confirm-title {
  display: block;
  margin: 0.5rem 0 0.35rem;
}

.confirm-values {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.confirm-table {
  margin-top: 0.6rem;
}

