/* ── EstimateNext Design System ─────────────────────────── */
:root {
  --en-primary: #1F4E79;
  --en-primary-600: #2B6A9A;
  --en-primary-100: #EAF3F9;
  --en-slate-900: #1F2937;
  --en-slate-700: #374151;
  --en-slate-500: #6B7280;
  --en-slate-300: #D1D5DB;
  --en-slate-200: #E5E7EB;
  --en-slate-100: #F3F4F6;
  --en-page-bg: #F8FAFC;
  --en-surface: #FFFFFF;
  --en-success: #2E7D32;
  --en-success-soft: #EAF6EC;
  --en-warning: #B7791F;
  --en-warning-soft: #FFF7E6;
  --en-danger: #C0392B;
  --en-danger-soft: #FDEDEC;
  --en-info: #0F6CBD;
  --en-info-soft: #EAF2FB;
  --en-radius-sm: 8px;
  --en-radius-md: 12px;
  --en-radius-lg: 16px;
  --en-shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --en-shadow-md: 0 6px 16px rgba(15, 23, 42, 0.08);
  --en-font-sans: Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --en-sidebar-width: 240px;
  --en-topbar-height: 56px;
}

body {
  font-family: var(--en-font-sans);
  background: var(--en-page-bg);
  color: var(--en-slate-900);
  font-size: 14px;
}

/* ── Topbar ──────────────────────────────────────────── */
.en-topbar {
  background: var(--en-primary);
  height: var(--en-topbar-height);
  z-index: 1040;
  box-shadow: var(--en-shadow-sm);
}
.en-brand {
  color: #fff !important;
  font-weight: 700;
  font-size: 18px;
  text-decoration: none;
}

/* ── Sidebar ─────────────────────────────────────────── */
.en-sidebar {
  position: fixed;
  top: var(--en-topbar-height);
  left: 0;
  bottom: 0;
  width: var(--en-sidebar-width);
  background: var(--en-surface);
  border-right: 1px solid var(--en-slate-200);
  overflow-y: auto;
  z-index: 1030;
  transition: transform 0.2s ease;
}
.en-sidebar .nav-link {
  color: var(--en-slate-700);
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  border-radius: 0;
  transition: background 0.15s, color 0.15s;
}
.en-sidebar .nav-link:hover {
  background: var(--en-primary-100);
  color: var(--en-primary);
}
.en-sidebar .nav-link.active {
  background: var(--en-primary-100);
  color: var(--en-primary);
  font-weight: 600;
  border-right: 3px solid var(--en-primary);
}
.en-sidebar .nav-link i {
  width: 20px;
  text-align: center;
}

/* Journey-nav section labels in the LEGACY shell (ui_refresh off). The refresh
 * treatment lives in ui_refresh/journey_nav.css under body.ui-refresh; without
 * this the labels render flush-left while the items sit at 20px. */
body:not(.ui-refresh) .en-sidebar .en-journey-header {
  display: block;
  padding: 10px 20px 4px;
}
body:not(.ui-refresh) .en-sidebar .en-journey-header .en-journey-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--en-slate-500, #64748b);
}
body:not(.ui-refresh) .en-sidebar a.en-journey-header--toggle {
  display: flex;
  color: var(--en-slate-500, #64748b);
}

/* ── Sidebar collapsed state ─────────────────────────── */
.en-sidebar.collapsed {
  width: 60px;
}
.en-sidebar.collapsed .nav-link {
  padding: 10px 0;
  text-align: center;
  font-size: 0;
  display: flex !important;
  align-items: center;
  justify-content: center !important;
}
.en-sidebar.collapsed .nav-link i {
  font-size: 18px;
  margin: 0 !important;
  margin-right: 0 !important;
  width: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.en-sidebar.collapsed .nav-link i.me-2 {
  margin-right: 0 !important;
}
.en-sidebar.collapsed .nav-link .nav-label { display: none !important; }
.en-sidebar.collapsed .nav-section-label { display: none !important; }
.en-sidebar.collapsed .nav-link > span {
  display: contents;
}
.en-sidebar.collapsed .nav-link .badge,
.en-sidebar.collapsed .nav-link .bi-chevron-down { display: none !important; }
.en-sidebar.collapsed .collapse,
.en-sidebar.collapsed .collapsing { display: none !important; }
.en-sidebar.collapsed .ms-3 { margin-left: 0 !important; }
.en-sidebar .sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--en-slate-200);
  transition: background 0.15s;
}
.en-sidebar .sidebar-toggle:hover { background: var(--en-slate-100); }
.en-sidebar.collapsed .sidebar-toggle { justify-content: center; padding: 12px 0; }
.en-sidebar.collapsed .sidebar-brand-text { display: none; }
.en-sidebar.collapsed + .en-main { margin-left: 60px; width: calc(100% - 60px); }

/* ── Main content ────────────────────────────────────── */
.en-main {
  margin-left: var(--en-sidebar-width);
  margin-top: var(--en-topbar-height);
  min-height: calc(100vh - var(--en-topbar-height));
  width: calc(100% - var(--en-sidebar-width));
  transition: margin-left 0.2s, width 0.2s;
}

/* ── Cards ───────────────────────────────────────────── */
.en-card {
  background: var(--en-surface);
  border: 1px solid var(--en-slate-200);
  border-radius: var(--en-radius-md);
  box-shadow: var(--en-shadow-sm);
}
.en-card .card-header {
  background: transparent;
  border-bottom: 1px solid var(--en-slate-200);
  padding: 16px 20px;
  font-weight: 600;
  font-size: 16px;
}
.en-card .card-body {
  padding: 20px;
}

/* ── Stat cards ──────────────────────────────────────── */
.en-stat-card {
  background: var(--en-surface);
  border: 1px solid var(--en-slate-200);
  border-radius: var(--en-radius-md);
  padding: 20px;
  transition: box-shadow 0.15s;
}
.en-stat-card:hover {
  box-shadow: var(--en-shadow-md);
}
.en-stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--en-slate-900);
  font-variant-numeric: tabular-nums;
}
.en-stat-card .stat-label {
  font-size: 13px;
  color: var(--en-slate-500);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* ── MetricCard baseline — .en-metric (_metric_card.html) ──────────────
   FIX-THEN-MERGE review on c683ce91 (HIGH): static/css/ui_refresh/
   design_system.css styles .en-metric* ONLY under `body.ui-refresh` (that
   file's own documented contract — "EVERY rule is scoped under
   body.ui-refresh. Flag off -> nothing matches"), so with the flag off
   (?ui=legacy / UI_REFRESH_ENABLED=0) the migrated board/dashboard tiles
   rendered as bare unstyled divs — breaking the context processor's
   documented "visually identical when off" invariant. This block is that
   missing baseline, unconditional, right beside .en-stat-card's own
   (which it deliberately mirrors — .en-metric replaces .en-stat-card on
   the screens migrated for UAT-UX-004). The body.ui-refresh block in
   design_system.css still applies on top of this and is the themed
   enhancement, not the only styling the component has. ─────────────── */
.en-metric-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}
.en-metric {
  background: var(--en-surface);
  border: 1px solid var(--en-slate-200);
  border-radius: var(--en-radius-md);
  padding: 12px 15px 11px;
  min-width: 11rem;
  flex: 1 1 11rem;
  max-width: 20rem;
}
.en-metric-label {
  font-size: 11px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--en-slate-500);
  font-weight: 500;
  margin-bottom: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.en-metric-amount {
  font-variant-numeric: tabular-nums;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--en-slate-900);
  white-space: nowrap;
}
.en-metric-currency {
  font-size: 12px;
  font-weight: 500;
  color: var(--en-slate-500);
  margin-right: 4px;
}
.en-metric-qualifier {
  font-size: 12px;
  color: var(--en-slate-500);
  margin-top: 4px;
}
.en-metric.en-metric-hero { border-left: 3px solid var(--en-primary); }
.en-metric.en-metric-hero .en-metric-amount { color: var(--en-primary); }
.en-metric-empty .en-metric-amount { color: var(--en-slate-500); font-weight: 400; }
.en-metric-denominator {
  font-size: 12px;
  font-weight: 400;
  color: var(--en-slate-500);
}
.en-metric-explain { margin-top: 6px; }

/* ── Tables ──────────────────────────────────────────── */
.en-table {
  font-size: 13px;
}
.en-table thead th {
  background: var(--en-slate-100);
  color: var(--en-slate-700);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 10px 12px;
  border-bottom: 2px solid var(--en-slate-200);
  white-space: nowrap;
}
.en-table tbody td {
  padding: 10px 12px;
  vertical-align: middle;
  border-bottom: 1px solid var(--en-slate-100);
}
.en-table tbody tr:hover {
  background: var(--en-primary-100);
}
.en-table .text-numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ── Badges ──────────────────────────────────────────── */
.en-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.en-badge-draft { background: var(--en-slate-100); color: var(--en-slate-700); }
.en-badge-uploaded { background: var(--en-info-soft); color: var(--en-info); }
.en-badge-parsing,
.en-badge-approved,
.en-badge-matching,
.en-badge-pricing,
.en-badge-generating { background: var(--en-warning-soft); color: var(--en-warning); }
.en-badge-parsed,
.en-badge-matched,
.en-badge-priced { background: var(--en-info-soft); color: var(--en-info); }
.en-badge-review { background: var(--en-warning-soft); color: var(--en-warning); }
.en-badge-completed { background: var(--en-success-soft); color: var(--en-success); }
.en-badge-failed { background: var(--en-danger-soft); color: var(--en-danger); }
.en-badge-cancelled { background: var(--en-slate-100); color: var(--en-slate-500); }
.en-badge-active { background: var(--en-success-soft); color: var(--en-success); }
.en-badge-pending { background: var(--en-warning-soft); color: var(--en-warning); }

/* Maturity badges */
.en-badge-beta { background: var(--en-warning-soft); color: var(--en-warning); }
.en-badge-good { background: var(--en-info-soft); color: var(--en-info); }
.en-badge-strong { background: var(--en-success-soft); color: var(--en-success); }
.en-badge-enterprise { background: #E8E0F0; color: #6B21A8; }

/* Confidence badges */
.en-badge-high { background: var(--en-success-soft); color: var(--en-success); }
.en-badge-medium { background: var(--en-warning-soft); color: var(--en-warning); }
.en-badge-low { background: var(--en-danger-soft); color: var(--en-danger); }
.en-badge-none { background: var(--en-slate-100); color: var(--en-slate-500); }

/* ── Buttons ─────────────────────────────────────────── */
.btn-en-primary {
  background: var(--en-primary);
  color: #fff;
  border: none;
  border-radius: var(--en-radius-sm);
  font-weight: 600;
  padding: 10px 20px;
}
.btn-en-primary:hover {
  background: var(--en-primary-600);
  color: #fff;
}
.btn-en-secondary {
  background: var(--en-surface);
  color: var(--en-slate-700);
  border: 1px solid var(--en-slate-300);
  border-radius: var(--en-radius-sm);
  font-weight: 500;
  padding: 10px 20px;
}
.btn-en-secondary:hover {
  background: var(--en-slate-100);
}

/* ── Upload zone ─────────────────────────────────────── */
.en-upload-zone {
  border: 2px dashed var(--en-slate-300);
  border-radius: var(--en-radius-lg);
  padding: 48px 24px;
  text-align: center;
  background: var(--en-surface);
  transition: border-color 0.2s, background 0.2s;
  cursor: pointer;
}
.en-upload-zone:hover,
.en-upload-zone.dragover {
  border-color: var(--en-primary);
  background: var(--en-primary-100);
}
.en-upload-zone i {
  font-size: 48px;
  color: var(--en-slate-300);
}
.en-upload-zone.dragover i {
  color: var(--en-primary);
}

/* ── Progress stepper ────────────────────────────────── */
.en-stepper {
  display: flex;
  gap: 4px;
  padding: 0;
  list-style: none;
}
.en-stepper li {
  flex: 1;
  text-align: center;
  font-size: 11px;
  font-weight: 500;
  color: var(--en-slate-500);
  position: relative;
  padding-top: 8px;
}
.en-stepper li::before {
  content: '';
  display: block;
  height: 4px;
  background: var(--en-slate-200);
  border-radius: 2px;
  margin-bottom: 6px;
}
.en-stepper li.completed::before { background: var(--en-success); }
.en-stepper li.running::before { background: var(--en-warning); }
.en-stepper li.failed::before { background: var(--en-danger); }
.en-stepper li.completed { color: var(--en-success); }
.en-stepper li.running { color: var(--en-warning); }
.en-stepper li.failed { color: var(--en-danger); }

/* ── Page header ─────────────────────────────────────── */
.en-page-header {
  margin-bottom: 24px;
}
.en-page-header h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--en-slate-900);
  margin: 0;
}
.en-page-header p {
  color: var(--en-slate-500);
  font-size: 14px;
  margin: 4px 0 0;
}

/* ── Hierarchy indentation ───────────────────────────── */
.en-indent-0 { padding-left: 12px; }
.en-indent-1 { padding-left: 28px; }
.en-indent-2 { padding-left: 44px; }
.en-indent-3 { padding-left: 60px; }
.en-indent-4 { padding-left: 76px; }

/* Section/total row styling */
tr.en-row-section td { font-weight: 700; background: var(--en-slate-100); }
tr.en-row-total td { font-weight: 700; border-top: 2px solid var(--en-slate-300); }
tr.en-row-note td { color: var(--en-slate-500); font-style: italic; }

/* ── Responsive ──────────────────────────────────────── */
/* Tablet breakpoint: sidebar overlay */
@media (max-width: 991.98px) {
  .en-sidebar {
    transform: translateX(-100%);
  }
  .en-sidebar.show {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.15);
    z-index: 1050;
  }
  .en-main {
    margin-left: 0;
    width: 100%;
  }
}

/* Mobile breakpoint (<768px) — E14 */
@media (max-width: 767.98px) {
  /* Sidebar: full overlay mode */
  .en-sidebar {
    width: 260px;
    transform: translateX(-100%);
  }
  .en-sidebar.show {
    transform: translateX(0);
  }
  .en-main {
    margin-left: 0;
    width: 100%;
  }

  /* Cards: stack vertically, reduce padding */
  .en-card .card-body {
    padding: 14px;
  }
  .en-card .card-header {
    padding: 12px 14px;
    font-size: 15px;
  }
  .en-stat-card {
    padding: 14px;
  }
  .en-stat-card .stat-value {
    font-size: 22px;
  }
  .en-stat-card .stat-label {
    font-size: 11px;
  }

  /* Row columns: force single column on mobile */
  .row > .col-md-3,
  .row > .col-md-4,
  .row > .col-md-6,
  .row > .col-lg-4,
  .row > .col-lg-6 {
    flex: 0 0 100%;
    max-width: 100%;
  }

  /* Tables: horizontal scroll */
  .en-card .card-body .table-responsive,
  .en-card .card-body > table {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .en-table {
    min-width: 600px;
  }

  /* Forms: full width inputs */
  .form-control,
  .form-select {
    font-size: 16px; /* prevent iOS zoom on focus */
  }

  /* Page header: stack actions */
  .en-page-header {
    flex-direction: column !important;
    gap: 12px;
  }
  .en-page-header h1 {
    font-size: 20px;
  }

  /* Topbar adjustments */
  .en-topbar .en-brand {
    font-size: 16px;
  }
  .en-topbar .btn-sm {
    font-size: 12px;
    padding: 4px 8px;
  }

  /* Dashboard stat cards: 2 columns */
  .dashboard-stats > .col-md-3 {
    flex: 0 0 50%;
    max-width: 50%;
  }

  /* Upload zone: reduce padding */
  .en-upload-zone {
    padding: 24px 16px;
  }
  .en-upload-zone i {
    font-size: 36px;
  }

  /* Stage timeline: vertical on mobile */
  .stage-timeline {
    flex-direction: column;
  }
  .stage-step::before,
  .stage-step::after {
    display: none;
  }
  .stage-step {
    flex-direction: row;
    text-align: left;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
  }
  .stage-step .stage-dot {
    margin: 0;
  }

  /* Breadcrumb: smaller font */
  .breadcrumb {
    font-size: 12px;
  }

  /* Tabs: scrollable */
  .nav-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }
  .nav-tabs .nav-item {
    flex-shrink: 0;
  }

  /* Buttons: full width stacking */
  .d-flex.gap-2 > .btn {
    flex: 1;
    min-width: 0;
  }

  /* Modal: near full width */
  .modal-dialog {
    margin: 8px;
    max-width: calc(100% - 16px);
  }

  /* Stepper on mobile */
  .en-stepper {
    flex-wrap: wrap;
    gap: 2px;
  }
  .en-stepper li {
    font-size: 10px;
  }

  /* DataTable overrides */
  .datatable-wrapper .datatable-top {
    flex-direction: column;
    gap: 8px;
  }
  .datatable-wrapper .datatable-bottom {
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
  }
  .datatable-wrapper .datatable-search input {
    width: 100%;
  }
}

/* Extra-small breakpoint (<375px) */
@media (max-width: 374.98px) {
  body {
    font-size: 13px;
  }
  .en-page-header h1 {
    font-size: 18px;
  }
  .en-stat-card .stat-value {
    font-size: 18px;
  }
  .en-topbar {
    height: 48px;
  }
  .en-main {
    margin-top: 48px;
  }
  .en-sidebar {
    top: 48px;
  }
  .container-fluid {
    padding-left: 8px !important;
    padding-right: 8px !important;
  }
}

/* ── Marketing pages ─────────────────────────────────── */
.en-hero {
  background: linear-gradient(135deg, var(--en-primary) 0%, #163a5c 100%);
  color: #fff;
  padding: 80px 0;
}
.en-hero h1 {
  font-size: 42px;
  font-weight: 700;
  line-height: 1.2;
}
.en-hero p.lead {
  font-size: 18px;
  opacity: 0.9;
  max-width: 640px;
}
.en-feature-card {
  background: var(--en-surface);
  border: 1px solid var(--en-slate-200);
  border-radius: var(--en-radius-md);
  padding: 32px;
  height: 100%;
}
.en-feature-card i {
  font-size: 32px;
  color: var(--en-primary);
  margin-bottom: 16px;
  display: block;
}

/* ── Auth pages ──────────────────────────────────────── */
.en-auth-container {
  max-width: 440px;
  margin: 80px auto;
}
.en-auth-card {
  background: var(--en-surface);
  border: 1px solid var(--en-slate-200);
  border-radius: var(--en-radius-md);
  box-shadow: var(--en-shadow-md);
  padding: 40px;
}

/* ── Form styling ────────────────────────────────────── */
.form-control, .form-select {
  border-radius: var(--en-radius-sm);
  border-color: var(--en-slate-300);
  font-size: 14px;
  padding: 10px 14px;
}
.form-control:focus, .form-select:focus {
  border-color: var(--en-primary);
  box-shadow: 0 0 0 3px rgba(31, 78, 121, 0.12);
}
.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--en-slate-700);
  margin-bottom: 4px;
}

/* ── Simple-DataTables overrides ─────────────────── */
.datatable-wrapper {
  font-family: var(--en-font-sans);
}
.datatable-wrapper .datatable-top,
.datatable-wrapper .datatable-bottom {
  padding: 12px 16px;
}
.datatable-wrapper .datatable-top {
  border-bottom: 1px solid var(--en-slate-200);
}
.datatable-wrapper .datatable-bottom {
  border-top: 1px solid var(--en-slate-200);
}
/* Hide the raw perPage label text, show just the select */
.datatable-wrapper .datatable-dropdown label {
  font-size: 0;   /* hide "Show {select} entries" text */
}
.datatable-wrapper .datatable-dropdown label .datatable-selector {
  font-size: 13px; /* restore font on the select itself */
}
.datatable-wrapper .datatable-dropdown label::after {
  content: " per page";
  font-size: 13px;
  color: var(--en-slate-500);
  margin-left: 6px;
}
.datatable-wrapper .datatable-search input {
  font-size: 13px;
  padding: 6px 12px;
  border: 1px solid var(--en-slate-300);
  border-radius: var(--en-radius-sm);
  outline: none;
}
.datatable-wrapper .datatable-search input:focus {
  border-color: var(--en-primary);
  box-shadow: 0 0 0 3px rgba(31, 78, 121, 0.12);
}
.datatable-wrapper .datatable-selector {
  font-size: 13px;
  padding: 4px 8px;
  border: 1px solid var(--en-slate-300);
  border-radius: var(--en-radius-sm);
}
.datatable-wrapper .datatable-info {
  font-size: 12px;
  color: var(--en-slate-500);
}
.datatable-wrapper .datatable-pagination .datatable-pagination-list {
  margin: 0;
  padding: 0;
}
/* Sort indicators — proper triangles */
.datatable-wrapper .datatable-sorter {
  position: relative;
  padding-right: 18px;
}
.datatable-wrapper .datatable-sorter::before,
.datatable-wrapper .datatable-sorter::after {
  content: "";
  position: absolute;
  right: 2px;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  opacity: 0.3;
}
.datatable-wrapper .datatable-sorter::before {
  /* Up triangle */
  top: 50%;
  margin-top: -6px;
  border-bottom: 5px solid var(--en-slate-500);
}
.datatable-wrapper .datatable-sorter::after {
  /* Down triangle */
  top: 50%;
  margin-top: 2px;
  border-top: 5px solid var(--en-slate-500);
}
.datatable-wrapper .datatable-sorter.asc::before {
  opacity: 1;
  border-bottom-color: var(--en-primary);
}
.datatable-wrapper .datatable-sorter.asc::after {
  opacity: 0.3;
}
.datatable-wrapper .datatable-sorter.desc::after {
  opacity: 1;
  border-top-color: var(--en-primary);
}
.datatable-wrapper .datatable-sorter.desc::before {
  opacity: 0.3;
}

/* ── Dual currency ───────────────────────────────────────────────────────
   A figure as contracted, and beside it the same figure in the currency the
   workspace reports in. The converted one is deliberately QUIETER than the
   original: the contract value is the fact, the conversion is a convenience,
   and typography should not let the two be confused. It is a <button> rather
   than a styled span because it opens the rate behind it — that is an action,
   and it has to be reachable from the keyboard. */
.en-money { white-space: nowrap; }
.en-fx {
  border: 0;
  background: none;
  padding: 0 0 0 0.4em;
  font: inherit;
  font-size: 0.85em;
  color: var(--en-slate-500);
  cursor: help;
  text-decoration: underline dotted currentColor;
  text-underline-offset: 0.2em;
}
.en-fx:hover, .en-fx:focus { color: var(--en-primary); outline: none; }
.en-fx-popover .popover-body { font-size: 0.8rem; }
.en-fx-popover .popover-header { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; }

/* In a table the two figures stack, so a column of contract values still
   lines up on its own digits instead of being pushed around by conversions
   of differing width. The figures themselves never break: "OMR 1.63 M" split
   across two lines reads as two numbers. Only the gap BETWEEN them wraps. */
td .en-money, th .en-money { white-space: normal; }
td .en-money > .en-money-figure,
th .en-money > .en-money-figure { white-space: nowrap; }
td .en-fx, th .en-fx { display: block; padding-left: 0; white-space: nowrap; }

/* ── Candidate-pool badges (Sprint 02 / PRC-002) ─────────────────────────────
   ONE vocabulary for where a match candidate came from, defined once in
   apps/boq/services/candidate_pool.py::POOL_BADGES and rendered by
   templates/components/candidate_pool_badge.html. The tone is semantic, not a
   colour name, so the ui_refresh skin can restyle it without renaming classes.

   `.en-pool-badge` is applied ALONGSIDE `.en-cascade-badge` (the shared chip
   geometry) on the review screen; the geometry is repeated here so the badge
   also renders correctly on screens that do not carry that class. */
.en-pool-badge {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 1px 7px; border-radius: 999px;
  font-size: 0.68rem; font-weight: 600; white-space: nowrap;
}
/* From a book the user actually chose — the only badge that may say so. */
.en-pool-badge-selected  { background:#dbeafe; color:#1e40af; }
/* The estimator's own prior work. */
.en-pool-badge-history   { background:#fef3c7; color:#92400e; }
/* Found by widening beyond the selection, same country. */
.en-pool-badge-wider     { background:#e0e7ff; color:#3730a3; }
/* Reference only — other country, unknown country, or synthesised. Amber on
   purpose: this is the one the estimator must not mistake for a chosen rate. */
.en-pool-badge-reference { background:#fef2e2; color:#92400e; }
/* A typed-in rate. Green because a human decided it — the same green the
   review row's retired "Manual rate" chip used, so nothing on the screen
   changes colour when it moved into the one vocabulary. */
.en-pool-badge-manual    { background:#dcfce7; color:#166534; }
/* Provenance never recorded. Deliberately drab: it is an absence, not a claim. */
.en-pool-badge-unknown   { background:#f1f5f9; color:#64748b; }

/* ── Price-status badges (Sprint 02 / MAT-002) ───────────────────────────────
   ONE vocabulary for where a BOQ line's MONEY stands, defined once in
   apps/boq/services/price_state.py::PRICE_STATE_BADGES and rendered by
   templates/components/price_state_badge.html. Separate from the pool badge
   (where the CANDIDATE came from) and from the confidence badge (how close the
   description match is) — three axes, three chips, never merged.

   Geometry is repeated rather than inherited so the badge renders correctly on
   any screen, with or without `.en-cascade-badge`. */
.en-price-state-badge {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 1px 7px; border-radius: 999px;
  font-size: 0.68rem; font-weight: 600; white-space: nowrap;
}
/* Nobody has established a price yet. Drab: an absence, not a failure. */
.en-price-state-unresolved  { background:#f1f5f9; color:#475569; }
/* A candidate is on the table; no rate has been carried across. */
.en-price-state-suggested   { background:#e0e7ff; color:#3730a3; }
/* The chain REFUSED. Red on purpose — this is the state PRC-003/004 create,
   and it must never read like a quieter kind of priced. */
.en-price-state-blocked     { background:#fee2e2; color:#b91c1c; }
/* Real money, from a source we can name. */
.en-price-state-priced      { background:#dcfce7; color:#166534; }
/* Real money, synthesised rather than published. Amber: verify it. */
.en-price-state-reference   { background:#fef2e2; color:#92400e; }
/* An allowance is money with a placeholder's standing. */
.en-price-state-provisional { background:#fef3c7; color:#92400e; }
/* Deliberately out: excluded, by others, included in another line. */
.en-price-state-out         { background:#ede9fe; color:#5b21b6; }
/* Status never recorded. Deliberately drab: an absence, not a claim. */
.en-price-state-unknown     { background:#f1f5f9; color:#64748b; }

/* ── Match Inspector step cards (Sprint 02 / UX-003) ─────────────────────────
   The inspector prints a ladder: target line → candidate source →
   compatibility → price build-up → decision. Each step is a card so a reader
   can see where the money stopped. */
.en-step-card {
  border: 1px solid var(--en-slate-200, #e2e8f0);
  border-radius: 0.5rem;
  padding: 0.6rem 0.7rem;
  margin-bottom: 0.75rem;
  background: #fff;
}
.en-step-card > .en-step-head {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--en-slate-500, #64748b);
  margin-bottom: 0.4rem;
}
.en-step-card dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 0; }
.en-step-card dt { font-size: 0.72rem; color: var(--en-slate-500, #64748b); font-weight: 500; }
.en-step-card dd { font-size: 0.78rem; margin: 0; word-break: break-word; }

/* A reading the estimator must not mistake for a value: an undeclared currency
   or unit is rendered in words, in red, and never as a symbol or a bare
   number. `{% en_money %}` given an empty code prints the READER's currency
   (SPR2-N21), so the inspector formats money itself and says "not declared"
   rather than guessing. */
.en-undeclared {
  color: #b91c1c; font-style: italic; font-weight: 600;
  text-decoration: underline dotted currentColor; text-underline-offset: 0.2em;
}

/* The price build-up ladder. A skipped step is shown, greyed, with its reason;
   a step after a blocker says it was never reached. Showing them is the point
   — a missing step and a skipped step used to look identical. */
.en-chain { font-size: 0.75rem; }
.en-chain-row {
  display: grid; grid-template-columns: 7.5rem 1fr; gap: 2px 8px;
  padding: 2px 0; border-bottom: 1px dashed var(--en-slate-100, #f1f5f9);
}
.en-chain-row:last-child { border-bottom: 0; }
.en-chain-step { font-weight: 600; color: var(--en-slate-600, #475569); }
.en-chain-skipped .en-chain-step,
.en-chain-skipped .en-chain-body { color: var(--en-slate-400, #94a3b8); }
.en-chain-blocked .en-chain-step,
.en-chain-blocked .en-chain-body { color: #b91c1c; }
.en-chain-final { font-weight: 700; }
.en-chain-final .en-chain-body { color: #166534; }

/* The refusal banner. It replaces the final number — it never sits beside
   one, because a partially computed rate IS the defect. */
.en-cannot-price {
  border: 1px solid #fecaca; background: #fef2f2; color: #b91c1c;
  border-radius: 0.5rem; padding: 0.5rem 0.6rem; font-size: 0.78rem;
}
.en-cannot-price .en-cannot-price-title { font-weight: 700; }

/* The four compatibility readings, side by side and never collapsed into one.
   A hard failure in unit or currency has to stay visible whatever the semantic
   score says (04_PRICING_RATE_ENGINE_INTEGRITY §5). */
.en-compat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.en-compat {
  border-radius: 0.375rem; padding: 3px 7px; font-size: 0.7rem; line-height: 1.25;
  background: #f8fafc;
}
.en-compat .en-compat-axis {
  display: block; font-size: 0.62rem; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--en-slate-500, #64748b); font-weight: 600;
}
.en-compat .en-compat-value { font-weight: 700; }
.en-compat-ok      { background:#dcfce7; color:#166534; }
.en-compat-warn    { background:#fef3c7; color:#92400e; }
.en-compat-bad     { background:#fee2e2; color:#b91c1c; }
.en-compat-unknown { background:#f1f5f9; color:#64748b; }

/* ── Themed confirm/alert modal must always win the stacking race ──
   Standing Rule 3: window.enConfirm/enAlert (templates/base/app.html #enModal)
   is the ONLY dialog surface in the app, so it must render above every
   drawer/offcanvas/flyout screens build for themselves. Several screens use
   very high z-index for their own slide-out panels (e.g.
   templates/bidlevel/leveling.html .cell-drawer at 2000, .cell-drawer-backdrop
   at 1999; templates/boq/schedule.html sticky header at 9999) — all comfortably
   above Bootstrap 5's own default modal (1055) / modal-backdrop (1050). A
   confirm triggered from inside one of those panels opened BEHIND it and was
   unclickable (found rehearsing the Kalpataru demo, 2026-09-23, bid-leveling
   rate drawer's "Revert to vendor rate"). Pin the modal and its backdrop above
   the highest z-index any drawer/offcanvas in this app uses, with headroom;
   only the transient toast layer (schedule.html/whatif_dashboard.html, 99999)
   is allowed to sit above it once the modal has closed. */
.modal-backdrop.show { z-index: 10590 !important; }
.modal.show, .modal.showing { z-index: 10600 !important; }
