/*
 * Pacto application overrides — loaded after Metronic bundles.
 *
 * Override strategy:
 * 1. Use Bootstrap 5 CSS custom properties (--bs-*) for brand colors
 * 2. Match Metronic specificity for stubborn selectors
 * 3. Never use !important
 */

/*
 * Windows ships no country-flag glyphs, so this font supplies them. It stays here
 * and not in plugins.bundle.css, which a Metronic upgrade replaces wholesale
 * (docs/metronic.md "Country flags on Windows").
 * Twemoji artwork CC-BY-4.0, font code MIT; LICENSE.md sits beside the font file.
 */
@font-face {
  font-family: "Twemoji Country Flags";
  src: url("/assets/twemoji-country-flags/TwemojiCountryFlags-468538bb.woff2") format("woff2");
  unicode-range: U+1F1E6-1F1FF, U+1F3F4, U+E0062-E0063, U+E0065, U+E0067,
    U+E006C, U+E006E, U+E0073-E0074, U+E0077, U+E007F;
  font-display: swap;
}

/*
 * Prepend the flag font to Metronic's stack. Referencing --bs-font-sans-serif
 * rather than restating "Inter, Helvetica, sans-serif" means a Metronic upgrade
 * that changes the body font is inherited automatically; only the prepend is ours.
 */
:root {
  --bs-body-font-family: "Twemoji Country Flags", var(--bs-font-sans-serif);
}

/* Record link style for index tables — bold, colored, underline on hover */
.record-link {
  color: var(--bs-gray-900);
  font-weight: 600;
  text-decoration: none;
}

.record-link:hover {
  color: var(--bs-primary);
  text-decoration: underline;
}

/* The row under the mouse in a list table (Bootstrap's table-hover): one
   colour for the light theme and one for the dark, each changed here. */
:root {
  --pacto-row-hover: #F1F1F4;
}

[data-bs-theme="dark"] {
  --pacto-row-hover: #26272F;
}

.table-hover {
  --bs-table-hover-bg: var(--pacto-row-hover);
  --bs-table-active-bg: var(--pacto-row-hover);
}

/* A record's summary card (shared/_summary_card), headed as a form's header
   card is: a tinted head with the tile, the title and the badges. */
.summary-card {
  overflow: hidden;
}

.summary-card-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.625rem;
  padding: 1.75rem 1.25rem 1.25rem;
  border-bottom: 1px solid color-mix(in srgb, var(--pacto-tone) 25%, transparent);
  background: color-mix(in srgb, var(--pacto-tone) 9%, var(--bs-card-bg));
  text-align: center;
}

.summary-card-head .record-header-avatar {
  background: var(--pacto-tone);
  color: var(--pacto-tone-on);
  box-shadow: 0 10px 30px color-mix(in srgb, var(--pacto-tone) 45%, transparent);
}

.summary-card-title {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--bs-gray-900);
}

.card > .summary-card-body {
  padding-top: 1.25rem;
}

.summary-card-label {
  margin-bottom: 0.75rem;
  color: var(--bs-gray-500);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* In the preview the summary is the panel's content, not a card within it:
   no border or shadow, and one layer of padding instead of two. The page
   keeps the card as it is. */
/* The drawer starts under the fixed top bar: drawn from the top of the window,
   its close button sat under the avatar and a click opened the user menu. */
#preview_panel {
  top: var(--bs-app-header-height, 70px);
}

#preview_panel > .card > .card-body {
  padding: 1rem 1.25rem;
}

#preview_panel .card-body .card {
  border: 0;
  box-shadow: none;
}

#preview_panel .card > .summary-card-body {
  padding: 0.5rem 0 0;
}

.collection-card-rows {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.collection-card-rows > [data-nested-form-target="field"] {
  margin-top: 0;
}

/* The list makes room for the preview at the pace the panel slides in
   (Metronic's drawer: 0.3s). */
.preview-host {
  transition: padding-right 0.3s ease-in-out;
}

@media (prefers-reduced-motion: reduce) {
  .preview-host {
    transition: none;
  }
}

/* Below 992px Metronic stops the page scrolling under an open drawer, which
   suits a drawer with an overlay. The preview has none: the list behind it
   stays in use. */
@media (max-width: 991.98px) {
  body[data-kt-drawer-preview="on"] {
    overflow: visible;
  }
}

/* An inline Google map needs a height of its own: Google draws into the box
   it is given. */
.google-map {
  height: 320px;
}

/* Inter, self-hosted: no page of the app links Google Fonts for
   its own text. Variable weight files, subset like the Twemoji
   flags font above them in spirit — unicode-range scoped, swap display. */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/assets/inter/inter-latin-var-1f021a24.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/assets/inter/inter-latin-ext-var-65edaaef.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* Auth layout: narrow form panel so the branding image takes more space.
   The width lives here alone — the layout deliberately carries no Bootstrap
   w-lg-* utility, whose own !important would force one here too. */
@media (min-width: 992px) {
  .auth-form-panel {
    width: 40%;
    max-width: 40%;
  }
}

/* Auth layout: the road scene beside the form (layouts/_sign_in_scene).
   Its animations exist only for visitors who have not asked for reduced
   motion; the route pulse is SMIL, which CSS cannot pause, so it is hidden. */
/* The panel is a stretched flex item, whose height a percentage cannot
   resolve against; pinned to its edges, the SVG gets the panel's real size
   and slice crops it from the middle. */
.sign-in-scene-panel {
  position: relative;
  background-color: #0a1a3a;
  overflow: hidden;
}

.sign-in-scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.sign-in-scene text { font-family: inherit; }
.sign-in-scene .wordmark { text-anchor: middle; }
.sign-in-scene .stars circle { fill: #bed7ff; opacity: .5; }
.sign-in-scene .route { fill: none; stroke: #58a6ff; stroke-opacity: .5; stroke-width: 2; stroke-dasharray: 6 6; }
.sign-in-scene .ring { fill: none; stroke: #58a6ff; stroke-width: 2; }
.sign-in-scene .dot,
.sign-in-scene .hub { fill: #58a6ff; }
.sign-in-scene .lane { stroke: #58a6ff; stroke-opacity: .7; stroke-width: 3; stroke-dasharray: 40 40; }
.sign-in-scene .edge { stroke: #58a6ff; stroke-opacity: .8; stroke-width: 2; }
.sign-in-scene .body { fill: #162848; stroke: #58a6ff; stroke-width: 3; stroke-linejoin: round; }
.sign-in-scene .tyre { fill: #162848; stroke: #58a6ff; stroke-width: 3; }
.sign-in-scene .wheel path { stroke: #58a6ff; stroke-opacity: .8; stroke-width: 2; }
.sign-in-scene .speed line { stroke: #58a6ff; stroke-width: 2; }

@media (prefers-reduced-motion: reduce) {
  .sign-in-scene .pulse { display: none; }
}

@media (prefers-reduced-motion: no-preference) {
  .sign-in-scene .stars circle { animation: sign-in-twinkle 3s ease-in-out infinite alternate; }
  .sign-in-scene .far { animation: sign-in-scroll-400 18s linear infinite; }
  .sign-in-scene .near { animation: sign-in-scroll-400 6s linear infinite; }
  .sign-in-scene .posts { animation: sign-in-scroll-160 .667s linear infinite; }
  .sign-in-scene .lane { animation: sign-in-lane .333s linear infinite; }
  .sign-in-scene .sign { animation: sign-in-sign 11s linear infinite; }
  .sign-in-scene .car { animation: sign-in-car 5s linear infinite; }
  .sign-in-scene .car.second { animation-duration: 7s; animation-delay: -3.2s; }
  .sign-in-scene .truck { animation: sign-in-bob .5s ease-in-out infinite alternate; }
  .sign-in-scene .wheel { animation: sign-in-spin .36s linear infinite; }
  .sign-in-scene .speed line { animation: sign-in-speed .6s linear infinite; }
  .sign-in-scene .speed line:nth-child(2) { animation-delay: -.2s; }
  .sign-in-scene .speed line:nth-child(3) { animation-delay: -.4s; }
}

/* Every period below matches its pattern's repeat (hills 400, posts 160,
   lane dashes 80) so each loop joins without a jump. */
@keyframes sign-in-twinkle { from { opacity: .15; } to { opacity: .9; } }
@keyframes sign-in-scroll-400 { to { transform: translateX(-400px); } }
@keyframes sign-in-scroll-160 { to { transform: translateX(-160px); } }
@keyframes sign-in-lane { to { stroke-dashoffset: 80; } }
@keyframes sign-in-sign { 0% { transform: translateX(0); } 36%, 100% { transform: translateX(-960px); } }
@keyframes sign-in-car { 0% { transform: translateX(0); } 45%, 100% { transform: translateX(-1300px); } }
@keyframes sign-in-bob { to { transform: translateY(1px); } }
@keyframes sign-in-spin { to { transform: rotate(360deg); } }
@keyframes sign-in-speed { from { transform: translateX(0); opacity: .9; } to { transform: translateX(-30px); opacity: 0; } }

/* Table view list — subtle active highlight instead of Bootstrap's bright blue */
.list-group-item.table-view-item.active {
  background-color: var(--bs-gray-200);
  border-color: var(--bs-border-color);
  color: var(--bs-gray-900);
}

/* AI chat thinking animation */
.thinking-dots {
  display: flex;
  gap: 4px;
  align-items: center;
}

.thinking-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--bs-gray-500);
  animation: thinking-bounce 1.4s infinite ease-in-out both;
}

.thinking-dots span:nth-child(1) { animation-delay: -0.32s; }
.thinking-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes thinking-bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* AI assistant markdown content */
.message-markdown { font-weight: normal; }
.message-markdown p { margin-bottom: 0.5rem; }
.message-markdown p:last-child { margin-bottom: 0; }
.message-markdown ul,
.message-markdown ol { padding-left: 1.4rem; margin-bottom: 0.5rem; }
.message-markdown h1,
.message-markdown h2,
.message-markdown h3 { font-size: 1rem; font-weight: 600; margin-top: 0.75rem; margin-bottom: 0.35rem; }
.message-markdown code { background: var(--bs-gray-200); border-radius: 3px; padding: 0.1em 0.35em; font-size: 0.85em; }
.message-markdown pre { background: var(--bs-gray-200); border: 1px solid var(--bs-border-color); border-radius: 6px; padding: 0.75rem; overflow-x: auto; margin-bottom: 0.5rem; }
.message-markdown pre code { background: none; padding: 0; }
.message-markdown blockquote { border-left: 3px solid var(--bs-gray-300); padding-left: 0.75rem; color: var(--bs-gray-600); margin: 0.5rem 0; }
.message-markdown hr { border-color: var(--bs-border-color); margin: 0.75rem 0; }
.message-markdown a { color: var(--bs-primary); text-decoration: underline; }

/* AI assistant markdown tables */
.message-markdown table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
  overflow-x: auto;
  display: block;
}

.message-markdown thead th {
  background: var(--bs-gray-200);
  color: var(--bs-gray-700);
  font-weight: 600;
  text-align: left;
  padding: 0.4rem 0.6rem;
  border-bottom: 2px solid var(--bs-border-color);
  white-space: nowrap;
}

.message-markdown tbody tr:nth-child(even) {
  background: var(--bs-gray-100);
}

.message-markdown tbody td {
  padding: 0.35rem 0.6rem;
  border-bottom: 1px solid var(--bs-border-color);
  vertical-align: top;
}

/* AI panel slide transition — mirrors sidebar's transition timing */
.table-col-transition {
  transition: all 0.3s ease-in-out;
}

.table-panel-col {
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  padding-left: 0;
  padding-right: 0;
  transition: max-width 0.3s ease-in-out, opacity 0.3s ease-in-out, padding 0.3s ease-in-out;
}

.table-panel-col--visible {
  max-width: 25%;
  opacity: 1;
  overflow: visible;
  padding-left: calc(var(--bs-gutter-x) * 0.5);
  padding-right: calc(var(--bs-gutter-x) * 0.5);
}

/* Suppress transitions on initial page load. Compound selectors match the
   two elements table-panel-toggle applies the class to, at higher
   specificity than the transition rules they silence — no !important. */
.table-panel-col.no-transition,
.table-col-transition.no-transition {
  transition: none;
}

/* ===== Operations Hub — dark futuristic theme ===== */

/* Dark background for the entire content area when the hub page is loaded.
   Nested: every rule here applies only while a .ohub page is in the main area. */
#kt_app_main:has(.ohub) {
  background: #0a0e27;

  .app-toolbar,
  #kt_app_footer {
    background: #0a0e27;
  }

  .page-heading {
    color: rgba(255, 255, 255, 0.95);
  }

  .breadcrumb-item.text-muted,
  .text-muted.text-hover-primary,
  #kt_app_footer .text-gray-800 {
    color: rgba(180, 195, 220, 0.65);
  }

  #kt_app_footer {
    border-top-color: rgba(0, 210, 255, 0.1);
  }
}

.ohub {
  --ohub-bg: #0a0e27;
  --ohub-card-bg: rgba(15, 20, 50, 0.85);
  --ohub-card-border: rgba(0, 210, 255, 0.15);
  --ohub-accent: #00d2ff;
  --ohub-accent-green: #00e676;
  --ohub-text: rgba(255, 255, 255, 0.95);
  --ohub-text-muted: rgba(180, 195, 220, 0.65);
  --ohub-separator: rgba(0, 210, 255, 0.12);
}

/* The shared colours, once: what reads as text, what reads as a hint. */
.ohub-title,
.ohub-kpi-value,
.ohub-card-header,
.ohub-text-light {
  color: var(--ohub-text);
}

.ohub-kpi-label,
.ohub-dots,
.ohub-table,
.ohub-table thead th,
.ohub-text-muted {
  color: var(--ohub-text-muted);
}

.ohub-title {
  font-size: 1.75rem;
  letter-spacing: 0.5px;
}

.ohub-subtitle {
  color: var(--ohub-accent);
  letter-spacing: 1px;
  text-transform: uppercase;
  font-size: 0.8rem;
}

.ohub-text-accent { color: var(--ohub-accent); }
.ohub-text-success { color: var(--ohub-accent-green); }

/* The three boxes share a surface and a border; the radius is each one's own. */
.ohub-kpi-card,
.ohub-card,
.ohub-map-card {
  background: var(--ohub-card-bg);
  border: 1px solid var(--ohub-card-border);
}

.ohub-kpi-card {
  border-radius: 8px;
}

.ohub-kpi-value {
  font-size: 2.5rem;
  line-height: 1.1;
}

.ohub-card {
  border-radius: 10px;
  padding: 1.25rem;
}

.ohub-map-card {
  background: var(--ohub-bg);
  overflow: hidden;
}

.ohub-dots {
  font-size: 1.5rem;
  letter-spacing: 2px;
  cursor: pointer;
}

.ohub-agent-icon {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: rgba(0, 210, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* One hairline under every row-like element. */
.ohub-bid-row,
.ohub-table thead th,
.ohub-table tbody tr,
.ohub-table tbody td {
  border-bottom: 1px solid var(--ohub-separator);
}

.ohub-bid-row:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.ohub-score-badge {
  display: inline-block;
  background: rgba(0, 210, 255, 0.15);
  color: var(--ohub-accent);
  font-weight: 700;
  font-size: 0.8rem;
  padding: 2px 8px;
  border-radius: 4px;
}

/* The two tinted boxes share their shape; the tint is each one's own. */
.ohub-highlight-box,
.ohub-profit-box {
  border-radius: 6px;
  padding: 0.75rem 1rem;
}

.ohub-highlight-box {
  background: rgba(0, 210, 255, 0.08);
  border: 1px solid rgba(0, 210, 255, 0.2);
}

.ohub-separator {
  border-color: var(--ohub-separator);
}

.ohub-profit-box {
  background: rgba(0, 230, 118, 0.08);
  border: 1px solid rgba(0, 230, 118, 0.2);
  color: var(--ohub-accent-green);
}

.ohub-progress-bar {
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
}

.ohub-progress-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--ohub-accent), var(--ohub-accent-green));
}

.ohub-table thead th {
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ohub-tier-badge {
  font-weight: 700;
  font-size: 0.8rem;
  padding: 3px 10px;
  border-radius: 4px;
  white-space: nowrap;
}

.ohub-tier-warning {
  background: rgba(255, 199, 0, 0.12);
  color: #ffc700;
}

.ohub-tier-secondary {
  background: rgba(180, 195, 220, 0.12);
  color: #b4c3dc;
}

.ohub-tier-info {
  background: rgba(205, 127, 50, 0.12);
  color: #cd7f32;
}

/* intl-tel-input — fits the vendor widget to Metronic's form controls.
   The library wraps the <input> in a .iti element that is inline-block by
   default, which collapses inside a Bootstrap column. */
.iti {
  width: 100%;
}

/* The country button sits inside the input, so its background must follow the
   field rather than the page — otherwise it stays white in dark mode. */
.iti__country-container .iti__selected-country {
  background-color: transparent;
  border-radius: var(--bs-border-radius) 0 0 var(--bs-border-radius);
}

/* The widget paints its dropdown from its own variables — a white
   --iti-country-selector-bg, a grey border, a black hover — which is what left
   the country list white in dark mode. Pointing those at Metronic's
   tokens themes the list in both modes; the earlier rule here targeted
   .iti__dropdown-content, a class this version of the widget does not render. */
:root {
  --iti-country-selector-bg: var(--bs-body-bg);
  --iti-border-color: var(--bs-border-color);
  --iti-hover-color: var(--bs-gray-100);
  --iti-icon-color: var(--bs-gray-600);
}

.iti__country-selector {
  border-radius: var(--bs-border-radius);
  color: var(--bs-body-color);
}

.iti__dial-code {
  color: var(--bs-gray-600);
}

.iti__search-input {
  background-color: var(--bs-body-bg);
  color: var(--bs-body-color);
  border-bottom: 1px solid var(--bs-border-color);
}

/* ==========================================================================
   Help articles
   ========================================================================== */

/* A value the reader has to reproduce exactly — the connector address, the name
   to type beside it. Set apart from the prose so it is obvious where the value
   starts and ends; monospaced so a 1 cannot be read as an l; selectable in one
   click; and free to wrap mid-string so a long address cannot push the card
   sideways on a phone. Named rather than a run of utility classes because every
   article needs the same treatment and it should not drift between them. */
.help-code {
  background-color: var(--bs-gray-100);
  border: 1px solid var(--bs-border-color);
  border-radius: var(--bs-border-radius);
  color: var(--bs-gray-900);
  display: inline-block;
  font-family: var(--bs-font-monospace);
  max-width: 100%;
  overflow-wrap: anywhere;
  padding: 0.5rem 0.85rem;
  user-select: all;
}

/* A field's ? (field_help): muted until pointed at, a help cursor over it. */
.field-help {
  color: var(--bs-gray-500);
  cursor: help;
}

.field-help:hover,
.field-help:focus-visible {
  color: var(--bs-primary);
}

/* Operation form: the checklist rail stays in view while the
   sections scroll, below the fixed header; a section is the jump target of a
   rail heading, so it lands below the header too. The chevron turns with the
   section controller's collapsed value, which Stimulus reflects as an attribute. */
.operation-rail {
  position: sticky;
  top: calc(var(--bs-app-header-height, 0px) + 1.5rem);
}

/* Its buttons stick to the window's foot, as a child of the rail: before the
   page is scrolled the checklist card starts below a short window, and a
   sticky child cannot leave its parent (spec/system/operation_rail_actions_spec.rb). */
.operation-rail-actions {
  position: sticky;
  bottom: 0.75rem;
  z-index: 1;
}

.operation-section {
  scroll-margin-top: calc(var(--bs-app-header-height, 0px) + 1rem);
}

.operation-section-head {
  cursor: pointer;
}

/* Folded, a chosen record's field grid ends the card, as far from its
   bottom edge as the tile is from the strip's top; open, the fields follow. */
.operation-section .form-section-body.operation-section-details {
  padding-top: 0.75rem;
  padding-bottom: 1rem;
}

/* The operation form's layout, after the office's design. Its one
   colour of its own is the accent: the designer's cyan on dark, a darker cyan
   on light, where the original is unreadable as small text. */
:root {
  --pacto-accent: #007A94;
}

[data-bs-theme="dark"] {
  --pacto-accent: #00B4D8;
}

.pacto-field-lbl {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--bs-gray-500);
  margin-bottom: 0.15rem;
}

.pacto-field-val {
  font-size: 0.925rem;
  font-weight: 600;
  color: var(--bs-gray-800);
  line-height: 1.35;
  overflow-wrap: break-word;
}

.pacto-field-val.pacto-pending {
  color: var(--bs-warning);
  font-weight: 700;
}

/* As many columns as the card's width takes, so a half-width card does not
   break a CIF or an email mid-word. */
.pacto-microgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
  gap: 0.9rem 1.1rem;
}

.btn.collapsed .pacto-when-open,
.btn:not(.collapsed) .pacto-when-collapsed {
  display: none;
}

.pacto-subhdr {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--bs-gray-500);
  margin: 0.85rem 0 0.4rem;
}

.pacto-subhdr:first-child {
  margin-top: 0;
}

.pacto-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--bs-gray-100);
  border: 1px solid var(--bs-border-color);
  border-radius: calc(var(--bs-border-radius) - 1px);
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
  color: var(--bs-gray-700);
}

.pacto-pending-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--bs-warning);
}

.pacto-doc-banner {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1.25rem;
  border-radius: var(--bs-border-radius);
  border: 1px solid color-mix(in srgb, var(--pacto-accent) 35%, var(--bs-border-color));
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--pacto-accent) 9%, transparent), transparent 65%),
    var(--bs-body-bg);
}

.pacto-doc-banner .pacto-doc-icon {
  flex: 0 0 auto;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--bs-border-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--pacto-accent) 16%, transparent);
  color: var(--pacto-accent);
}

.pacto-accent-btn {
  background: var(--pacto-accent);
  color: #fff;
  font-weight: 700;
}

.pacto-status-mini {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.pacto-status-mini-item {
  background: var(--bs-gray-100);
  border: 1px solid var(--bs-border-color);
  border-radius: calc(var(--bs-border-radius) - 1px);
  padding: 0.45rem 0.55rem;
}

/* Each party's box in the colour of its step. */
.pacto-status-mini-item[class*="pacto-tone-"] {
  background: color-mix(in srgb, var(--pacto-tone) 9%, var(--bs-card-bg));
  border-color: color-mix(in srgb, var(--pacto-tone) 25%, transparent);
}

.pacto-status-mini-item .lbl {
  display: block;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--bs-gray-500);
}

.pacto-status-mini-item .val {
  font-size: 0.85rem;
  font-weight: 800;
  margin-top: 0.05rem;
}

.pacto-status-mini-item .val.is-empty {
  color: var(--bs-gray-500);
}

.pacto-status-mini-item .val.is-success {
  color: var(--bs-success);
}

.pacto-status-mini-item .val.is-warning {
  color: var(--bs-warning);
}

.pacto-status-mini-item .val.is-accent {
  color: var(--pacto-accent);
}

.pacto-checklist-count {
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0.15rem 0.55rem;
  border-radius: 20px;
  background: color-mix(in srgb, var(--pacto-accent) 15%, transparent);
  color: var(--pacto-accent);
}

.pacto-cost-panel .pacto-cost-col + .pacto-cost-col {
  border-left: 1px solid var(--bs-border-color);
  padding-left: 1.6rem;
}

@media (max-width: 1199.98px) {
  .pacto-cost-panel .pacto-cost-col + .pacto-cost-col {
    border-left: 0;
    padding-left: 0;
    border-top: 1px solid var(--bs-border-color);
    padding-top: 1rem;
    margin-top: 1rem;
  }
}

.pacto-cost-price {
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--bs-gray-900);
}

.pacto-cost-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.875rem;
  color: var(--bs-gray-700);
}

.pacto-cost-row.pacto-cost-total {
  font-weight: 800;
  color: var(--bs-gray-900);
  border-top: 1px solid var(--bs-border-color);
  padding-top: 0.4rem;
  margin-top: 0.15rem;
}

.pacto-profit-box {
  border-radius: var(--bs-border-radius);
  padding: 0.6rem 0.8rem;
  background: color-mix(in srgb, var(--bs-success) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--bs-success) 35%, transparent);
}

.pacto-profit-box .val {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--bs-success);
}

.pacto-progress {
  height: 6px;
  border-radius: 4px;
  background: var(--bs-gray-200);
  overflow: hidden;
}

.pacto-progress > div {
  height: 100%;
  background: linear-gradient(90deg, var(--pacto-accent), var(--bs-success));
}

/* Two-factor setup: the QR is shown at the size rqrcode drew it —
   it carries no viewBox, so a CSS width would clip it, not scale it — with a
   white ground in dark mode so a phone camera reads it. The backup codes stay
   legible at a glance. */
.qr-code svg {
  display: block;
  background: #fff;
  border-radius: 0.475rem;
}

.backup-codes code {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.05em;
}

/* New route (Gus's quote card): empty fields grey, filled ones light blue,
   as in his sketch. filled-tint marks a field holding a value; :root outweighs
   the light theme's grey border on solid fields. */
:root .form-control.form-control-solid.pacto-quote-field.pacto-filled,
:root .form-select.pacto-quote-field.pacto-filled + .select2-container .select2-selection.form-select-solid {
  background-color: var(--bs-primary-light);
  border-color: var(--bs-primary);
  color: var(--bs-gray-900);
}
:root .form-select.pacto-quote-field.pacto-filled + .select2-container .select2-selection__rendered { color: var(--bs-gray-900); }
/* An empty date shows its dd/mm/aaaa as the other fields show their hints. */
.form-control.form-control-solid.pacto-quote-field[type="date"]:not(.pacto-filled) { color: var(--bs-gray-500); }
.pacto-quote-estimate {
  background-color: var(--bs-success-light);
  border: 1px solid var(--bs-success);
}
/* The AUTO tag sits inside the town field, so the origin's and the
   destination's fields keep one width. */
.pacto-city-box .pacto-auto-tag {
  position: absolute;
  top: 50%;
  right: 0.75rem;
  transform: translateY(-50%);
  pointer-events: auto;
}
.pacto-city-box:has(.pacto-auto-tag:not([hidden])) .pacto-city { padding-right: 3.25rem; }
/* Where Google placed a town typed by hand, inside the field like AUTO. */
.pacto-city-box .pacto-place-tag {
  position: absolute;
  top: 50%;
  right: 0.75rem;
  transform: translateY(-50%);
  max-width: 55%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pacto-city-box:has(.pacto-place-tag:not([hidden])) .pacto-city { padding-right: 55%; }
/* About six rows of New route's unfinished quotes, the rest a scroll away. */
.pacto-unfinished-quotes { max-height: 16rem; overflow-y: auto; }
.pacto-unfinished-quotes .table { --bs-table-bg: transparent; }
/* Two thirds of its width, whatever the window (the owner's choice). */
.pacto-quote-map { height: auto; aspect-ratio: 3 / 2; }
@media (min-width: 992px) {
  .pacto-quote-card .border-end-lg { border-right: 1px solid var(--bs-border-color); }
}
/* A point Leo dragged New route's line through: draggable, a click removes it. */
.pacto-via-point {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--bs-body-bg);
  border: 3px solid var(--bs-primary);
  cursor: grab;
}

/* The sidebar's icons, 15% over Metronic's fs-2 (1.5rem), which is
   !important and so cannot be overridden on .menu-icon. */
.pacto-sidebar-icon {
  font-size: 1.725rem;
}

.app-sidebar .pacto-sidebar-group {
  position: relative;
}

/* A menu taller than the sidebar is cut by its scroll, and the sliver of the
   icon cut there read as a stray «·». The edge fades instead; the padding
   lets the last entry scroll clear of the fade. */
#kt_app_sidebar_menu_scroll {
  padding-bottom: 1.5rem;
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 1.5rem), transparent calc(100% - 0.5rem));
  mask-image: linear-gradient(to bottom, #000 calc(100% - 1.5rem), transparent calc(100% - 0.5rem));
}

/* Collapsed, Metronic fades a sidebar heading out and leaves a gap: a line
   in its place keeps the groups readable from the icons alone. */
[data-kt-app-sidebar-minimize="on"] .app-sidebar .pacto-sidebar-group:not(:first-child)::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 0.75rem;
  right: 0.75rem;
  border-top: 1px solid var(--bs-border-color);
}

/* Form sections (shared/_form_section, docs/crud_patterns.md "Form sections").
   A tone is one colour; its tint and line are mixed from it, so a tone reads
   in both themes. Metronic's own colours where it has them, the operation
   form's accent for teal; orange and slate are the design's. The tile's
   glyph is dark on the bright tones in either theme. */
.pacto-tone-blue   { --pacto-tone: var(--bs-primary); --pacto-tone-on: var(--bs-primary-inverse); }
.pacto-tone-violet { --pacto-tone: var(--bs-info);    --pacto-tone-on: var(--bs-info-inverse); }
.pacto-tone-amber  { --pacto-tone: var(--bs-warning); --pacto-tone-on: rgba(0, 0, 0, 0.85); }
.pacto-tone-green  { --pacto-tone: var(--bs-success); --pacto-tone-on: rgba(0, 0, 0, 0.85); }
.pacto-tone-red    { --pacto-tone: var(--bs-danger);  --pacto-tone-on: var(--bs-danger-inverse); }
.pacto-tone-teal   { --pacto-tone: var(--pacto-accent); --pacto-tone-on: var(--bs-primary-inverse); }
.pacto-tone-orange { --pacto-tone: #FF8A3D; --pacto-tone-on: rgba(0, 0, 0, 0.85); }
.pacto-tone-slate  { --pacto-tone: #5E6278; --pacto-tone-on: var(--bs-primary-inverse); }

.form-section {
  overflow: hidden;
}

.form-section-strip {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  width: 100%;
  padding: 0.75rem 1.125rem;
  border: 0;
  border-bottom: 1px solid transparent;
  background: color-mix(in srgb, var(--pacto-tone) 10%, var(--bs-card-bg));
  color: var(--bs-gray-900);
  text-align: left;
  cursor: pointer;
}

.form-section-strip-static,
.form-section-strip[aria-expanded="true"] {
  border-bottom-color: color-mix(in srgb, var(--pacto-tone) 28%, transparent);
}

.form-section-tile {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.7rem;
  background: var(--pacto-tone);
  color: var(--pacto-tone-on);
  font-size: 1.25rem;
  font-weight: 800;
}

.form-section-tile [class*="ki-"] {
  color: inherit;
  font-size: inherit;
}

.form-section-title {
  font-size: 1.075rem;
  font-weight: 700;
}

.form-section-summary {
  min-width: 0;
  overflow: hidden;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--bs-gray-600);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.form-section-strip-static {
  cursor: default;
}

/* A record page's card folds from a button inside its static strip, so the
   strip's toolbar (Add contact) stays outside the toggle. */
.form-section-toggle-heading {
  flex: 1;
  min-width: 0;
  font-size: inherit;
  font-weight: inherit;
}

.form-section-toggle {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
}

.form-section-toggle[aria-expanded="true"] .form-section-chevron {
  transform: rotate(180deg);
}

.form-section-chevron-button {
  display: inline-flex;
  flex: none;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

.form-section-strip-static:has(.form-section-toggle[aria-expanded="true"]) .form-section-chevron-button .form-section-chevron {
  transform: rotate(180deg);
}

.form-section-strip-static:has(.form-section-toggle[aria-expanded="false"]) {
  border-bottom-color: transparent;
}

.form-section-error {
  flex: none;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--bs-danger);
}

.form-section-chevron {
  flex: none;
  margin-left: auto;
  font-size: 1.15rem;
  color: var(--bs-gray-600);
  transition: transform 0.2s;
}

.form-section-strip[aria-expanded="true"] .form-section-chevron {
  transform: rotate(180deg);
}

@media (prefers-reduced-motion: reduce) {
  .form-section-chevron {
    transition: none;
  }
}

.form-section .form-section-body {
  padding: 1rem 1.125rem 1.125rem;
}

/* Compact: a form inside another (an inline-create frame) — a bordered
   sub-card without the page card's shadow. */
.form-section-compact {
  border: 1px solid var(--bs-border-color);
  border-radius: 0.75rem;
  box-shadow: none;
}

.form-section-compact .form-section-strip {
  gap: 0.625rem;
  padding: 0.55rem 0.75rem;
}

.form-section-compact .form-section-tile {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 0.5rem;
  font-size: 0.95rem;
}

.form-section-compact .form-section-title {
  font-size: 0.875rem;
}

.form-section-compact .form-section-summary {
  font-size: 0.75rem;
}

.form-section-compact .form-section-body.card-body {
  padding: 0.75rem;
}

/* Related lists as tabs (shared/_tab_card, docs/crud_patterns.md "Related
   lists as tabs"): a teal strip holding the tab bar and the chevron; each
   tab's icon in its own tone, the chosen tab solid blue. */
.tab-card {
  overflow: hidden;
}

.tab-card-strip {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 1.125rem;
  border-bottom: 1px solid transparent;
  background: color-mix(in srgb, var(--pacto-tone) 9%, var(--bs-card-bg));
  overflow-x: auto;
}

.tab-card[data-tab-card-open-value="true"] .tab-card-strip {
  border-bottom-color: color-mix(in srgb, var(--pacto-tone) 25%, transparent);
}

.tab-card-tabs {
  display: flex;
  flex: 1;
  gap: 0.25rem;
  min-width: 0;
  padding: 0.25rem;
  border: 1px solid color-mix(in srgb, var(--pacto-tone) 18%, transparent);
  border-radius: 0.75rem;
  background: color-mix(in srgb, var(--bs-body-bg) 55%, transparent);
}

.tab-card-tab {
  display: flex;
  flex: 1 1 0;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 2.5rem;
  padding: 0 0.75rem;
  border: 0;
  border-radius: 0.55rem;
  background: transparent;
  color: var(--bs-gray-700);
  font-weight: 600;
  white-space: nowrap;
}

.tab-card-tab-icon {
  color: var(--pacto-tone);
  font-size: 1.1rem;
}

.tab-card-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.4rem;
  height: 1.25rem;
  padding: 0 0.375rem;
  border-radius: 0.625rem;
  background: var(--bs-gray-200);
  color: var(--bs-gray-700);
  font-size: 0.7rem;
  font-weight: 700;
}

.tab-card-tab[aria-selected="true"] {
  background: var(--bs-primary);
  color: var(--bs-primary-inverse);
  font-weight: 700;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--bs-primary) 35%, transparent);
}

.tab-card-tab[aria-selected="true"] .tab-card-tab-icon {
  color: inherit;
}

.tab-card-tab[aria-selected="true"] .tab-card-count {
  background: rgba(255, 255, 255, 0.22);
  color: inherit;
}

.tab-card-chevron {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 0;
  border-radius: 0.55rem;
  background: transparent;
  color: var(--bs-gray-600);
  font-size: 1.15rem;
  transition: transform 0.2s;
}

.tab-card[data-tab-card-open-value="true"] .tab-card-chevron {
  transform: rotate(180deg);
}

@media (prefers-reduced-motion: reduce) {
  .tab-card-chevron {
    transition: none;
  }
}

.tab-card-pane {
  padding: 0.875rem 1.125rem 1.125rem;
}

.tab-card-compact {
  border: 1px solid var(--bs-border-color);
  border-radius: 0.75rem;
  box-shadow: none;
}

.tab-card-compact .tab-card-strip {
  padding: 0.375rem 0.5rem;
}

.tab-card-compact .tab-card-tab {
  height: 2rem;
  padding: 0 0.625rem;
  font-size: 0.75rem;
}

.tab-card-compact .tab-card-pane {
  padding: 0.625rem 0.75rem;
}

/* A lone list (a section's, or a form's only one) is a heading, not a choice:
   no solid blue bar. */
.tab-card-tab:only-child[aria-selected="true"] {
  justify-content: flex-start;
  background: transparent;
  color: var(--bs-gray-800);
  box-shadow: none;
}

.tab-card-tab:only-child[aria-selected="true"] .tab-card-tab-icon {
  color: var(--pacto-tone);
}

.tab-card-tab:only-child[aria-selected="true"] .tab-card-count {
  background: var(--bs-gray-200);
  color: var(--bs-gray-700);
}

/* A list's Add, its header row and its empty state. */
.collection-list-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.5rem;
}

.collection-list-columns {
  padding-bottom: 0.25rem;
  color: var(--bs-gray-500);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.collection-list-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 2rem 1rem;
  border: 2px dashed var(--bs-border-color);
  border-radius: 0.875rem;
}

.collection-list-empty[hidden] {
  display: none;
}

.collection-list-empty-tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  border-radius: 0.75rem;
  background: var(--bs-primary);
  color: var(--bs-primary-inverse);
  font-size: 1.5rem;
}

.collection-list-empty-tile [class*="ki-"] {
  color: inherit;
}

/* A row of a list with a header (phones, emails, documents): one grid, the
   header's and the rows', so the columns line up. */
.collection-row {
  display: grid;
  align-items: center;
  gap: 0.875rem;
  padding: 0.25rem 0.5rem;
  border-radius: 0.625rem;
}

.collection-card-rows > .collection-row:hover {
  background: var(--bs-gray-100);
}

.collection-row-phones,
.collection-row-emails {
  grid-template-columns: 10.5rem minmax(0, 1fr) 10.5rem 2.5rem;
}

.collection-row-attachments {
  grid-template-columns: 12rem 10rem minmax(0, 1fr) 2.5rem;
}

.collection-row-attachments > [class*="col"] {
  width: auto;
  max-width: none;
  padding: 0;
}

/* A row's primary flag: the badge when its checkbox is on, else the button. */
.collection-row-primary .primary-badge,
.collection-row-primary:has(input[type="checkbox"]:checked) .primary-set {
  display: none;
}

.collection-row-primary:has(input[type="checkbox"]:checked) .primary-badge {
  display: inline-flex;
  align-items: center;
}

/* An address or a contact: a bordered card with a head line over its fields. */
.collection-item {
  padding: 1rem;
  border: 1px solid var(--bs-border-color);
  border-radius: 0.875rem;
}

.collection-item-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.875rem;
}

.collection-item-tile,
.collection-item-avatar {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  background: var(--pacto-tone);
  color: var(--pacto-tone-on);
}

.collection-item-tile {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.7rem;
  font-size: 1.2rem;
}

.collection-item-avatar {
  width: 2.875rem;
  height: 2.875rem;
  border-radius: 50%;
  font-weight: 800;
}

.collection-item-tile [class*="ki-"],
.collection-item-avatar [class*="ki-"] {
  color: inherit;
}

.collection-rows-contacts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* A modal is too narrow for two cards side by side: phones and emails were cut. */
.modal .collection-rows-contacts {
  grid-template-columns: minmax(0, 1fr);
}

@media (max-width: 991.98px) {
  .collection-rows-contacts {
    grid-template-columns: minmax(0, 1fr);
  }

  .collection-row-phones,
  .collection-row-emails,
  .collection-row-attachments {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

/* The header card over a record's form (shared/_record_header). */
.record-header-avatar {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 5.25rem;
  height: 5.25rem;
  border-radius: 1.25rem;
  background: var(--pacto-tone);
  color: var(--pacto-tone-on);
  font-size: 1.875rem;
  font-weight: 800;
  box-shadow: 0 10px 30px color-mix(in srgb, var(--pacto-tone) 45%, transparent);
}

.record-header-avatar-new {
  border: 2px dashed var(--bs-border-color);
  background: var(--bs-gray-100);
  box-shadow: none;
  color: var(--bs-gray-500);
}

.record-header-avatar [class*="ki-"] {
  color: inherit;
  font-size: 2rem;
}

.record-header-title {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.record-header-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.75rem;
  border: 1px solid var(--bs-border-color);
  border-radius: 999px;
  background: var(--bs-gray-100);
  color: var(--bs-gray-700);
  font-size: 0.8125rem;
}

.record-header-tile {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  height: 100%;
  padding: 0.875rem;
  border: 1px solid var(--bs-border-color);
  border-radius: 0.875rem;
}

.record-header-tile-icon {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  border-radius: 0.75rem;
  background: color-mix(in srgb, var(--pacto-tone) 14%, transparent);
  color: var(--pacto-tone);
  font-size: 1.5rem;
}

.record-header-tile-icon [class*="ki-"] {
  color: inherit;
}

.record-header-tile-value {
  font-size: 1.625rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.record-header-tile-caption {
  color: var(--bs-gray-600);
  font-size: 0.75rem;
  font-weight: 600;
}

/* A cargo's pickups or deliveries in the route card: a teal sub-card with its
   own Add (shipments/_stop_lists). */
.stop-list {
  border: 1px solid var(--bs-border-color);
  border-radius: 0.75rem;
  overflow: hidden;
}

.stop-list-head {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid color-mix(in srgb, var(--pacto-tone) 25%, transparent);
  background: color-mix(in srgb, var(--pacto-tone) 9%, var(--bs-card-bg));
}

.stop-list-head .form-section-tile,
.pacto-subheading .form-section-tile {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 0.5rem;
  font-size: 0.95rem;
}

.stop-list-head .form-section-title,
.pacto-subheading .form-section-title {
  font-size: 0.875rem;
}

/* A part of a page headed as a compact form section (New route's parts). */
.pacto-subheading {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.4rem 0.6rem;
  border-radius: 0.625rem;
  background: color-mix(in srgb, var(--pacto-tone) 9%, var(--bs-card-bg));
}

.stop-list-body {
  padding: 0.75rem;
}

/* A record page's tab bar, drawn as a form's tab card bar (the detail pages
   carry pacto-show-tabs; the invoice page keeps Metronic's line tabs). */
.pacto-show-tabs {
  align-items: center;
  gap: 0.25rem;
  margin-bottom: 1.5rem;
  padding: 0.25rem;
  border: 1px solid color-mix(in srgb, var(--pacto-accent) 18%, transparent);
  border-radius: 0.75rem;
  background: color-mix(in srgb, var(--pacto-accent) 9%, var(--bs-card-bg));
}

.pacto-show-tabs .nav-link {
  padding: 0.55rem 1rem;
  border: 0;
  border-radius: 0.55rem;
  color: var(--bs-gray-700);
  font-weight: 600;
}

.pacto-show-tabs .nav-link.active {
  background: var(--bs-primary);
  color: var(--bs-primary-inverse);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--bs-primary) 35%, transparent);
}

/* Views: multi-line text kept as typed, and the table AI's message bubbles. */
.text-pre-line {
  white-space: pre-line;
}

.chat-bubble {
  max-width: 85%;
}

/* Gus's flow bar and the screen map. docs/superpowers/specs/2026-10-31-workflow-v7-design.md */
.pacto-flow-nav { display: flex; align-items: stretch; gap: .5rem; padding: .5rem; border-radius: 1rem; background: var(--bs-card-bg); border: 1px solid var(--bs-border-color); }
.pacto-flow-step { flex: 1 1 0; min-width: 0; display: flex; align-items: center; gap: .75rem; padding: .7rem .9rem; border-radius: .75rem; border: 1px solid transparent; color: var(--bs-gray-800); }
a.pacto-flow-step:hover { background: var(--bs-gray-100); color: var(--bs-gray-900); }
.pacto-flow-step.active { background: var(--bs-primary-light); border-color: color-mix(in srgb, var(--bs-primary) 35%, transparent); }
.pacto-flow-step.is-static { cursor: default; border-style: dashed; border-color: var(--bs-border-color); }
.pacto-flow-icon { flex: 0 0 42px; height: 42px; border-radius: .7rem; display: grid; place-items: center; font-size: 1.4rem; color: var(--pacto-flow-c); background: color-mix(in srgb, var(--pacto-flow-c) 14%, transparent); }
.pacto-flow-icon i { color: inherit; font-size: inherit; }
.pacto-flow-step.active .pacto-flow-icon { color: #fff; background: var(--pacto-flow-c); }
.pacto-flow-ruta { --pacto-flow-c: #1B84FF; }
.pacto-flow-ops { --pacto-flow-c: #7239EA; }
.pacto-flow-carrier { --pacto-flow-c: #E07A2E; }
.pacto-flow-control { --pacto-flow-c: #17C653; }
.pacto-flow-text { display: flex; flex-direction: column; min-width: 0; }
.pacto-flow-label { font-size: 1.05rem; font-weight: 800; line-height: 1.2; white-space: nowrap; }
.pacto-flow-sep { flex: 0 0 auto; display: grid; place-items: center; color: var(--bs-gray-400); }
@media (max-width: 991.98px) { .pacto-flow-nav { flex-wrap: wrap; } .pacto-flow-step { flex: 1 1 45%; } .pacto-flow-sep { display: none; } }
.pacto-help-num { color: var(--bs-primary); background: var(--bs-primary-light); }
.pacto-help-edit { color: var(--bs-info); background: var(--bs-info-light); }
.pacto-help-miss { color: var(--bs-warning-active, #b58900); background: var(--bs-warning-light); }
.pacto-help-dir { color: var(--bs-success-active, #0f8a3c); background: var(--bs-success-light); }
.pacto-map { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.pacto-map-box { padding: 1rem; border-radius: .75rem; border: 2px solid var(--pacto-map-c, var(--bs-border-color)); text-align: center; background: var(--bs-card-bg); }
.pacto-map-box-title { font-size: 1.1rem; font-weight: 800; color: var(--bs-gray-900); }
.pacto-map-box-sub { font-size: .8rem; color: var(--bs-gray-600); }
.pacto-map-box.is-dashed { border-style: dashed; --pacto-map-c: var(--bs-gray-400); }
.pacto-map-walk { display: flex; flex-wrap: wrap; gap: .5rem; align-items: stretch; margin-bottom: 1rem; }
.pacto-map-walk-step { flex: 1 1 180px; padding: .6rem .8rem; border-radius: .6rem; background: var(--bs-gray-100); font-size: .85rem; }
.pacto-kv-label { font-size: .7rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--bs-gray-500); }
.pacto-views { display: flex; flex-wrap: wrap; gap: .4rem; }
.pacto-view { padding: .4rem .8rem; border-radius: .6rem; border: 1px solid var(--bs-border-color); font-weight: 700; color: var(--bs-gray-700); }
.pacto-view.active { background: var(--bs-primary-light); border-color: color-mix(in srgb, var(--bs-primary) 35%, transparent); color: var(--bs-primary); }
.pacto-stage-group { display: block; font-size: .65rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--bs-gray-500); }
.pacto-index-item { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .4rem .6rem; border-radius: .55rem; font-size: .85rem; font-weight: 600; color: var(--bs-gray-800); }
.pacto-index-item:hover { background: var(--bs-gray-100); }
.pacto-missing-field { outline: 2px dashed var(--bs-warning); outline-offset: 2px; border-radius: .45rem; }
.form-control.form-control-solid.pacto-pending,
.form-select.form-select-solid.pacto-pending { background-color: var(--bs-warning-light); }
/* A pending field with a placeholder stops being amber once something is typed in it. */
.form-control.form-control-solid.pacto-pending[placeholder]:not(:placeholder-shown) { background-color: var(--bs-gray-100); }
.pacto-stage-dot { display: inline-block; width: .5rem; height: .5rem; margin-right: .35rem; border-radius: 50%; background: var(--bs-gray-400); }
.pacto-stage-dot-por_validar, .pacto-stage-dot-asignado { background: var(--bs-purple, #7239ea); }
.pacto-stage-dot-enviado, .pacto-stage-dot-finalizado { background: var(--bs-primary); }
.pacto-stage-dot-en_negociacion { background: var(--bs-danger); }
.pacto-stage-dot-por_completar { background: var(--bs-warning); }
.pacto-stage-dot-sin_asignar, .pacto-stage-dot-en_curso { background: var(--bs-success); }
.pacto-stage-dot-perdido, .pacto-stage-dot-cancelado { background: #e8772e; }
:root { --pacto-route-1: #1b84ff; --pacto-route-2: #17c653; --pacto-route-3: #7239ea; --pacto-route-4: #f28c28; }
[data-bs-theme="dark"] { --pacto-route-1: #4da3ff; --pacto-route-2: #2edc8b; --pacto-route-3: #a47bff; --pacto-route-4: #ff9f43; }
.pacto-route-1 { color: var(--pacto-route-1); }
.pacto-route-2 { color: var(--pacto-route-2); }
.pacto-route-3 { color: var(--pacto-route-3); }
.pacto-route-4 { color: var(--pacto-route-4); }
.pacto-route-dot { width: 10px; height: 10px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.pacto-route-pt { display: block; width: 12px; height: 12px; border-radius: 50%; background: var(--bs-body-bg); border: 3px solid currentColor; }
.pacto-route-pt.is-end { background: currentColor; border-color: var(--bs-body-bg); box-shadow: 0 0 0 2px currentColor; }
.pacto-run-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.25rem; }
/* Full width and short, the trips could only be fitted at the zoom of a continent. */
.google-map.pacto-run-canvas { height: 360px; }
@media (min-width: 1680px) {
  .pacto-run-grid { grid-template-columns: 300px minmax(0, 1fr); }
  .google-map.pacto-run-canvas { height: 230px; }
}
.pacto-num { font-family: var(--bs-font-monospace); font-weight: 700; color: var(--bs-primary); border-bottom: 1px dashed currentColor; white-space: nowrap; }
.pacto-habitual { padding: .6rem .8rem; border: 1px dashed color-mix(in srgb, var(--bs-primary) 40%, transparent); border-radius: .6rem; background: var(--bs-primary-light); }

/* The ficha: where it was opened from, its state bar, what is missing. */
.pacto-origin { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; padding: .75rem 1rem; margin-bottom: 1rem; border-radius: .75rem; background: var(--bs-primary-light); border: 1px solid color-mix(in srgb, var(--bs-primary) 35%, transparent); }
.pacto-flow-states { display: grid; grid-template-columns: repeat(6, 1fr); gap: .5rem; }
.pacto-flow-state { padding: .4rem .5rem; border-radius: .5rem; text-align: center; font-size: .85rem; font-weight: 600; background: var(--bs-gray-100); color: var(--bs-gray-500); }
.pacto-flow-state.is-done { background: var(--bs-success-light); color: var(--bs-success); }
.pacto-flow-state.is-current { background: var(--bs-primary); color: var(--bs-white); }
/* A direct trip never was a quote. */
.pacto-flow-state.is-skipped { text-decoration: line-through; opacity: .5; }
.pacto-missing-chip { display: inline-block; min-width: 9rem; padding: .2rem .6rem; border-radius: .4rem; text-align: center; font-weight: 600; font-size: .85rem; background: var(--bs-warning-light); color: var(--bs-warning-text-emphasis); }
.pacto-missing-chip.is-client { background: var(--bs-info-light); color: var(--bs-info); }
.pacto-missing-chip.is-optional { background: transparent; border: 1px dashed var(--bs-border-color); color: var(--bs-gray-700); }
.pacto-came-to { padding: .1rem .5rem; border-radius: .4rem; font-size: .75rem; font-weight: 700; background: var(--bs-warning-light); color: var(--bs-warning-text-emphasis); }
.operation-section, .form-section, .form-section-body, #operation_route, .pacto-focus-target { scroll-margin-top: 6rem; }
@media (max-width: 767.98px) { .pacto-flow-states { grid-template-columns: repeat(3, 1fr); } }
.pacto-recipient { display: inline-flex; align-items: center; gap: .3rem; font-size: .78rem; font-weight: 700; color: var(--bs-gray-800); padding: .3rem .6rem; border-radius: 999px; background: var(--bs-gray-100); }
.pacto-recipient i { color: var(--bs-success); }
.pacto-miss-carrier { color: #B58A00; background: var(--bs-warning-light); }
[data-bs-theme="dark"] .pacto-miss-carrier { color: var(--bs-warning); }
.pacto-row-missing > td { background: color-mix(in srgb, var(--bs-warning-light) 60%, transparent); }
.pacto-map-wrap { overflow-x: auto; }
.pacto-map-svg { width: 100%; min-width: 900px; height: auto; display: block; }
.pacto-map-svg .pm-box { fill: var(--bs-body-bg); stroke-width: 2; }
.pacto-map-svg .pm-soft { fill: var(--bs-gray-100); }
.pacto-map-svg .pm-dash { stroke: var(--bs-gray-400); stroke-dasharray: 6 5; stroke-width: 1.5; }
.pacto-map-svg text { font-family: inherit; }
.pacto-map-svg .pm-title { font-size: 19px; font-weight: 800; fill: var(--bs-gray-900); text-anchor: middle; }
.pacto-map-svg .pm-sub { font-size: 13px; font-weight: 600; fill: var(--bs-gray-600); text-anchor: middle; }
.pacto-map-svg .pm-label { font-size: 13px; font-weight: 700; fill: var(--bs-gray-700); text-anchor: middle; }
.pacto-map-svg .pm-left { text-anchor: start; }
.pacto-map-svg .pm-line { fill: none; stroke: #99A1B7; stroke-width: 2; }
.pacto-map-svg .pm-bus { fill: none; stroke: var(--bs-gray-400); stroke-width: 2; }
.pacto-map-svg .pm-back { stroke: #99A1B7; stroke-dasharray: 5 5; stroke-width: 1.6; fill: none; }
.pacto-map-svg .pm-dot { stroke-dasharray: 2 4; }
.pacto-map-svg .pm-legend { font-size: 13px; font-weight: 600; fill: var(--bs-gray-700); }
a.pacto-map-walk-step { display: block; color: var(--bs-primary); }
a.pacto-map-walk-step:hover { background: var(--bs-primary-light); }

/* Bootstrap's link blue and Metronic's submenu grey fall short of readable on the dark background. */
[data-bs-theme="dark"] .table thead a {
  color: #7db4ff;
}

/* Bootstrap's alert row is pale pink whatever the theme, under the dark theme's light text. */
[data-bs-theme="dark"] .table-danger {
  --bs-table-color: rgb(245, 245, 245);
  --bs-table-bg: rgb(74, 32, 44);
  --bs-table-border-color: rgb(102, 48, 62);
  --bs-table-hover-color: rgb(245, 245, 245);
  --bs-table-hover-bg: rgb(88, 38, 52);
}

[data-bs-theme="dark"] .table tbody tr.table-danger,
[data-bs-theme="dark"] .table tbody tr.table-danger > td {
  color: rgb(245, 245, 245);
}

/* What sits in such a row was coloured for the page's own background: the blue
   number, the muted grey and the light-primary button all sank into the maroon. */
[data-bs-theme="dark"] .table tbody tr.table-danger a:not(.btn),
[data-bs-theme="dark"] .table tbody tr.table-danger .pacto-num {
  color: rgb(170, 204, 255);
}

[data-bs-theme="dark"] .table tbody tr.table-danger {
  --bs-secondary-color: rgb(218, 218, 218);
  --bs-text-muted: rgb(218, 218, 218);
  --bs-text-gray-500: rgb(218, 218, 218);
  --bs-text-gray-600: rgb(218, 218, 218);
  --bs-text-gray-700: rgb(225, 225, 225);
}

[data-bs-theme="dark"] .table tbody tr.table-danger .btn.btn-light-primary {
  color: rgb(255, 255, 255);
  background-color: var(--bs-primary);
}

[data-bs-theme="dark"] .app-sidebar .menu .menu-sub .menu-item .menu-link:not(.active):not(:hover) .menu-title {
  color: var(--bs-gray-700);
}

/* On white the solid fields' grey is hard to find; the dark theme's contrast already shows them. */
[data-bs-theme="light"] .form-control.form-control-solid:not(:focus),
[data-bs-theme="light"] .form-select.form-select-solid:not(:focus),
[data-bs-theme="light"] .select2-container--bootstrap5 .select2-selection.form-select-solid {
  border-color: var(--bs-gray-300);
}

/* Collapsed, the sidebar is too narrow for the build line: it read «3 No…». Hover
   does not widen it (no data-kt-app-sidebar-hoverable), so hover must not show it. */
[data-kt-app-sidebar-minimize="on"] .app-sidebar .pacto-build-version {
  display: none;
}

/* Metronic's light warning is #F6C000 on #FFF8DD, under 2:1 contrast. */
[data-bs-theme="light"] .badge.badge-light-warning,
[data-bs-theme="light"] .btn.btn-light-warning:not(:hover):not(:focus):not(:active):not(.active):not(.show),
[data-bs-theme="light"] .btn.btn-light-warning:not(:hover):not(:focus):not(:active):not(.active):not(.show) i {
  color: var(--bs-warning-text-emphasis);
}

.pacto-number {
  font-variant-numeric: tabular-nums;
}

/* Dark theme: Metronic's light-primary badge is blue text on dark blue, and a
   disabled light button almost vanishes. Both lifted, the light theme untouched. */
[data-bs-theme="dark"] .badge.badge-light-primary,
[data-bs-theme="dark"] .badge.badge-light-info {
  color: color-mix(in srgb, var(--bs-primary) 45%, #ffffff);
}

[data-bs-theme="dark"] .btn.btn-light:disabled,
[data-bs-theme="dark"] .btn.btn-light.disabled {
  color: var(--bs-gray-600);
  border: 1px dashed var(--bs-gray-400);
  opacity: 1;
}

/* Metronic draws scrollbars in gray-200, invisible on a white card: a list
   wider than its card (the preview or the views panel open) gave no sign
   that its last columns were there to scroll to. */
.pacto-list-scroll {
  scrollbar-width: auto;
  scrollbar-color: var(--bs-gray-500) var(--bs-gray-100);
}

.pacto-list-scroll::-webkit-scrollbar {
  height: 10px;
}

.pacto-list-scroll::-webkit-scrollbar-thumb {
  background-color: var(--bs-gray-500);
  border-radius: 5px;
}

/* A shipment's Acciones lists many steps: the menu scrolls inside, held by
   menu-fit to the room below its button. */
.pacto-actions-menu {
  overflow-y: auto;
}

/* The browser paints a field it filled in itself (a saved email or password)
   with its own pale fill, so at sign-in the two fields looked different. The
   inset shadow is the only paint it lets a page put over that fill. */
.form-control.form-control-solid:-webkit-autofill,
.form-control.form-control-solid:-webkit-autofill:hover,
.form-control.form-control-solid:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px var(--bs-gray-100) inset;
  -webkit-text-fill-color: var(--bs-gray-700);
  caret-color: var(--bs-gray-700);
}

/* A list's cell stays on one line: a long name or reference broke over three
   while the columns beside it had room. The list scrolls sideways instead,
   and prose wider than a column ends in an ellipsis (the preview has it whole). */
.pacto-list-scroll > .table > tbody > tr > td {
  white-space: nowrap;
  max-width: 24rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* A locked select (a contact's company, a vehicle's carrier, set by the page it
   was opened from) is native, and Chrome cut its name mid-letter. */
.form-select:disabled {
  text-overflow: ellipsis;
}

/* A chosen value of a multiple select (a carrier's zones): its × sat against
   the flag that starts the name. */
.select2-container--bootstrap5 .select2-selection--multiple:not(.form-select-sm):not(.form-select-lg) .select2-selection__choice .select2-selection__choice__display,
.select2-container--bootstrap5 .select2-selection--multiple.form-select-sm .select2-selection__choice .select2-selection__choice__display {
  margin-left: 1.45rem;
}

/* A greyed-out control's reasons (shared/_unavailable): read as a list, so left-aligned.
   The control itself lets the pointer through to the wrapper that carries them. */
.pacto-reasons-tooltip .tooltip-inner {
  text-align: left;
  max-width: 22rem;
}
.pacto-unavailable > .disabled,
.pacto-unavailable > :disabled {
  pointer-events: none;
}

/* An error on the field (FieldErrorMarkup): a select Select2 draws over is
   marked on its drawn box, and a list's row holding one is outlined. */
.is-invalid + .select2-container .select2-selection {
  border-color: var(--bs-danger);
}
[data-nested-form-target="field"]:has(.is-invalid) {
  box-shadow: inset 3px 0 0 var(--bs-danger);
}
.is-invalid ~ [data-field-error],
.input-group:has(.is-invalid) ~ [data-field-error] {
  display: block;
}
