/* Building payback tool. Loads after bico-theme.css and tools/tools.css. */

.rb-meta {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  margin-bottom: var(--gap-sm);
  min-height: 26px;
}
.rb-sheet {
  font-family: var(--font-ui);
  font-size: 11px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--text-eyebrow);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 4px 13px;
}
.rb-sheet:empty { display: none; }

/* ---- assumptions ---------------------------------------------------- */

.rb-settings {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--gap-sm) var(--gap-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: var(--pad-md) var(--pad-lg);
  margin-bottom: var(--gap-md);
}

.rb-field { display: grid; gap: 4px; min-width: 0; }
.rb-field__k {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--text-eyebrow);
}

.rb-note {
  grid-column: 1 / -1;
  margin: 0;
  font-family: var(--font-prose);
  font-size: 15px;
  font-style: italic;
  color: var(--text-muted);
}

.rb-input {
  width: 100%;
  min-width: 0;
  font-family: var(--font-ui);
  font-size: 15px;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-3);
  color: var(--text-primary);
}
.rb-input:hover { border-color: var(--border-strong); }
.rb-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--gold-wash);
}

/* ---- layout --------------------------------------------------------- */

.rb-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--gap-md);
  align-items: start;
}

.rb-panel {
  min-width: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: var(--pad-md) var(--pad-lg) var(--pad-lg);
}

/* The site header is sticky, so the detail panel sticks just below it. */
.rb-panel--detail {
  position: sticky;
  top: 88px;
  max-height: calc(100vh - 104px);
  overflow-y: auto;
}

.rb-panel__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 9px;
  margin-bottom: var(--gap-md);
}
.rb-panel__head h2 {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 500;
  margin: 0;
  color: var(--text-primary);
}
.rb-count { font-family: var(--font-ui); font-size: 13px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.rb-filters {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--gap-xs);
  margin-bottom: var(--gap-sm);
}
.rb-filters #rbSearch { grid-column: 1 / -1; }

.rb-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
}
.rb-check input { accent-color: var(--accent); width: 16px; height: 16px; }

/* ---- building list -------------------------------------------------- */

.rb-scroll {
  max-height: 68vh;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-3);
}

.rb-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-ui);
  font-size: 14px;
}
.rb-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 0;
  text-align: left;
  background: var(--surface-3);
  border-bottom: 1px solid var(--border-strong);
}
.rb-table th.rb-num .rb-sort { text-align: right; }

.rb-sort {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  background: none;
  text-align: left;
  font: inherit;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-eyebrow);
  cursor: pointer;
  white-space: nowrap;
}
.rb-sort:hover { color: var(--text-primary); }
.rb-sort.is-on { color: var(--text-primary); }
th[aria-sort="ascending"] .rb-sort::after { content: " \2191"; }
th[aria-sort="descending"] .rb-sort::after { content: " \2193"; }

.rb-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: middle;
}
.rb-table tbody tr[data-slug] { cursor: pointer; }
.rb-table tbody tr[data-slug]:hover td { background: var(--gold-wash); }
.rb-table tbody tr[data-slug]:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.rb-table tbody tr.is-on td { background: var(--gold-wash); }
.rb-table tbody tr.is-on td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.rb-table tbody tr:last-child td { border-bottom: 0; }
.rb-norow td { color: var(--text-muted); font-style: italic; }

.rb-name { display: block; font-weight: 500; color: var(--text-primary); }
.rb-sub { display: block; font-size: 12px; color: var(--text-muted); }

.rb-num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.rb-pos { color: var(--ok); }
.rb-neg { color: var(--danger); }

.rb-tag {
  display: inline-block;
  font-family: var(--font-ui);
  font-size: 11.5px;
  line-height: 1.5;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  white-space: nowrap;
}
.rb-tag--never { border-color: var(--danger); color: var(--danger); }

/* ---- detail --------------------------------------------------------- */

.rb-empty,
.rb-error {
  font-family: var(--font-prose);
  padding: var(--pad-xl) 4px;
  color: var(--text-muted);
  font-style: italic;
}
.rb-error { color: var(--danger); padding: var(--pad-md); }

.rb-d__head { border-bottom: 1px solid var(--border); padding-bottom: 10px; margin-bottom: var(--gap-md); }
.rb-d__group {
  margin: 0 0 2px;
  font-family: var(--font-ui);
  font-size: 11px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--text-eyebrow);
}
.rb-d__name {
  margin: 0;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 500;
  color: var(--text-primary);
}

.rb-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--gap-sm); }

.rb-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 0;
  padding: 11px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-3);
  text-align: center;
}
.rb-stat__k { font-family: var(--font-ui); font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--text-eyebrow); }
.rb-stat__v {
  font-family: var(--font-display);
  font-size: 25px;
  font-weight: 500;
  line-height: 1.15;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.rb-stat__u { font-family: var(--font-ui); font-size: 12px; color: var(--text-muted); }

/* How long until it pays back is the answer the page exists to give. */
.rb-stat--key { border: 2px solid var(--gold); background: var(--gold-wash); }
.rb-stat--key .rb-stat__v { color: var(--gold); }
.rb-stat--key.is-never { border-color: var(--danger); }
.rb-stat--key.is-never .rb-stat__v { color: var(--danger); }

.rb-verdict {
  margin: 10px 0 0;
  font-family: var(--font-prose);
  font-size: 16px;
  color: var(--text-secondary);
}

.rb-block { margin-top: var(--gap-lg); }
.rb-block h3 {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--text-eyebrow);
  margin: 0 0 10px;
}

.rb-assign { display: flex; align-items: center; gap: 14px; }
.rb-assign input[type="range"] { flex: 1; min-width: 0; accent-color: var(--accent); }
.rb-assign__out {
  min-width: 70px;
  text-align: right;
  font-family: var(--font-ui);
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.rb-choices { display: grid; gap: var(--gap-xs); margin-top: var(--gap-sm); }

.rb-small {
  margin: 6px 0 0;
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--text-muted);
}
.rb-warn { color: var(--danger); }

.rb-x { overflow-x: auto; }

.rb-lines {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-ui);
  font-size: 14px;
}
.rb-lines th {
  text-align: left;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-eyebrow);
  border-bottom: 1px solid var(--border-strong);
  padding: 6px 8px;
}
.rb-lines th.rb-num { text-align: right; }
.rb-lines td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}
.rb-lines .rb-line--total td {
  font-weight: 700;
  border-top: 1px solid var(--border-strong);
  border-bottom: 0;
}

.rb-rules p {
  margin: 0 0 8px;
  font-family: var(--font-prose);
  font-size: 15px;
  color: var(--text-secondary);
}

/* ---- detail / plan tabs --------------------------------------------- */

.rb-tabs {
  display: flex;
  gap: var(--gap-md);
  border-bottom: 1px solid var(--border);
  margin: -4px 0 var(--gap-md);
}

.rb-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 2px 9px;
  margin-bottom: -1px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
}
.rb-tab:hover { color: var(--text-primary); }
.rb-tab[aria-selected="true"] { color: var(--text-primary); border-bottom-color: var(--accent); }
.rb-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.rb-badge {
  min-width: 22px;
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--surface-1);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.bico-motion .rb-badge.is-bump { animation: rb-bump 420ms var(--ease); }
@keyframes rb-bump {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.35); }
  100% { transform: scale(1); }
}

.rb-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---- adding to the plan --------------------------------------------- */

.rb-btn {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 13px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--surface-1);
  cursor: pointer;
  white-space: nowrap;
  transition: opacity var(--dur) var(--ease), background var(--dur) var(--ease);
}
.rb-btn:hover { opacity: 0.85; }
.rb-btn--ghost { background: transparent; color: var(--accent); }
.rb-btn--ghost:hover { background: var(--gold-wash); opacity: 1; }

.rb-addcol { width: 44px; text-align: center; }
.rb-table td.rb-addcol { padding: 4px 8px 4px 0; }

.rb-addbtn {
  position: relative;
  width: 30px;
  height: 30px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: transparent;
  color: var(--accent);
  font-family: var(--font-ui);
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
}
.rb-addbtn:hover { border-color: var(--accent); background: var(--surface-2); }
.rb-addbtn.is-in { border-color: var(--accent); background: var(--gold-wash); }
.rb-addbtn[data-count]::after {
  content: attr(data-count);
  position: absolute;
  top: -7px;
  right: -8px;
  min-width: 17px;
  padding: 0 4px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--surface-1);
  font-size: 10.5px;
  font-weight: 700;
  line-height: 17px;
}

.rb-d__head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--gap-sm); }
.rb-d__title { min-width: 0; }
.rb-d__add { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex-shrink: 0; }
.rb-d__add .rb-small { margin: 0; }

/* ---- the plan ------------------------------------------------------- */

.rb-plan__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--gap-sm);
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}
.rb-plan__actions { display: flex; flex-wrap: wrap; gap: var(--gap-xs); }

.rb-block--first { margin-top: var(--gap-md); }

.rb-copybox {
  display: block;
  margin-top: var(--gap-sm);
  font-size: 13px;
  line-height: 1.45;
  resize: vertical;
}

.rb-cards { display: flex; flex-wrap: wrap; gap: var(--gap-xs); }

.rb-card {
  min-width: 92px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-3);
  text-align: center;
}
.rb-card__n {
  display: block;
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 500;
  line-height: 1.15;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.rb-card__l { display: block; font-family: var(--font-ui); font-size: 12px; color: var(--text-muted); }
.rb-card.is-unpriced { border-color: var(--danger); }

.rb-link {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: var(--text-primary);
  text-align: left;
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 3px;
  cursor: pointer;
}
.rb-link:hover { text-decoration-color: var(--accent); }

.rb-step { display: inline-flex; align-items: center; gap: 4px; }
.rb-step button,
.rb-remove {
  width: 26px;
  height: 26px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.rb-step button:hover:not(:disabled),
.rb-remove:hover { border-color: var(--accent); }
.rb-step button:disabled { opacity: 0.4; cursor: default; }
.rb-remove { color: var(--danger); }

.rb-step input {
  width: 46px;
  padding: 3px 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 14px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.rb-step input:focus { outline: none; border-color: var(--accent); }

.rb-foot {
  font-family: var(--font-prose);
  font-size: 15px;
  font-style: italic;
  color: var(--text-muted);
  margin: var(--gap-lg) 0 0;
}

@media (max-width: 1000px) {
  .rb-wrap { grid-template-columns: minmax(0, 1fr); }
  .rb-panel--detail { position: static; max-height: none; overflow: visible; }
  .rb-scroll { max-height: 48vh; }
}

@media (max-width: 640px) {
  .rb-settings { grid-template-columns: minmax(0, 1fr); padding: var(--pad-md); }
  .rb-panel { padding: var(--pad-md); }
  .rb-filters { grid-template-columns: minmax(0, 1fr); }
  .rb-stat__v { font-size: 21px; }
  .rb-table .rb-sub { display: none; }
  /* Payback is the column that matters; the cost is repeated in the detail. */
  .rb-table th:nth-child(2),
  .rb-table td:nth-child(2) { display: none; }
  .rb-table td, .rb-sort { padding-left: 8px; padding-right: 8px; }
}

@media (max-width: 420px) {
  /* Profit is in the detail and the plan; the list keeps what fits a phone. */
  .rb-table th:nth-child(3),
  .rb-table td:nth-child(3) { display: none; }
}
