/* src/styles/us-takeback.css
   🇺🇸 US Take-Back — Remedy Reserve
   Uses Nelsons design tokens (--bg, --surface, --text, --green, etc.) defined in main stylesheet.
*/

/* -------------------------------------------------------------------------
   Page shell
   ------------------------------------------------------------------------- */
.takeback-page {
  padding: 24px;
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', system-ui, sans-serif;
}

.takeback-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.takeback-title-block { flex: 1; min-width: 0; }

.takeback-title {
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 4px 0;
  letter-spacing: -0.01em;
}

.takeback-subtitle {
  font-size: 14px;
  color: var(--text2);
  margin: 0;
}

.takeback-status {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  max-width: 360px;
  text-align: right;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
}
.status-pending {
  background: var(--amber-bg);
  color: var(--amber);
  border: 1px solid var(--amber-border);
}

.status-meta {
  font-size: 12px;
  color: var(--text3);
  line-height: 1.4;
}

/* -------------------------------------------------------------------------
   Tabs
   ------------------------------------------------------------------------- */
.takeback-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.takeback-tabs .tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 16px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--text2);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.takeback-tabs .tab:hover {
  color: var(--text);
}

.takeback-tabs .tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* -------------------------------------------------------------------------
   Section
   ------------------------------------------------------------------------- */
.tb-section { display: flex; flex-direction: column; gap: 20px; }

.tb-section-head h3 {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 4px 0;
  color: var(--text);
}

.tb-section-sub {
  font-size: 13px;
  color: var(--text2);
  margin: 0;
}

/* -------------------------------------------------------------------------
   Scenario bar (Business Case top strip)
   ------------------------------------------------------------------------- */
.tb-scenario-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
}

.tb-scenario-bar label {
  font-weight: 500;
  color: var(--text);
}

.tb-scenario-bar select {
  padding: 6px 10px;
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
}

.tb-hint {
  color: var(--text3);
  font-size: 12px;
}

.tb-hint code,
.tb-callout code,
.tb-readiness-hint code {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  background: var(--surface2);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--text);
}

/* -------------------------------------------------------------------------
   KPI grid
   ------------------------------------------------------------------------- */
.tb-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.tb-kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.tb-kpi-label {
  font-size: 12px;
  color: var(--text2);
  margin-bottom: 6px;
}

.tb-kpi-value {
  font-family: 'DM Mono', monospace;
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  letter-spacing: -0.02em;
}

.tb-kpi-value.placeholder {
  color: var(--text3);
  font-weight: 500;
}

.tb-kpi-hint {
  font-size: 11px;
  color: var(--text3);
  line-height: 1.4;
}

/* -------------------------------------------------------------------------
   Readiness summary (Transition Plan)
   ------------------------------------------------------------------------- */
.tb-readiness-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.tb-readiness-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.tb-readiness-label {
  font-size: 12px;
  color: var(--text2);
  margin-bottom: 4px;
}

.tb-readiness-value {
  font-family: 'DM Mono', monospace;
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.tb-readiness-value.placeholder {
  color: var(--text3);
  font-weight: 500;
}

.tb-readiness-hint {
  font-size: 11px;
  color: var(--text3);
  line-height: 1.4;
}

/* -------------------------------------------------------------------------
   ASIN table
   ------------------------------------------------------------------------- */
.tb-asin-table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.tb-asin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.tb-asin-table thead th {
  text-align: left;
  padding: 10px 12px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  font-weight: 500;
  color: var(--text2);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tb-asin-table tbody td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
}

.tb-asin-table tbody tr:last-child td { border-bottom: none; }

.tb-table-empty {
  text-align: center;
  color: var(--text3);
  font-size: 13px;
  padding: 32px 12px !important;
}

/* -------------------------------------------------------------------------
   Economics model
   ------------------------------------------------------------------------- */
.tb-econ-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.tb-econ-col {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.tb-econ-col h4 {
  margin: 0 0 12px 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tb-input-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 13px;
  gap: 8px;
}

.tb-input-row label {
  color: var(--text2);
  flex: 1;
}

.tb-input-row input,
.tb-input-row select {
  width: 100px;
  padding: 4px 8px;
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  text-align: right;
  background: var(--bg);
  color: var(--text);
}

.tb-input-row input:disabled,
.tb-input-row select:disabled {
  color: var(--text3);
  cursor: not-allowed;
}

.tb-econ-output {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.tb-econ-output h4 {
  margin: 0 0 12px 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* -------------------------------------------------------------------------
   Risk cards
   ------------------------------------------------------------------------- */
.tb-risk-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tb-risk-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.tb-risk-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.tb-risk-head strong {
  font-size: 14px;
  color: var(--text);
}

.tb-risk-card p {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.5;
  margin: 0 0 8px 0;
}

.tb-risk-card p:last-child { margin-bottom: 0; }

.tb-risk-mit { color: var(--text) !important; }

.tb-risk-sev {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tb-risk-sev-high {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid var(--red-border);
}

.tb-risk-sev-amber {
  background: var(--amber-bg);
  color: var(--amber);
  border: 1px solid var(--amber-border);
}

.tb-risk-sev-low {
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid var(--green-border);
}

/* -------------------------------------------------------------------------
   Callouts
   ------------------------------------------------------------------------- */
.tb-callout {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.5;
}

.tb-callout strong { color: var(--text); }

.tb-callout-info {
  background: var(--blue-bg);
  color: var(--blue);
  border: 1px solid var(--blue-border);
}

.tb-callout-amber {
  background: var(--amber-bg);
  color: var(--amber);
  border: 1px solid var(--amber-border);
}

/* -------------------------------------------------------------------------
   Empty state
   ------------------------------------------------------------------------- */
.takeback-empty {
  padding: 48px;
  text-align: center;
  color: var(--text3);
  font-size: 14px;
}

/* -------------------------------------------------------------------------
   Transition Plan toolbar — filter chips, refresh, CSV export
   ------------------------------------------------------------------------- */
.tp-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.tp-filter-chips {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.tp-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--text2);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.tp-chip:hover { color: var(--text); border-color: var(--border2); }

.tp-chip.active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--surface);
}

.tp-chip-count {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  background: var(--surface2);
  padding: 1px 6px;
  border-radius: 3px;
  color: var(--text3);
}

.tp-chip.active .tp-chip-count {
  background: var(--green-bg);
  color: var(--green);
}

.tp-toolbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.tp-meta {
  font-size: 11px;
  color: var(--text3);
  margin-right: 4px;
}

.tp-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-family: inherit;
  font-size: 12px;
  color: var(--text2);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.tp-btn:hover { color: var(--text); border-color: var(--border2); }

/* -------------------------------------------------------------------------
   Grid cell helpers
   ------------------------------------------------------------------------- */
.tp-product-cell {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tp-hero-pill {
  display: inline-block;
  font-size: 9px;
  font-weight: 600;
  padding: 1px 5px;
  margin-left: 4px;
  border-radius: 2px;
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid var(--green-border);
  vertical-align: middle;
}

.tp-pill-unknown {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 500;
  background: var(--surface2);
  color: var(--text3);
  border: 1px solid var(--border);
}

/* -------------------------------------------------------------------------
   Component cell + mixed-bundle marker (added when ASIN↔SKU mapping wired in)
   ------------------------------------------------------------------------- */
.tp-component-code {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  color: var(--text);
  background: var(--surface2);
  padding: 2px 6px;
  border-radius: 3px;
  cursor: help;
  white-space: nowrap;
}

.tp-bundle-pill {
  display: inline-block;
  font-size: 9px;
  font-weight: 600;
  padding: 1px 5px;
  margin-left: 4px;
  border-radius: 2px;
  background: var(--blue-bg);
  color: var(--blue);
  border: 1px solid var(--blue-border);
  vertical-align: middle;
}

/* -------------------------------------------------------------------------
   Transition Plan — view toggle (By ASIN / By Component)
   ------------------------------------------------------------------------- */
.tp-view-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
}

.tp-view-btn {
  background: transparent;
  border: none;
  border-right: 1px solid var(--border);
  padding: 5px 12px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--text2);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.tp-view-btn:last-child { border-right: none; }
.tp-view-btn:hover { color: var(--text); }

.tp-view-btn.active {
  background: var(--accent);
  color: #fff;
}

/* -------------------------------------------------------------------------
   Transition Plan — Component group header rows + per-row tinting
   ------------------------------------------------------------------------- */
.tp-group-header td {
  background: var(--surface2);
  border-top: 2px solid var(--border2);
  padding: 10px 12px !important;
}

.tp-group-head-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.tp-group-head-id {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.tp-group-code {
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  font-weight: 600;
  background: var(--surface);
  border: 1px solid var(--border2);
  padding: 2px 8px;
  border-radius: 3px;
  color: var(--text);
}

.tp-group-desc {
  font-size: 12px;
  color: var(--text2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tp-group-stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.tp-grp-stat {
  font-size: 11px;
  color: var(--text2);
  padding: 2px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  white-space: nowrap;
}

.tp-grp-stat strong { color: var(--text); font-weight: 600; }

.tp-grp-pct { color: var(--text3); font-size: 10px; margin-left: 2px; }

.tp-grp-stat-done {
  background: var(--green-bg);
  color: var(--green);
  border-color: var(--green-border);
}

.tp-grp-stat-progress {
  background: var(--amber-bg);
  color: var(--amber);
  border-color: var(--amber-border);
}

.tp-grp-stat-todo {
  background: var(--red-bg);
  color: var(--red);
  border-color: var(--red-border);
}

.tp-grp-stat-clean {
  color: var(--text3);
  font-style: italic;
}

.tp-principal-pill {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  margin-left: 4px;
  border-radius: 2px;
  background: var(--accent);
  color: #fff;
  vertical-align: middle;
}

/* Subtle row tint for duplicate ASINs inside Component groups so the eye can scan
   draw-down progress at a glance */
tr.tp-row-dup-cleared td {
  background: rgba(26, 107, 69, 0.04);
}

tr.tp-row-dup-active td {
  background: rgba(204, 51, 51, 0.04);
}

/* Buyback exposure badge — slightly emphasised so the eye finds it quickly
   (it's the headline take-back number per group, always present) */
.tp-grp-stat-buyback {
  background: var(--blue-bg);
  color: var(--blue);
  border-color: var(--blue-border);
  font-weight: 500;
}

/* Singleton marker — subtle dot to distinguish "standalone primary" rows
   from cleanup primaries (which get the bold "P" pill) */
.tp-principal-solo {
  background: transparent !important;
  color: var(--text3) !important;
  font-weight: 400 !important;
  padding: 0 4px !important;
}

/* -------------------------------------------------------------------------
   Critical Dates panel — Economics Model tab header section
   ------------------------------------------------------------------------- */
.tb-cd-section {
  border-left: 3px solid var(--blue);
  background: var(--surface);
}

.tb-cd-presets {
  display: flex;
  gap: 8px;
  margin: 16px 0;
  flex-wrap: wrap;
}

.tb-cd-preset {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  min-width: 200px;
  transition: border-color 0.15s, background 0.15s;
}

.tb-cd-preset:hover { border-color: var(--border2); }

.tb-cd-preset.active {
  border-color: var(--blue);
  background: var(--blue-bg);
}

.tb-cd-preset-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.tb-cd-preset-sub {
  font-size: 11px;
  color: var(--text2);
}

.tb-cd-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 24px;
  margin: 16px 0;
}

.tb-cd-input {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tb-cd-input label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text2);
}

.tb-cd-input input[type="date"] {
  padding: 8px 10px;
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
}

.tb-cd-input-hint {
  font-size: 11px;
  color: var(--text3);
  line-height: 1.5;
  margin-top: 4px;
}

.tb-cd-computed {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.tb-cd-card {
  padding: 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.tb-cd-card-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tb-cd-card-value {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin: 4px 0;
}

.tb-cd-card-hint {
  font-size: 11px;
  color: var(--text3);
}

.tb-cd-status-ok   .tb-cd-card-value { color: var(--green); }
.tb-cd-status-warn .tb-cd-card-value { color: var(--amber); }
.tb-cd-status-bad  .tb-cd-card-value { color: var(--red); }

.tb-cd-banner {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin: 12px 0;
  font-size: 13px;
  line-height: 1.5;
}

.tb-cd-banner-ok   { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-border); }
.tb-cd-banner-warn { background: var(--amber-bg); color: var(--amber); border: 1px solid var(--amber-border); }
.tb-cd-banner-bad  { background: var(--red-bg);   color: var(--red);   border: 1px solid var(--red-border); }

.tb-cd-implication {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  margin-top: 12px;
}

.tb-cd-implication h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 8px;
}

.tb-cd-implication p {
  font-size: 12px;
  color: var(--text2);
  line-height: 1.6;
  margin: 6px 0;
}

/* -------------------------------------------------------------------------
   Roadmap tab — phase-by-phase checklist
   ------------------------------------------------------------------------- */
.tb-rm-overall {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
}

.tb-rm-overall-bar {
  flex: 1;
  height: 8px;
  background: var(--surface2);
  border-radius: 4px;
  overflow: hidden;
}

.tb-rm-overall-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.3s;
}

.tb-rm-overall-text {
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
}

.tb-rm-overall-pct {
  color: var(--text3);
  font-weight: 400;
  margin-left: 4px;
}

.tb-rm-phases {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.tb-rm-phase {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
}

.tb-rm-phase.tb-rm-phase-done {
  border-left: 3px solid var(--green);
}

.tb-rm-phase.tb-rm-phase-progress {
  border-left: 3px solid var(--amber);
}

.tb-rm-phase.tb-rm-phase-todo {
  border-left: 3px solid var(--border2);
}

.tb-rm-phase-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 14px 16px 8px;
}

.tb-rm-phase-id h4 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.tb-rm-phase-blurb {
  font-size: 12px;
  color: var(--text2);
  margin: 2px 0 0;
  line-height: 1.5;
}

.tb-rm-phase-progress {
  text-align: right;
  white-space: nowrap;
}

.tb-rm-phase-ratio {
  font-size: 14px;
  color: var(--text);
}

.tb-rm-phase-ratio strong {
  font-weight: 600;
}

.tb-rm-phase-pct {
  font-size: 11px;
  color: var(--text3);
}

.tb-rm-phase-bar {
  height: 4px;
  background: var(--surface2);
  margin: 0 16px;
}

.tb-rm-phase-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.3s;
}

.tb-rm-phase-done .tb-rm-phase-fill { background: var(--green); }
.tb-rm-phase-progress .tb-rm-phase-fill { background: var(--amber); }

.tb-rm-tasks {
  list-style: none;
  padding: 8px 0;
  margin: 0;
}

.tb-rm-task {
  padding: 0;
  border-top: 1px solid var(--border);
}

.tb-rm-task:first-child {
  border-top: none;
}

.tb-rm-task-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.15s;
}

.tb-rm-task-row:hover {
  background: var(--surface2);
}

.tb-rm-task-cb {
  margin-top: 3px;
  cursor: pointer;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.tb-rm-task-body {
  flex: 1;
  min-width: 0;
}

.tb-rm-task-title {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
  line-height: 1.4;
}

.tb-rm-task-done .tb-rm-task-title {
  color: var(--text3);
  text-decoration: line-through;
}

.tb-rm-task-meta {
  display: flex;
  gap: 8px;
  margin-top: 2px;
}

.tb-rm-task-owner-input {
  font-family: inherit;
  font-size: 11px;
  color: var(--text);
  background: var(--surface2);
  padding: 2px 8px;
  border-radius: 3px;
  border: 1px solid var(--border);
  min-width: 130px;
  max-width: 220px;
  transition: background 0.15s, border-color 0.15s;
}

.tb-rm-task-owner-input::placeholder {
  color: var(--text3);
  font-style: italic;
  opacity: 0.7;
}

.tb-rm-task-owner-input:hover {
  border-color: var(--border2);
  background: var(--surface);
  cursor: text;
}

.tb-rm-task-owner-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
}

/* Flash a subtle green tint right after save to confirm the write landed */
.tb-rm-task-owner-input.tb-rm-owner-saved {
  background: var(--green-bg);
  border-color: var(--green-border);
  transition: background 0.6s, border-color 0.6s;
}

.tb-rm-task-desc {
  font-size: 11px;
  color: var(--text3);
  line-height: 1.5;
  margin-top: 4px;
}

/* -------------------------------------------------------------------------
   Timeline tab — interactive Gantt
   ------------------------------------------------------------------------- */

/* Department palette — color-coded bars per dept, scoped to this widget */
:root {
  --dept-legal-bg:           #EEEDFE; --dept-legal-fg:           #3C3489; --dept-legal-bar:           #7F77DD;
  --dept-commercial-bg:      #E1F5EE; --dept-commercial-fg:      #085041; --dept-commercial-bar:      #1D9E75;
  --dept-finance-bg:         #EAF3DE; --dept-finance-fg:         #27500A; --dept-finance-bar:         #639922;
  --dept-operations-bg:      #FAECE7; --dept-operations-fg:      #712B13; --dept-operations-bar:      #D85A30;
  --dept-supplychain-bg:     #FAEEDA; --dept-supplychain-fg:     #633806; --dept-supplychain-bar:     #EF9F27;
  --dept-customerservice-bg: #FBEAF0; --dept-customerservice-fg: #72243E; --dept-customerservice-bar: #D4537E;
  --dept-marketing-bg:       #E6F1FB; --dept-marketing-fg:       #0C447C; --dept-marketing-bar:       #378ADD;
  --dept-it-bg:              #F1EFE8; --dept-it-fg:              #444441; --dept-it-bar:              #888780;
  --dept-hr-bg:              #FCEBEB; --dept-hr-fg:              #791F1F; --dept-hr-bar:              #E24B4A;
}

.gantt-hdr-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  flex-wrap: wrap;
}

.gantt-launch-input {
  display: flex;
  gap: 8px;
  align-items: center;
}
.gantt-launch-input label {
  font-size: 12px;
  color: var(--text2);
}
.gantt-launch-input input {
  padding: 6px 10px;
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 12px;
  background: var(--surface);
  color: var(--text);
}

.gantt-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.gantt-danger-btn {
  color: var(--red);
}

.gantt-summary-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  margin: 8px 0 12px;
}
.gantt-summary-card {
  background: var(--surface2);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.gantt-summary-label {
  font-size: 10px;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.gantt-summary-value {
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  margin-top: 2px;
}

.gantt-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px 0 12px;
}
.gantt-legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text2);
  padding: 3px 8px;
  border-radius: 3px;
  cursor: pointer;
  user-select: none;
  border: 1px solid transparent;
  background: var(--surface2);
}
.gantt-legend-chip:hover { border-color: var(--border); }
.gantt-legend-chip.muted { opacity: 0.35; }
.gantt-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  display: inline-block;
}

.gantt-month-header {
  display: grid;
  gap: 0;
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
  margin-bottom: 4px;
  font-size: 10px;
  color: var(--text2);
}
.gantt-month-header > div {
  text-align: center;
  border-left: 1px solid var(--border);
  padding: 2px 0;
}
.gantt-month-header > div:first-child {
  border-left: none;
}

.gantt-phase-block { margin: 12px 0 4px; }

.gantt-phase-hdr {
  font-size: 13px;
  font-weight: 500;
  padding: 8px 0 4px;
  color: var(--text);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.gantt-phase-dates {
  font-size: 11px;
  color: var(--text2);
  font-weight: 400;
}

.gantt-row {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 8px;
  padding: 4px 0;
  align-items: center;
  border-bottom: 1px solid var(--border);
}
.gantt-row:hover {
  background: var(--surface2);
  cursor: pointer;
}
.gantt-row.selected {
  background: var(--surface2);
}

.gantt-task-left {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.gantt-dept-pill {
  font-size: 9px;
  padding: 1px 4px;
  border-radius: 2px;
  line-height: 1.4;
  font-weight: 500;
  flex-shrink: 0;
  letter-spacing: 0.2px;
}
.gantt-task-name {
  font-size: 12px;
  line-height: 1.3;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gantt-timeline-area {
  position: relative;
  height: 20px;
  background: var(--surface2);
  border-radius: 3px;
}
.gantt-task-bar {
  position: absolute;
  top: 2px;
  height: 16px;
  border-radius: 3px;
  font-size: 10px;
  padding: 0 5px;
  line-height: 16px;
  white-space: nowrap;
  overflow: hidden;
  font-weight: 500;
  color: #fff;
}

.gantt-editor {
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin: 4px 0 8px;
  border: 1px solid var(--border2);
}
.gantt-editor-row {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
}
.gantt-editor-row label {
  font-size: 12px;
  color: var(--text2);
}
.gantt-editor-row input,
.gantt-editor-row select {
  font-size: 13px;
  height: 30px;
  padding: 4px 8px;
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
}
.gantt-editor-derived {
  font-size: 11px;
  color: var(--text3);
}
.gantt-editor-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
