:root {
  --rca-navy: #1B2E52;
  --rca-navy-deep: #13213C;
  --rca-teal: #2CA6AF;
  --rca-teal-light: #4FC3CC;
  --rca-gold: #C9A66B;
  --rca-green: #1A7A4A;
  --rca-amber: #C98A1B;
  --rca-red: #B5211A;
}

/* Login */

.rca-login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--rca-navy-deep), var(--rca-navy));
}

.rca-login-card {
  width: 100%;
  max-width: 380px;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 20px 45px rgba(13, 21, 38, 0.35);
  padding: 2.5rem 2rem;
}

.rca-login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 1.75rem;
}

.rca-login-brand img {
  height: 48px;
}

.rca-login-brand-title {
  margin-top: 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--rca-navy);
}

.rca-btn-primary {
  background-color: var(--rca-teal);
  border-color: var(--rca-teal);
  color: #ffffff;
}

.rca-btn-primary:hover,
.rca-btn-primary:focus {
  background-color: var(--rca-teal-light);
  border-color: var(--rca-teal-light);
  color: #ffffff;
}

.rca-btn-primary:disabled {
  background-color: var(--rca-teal);
  border-color: var(--rca-teal);
  opacity: 0.65;
}

/* App shell (sidebar layout pages) */

.rca-sidebar {
  background-color: var(--rca-navy);
  /* AdminLTE/Bootstrap's [data-bs-theme=dark] (applied to .app-sidebar for
     its dark nav colors) redefines --bs-body-bg to a near-black default
     (#212529). Nothing in our current sidebar markup reads that variable
     for its own background, but plenty of Bootstrap components do
     (dropdowns, cards, form controls) — override it here so any future
     addition inside the sidebar inherits our navy instead of AdminLTE's
     default black. */
  --bs-body-bg: var(--rca-navy);
}

.rca-sidebar-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem;
  text-align: center;
  transition: padding 0.2s ease-in-out;
}

.rca-sidebar-brand img {
  height: 32px;
  transition: height 0.2s ease-in-out;
}

.rca-nav-link {
  color: rgba(255, 255, 255, 0.75);
}

.rca-nav-link:hover {
  color: #ffffff;
}

.rca-nav-link.active {
  color: #ffffff;
  background-color: rgba(44, 166, 175, 0.25);
  border-left: 3px solid var(--rca-teal);
}

.rca-sidebar-toggle-btn {
  border: none;
  background: transparent;
  color: var(--rca-navy);
  font-size: 1.25rem;
  line-height: 1;
  padding: 0.25rem 0.5rem;
}

.rca-sidebar-toggle-btn:hover,
.rca-sidebar-toggle-btn:focus {
  color: var(--rca-teal);
}

/* Collapsed (icon-only) sidebar state — toggled by sidebar.js via a class on
   <body>, in-memory only for the current navigation session (see that file's
   comment: no persistence, always starts expanded on reload). .app-sidebar
   sits in a CSS Grid column sized "1fr" for .app-main (see AdminLTE's
   .app-wrapper), so shrinking the sidebar's own width is enough for the
   content column to reclaim the freed space — no manual margin needed. */
body.sidebar-collapsed .app-sidebar {
  min-width: 4.25rem;
  max-width: 4.25rem;
}

body.sidebar-collapsed .rca-sidebar-brand {
  padding: 1rem 0.25rem;
}

body.sidebar-collapsed .rca-sidebar-brand img {
  height: 26px;
}

body.sidebar-collapsed .rca-sidebar-brand-text,
body.sidebar-collapsed .rca-nav-label {
  display: none;
}

body.sidebar-collapsed .nav-link {
  text-align: center;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}

body.sidebar-collapsed .nav-link i {
  margin-right: 0 !important;
}

/* .app-wrapper resets min-width:0 on its own direct children
   (.app-header/.app-sidebar/.app-main) so CSS Grid track sizing doesn't get
   pulled wide by content. But .app-main is ALSO its own flex container
   (display:flex;flex-direction:column), and that reset never cascades to
   *its* children — .app-content is a flex item in that inner flex context
   with no min-width:0/definite width of its own, relying on cross-axis
   "stretch" to size it, which isn't fully reliable once real content (an
   editable row's actual <select> elements, wider than the read-only status
   badges shown elsewhere, widen the table further) pushes hard enough on it.
   width:100% here makes the size definite instead of relying on stretch, so
   there's no ambiguity left for it to be pulled wider by content.
   NOT using overflow-x:hidden anywhere in this chain on purpose: if
   .rca-table-scroll below ever still doesn't fully contain a given table's
   width, the fallback must remain a scrollbar (even at the wrong level) —
   never silent clipping that hides columns with no way to reach them. */
.app-content {
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

#loading-indicator {
  padding: 2rem;
  text-align: center;
  color: var(--rca-navy);
}

/* Dashboard */

.rca-kpi-card {
  background: #ffffff;
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 4px 16px rgba(13, 21, 38, 0.08);
}

.rca-kpi-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6c757d;
}

.rca-kpi-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--rca-navy);
}

.rca-kpi-subvalue {
  font-size: 0.85rem;
  color: #6c757d;
  margin-top: 0.25rem;
}

.rca-bars-card {
  background: #ffffff;
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 4px 16px rgba(13, 21, 38, 0.08);
  height: 100%;
}

.rca-bars-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--rca-navy);
  margin-bottom: 1rem;
}

.rca-bar-row {
  margin-bottom: 0.75rem;
}

.rca-bar-row:last-child {
  margin-bottom: 0;
}

.rca-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--rca-navy);
  margin-bottom: 0.25rem;
}

.rca-bar-track {
  background: #eef1f6;
  border-radius: 4px;
  height: 8px;
  overflow: hidden;
}

.rca-bar-fill {
  background: var(--rca-teal);
  height: 100%;
  border-radius: 4px;
}

.rca-empty-message {
  color: #6c757d;
  font-size: 0.85rem;
}

/* Imports */

.rca-kpi-value-success {
  color: var(--rca-green);
}

.rca-kpi-value-error {
  color: var(--rca-red);
}

/* Renewal tracking */

.rca-legend-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6c757d;
  margin-bottom: 0.5rem;
}

.rca-legend-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  align-items: center;
}

.rca-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--rca-navy);
}

.rca-semaphore-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.rca-semaphore-green {
  background-color: var(--rca-green);
}

.rca-semaphore-amber {
  background-color: var(--rca-amber);
}

.rca-semaphore-red {
  background-color: var(--rca-red);
}

.rca-period-btn {
  min-width: 120px;
}

.rca-filter-select {
  width: auto;
  min-width: 140px;
}

.rca-tracking-table {
  border-collapse: collapse;
}

/* Sticky on the whole <thead> (not each row individually) so both header
   rows move together as one unit and stay pinned to the top of
   .rca-table-scroll's own vertical scroll — no need to hardcode a second
   top offset for the group-header row vs. the column-label row. An
   explicit white background here backs the plain column-label row's <th>s
   (which don't set their own); .rca-group-header's own background-color
   still paints on top of that for the grouped row above it, unaffected. */
.rca-tracking-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
  background-color: #ffffff;
  box-shadow: 0 2px 4px rgba(13, 21, 38, 0.08);
}

/* Bootstrap's .table-responsive already sets overflow-x:auto, containing the
   table's horizontal scroll on its own instead of the whole page. Explicit
   width (not just max-width) matters here: without it, this div's own used
   width for shrink-to-fit purposes can end up derived from its content (the
   wide table) in some nested flex/grid contexts instead of being capped to
   the available space handed down by .rca-bars-card — width:100% pins it to
   that available space unconditionally, so overflow-x:auto has something
   fixed to actually measure the table's overflow against. */
.rca-table-scroll {
  overflow-x: auto;
  width: 100%;
  max-width: 100%;
  /* Without a height cap, the horizontal scrollbar renders at the natural
     bottom of the whole (unbounded) table — with many rows, that's far past
     the fold, unreachable without scrolling the entire page down first.
     Capping the height and adding overflow-y:auto turns this into its own
     scroll box in both axes, so the horizontal scrollbar always sits right
     below whatever rows are currently visible. */
  max-height: 65vh;
  overflow-y: auto;
}

.rca-group-header {
  background-color: #eef1f6;
  color: var(--rca-navy);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.group-divider-gold {
  border-left: 2px solid var(--rca-gold);
}

.group-divider-teal {
  border-left: 2px solid var(--rca-teal);
}

.group-divider-navy {
  border-left: 2px solid var(--rca-navy);
}

.group-divider-green {
  border-left: 2px solid var(--rca-green);
}

/* Matches Bootstrap's default --bs-border-color (#dee2e6), same tone the
   table's own borders already use. */
.group-divider-neutral {
  border-left: 2px solid #dee2e6;
}

.rca-date-separator td {
  background-color: #f8f9fb;
  color: var(--rca-navy);
  font-weight: 600;
  font-size: 0.85rem;
  padding-top: 0.6rem;
  padding-bottom: 0.6rem;
}

.rca-badge-pending {
  background-color: #6c757d;
  color: #ffffff;
}

.rca-badge-sent {
  background-color: var(--rca-teal);
  color: #ffffff;
}

.rca-badge-confirmed {
  background-color: var(--rca-green);
  color: #ffffff;
}

.rca-badge-ignored {
  background-color: var(--rca-amber);
  color: #ffffff;
}

.rca-badge-na {
  background-color: #dee2e6;
  color: #495057;
}

/* Soft/pastel tone on purpose — a status readout, not an action badge like
   the notification badges above, so it shouldn't visually compete with them. */
.rca-status-active {
  background-color: rgba(26, 122, 74, 0.12);
  color: var(--rca-green);
}

.rca-status-not-renewed {
  background-color: rgba(201, 138, 27, 0.16);
  color: var(--rca-amber);
}

.rca-status-other {
  background-color: #eef1f6;
  color: #495057;
}

/* Shown on both renewal-tracking.html (results are already filtered out, so
   this only ever appears in policy-search.html) and the search results
   list/detail — same pastel-badge treatment as the status badges above. */
.rca-badge-excluded {
  background-color: rgba(181, 33, 26, 0.12);
  color: var(--rca-red);
}

.rca-progress-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 110px;
}

.rca-progress-wrapper .progress {
  flex: 1;
  height: 8px;
}

.rca-progress-bar {
  background-color: var(--rca-teal);
}

.rca-progress-label {
  font-size: 0.8rem;
  color: var(--rca-navy);
  min-width: 2.5rem;
  text-align: right;
}

#toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1080;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 360px;
}

.rca-toast {
  box-shadow: 0 4px 16px rgba(13, 21, 38, 0.15);
  margin-bottom: 0;
}

/* Policy Search */

.rca-field-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6c757d;
  margin-bottom: 0.15rem;
}

.rca-clickable-row {
  cursor: pointer;
}

.rca-clickable-row:hover {
  background-color: #eef1f6;
}

/* Reports */

.rca-back-link {
  color: var(--rca-navy);
  text-decoration: none;
  font-size: 0.85rem;
  white-space: nowrap;
}

.rca-back-link:hover {
  color: var(--rca-teal);
}

.rca-report-card-link {
  display: block;
  max-width: 360px;
  text-decoration: none;
  color: inherit;
}

.rca-report-card {
  cursor: pointer;
  transition: box-shadow 0.15s ease-in-out;
}

.rca-report-card:hover {
  box-shadow: 0 4px 16px rgba(13, 21, 38, 0.18);
}

/* Comparativo (desktop only) */
.rca-comparativo-card {
  max-width: 720px;
}

/* Review table: one column per quote. A marked column gets its border from
   box-shadow so the cells keep their size. --rca-col-outer is the alert
   color (or gold when there is no alert); --rca-col-inner shows the gold
   inside the alert color when the cheapest column also has an alert. This
   replaces Bootstrap's own cell box-shadow, used only by striped/hover/active
   tables, none of which applies here. */
.rca-review-table th,
.rca-review-table td {
  min-width: 190px;
  vertical-align: top;
}

.rca-review-table .rca-review-label {
  min-width: 170px;
  color: #495057;
  font-weight: 600;
  white-space: nowrap;
}

.rca-review-table .rca-review-section th {
  background-color: #eef1f6;
  color: var(--rca-navy);
}

.rca-review-table .rca-col {
  --rca-col-outer: transparent;
  --rca-col-inner: transparent;
  box-shadow:
    inset 2px 0 0 var(--rca-col-outer), inset -2px 0 0 var(--rca-col-outer),
    inset 4px 0 0 var(--rca-col-inner), inset -4px 0 0 var(--rca-col-inner);
}

.rca-review-table thead .rca-col {
  box-shadow:
    inset 2px 0 0 var(--rca-col-outer), inset -2px 0 0 var(--rca-col-outer),
    inset 0 2px 0 var(--rca-col-outer),
    inset 4px 0 0 var(--rca-col-inner), inset -4px 0 0 var(--rca-col-inner),
    inset 0 4px 0 var(--rca-col-inner);
}

.rca-review-table tbody tr:last-child .rca-col {
  box-shadow:
    inset 2px 0 0 var(--rca-col-outer), inset -2px 0 0 var(--rca-col-outer),
    inset 0 -2px 0 var(--rca-col-outer),
    inset 4px 0 0 var(--rca-col-inner), inset -4px 0 0 var(--rca-col-inner),
    inset 0 -4px 0 var(--rca-col-inner);
}

/* Order matters: blocking wins over warning, and both over gold. */
.rca-review-table .rca-col-cheapest {
  --rca-col-outer: var(--rca-gold);
}

.rca-review-table .rca-col-warning {
  --rca-col-outer: var(--rca-amber);
}

.rca-review-table .rca-col-blocking {
  --rca-col-outer: var(--rca-red);
}

.rca-review-table .rca-col-cheapest.rca-col-warning,
.rca-review-table .rca-col-cheapest.rca-col-blocking {
  --rca-col-inner: var(--rca-gold);
}

.rca-cheapest-star {
  color: var(--rca-gold);
}

.rca-review-hint {
  font-size: 0.8rem;
  color: #6c757d;
}

.rca-promotion-input {
  font-size: 0.85rem;
  resize: vertical;
}

/* Raw import-error data is pretty-printed JSON — wraps instead of
   overflowing the table horizontally. */
.rca-import-error-data {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.8rem;
}

.rca-coverage-item {
  border-bottom: 1px solid #eef1f6;
  padding-bottom: 0.5rem;
  margin-bottom: 0.5rem;
}

.rca-suggestion {
  border: 1px solid #dee2e6;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  height: 100%;
}

/* Stays at the bottom of the viewport while the executive edits, so the
   button, its reason and a failed recalculation are always visible. */
.rca-generate-bar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  background-color: #ffffff;
  border-top: 1px solid #dee2e6;
  padding: 0.75rem 0;
  margin-bottom: 1rem;
}
