/* Mudflap brand overrides on Zephyr's Bootstrap variables. */
:root,
[data-bs-theme="light"] {
  --bs-primary: rgb(4, 50, 186);
  --bs-primary-rgb: 4, 50, 186;
  --bs-primary-text-emphasis: rgb(4, 50, 186);
  --bs-primary-bg-subtle: rgba(4, 50, 186, 0.1);
  --bs-primary-border-subtle: rgba(4, 50, 186, 0.3);
  --bs-link-color: rgb(4, 50, 186);
  --bs-link-color-rgb: 4, 50, 186;
  --bs-link-hover-color: rgb(2, 30, 130);
  --bs-link-hover-color-rgb: 2, 30, 130;
  --bs-success: rgb(0, 186, 127);
  --bs-success-rgb: 0, 186, 127;
  --bs-success-text-emphasis: rgb(0, 110, 75);
  --bs-success-bg-subtle: rgba(0, 186, 127, 0.12);
  --bs-success-border-subtle: rgba(0, 186, 127, 0.3);
}
.btn-primary { --bs-btn-bg: rgb(4, 50, 186); --bs-btn-border-color: rgb(4, 50, 186); --bs-btn-hover-bg: rgb(2, 30, 130); --bs-btn-hover-border-color: rgb(2, 30, 130); --bs-btn-active-bg: rgb(2, 30, 130); --bs-btn-active-border-color: rgb(2, 30, 130); }
.btn-outline-primary { --bs-btn-color: rgb(4, 50, 186); --bs-btn-border-color: rgb(4, 50, 186); --bs-btn-hover-bg: rgb(4, 50, 186); --bs-btn-hover-border-color: rgb(4, 50, 186); --bs-btn-active-bg: rgb(4, 50, 186); --bs-btn-active-border-color: rgb(4, 50, 186); }
.bg-primary { background-color: rgb(4, 50, 186) !important; }
.text-bg-success { background-color: rgb(0, 186, 127) !important; color: #fff !important; }
.bg-success { background-color: rgb(0, 186, 127) !important; }
.alert-success { --bs-alert-bg: rgba(0, 186, 127, 0.12); --bs-alert-color: rgb(0, 110, 75); --bs-alert-border-color: rgba(0, 186, 127, 0.3); }

pre.payload { font-size: 12px; max-height: 70vh; overflow: auto; }

/* Zephyr's active nav treatment is a heavy dark block; hairline instead. */
.navbar .navbar-nav .nav-link { font-weight: 500; position: relative; }
.navbar .navbar-nav .nav-link.active { background-color: transparent; color: #fff; }
@media (min-width: 992px) {
  .navbar .navbar-nav .nav-link.active::after {
    content: "";
    position: absolute;
    left: var(--bs-navbar-nav-link-padding-x);
    right: var(--bs-navbar-nav-link-padding-x);
    bottom: 0.3rem;
    height: 1px;
    background: rgba(255, 255, 255, 0.5);
  }
}
/* Lifts the bar's dropdowns (z-index 1000) over a .card-pinned card at 1020. */
.navbar { position: relative; z-index: 1030; }

.toast {
  --bs-toast-max-width: 380px;
  --bs-toast-font-size: 0.9375rem;
  --bs-toast-padding-x: 0.875rem;
  --bs-toast-padding-y: 0.625rem;
  --bs-toast-box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.08);
}

/* Zephyr's dropdown hover is solid blue, and .text-danger wins on !important,
 * so a destructive item would hover as red on blue. */
.dropdown-item.text-danger:hover,
.dropdown-item.text-danger:focus { background-color: var(--bs-danger-bg-subtle); }

.ts-wrapper.form-select { --ts-pr-caret: 3rem; min-height: 0; box-shadow: var(--bs-box-shadow-inset); }
.ts-wrapper.form-select .ts-control { padding: 0.5rem 1rem; }
.ts-wrapper.form-select-sm .ts-control { padding: 0.25rem 0.5rem; }
.ts-dropdown { min-width: max-content; font-size: 0.875rem; color: var(--bs-body-color); }
.ts-wrapper.form-select.focus {
  border-color: rgb(from var(--bs-focus-ring-color) r g b / 50%);
  box-shadow: var(--bs-box-shadow-inset), 0 0 0 var(--bs-focus-ring-width) var(--bs-focus-ring-color);
}
.ts-wrapper.form-select.focus .ts-control { box-shadow: none; }
.ts-dropdown [data-selectable] .highlight { background: var(--bs-highlight-bg); }
.plugin-dropdown_input .dropdown-input,
.plugin-dropdown_input.focus .ts-dropdown .dropdown-input {
  color: var(--bs-body-color);
  border-color: var(--bs-border-color);
  outline: 0;
  box-shadow: none;
}
/* Tom Select can only open its list inside the modal, so the SBFE search keeps room
   below the form for the State list. Capped by the window so the footer stays visible. */
.uw-sbfe-search-body { min-height: min(29rem, calc(100vh - 10rem)); }
/* Between Bootstrap's py-2 and py-3 steps: compact, but not cramped. */
.uw-sbfe-results { --bs-list-group-item-padding-y: 0.75rem; }

/* Zephyr maps "secondary" to white, so neutral badges come out invisible.
 * !important mirrors the utilities being overridden. */
.badge.bg-secondary-subtle,
.badge.text-bg-secondary,
.badge.text-bg-light {
  background-color: var(--bs-gray-100) !important;
  color: var(--bs-gray-700) !important;
  border: 1px solid var(--bs-gray-300);
}

.navbar .btn-outline-light,
.navbar .btn-outline-light:focus,
.navbar .btn-outline-light:active { color: #fff; --bs-btn-color: #fff; }

.collapsible-card .collapsible-toggle { width: 100%; border: 0; text-align: left; display: flex; align-items: center; gap: 0.5rem; cursor: pointer; background-color: var(--bs-tertiary-bg) !important; }
.collapsible-card .collapsible-toggle:hover { background-color: var(--bs-secondary-bg) !important; }
/* A split header (toggle plus a control beside it): the strip carries the colour so the
   control shares it, and darkens only over the toggle, since clicking the control doesn't collapse. */
.collapsible-card .collapsible-header { background-color: var(--bs-tertiary-bg); }
.collapsible-card .collapsible-header:has(.collapsible-toggle:hover) { background-color: var(--bs-secondary-bg); }
.collapsible-card .collapsible-header .collapsible-toggle { background-color: transparent !important; }
.minimizable-card > .collapsible-header { border-bottom: var(--bs-card-border-width) solid var(--bs-card-border-color); border-radius: var(--bs-card-inner-border-radius) var(--bs-card-inner-border-radius) 0 0; }
.minimizable-card > .card-body.collapsing { transition: none; }
.collapsible-card .collapsible-toggle:focus-visible { outline: 2px solid var(--bs-primary); outline-offset: -2px; }
.collapsible-card .collapse-chevron { flex-shrink: 0; width: 0.5rem; height: 0.5rem; border-right: 2px solid var(--bs-secondary-color); border-bottom: 2px solid var(--bs-secondary-color); transform: rotate(-45deg); transition: transform 0.2s ease; margin-bottom: 2px; }
.collapsible-card .collapsible-toggle[aria-expanded="true"] .collapse-chevron { transform: rotate(45deg); margin: -2px 0 0 0; }
/* Bootstrap cannot shrink a collapsing tbody — CSS height is a minimum on a
   table-row-group — so its transition animates nothing and only delays the
   rows hiding. It also swallows input: show()/hide() no-op while an instance
   is transitioning, so a toggle clicked during the wait is dropped. */
tbody.collapsing { transition: none; }
/* No font-size: one here outranks Bootstrap's relative utilities on source
   order, so `mono small` would take it instead of .small's. */
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.admin-link-id { color: inherit; text-decoration: none; transition: color 0.15s; }
.admin-link-id:hover, .admin-link-id:focus-visible { color: var(--bs-primary); text-decoration: none; outline: none; }
.admin-link-id .admin-link-arrow { display: inline-block; margin-left: 2px; font-size: 0.85em; color: var(--bs-secondary-color); transition: color 0.15s, transform 0.15s; }
.admin-link-id:hover .admin-link-arrow, .admin-link-id:focus-visible .admin-link-arrow { color: var(--bs-primary); transform: translate(1px, -1px); }

/* Markdown-rendered LLM responses */
.markdown-body h1, .markdown-body h2 { font-size: 1.1rem; margin: 1rem 0 0.5rem; padding-bottom: 0.25rem; border-bottom: 1px solid var(--bs-border-color); }
.markdown-body h3, .markdown-body h4 { font-size: 0.95rem; font-weight: 600; margin: 0.75rem 0 0.25rem; }
.markdown-body ul { padding-left: 1.5rem; }
.markdown-body li { margin-bottom: 0.1rem; }
.markdown-body code { background: var(--bs-secondary-bg); padding: 0 4px; border-radius: 3px; font-size: 0.85em; }
.markdown-body pre { background: var(--bs-secondary-bg); padding: 12px; border-radius: 4px; overflow: auto; }
.markdown-body table { width: 100%; margin: 0.5rem 0; font-size: 0.875rem; border-collapse: collapse; }
.markdown-body table th, .markdown-body table td { padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--bs-border-color); text-align: left; vertical-align: top; }
.markdown-body table th { font-weight: 600; color: var(--bs-secondary-color); border-bottom-width: 2px; }
.markdown-body table tbody tr:hover { background-color: var(--bs-tertiary-bg); }

.stat-tile-label { font-size: 10.5px; color: var(--bs-secondary-color); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 2px; line-height: 1.2; }
.stat-tile-value { font-size: 17px; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat-tile.tone-neutral .stat-tile-value { color: var(--bs-secondary-color); }
.stat-tile.tone-good .stat-tile-value { color: var(--bs-success-text-emphasis); }
.stat-tile.tone-warn .stat-tile-value { color: var(--bs-warning-text-emphasis); }
.stat-tile.tone-alert .stat-tile-value { color: var(--bs-danger-text-emphasis); }

/* Underwriting application page chrome */

/* Lifts the header's dropdowns (z-index 1000) over a .card-pinned card at 1020,
   while staying below .navbar's own 1030 so the nav dropdowns aren't clipped. */
.uw-page-header {
  position: relative;
  z-index: 1025;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--bs-border-color);
}
.uw-page-title { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.015em; color: var(--bs-primary); line-height: 1.1; }


.uw-references .table th, .uw-references .table td { padding: 0.55rem 0.85rem; }
.uw-row-label { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--bs-secondary-color); vertical-align: middle; }
.uw-source-badge { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.7rem; font-weight: 600; letter-spacing: 0.02em; padding: 0.25em 0.55em; }

/* No Bootstrap colour utility on the element: those win on !important. The base
   carries solved, closed and any status Zendesk adds before we style it. */
.uw-ticket-status { background-color: rgb(91, 105, 112); color: #fff; }
.uw-ticket-status--new { background-color: rgb(252, 163, 71); color: var(--bs-dark); }
.uw-ticket-status--open { background-color: rgb(205, 54, 66); }
.uw-ticket-status--pending { background-color: rgb(31, 115, 182); }
.uw-ticket-status--hold { background-color: rgb(28, 34, 39); }
.uw-status-swatch { display: inline-block; width: .75rem; height: .75rem; border-radius: var(--bs-border-radius-sm); }
.btn-group-sm > .btn + .uw-split-toggle { padding-inline: .75rem; border-left-color: rgba(var(--bs-white-rgb), .35); }

.uw-flag-icon { width: 1rem; height: 1rem; flex-shrink: 0; }
.uw-sales-priority-icon { vertical-align: -0.125em; }
.uw-flag-trigger { display: inline-flex; align-items: center; padding: 0.25rem 0.5rem; }

/* Underwriting dashboard */

.uw-stat .card-body { padding: 1rem 1.15rem; }
.uw-stat-label { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; color: var(--bs-secondary-color); margin-bottom: 0.15rem; }
.uw-stat-value { font-size: 2.1rem; font-weight: 700; line-height: 1.05; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; color: var(--bs-emphasis-color); }

.uw-stat-link { display: block; color: inherit; transition: transform 0.12s ease, box-shadow 0.12s ease; }
.uw-stat-link:hover { transform: translateY(-2px); box-shadow: 0 0.35rem 0.85rem rgba(4, 50, 186, 0.12) !important; }
.uw-stat-link:hover .uw-stat-value { color: var(--bs-primary); }
.uw-stat-link:focus-visible { outline: 2px solid var(--bs-primary); outline-offset: 2px; }

.uw-col-label { font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--bs-secondary-color); border-bottom-width: 2px; white-space: nowrap; }
.uw-sort-link { color: inherit; text-decoration: none; transition: color 0.12s ease; }
.uw-sort-link:hover, .uw-sort-link:focus-visible { color: var(--bs-primary); }
.uw-sort-arrow { margin-left: 0.25em; }
.uw-sort-hint { margin-left: 0.25em; opacity: 0.5; }
.uw-sort-link:hover .uw-sort-hint, .uw-sort-link:focus-visible .uw-sort-hint { opacity: 1; }
.uw-row-title { color: var(--bs-body-color); transition: color 0.12s ease; }
.uw-row-title:hover, .uw-row-title:focus-visible { color: var(--bs-primary); }
.uw-row-chevron { color: var(--bs-secondary-color); font-size: 1.15rem; line-height: 1; display: inline-block; transition: transform 0.12s ease, color 0.12s ease; }
.uw-row-chevron:focus-visible { outline: 2px solid var(--bs-primary); outline-offset: 2px; border-radius: 2px; }
.uw-row-link { cursor: pointer; }
.uw-row-link:hover .uw-row-chevron { color: var(--bs-primary); transform: translateX(3px); }
.uw-row-link:hover .uw-row-title { color: var(--bs-primary); }

.table-hover > tbody > tr.uw-row-link:hover > * { --bs-table-bg-state: rgba(4, 50, 186, 0.04); }
/* Bootstrap paints a cell's hover tint with this same box-shadow; keep its layer after the stripe. */
.table > tbody > tr.uw-priority-stripe > :first-child {
  box-shadow: inset 3px 0 0 var(--bs-warning),
    inset 0 0 0 9999px var(--bs-table-bg-state, var(--bs-table-bg-type, var(--bs-table-accent-bg)));
}

/* Relative timestamps ("about 1 hour ago") read poorly wrapped mid-phrase. */
.table time { white-space: nowrap; }

/* Numeric values in the body face; .mono is for identifiers only. */
.tabular { font-variant-numeric: tabular-nums; }
/* Drawn inside the pinned cell, not as border-end: under the table's collapsed
   borders a pinned cell's border stays with the grid and scrolls away. */
.weekly-financials-table > :not(caption) > tr > .position-sticky::after {
  content: ""; position: absolute; top: 0; right: 0; bottom: 0;
  border-right: var(--bs-border-width) solid var(--bs-border-color);
}

.text-orange { color: color-mix(in srgb, var(--bs-orange) 75%, black); }


:root {
  --muddy-blue: rgb(4, 50, 186);
  --muddy-blue-deep: rgb(2, 26, 110);
  --muddy-grad: linear-gradient(135deg, rgb(27, 74, 214) 0%, rgb(4, 50, 186) 55%, rgb(2, 26, 110) 100%);
  --muddy-ink: rgb(30, 35, 48);
  --muddy-muted: rgb(112, 119, 136);
  --muddy-hairline: rgba(18, 28, 60, 0.1);
  --muddy-field: rgb(246, 247, 250);
  --muddy-shadow:
    0 24px 64px -16px rgba(8, 18, 58, 0.28),
    0 8px 24px -8px rgba(8, 18, 58, 0.14),
    0 0 0 1px rgba(18, 28, 60, 0.05);
}

/* --- Launcher ------------------------------------------------------------ */

.chat-launcher {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  z-index: 1040;
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 50%;
  background: var(--muddy-blue);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(4, 50, 186, 0.38);
  transition: transform 160ms ease, box-shadow 160ms ease;
  animation: muddy-pop 320ms cubic-bezier(0.34, 1.4, 0.4, 1) both;
}
.chat-launcher:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 10px 28px rgba(4, 50, 186, 0.45);
}
.chat-launcher:active { transform: translateY(0) scale(0.97); }
.chat-launcher svg { width: 24px; height: 24px; transition: transform 200ms ease, opacity 200ms ease; }
.chat-launcher .chat-launcher-close { display: none; }
.chat-open .chat-launcher .chat-launcher-open { display: none; }
.chat-open .chat-launcher .chat-launcher-close { display: block; }

@keyframes muddy-pop {
  from { transform: scale(0.6); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* --- Panel --------------------------------------------------------------- */

.chat-panel {
  position: fixed;
  right: 1.5rem;
  bottom: 6rem;
  z-index: 1040;
  width: min(480px, calc(100vw - 3rem));
  height: min(780px, calc(100vh - 7.5rem));
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid var(--muddy-hairline);
  border-radius: 16px;
  box-shadow: var(--muddy-shadow);
  opacity: 0;
  transform: translateY(12px) scale(0.97);
  transform-origin: bottom right;
  pointer-events: none;
  transition: opacity 200ms ease, transform 220ms cubic-bezier(0.32, 1.2, 0.36, 1);
  overflow: hidden;
}
.chat-open .chat-panel { opacity: 1; transform: none; pointer-events: auto; }

/* --- Header -------------------------------------------------------------- */

.chat-panel-header {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.75rem 0.875rem;
  border-bottom: 1px solid var(--muddy-hairline);
  background: #fff;
}
.chat-avatar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: var(--muddy-grad);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 2px 6px rgba(4, 50, 186, 0.25);
}
.chat-avatar svg { width: 18px; height: 18px; }
.chat-panel-titles { flex: 1; min-width: 0; }
.chat-panel-title { font-size: 0.9375rem; font-weight: 650; color: var(--muddy-ink); line-height: 1.2; }
.chat-panel-close {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muddy-muted);
  transition: background 140ms ease, color 140ms ease;
}
.chat-panel-close:hover { background: var(--muddy-field); color: var(--muddy-ink); }
.chat-panel-close svg { width: 15px; height: 15px; }

/* --- Messages ------------------------------------------------------------ */

.chat-panel-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.125rem 0.75rem;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(18, 28, 60, 0.18) transparent;
}
.chat-panel-messages::-webkit-scrollbar { width: 8px; }
.chat-panel-messages::-webkit-scrollbar-thumb {
  background: rgba(18, 28, 60, 0.18);
  border-radius: 4px;
  border: 2px solid #fff;
}

.chat-message {
  margin-bottom: 1.125rem;
  font-size: 0.84rem;
  line-height: 1.55;
  color: var(--muddy-ink);
  animation: muddy-rise 260ms cubic-bezier(0.2, 0.7, 0.3, 1) both;
}
@keyframes muddy-rise {
  from { transform: translateY(6px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.chat-message-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.2rem;
}
.chat-message-sender {
  font-size: 0.64rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muddy-muted);
}
.chat-message-time {
  font-size: 0.66rem;
  color: var(--muddy-muted);
  font-variant-numeric: tabular-nums;
}

.chat-message--user {
  background: var(--muddy-field);
  margin: 0 -1.125rem 1.125rem;
  padding: 0.625rem 1.125rem 0.6875rem;
}

.chat-message--assistant .chat-message-sender { color: var(--muddy-blue); }

.chat-message-body > :last-child { margin-bottom: 0; }
.chat-message-body p { margin-bottom: 0.5rem; }
.chat-message-body ul, .chat-message-body ol { padding-left: 1.25rem; margin-bottom: 0.5rem; }
.chat-message-body li { margin-bottom: 0.125rem; }
.chat-message-body a { color: var(--muddy-blue); }

.chat-cite {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-left: 4px;
  padding: 0 6px;
  font-size: 0.72em;
  line-height: 1.5;
  white-space: nowrap;
  vertical-align: baseline;
  color: var(--muddy-blue);
  background: var(--muddy-field);
  border: 1px solid var(--muddy-hairline);
  border-radius: 10px;
  text-decoration: none;
  cursor: pointer;
}
.chat-cite::before { content: "\2197"; font-size: 0.9em; opacity: 0.7; } /* up-right arrow */
.chat-cite:hover { background: var(--muddy-hairline); text-decoration: none; }

@keyframes cite-flash {
  0%   { box-shadow: 0 0 0 3px rgba(var(--bs-primary-rgb), 0.45); }
  100% { box-shadow: 0 0 0 3px rgba(var(--bs-primary-rgb), 0); }
}
/* Citation scroll lands the section header near the top, with breathing room. */
[data-cite-id] { scroll-margin-top: 1rem; }

.cite-highlight {
  animation: cite-flash 2s ease-out;
  border-radius: 8px;
}

@keyframes comment-flash {
  0%, 25% { box-shadow: 0 0 0 0.25rem rgba(var(--bs-primary-rgb), 0.4); }
  100%    { box-shadow: 0 0 0 0.25rem rgba(var(--bs-primary-rgb), 0); }
}
.comment-highlight {
  animation: comment-flash 2s ease-out;
  border-radius: var(--bs-border-radius);
  scroll-margin-top: 0.5rem;
}

@keyframes row-flash {
  0%, 25% { background-color: var(--bs-primary-bg-subtle); }
}
.uw-row-new > * {
  --bs-table-bg-type: rgba(var(--bs-primary-rgb), 0.06);
  animation: row-flash 3s ease-out;
}

.chat-message-body code {
  background: var(--muddy-field);
  border: 1px solid var(--muddy-hairline);
  padding: 0 4px;
  border-radius: 4px;
  font-size: 0.78em;
}
.chat-message-body pre {
  font-size: 0.72rem;
  padding: 0.625rem 0.75rem;
  background: var(--muddy-field);
  border: 1px solid var(--muddy-hairline);
  border-radius: 8px;
}
.chat-message-body pre code { background: none; border: 0; padding: 0; }
.chat-message-body blockquote {
  border-left: 3px solid var(--muddy-hairline);
  padding-left: 0.75rem;
  color: var(--muddy-muted);
  margin: 0.5rem 0;
}
.chat-message-body :is(h1, h2, h3, h4, h5, h6) {
  font-size: 0.875rem;
  font-weight: 650;
  margin: 0.875rem 0 0.3rem;
  color: var(--muddy-ink);
}
.chat-message-body hr { margin: 0.75rem 0; border-color: var(--muddy-hairline); opacity: 1; }

.chat-message-body table {
  width: 100%;
  margin: 0.625rem 0;
  border-collapse: collapse;
  font-size: 0.78rem;
}
.chat-message-body th {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muddy-muted);
}
.chat-message-body th, .chat-message-body td {
  padding: 0.3rem 0.5rem;
  border-bottom: 1px solid var(--muddy-hairline);
  text-align: left;
}
.chat-message-body tbody tr:last-child td { border-bottom: 0; }
.chat-message-body td { font-variant-numeric: tabular-nums; }

.chat-message--tool {
  margin: -0.625rem 0 1.125rem;
  animation: muddy-rise 260ms cubic-bezier(0.2, 0.7, 0.3, 1) both;
}
.chat-tool-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  max-width: 100%;
  padding: 0.125rem 0.5625rem;
  border: 1px solid var(--muddy-hairline);
  border-radius: 999px;
  background: var(--muddy-field);
  font-size: 0.66rem;
  color: var(--muddy-muted);
}
.chat-tool-chip .chat-tool-arrow { color: rgba(4, 50, 186, 0.55); font-weight: 600; }
.chat-tool-chip .mono { font-size: 0.66rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Agent-rendered chart (render_chart tool). Canvas needs a bounded height
   since Chart.js is responsive with maintainAspectRatio:false. */
.chat-chart {
  width: 100%;
  margin: 0.25rem 0;
  padding: 0.5rem;
  background: #fff;
  border: 1px solid var(--muddy-hairline);
  border-radius: 8px;
}
.chat-chart-canvas { position: relative; height: 220px; }
.chat-chart-data { margin-top: 0.5rem; }
.chat-chart-data > summary { cursor: pointer; font-size: 0.72rem; color: var(--muddy-blue); }
.chat-chart-data table { font-size: 0.72rem; margin-top: 0.25rem; }

.chat-message-thinking { margin-bottom: 0.375rem; }
.chat-message-thinking summary {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  list-style: none;
  font-size: 0.66rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muddy-muted);
  cursor: pointer;
  user-select: none;
}
.chat-message-thinking summary::-webkit-details-marker { display: none; }
.chat-message-thinking summary::before {
  content: "";
  width: 0.32rem;
  height: 0.32rem;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 160ms ease;
  margin-bottom: 1px;
}
.chat-message-thinking[open] summary::before { transform: rotate(45deg); margin-bottom: 3px; }
.chat-message-thinking summary:hover { color: var(--muddy-ink); }
.chat-message-thinking-body {
  margin: 0.375rem 0 0.625rem;
  font-size: 0.76rem;
  line-height: 1.5;
  color: var(--muddy-muted);
}
.chat-message-thinking-body > :last-child { margin-bottom: 0; }

.chat-draft-caret {
  display: inline-block;
  width: 2px;
  height: 0.9em;
  margin-left: 2px;
  vertical-align: -0.12em;
  background: var(--muddy-blue);
  animation: muddy-caret 1s steps(2, jump-none) infinite;
}
@keyframes muddy-caret { 50% { opacity: 0; } }

/* --- Empty state ----------------------------------------------------------- */

#chat-messages:has(.chat-message) .chat-panel-empty { display: none; }
.chat-panel-empty { padding: 2.25rem 0.5rem 1rem; text-align: center; }
.chat-panel-empty .chat-avatar {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  margin: 0 auto 0.75rem;
}
.chat-panel-empty .chat-avatar svg { width: 23px; height: 23px; }
.chat-panel-empty-title { font-size: 0.9375rem; font-weight: 650; color: var(--muddy-ink); margin-bottom: 0.25rem; }
.chat-panel-empty-sub { font-size: 0.76rem; color: var(--muddy-muted); }

/* --- Status / typing ------------------------------------------------------- */

.chat-panel-status { font-size: 0.7rem; color: var(--muddy-muted); }
.chat-panel-status:not(:empty) { padding: 0.125rem 1.125rem 0.5rem; }
.chat-typing { display: inline-flex; align-items: center; gap: 0.5rem; }
.chat-typing-dots { display: inline-flex; gap: 3px; }
.chat-typing-dots i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--muddy-blue);
  opacity: 0.35;
  animation: muddy-dot 1.2s ease-in-out infinite;
}
.chat-typing-dots i:nth-child(2) { animation-delay: 0.15s; }
.chat-typing-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes muddy-dot {
  0%, 60%, 100% { opacity: 0.35; transform: none; }
  30% { opacity: 1; transform: translateY(-2px); }
}
.chat-status-failed { color: var(--bs-danger); }

/* --- Composer -------------------------------------------------------------- */

.chat-panel-form { padding: 0.75rem 0.875rem 0.875rem; border-top: 1px solid var(--muddy-hairline); background: #fff; }
.chat-composer {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.25rem 0.25rem 0.875rem;
  border: 1px solid var(--muddy-hairline);
  border-radius: 999px;
  background: var(--muddy-field);
  transition: border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}
.chat-composer:focus-within {
  border-color: rgba(4, 50, 186, 0.45);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(4, 50, 186, 0.12);
}
.chat-composer-input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 0.84rem;
  color: var(--muddy-ink);
  padding: 0.375rem 0;
}
.chat-composer-input::placeholder { color: var(--muddy-muted); }
.chat-composer-send {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: var(--muddy-blue);
  color: #fff;
  box-shadow: 0 2px 6px rgba(4, 50, 186, 0.3);
  transition: transform 140ms ease, box-shadow 140ms ease;
}
.chat-composer-send:hover:not(:disabled) { transform: scale(1.06); box-shadow: 0 4px 10px rgba(4, 50, 186, 0.38); }
.chat-composer-send:active:not(:disabled) { transform: scale(0.94); }
.chat-composer-send:disabled {
  background: var(--muddy-muted);
  box-shadow: none;
  cursor: not-allowed;
}
.chat-composer-send svg { width: 15px; height: 15px; margin: 1px 1px 0 0; }

/* --- Reduced motion -------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .chat-panel, .chat-launcher, .chat-launcher svg, .chat-message, .chat-message--tool,
  .chat-composer, .chat-composer-send {
    transition: none;
    animation: none;
  }
  .chat-typing-dots i { animation: none; opacity: 0.8; }
  .chat-draft-caret { animation: none; }
}

.uw-note-body { white-space: pre-wrap; }
.form-control.uw-note-editor { field-sizing: content; min-height: calc(7lh + 1rem + 2 * var(--bs-border-width)); }
.application-notes-frame { display: contents; }

@media (min-width: 992px) {
  .application-workspace,
  .application-notes-pane,
  .application-report-pane { min-height: 0; }
  .application-notes-pane--populated { max-height: 30%; }
  .application-notes-pane--populated:has(.application-note-composer) { min-height: calc(7 * 1.5 * .875rem + 3.25rem + 6 * var(--bs-border-width)); }
  .application-notes-pane--populated > .card { max-height: 100%; }
  .application-notes-pane--populated .row,
  .application-notes-pane--populated .row > * { min-height: 0; }
  .application-notes-pane--populated .row > * { height: 100%; }
  .application-report-pane { scrollbar-gutter: stable; }
}

/* z-index 1020 is the sticky layer: under .back-to-top (1030), Muddy (1040),
 * modals (1055). The shadow is spelled out because Zephyr's --bs-box-shadow-lg
 * (0 1px 3px) is shallower than its -sm, so no shadow-* utility can carry a
 * white-on-white overlap. */
.card-pinned {
  position: sticky;
  top: 0;
  z-index: 1020;
  max-height: 50vh;
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}
.card-pinned .card-body { overflow-y: auto; min-height: 0; }

/* The notes card carries an mb-4 utility, which only another !important can take back.
 * The body's flex is keyed on .show so it can't beat Bootstrap's .collapse:not(.show)
 * display: none. */
.uw-workspace-notes > .card { flex: 1 1 auto; min-height: 0; max-height: none; margin-bottom: 0 !important; }
.uw-workspace-notes .card-body.show { flex: 1 1 auto; display: flex; flex-direction: column; }
.uw-workspace-notes .card-body.show > div { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }
.uw-workspace-notes textarea { flex: 1 1 auto; min-height: 0; resize: none; }
.uw-workspace-notes:has(> .card > .collapse:not(.show)) { height: auto !important; }
.uw-workspace-notes:has(> .card > .collapse:not(.show)) + .uw-workspace-handle { visibility: hidden; }
/* The fold animates the body's fixed height, not the pane's percentage, so the
 * textarea drops to its rows mid-fold and the pane snaps only at the end. */
.uw-workspace-notes .card-body.collapsing { transition: none; }

.uw-workspace-handle {
  flex: 0 0 0.5rem;
  cursor: col-resize;
  touch-action: none;
  border-radius: var(--bs-border-radius-sm);
}
.uw-workspace-handle[aria-orientation="horizontal"] { cursor: row-resize; }
.uw-workspace-rail { flex: 0 0 2.75rem; background-color: var(--bs-body-bg); }
.uw-workspace-rail:hover { background-color: rgba(var(--bs-primary-rgb), 0.05); }
.uw-workspace-rail-text { writing-mode: vertical-rl; }

.uw-queue-rail { border-bottom: var(--bs-border-width) solid var(--bs-border-color); }
.uw-queue-rail .list-group-item { min-width: 5rem; }
.uw-queue-rail-caption { font-size: 0.75rem; line-height: 1rem; }
@media (min-width: 992px) {
  .uw-queue-rail { width: 5rem; border-bottom: 0; border-right: var(--bs-border-width) solid var(--bs-border-color); }
}
.uw-queue-page .uw-page-header { margin-bottom: 0.5rem !important; }
.uw-queue-page .uw-queue-content > .nav-tabs { margin-bottom: 0 !important; }
.uw-queue-page .uw-queue-content > .card { border-top: 0; border-top-left-radius: 0; border-top-right-radius: 0; }
@media (max-width: 991.98px) {
  .uw-queue-page .uw-queue-content { overflow-y: auto; }
}
@media (min-width: 992px) {
  .uw-queue-page .uw-queue-content > :not(.card) { flex-shrink: 0; }
  .uw-queue-page .uw-queue-content > .card { flex: 0 1 auto; min-height: 0; margin-bottom: 0 !important; }
  /* Every flex box from main down to here needs min-height: 0, or the table grows
   * instead of scrolling and its last rows end up clipped under the overflow-hidden body. */
  .uw-queue-page .uw-queue-content > .card > .table-responsive {
    flex: 0 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: none;
  }
  .uw-queue-page .uw-queue-content > .card > .table-responsive > .table { border-collapse: separate; border-spacing: 0; }
  .uw-queue-page .uw-queue-content > .card > .table-responsive > .table > thead > tr > th {
    position: sticky;
    top: 0;
    z-index: 2;
    line-height: 1rem;
    border-bottom-width: 0;
  }
  .uw-queue-page .uw-queue-content > .card > .table-responsive > .table > thead > tr > th::after {
    content: ""; position: absolute; left: 0; right: 0; bottom: 0;
    border-bottom: 2px solid var(--bs-table-border-color);
  }
  /* Sticky on the row, not the cell, so the next group pushes it out instead of covering it.
   * 3rem is the column header row (1rem cell padding top and bottom plus its pinned 1rem
   * line-height); the 1px overlap tucks this row under the header's divider. */
  .uw-queue-page .uw-queue-content > .card > .table-responsive > .table > tbody > tr:has(> th[scope="rowgroup"]) {
    position: sticky;
    top: calc(3rem - 1px);
    z-index: 1;
  }
  .uw-queue-page .uw-queue-content > .card > .table-responsive > .table > tbody > tr > th[scope="rowgroup"] {
    position: relative;
    border-bottom-width: 0;
  }
  .uw-queue-page .uw-queue-content > .card > .table-responsive > .table > tbody > tr > th[scope="rowgroup"]::after {
    content: ""; position: absolute; left: 0; right: 0; bottom: 0;
    border-bottom: var(--bs-border-width) solid var(--bs-table-border-color);
  }
}
.uw-composer-body { resize: none; }
.uw-composer-box:focus-within {
  border-color: rgba(var(--bs-primary-rgb), 0.5);
  box-shadow: 0 0 0 0.25rem rgba(var(--bs-primary-rgb), 0.25);
}
.uw-visibility-menu {
  --bs-dropdown-link-hover-color: var(--bs-body-color);
  --bs-dropdown-link-hover-bg: rgba(var(--bs-primary-rgb), 0.1);
  --bs-dropdown-link-active-color: var(--bs-body-color);
  --bs-dropdown-link-active-bg: rgba(var(--bs-primary-rgb), 0.1);
}
.uw-visibility-menu .uw-internal-option { background-color: rgba(var(--bs-warning-rgb), 0.35); }
.uw-visibility-menu .uw-internal-option:hover,
.uw-visibility-menu .uw-internal-option:focus-visible,
.uw-visibility-menu .uw-internal-option:active { background-color: var(--bs-warning-bg-subtle); }
.uw-workspace-handle:hover,
.uw-workspace-handle:focus-visible {
  background: rgba(var(--bs-primary-rgb), 0.25);
  outline: none;
}

/* A side panel, not a modal: Bootstrap's backdrop would block the panes, so the
 * dim ignores the pointer. Sits over the navbar (1030), under the drawer (1045). */
.uw-decision-drawer { --bs-offcanvas-width: 720px; }
.uw-workspace-dim {
  position: fixed;
  inset: 0;
  z-index: 1040;
  background: rgba(var(--bs-dark-rgb), 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.is-open > .uw-workspace-dim { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .uw-workspace-dim { transition: none; }
}

.back-to-top {
  --bs-btn-bg: var(--bs-body-bg);
  position: fixed;
  right: 0;
  top: 50%;
  z-index: 1030;
  translate: 100% -50%;
  opacity: 0;
  visibility: hidden;
  border-start-end-radius: 0;
  border-end-end-radius: 0;
  transition: translate 200ms ease, opacity 200ms ease, visibility 200ms;
}
.back-to-top.is-visible { translate: 0 -50%; opacity: 1; visibility: visible; }
.back-to-top-icon { width: 1.25rem; height: 1.25rem; display: block; }

@media (prefers-reduced-motion: reduce) {
  .back-to-top { transition: none; }
}

.match-token { background-color: var(--bs-highlight-bg); box-shadow: 0 0 0 2px var(--bs-highlight-bg); border-radius: 2px; }
.min-w-0 { min-width: 0; }
.min-h-0 { min-height: 0; }
.overscroll-contain { overscroll-behavior: contain; }

/* Fixed columns so the same fact lines up across candidates. */
.usdot-facts {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1.6fr);
  gap: 0.5rem 1.25rem;
}
@media (max-width: 991.98px) {
  .usdot-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
