/**
 * atm_fleet_triage.css
 * Purpose : Page-specific styles for atm_fleet_triage.html. Sits on top of
 *           the shared hex-design-system + atm_fleet_styles. Only rules
 *           unique to the Fleet Triage portal live here — table-row state
 *           (picked/blocked), the sticky bottom-line panel, waterfall bars,
 *           and the refine progress overlay.
 * Depends : /shared/css/hex-design-system.css (CSS variables), hex-components,
 *           hex-utilities, css/atm_fleet_styles.css (base patterns).
 */

/* ───── Target setter ────────────────────────────────────────────────── */

.triage-target {
  background: var(--panel-bg);
  border-bottom: 1px solid var(--border-color);
  padding: 14px 24px;
}
.target-row {
  display: flex; gap: 22px; align-items: flex-end; flex-wrap: wrap;
}
.target-group { display: flex; flex-direction: column; gap: 4px; }
.target-label {
  font-size: 9px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.08em;
}
.target-input-wrap { display: flex; align-items: center; gap: 6px; }
.target-input-wrap .form-input { width: 160px; }
.target-prefix, .target-suffix {
  color: var(--text-muted); font-family: var(--font-mono); font-size: 11px;
}
.target-sep {
  font-family: var(--font-mono); font-size: 10px; color: var(--text-muted);
  padding-bottom: 6px;
}
.target-constraints {
  gap: 4px;
}
.check-item.tight {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--text-main); cursor: pointer;
}
.check-item.tight input { accent-color: var(--hex-blue); }
.target-status {
  margin-top: 8px; font-size: 11px; color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ───── Main layout (table left, BL panel right) ─────────────────────── */

.triage-layout {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 16px;
  padding: 14px 16px;
  align-items: start;
}
.triage-main { min-width: 0; }

/* ───── Estimate banner ──────────────────────────────────────────────── */

.estimate-banner {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; margin-bottom: 10px;
  background: rgba(251, 191, 36, 0.08);
  border-left: 3px solid var(--accent-orange);
  color: #fcd34d; font-size: 11px; line-height: 1.4;
  border-radius: 2px;
}
.estimate-banner.banner-refined {
  background: rgba(16, 185, 129, 0.08);
  border-left-color: var(--accent-green);
  color: #86efac;
}
.estimate-banner .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: currentColor; flex-shrink: 0;
}
.estimate-banner em { font-style: italic; color: inherit; opacity: 0.9; }

/* ───── Portfolio table ──────────────────────────────────────────────── */

.triage-table th[data-sort] {
  cursor: pointer; user-select: none;
}
.triage-table th[data-sort]:hover { color: var(--hex-blue); }
.triage-table .col-check { width: 32px; text-align: center; }
.triage-table .col-rank { width: 36px; }
.triage-table .col-unit {
  font-size: 8px; color: var(--text-muted); font-weight: 500;
  text-transform: uppercase; display: block;
}
.triage-table td.num, .triage-table th.num {
  font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap;
}
.triage-table td.pos { color: var(--accent-green); }
.triage-table td.neg { color: var(--accent-red); }
.triage-table tr.row-picked { background: rgba(59, 130, 246, 0.06); }
.triage-table tr.row-blocked { opacity: 0.55; }
.triage-table tr.row-blocked .row-check { cursor: not-allowed; }
.triage-table .row-sub { font-size: 9px; color: var(--text-dim); }
.triage-table a.atm-deep-link {
  color: var(--hex-blue); text-decoration: none; font-variant-numeric: tabular-nums;
}
.triage-table a.atm-deep-link:hover { text-decoration: underline; }
.triage-table td.flags { white-space: nowrap; }
.triage-table .chip {
  display: inline-block; padding: 2px 7px; border-radius: 10px;
  font-size: 9px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; margin-right: 4px;
}
.chip-elig-eligible {
  background: rgba(16, 185, 129, 0.18); color: #a7f3d0;
}
.chip-elig-caution {
  background: rgba(245, 158, 11, 0.18); color: #fcd34d;
}
.chip-elig-blocked {
  background: rgba(239, 68, 68, 0.18); color: #fca5a5;
}
.chip-warn {
  background: rgba(251, 146, 60, 0.20); color: #fdba74;
  cursor: help;
}

/* ───── Bottom-line panel ────────────────────────────────────────────── */

.bottom-line-panel {
  position: sticky; top: 80px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 14px 16px;
  backdrop-filter: blur(6px);
  font-family: var(--font-ui);
  min-width: 240px;
}
.bl-title {
  font-size: 9px; font-weight: 800; letter-spacing: 0.14em;
  color: var(--hex-blue); text-align: center; margin-bottom: 10px;
}
.bl-kpi { margin-bottom: 6px; }
.bl-kpi.emphasise .bl-value { font-size: 17px; font-weight: 800; }
.bl-label {
  font-size: 9px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.bl-value {
  font-family: var(--font-mono); font-size: 14px; font-weight: 700;
  color: var(--text-main); font-variant-numeric: tabular-nums;
}
.bl-value.pos { color: var(--accent-green); }
.bl-value.neg { color: var(--accent-red); }
.bl-divider {
  border: none; border-top: 1px solid var(--border-color);
  margin: 8px 0;
}
.bl-footnote {
  font-size: 9px; color: var(--text-dim); line-height: 1.4;
  font-family: var(--font-mono);
}

/* ───── Waterfall chart ──────────────────────────────────────────────── */

.waterfall-section {
  margin: 18px 0 8px; padding: 14px;
  background: var(--panel-bg);
  border: 1px solid var(--border-color);
  border-radius: 4px;
}
.section-title {
  margin: 0 0 10px; font-size: 12px; font-weight: 700;
  color: var(--text-main); text-transform: uppercase; letter-spacing: 0.06em;
}
.waterfall-chart { display: flex; flex-direction: column; gap: 6px; }
.wl-row { display: flex; align-items: center; gap: 10px; font-size: 11px; }
.wl-label {
  width: 170px; color: var(--text-muted); text-align: right;
  font-family: var(--font-mono); font-size: 10px;
}
.wl-track {
  flex: 1; height: 20px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 3px; overflow: hidden;
}
.wl-bar { height: 100%; border-radius: 3px; transition: width 0.4s ease; }
.wl-saving { background: linear-gradient(90deg, #10b981, #06d6a0); }
.wl-loss   { background: linear-gradient(90deg, #ef4444, #dc2626); }
.wl-leak   { background: linear-gradient(90deg, #fb923c, #f59e0b); }
.wl-final  { background: linear-gradient(90deg, #3b82f6, #06b6d4); }
.wl-base   { background: linear-gradient(90deg, #64748b, #94a3b8); }
.wl-value {
  width: 120px; text-align: right; font-family: var(--font-mono);
  font-size: 11px; color: var(--text-main);
  font-variant-numeric: tabular-nums;
}
.waterfall-legend {
  display: flex; gap: 12px; margin-top: 10px; font-size: 9px;
  color: var(--text-muted); align-items: center; flex-wrap: wrap;
}
.wl-swatch {
  display: inline-block; width: 10px; height: 10px; border-radius: 2px;
  margin-right: 2px; vertical-align: middle;
}

/* ───── Action bar + refine overlay ──────────────────────────────────── */

.triage-actions {
  display: flex; gap: 10px; align-items: center;
  margin-top: 14px; padding: 10px 0;
  border-top: 1px solid var(--border-color);
}
.refine-status {
  font-family: var(--font-mono); font-size: 10px; color: var(--text-muted);
  margin-left: auto;
}

.refine-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 300;
  backdrop-filter: blur(2px);
}
.refine-overlay[hidden] { display: none; }
.refine-modal {
  width: 560px; max-width: 90vw;
  background: var(--panel-bg-solid);
  border: 1px solid var(--border-color);
  border-radius: 6px; padding: 20px 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
.refine-title {
  font-size: 14px; font-weight: 700; color: var(--text-main);
}
.refine-subtitle {
  font-size: 11px; color: var(--text-muted); margin-top: 4px;
}
.refine-bar-wrap {
  margin: 14px 0; height: 8px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 4px; overflow: hidden;
}
.refine-bar {
  height: 100%; background: linear-gradient(90deg, #3b82f6, #06b6d4);
  transition: width 0.3s ease;
}
.refine-log {
  max-height: 220px; overflow-y: auto;
  font-family: var(--font-mono); font-size: 10px;
  background: rgba(0, 0, 0, 0.3); padding: 10px;
  border-radius: 3px; color: var(--text-main);
  line-height: 1.5;
}
.refine-log .log-line { margin-bottom: 3px; }
.log-ts { color: var(--text-dim); margin-right: 6px; }
.refine-actions {
  margin-top: 14px; display: flex; justify-content: flex-end;
}

/* ───── Toast (matches other Fleet pages) ───────────────────────────── */

#toast {
  position: fixed; bottom: 28px; right: 28px; z-index: 500;
  padding: 10px 16px; background: var(--panel-bg-solid);
  border: 1px solid var(--border-color); border-radius: 4px;
  color: var(--text-main); font-size: 12px;
  opacity: 0; transform: translateY(8px); pointer-events: none;
  transition: all 0.25s ease;
}
#toast.show { opacity: 1; transform: translateY(0); }
#toast.error { border-color: var(--accent-red); color: #fca5a5; }
#toast.warn  { border-color: var(--accent-orange); color: #fdba74; }

/* ───── Small screens — stack layout ─────────────────────────────────── */

@media (max-width: 1100px) {
  .triage-layout { grid-template-columns: 1fr; }
  .bottom-line-panel { position: static; }
}
