/* Cost Optimisation — aligned with Resourcing / Tech Ops gold and black wash */

.cost-opt-page.resource-page {
  max-width: none;
}

/* Snapshot cards: equal width across the full line, equal height. */
.cost-opt-page .section-header-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  width: 100%;
  align-items: stretch;
}

.cost-opt-page .section-stat {
  min-width: 0;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 5.25rem;
}

.cost-opt-page .section-stat strong {
  font-size: 1.75rem;
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: 0;
  font-variant-numeric: lining-nums;
  font-feature-settings: "lnum" 1;
}

@media (max-width: 720px) {
  .cost-opt-page .section-header-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.cost-opt-notice {
  margin: 0 0 1rem;
}

.cost-opt-tabs.resource-page-tabs {
  margin: 0.5rem 0 1.25rem;
}

.cost-opt-body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Process flow */

.cost-opt-flow-panel {
  margin-bottom: 0.25rem;
}

.cost-opt-flow-panel .ap-flow-panel-head .ap-purpose {
  max-width: none;
  white-space: nowrap;
}

@media (max-width: 900px) {
  .cost-opt-flow-panel .ap-flow-panel-head .ap-purpose {
    white-space: normal;
  }
}

.cost-opt-flow-steps {
  list-style: none;
  margin: 0;
  padding: 0 0 4px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.cost-opt-flow-step {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  border: 1px solid var(--resource-border, rgba(201, 169, 110, 0.22));
  background: var(--ap-panel-bg, linear-gradient(165deg, rgba(201, 169, 110, 0.07) 0%, rgba(0, 0, 0, 0.28) 42%, rgba(0, 0, 0, 0.38) 100%));
  min-width: 0;
}

.cost-opt-flow-step-num {
  flex: 0 0 auto;
  font-family: var(--resource-display, "Cormorant Garamond", Georgia, serif);
  font-size: 20px;
  line-height: 1;
  color: var(--resource-gold, var(--brand-gold, #c9a96e));
}

.cost-opt-flow-step strong {
  display: block;
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 500;
  color: var(--resource-text, inherit);
}

.cost-opt-flow-step p {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--resource-muted, inherit);
}

/* Panels and cards */

.cost-opt-panel,
.cost-opt-card {
  border: 1px solid var(--resource-border, rgba(201, 169, 110, 0.22));
  background: var(--ap-panel-bg, linear-gradient(165deg, rgba(201, 169, 110, 0.07) 0%, rgba(0, 0, 0, 0.28) 42%, rgba(0, 0, 0, 0.38) 100%));
  padding: 16px 18px;
  box-sizing: border-box;
}

.cost-opt-panel > .resource-section-head {
  margin-bottom: 12px;
}

.cost-opt-head-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.cost-opt-split {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(280px, 1fr);
  gap: 1rem;
}

@media (max-width: 900px) {
  .cost-opt-split {
    grid-template-columns: 1fr;
  }
}

/* Overview: Ask Compass full-width, spenders card underneath */
.cost-opt-overview-stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.cost-opt-panel--ask {
  min-height: 42rem;
  display: flex;
  flex-direction: column;
}

.cost-opt-panel--ask .cost-opt-prompt-row {
  max-width: none;
}

.cost-opt-panel--ask .cost-opt-qa-scroll {
  flex: 1 1 auto;
  max-height: none;
  min-height: 30rem; /* 320px default × 1.5 */
}

/* Budget meter */

.cost-opt-budget-card {
  margin-top: 0.25rem;
}

.cost-opt-meter {
  position: relative;
  height: 14px;
  margin-top: 10px;
  border: 1px solid var(--resource-line, rgba(255, 255, 255, 0.1));
  background: var(--resource-inset, rgba(0, 0, 0, 0.35));
  overflow: hidden;
}

.cost-opt-meter-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(90deg, rgba(201, 169, 110, 0.55), rgba(201, 169, 110, 0.85));
  transition: width 300ms ease;
}

.cost-opt-meter.is-warn .cost-opt-meter-fill {
  background: linear-gradient(90deg, rgba(201, 169, 110, 0.75), rgba(196, 128, 66, 0.9));
}

.cost-opt-meter.is-over .cost-opt-meter-fill {
  background: linear-gradient(90deg, rgba(196, 128, 66, 0.85), rgba(178, 92, 78, 0.95));
}

.cost-opt-meter-projection,
.cost-opt-meter-threshold {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 2px;
}

.cost-opt-meter-projection {
  background: rgba(255, 255, 255, 0.65);
}

.cost-opt-meter-threshold {
  background: rgba(178, 92, 78, 0.9);
}

.cost-opt-meter-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 8px;
  font-size: 11px;
  color: var(--resource-muted, inherit);
}

.cost-opt-key {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  vertical-align: -1px;
}

.cost-opt-key--used {
  background: rgba(201, 169, 110, 0.85);
}

.cost-opt-key--proj {
  background: rgba(255, 255, 255, 0.65);
}

.cost-opt-key--threshold {
  background: rgba(178, 92, 78, 0.9);
}

.cost-opt-alert {
  margin-top: 12px;
}

/* Lists */

.cost-opt-list {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cost-opt-spend-row,
.cost-opt-feed-row,
.cost-opt-qa,
.cost-opt-proposal {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--resource-line, rgba(255, 255, 255, 0.07));
  background: var(--resource-inset, rgba(0, 0, 0, 0.35));
}

.cost-opt-spend-row {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.cost-opt-spend-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.cost-opt-spend-figures {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: flex-end;
  flex: 0 0 auto;
}

.cost-opt-spend-row strong,
.cost-opt-feed-row strong,
.cost-opt-qa strong,
.cost-opt-proposal strong {
  font-size: 13px;
  font-weight: 500;
}

.cost-opt-qa p,
.cost-opt-proposal p {
  margin: 2px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--resource-muted, inherit);
  white-space: pre-line;
}

.cost-opt-feed {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(201, 169, 110, 0.18);
}

/* Ask Compass Q&A — scrolls inside the card, never spills below it */

.cost-opt-qa-scroll {
  max-height: 320px;
  overflow-y: auto;
  margin-top: 0.75rem;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(201, 169, 110, 0.45) transparent;
}

.cost-opt-qa-scroll .cost-opt-list {
  margin-top: 0;
}

.cost-opt-qa-scroll::-webkit-scrollbar {
  width: 6px;
}

.cost-opt-qa-scroll::-webkit-scrollbar-thumb {
  background: rgba(201, 169, 110, 0.35);
}

/* Pills */

.cost-opt-pill {
  display: inline-block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.15rem 0.45rem;
  width: fit-content;
  color: var(--resource-gold, var(--brand-gold, #c9a96e));
  border: 1px solid rgba(201, 169, 110, 0.35);
  background: rgba(201, 169, 110, 0.08);
}

.cost-opt-pill--ok {
  color: #7d9e88;
  border-color: rgba(125, 158, 136, 0.4);
  background: rgba(125, 158, 136, 0.1);
}

.cost-opt-pill--warn {
  color: #c48042;
  border-color: rgba(196, 128, 66, 0.45);
  background: rgba(196, 128, 66, 0.1);
}

.cost-opt-pill--muted {
  opacity: 0.65;
}

/* Prompt */

.cost-opt-prompt-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

.cost-opt-prompt {
  flex: 1;
  min-width: 0;
  padding: 0.55rem 0.7rem;
  font: inherit;
  border: 1px solid var(--resource-line, rgba(255, 255, 255, 0.07));
  background: var(--resource-input, rgba(0, 0, 0, 0.35));
  color: inherit;
}

/* Breakdown table */

.cost-opt-highlights {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin: 4px 0 14px;
}

.cost-opt-highlight {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--resource-line, rgba(255, 255, 255, 0.07));
  background: var(--resource-inset, rgba(0, 0, 0, 0.35));
}

.cost-opt-highlight strong {
  font-size: 14px;
  font-weight: 500;
}

.cost-opt-table-wrap {
  overflow-x: auto;
}

.cost-opt-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.cost-opt-table th {
  text-align: left;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--resource-muted, inherit);
  padding: 8px 10px;
  border-bottom: 1px solid rgba(201, 169, 110, 0.25);
  white-space: nowrap;
}

.cost-opt-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--resource-line, rgba(255, 255, 255, 0.06));
  vertical-align: top;
}

.cost-opt-table tr.is-paused td {
  opacity: 0.55;
}

.cost-opt-adjusted {
  display: inline-block;
  margin-left: 6px;
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--resource-gold, #c9a96e);
}

.cost-opt-footnote {
  margin: 12px 0 0;
  font-size: 11px;
  line-height: 1.5;
}

/* Proposals */

.cost-opt-proposal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.cost-opt-saving {
  font-size: 11px;
  color: #7d9e88;
  letter-spacing: 0.04em;
}

.cost-opt-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.65rem;
}

.cost-opt-history {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(201, 169, 110, 0.18);
}

/* Connection status */

.cost-opt-conn {
  margin: 8px 0 0;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.cost-opt-conn.is-on {
  color: #7d9e88;
}

.cost-opt-conn.is-off {
  color: var(--resource-muted, #8a9099);
}

.cost-opt-schedules {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(201, 169, 110, 0.18);
}

/* Settings */

.cost-opt-settings-form {
  margin-top: 4px;
}

.cost-opt-settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.cost-opt-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid var(--resource-line, rgba(255, 255, 255, 0.07));
  background: var(--resource-inset, rgba(0, 0, 0, 0.35));
}

.cost-opt-field--wide {
  grid-column: 1 / -1;
}

.cost-opt-field-label {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--resource-muted, inherit);
}

.cost-opt-field .muted {
  margin: 0;
  font-size: 11px;
}

.cost-opt-input {
  padding: 0.5rem 0.65rem;
  font: inherit;
  border: 1px solid var(--resource-line, rgba(255, 255, 255, 0.07));
  background: var(--resource-input, rgba(0, 0, 0, 0.35));
  color: inherit;
}

.cost-opt-textarea {
  resize: vertical;
  min-height: 64px;
}

.cost-opt-toggle {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 8px;
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  font-size: 12px;
  line-height: 1.4;
  color: #fff;
  cursor: pointer;
  text-align: left;
}

.cost-opt-toggle input[type="checkbox"] {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  min-height: 0;
  margin: 2px 0 0;
  padding: 0;
  accent-color: var(--resource-gold, #c9a96e);
}

.cost-opt-toggle-copy {
  flex: 1 1 auto;
  min-width: 0;
  color: #fff;
  text-align: left;
  white-space: normal;
}

.cost-opt-table tr.is-zero td {
  opacity: 0.55;
}

.cost-opt-report {
  margin-top: 8px;
}

.cost-opt-report-narrative {
  margin: 0 0 14px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--resource-muted, inherit);
  white-space: pre-line;
}

.cost-opt-list-item {
  width: 100%;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--resource-line, rgba(255, 255, 255, 0.07));
  background: var(--resource-inset, rgba(0, 0, 0, 0.35));
  color: inherit;
  cursor: pointer;
  font: inherit;
}

.cost-opt-list-item.is-active {
  border-color: rgba(201, 169, 110, 0.45);
  background: var(--resource-inset-active, rgba(201, 169, 110, 0.06));
}

.cost-opt-adjustments {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(201, 169, 110, 0.18);
}

/* Light theme */

.theme-light .cost-opt-page.resource-page .cost-opt-flow-step,
.theme-light .cost-opt-page.resource-page .cost-opt-panel,
.theme-light .cost-opt-page.resource-page .cost-opt-card {
  background: var(--ap-panel-bg);
  border-color: var(--ap-panel-border, rgba(201, 169, 110, 0.35));
}

.theme-light .cost-opt-toggle,
.theme-light .cost-opt-toggle-copy {
  color: var(--resource-text, #1a1a1a);
}

/* Work products */

.cost-opt-work-product-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cost-opt-work-product {
  border: 1px solid var(--resource-line, rgba(201, 169, 110, 0.22));
  background: var(--resource-inset, rgba(10, 10, 10, 0.35));
}

.cost-opt-work-product-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.cost-opt-work-product-toggle-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.cost-opt-work-product-toggle-copy strong {
  font-size: 13px;
  font-weight: 500;
}

.cost-opt-work-product-toggle-copy small {
  color: var(--resource-muted, #c8c0b0);
  font-size: 11px;
}

.cost-opt-work-product-chevron {
  flex: 0 0 auto;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--resource-gold, #c9a96e);
}

.cost-opt-work-product.is-open .cost-opt-work-product-toggle {
  border-bottom: 1px solid var(--resource-line, rgba(201, 169, 110, 0.22));
}

.cost-opt-firm-impact {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px 14px 14px;
}

.cost-opt-firm-impact-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.cost-opt-gate-copy,
.cost-opt-handoff-preview,
.cost-opt-map-intro {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
}

.cost-opt-field-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  letter-spacing: 0.02em;
  color: var(--text-secondary, var(--resource-muted, #c8c0b0));
}

.cost-opt-field-block h4 {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 500;
  color: var(--brand-gold, var(--resource-gold, #c9a96e));
}

.cost-opt-field-block p {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--resource-text, inherit);
}

.cost-opt-impact-form textarea,
.cost-opt-impact-form input[type="text"] {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border: 1px solid rgba(201, 169, 110, 0.22);
  border-radius: 2px;
  background: rgba(10, 10, 10, 0.55);
  color: inherit;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.45;
}

.theme-light .cost-opt-impact-form textarea,
.theme-light .cost-opt-impact-form input[type="text"] {
  background: rgba(255, 255, 255, 0.85);
  border-color: rgba(201, 169, 110, 0.4);
}

.cost-opt-impact-form textarea:focus,
.cost-opt-impact-form input[type="text"]:focus {
  outline: 1px solid rgba(201, 169, 110, 0.45);
}

.cost-opt-firm-map {
  display: grid;
  gap: 10px;
}

.cost-opt-firm-map h5 {
  margin: 0 0 6px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 500;
  color: rgba(201, 169, 110, 0.85);
}

.cost-opt-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.cost-opt-chip {
  padding: 4px 8px;
  border: 1px solid rgba(201, 169, 110, 0.22);
  background: rgba(201, 169, 110, 0.06);
  font-size: 11px;
  line-height: 1.35;
}

.cost-opt-map-empty {
  margin: 0;
  font-size: 12px;
}

.cost-opt-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cost-opt-page .ri-agent-pill,
.cost-opt-work-product .ri-agent-pill {
  margin: 0;
}
