/* V2.2 features: Targets and Compare panels (settings.js, compare.js),
   Contribution margin and Amazon pages (profit.js), Campaigns and flows (email.js), SMS pages (sms.js), the net sales target line.
   Uses the tokens in styles.css (:root). Nunito only; palette colors and tints only. */

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

/* Collapsible bars ------------------------------------------------------- */
.fx-panel {
  margin: 0 0 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--white, #fff);
  color: var(--midnight);
  font-family: "Nunito", sans-serif;
}
.fx-panel > summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 14px;
  padding: 12px 18px;
  cursor: pointer;
  list-style: none;
}
.fx-panel > summary::-webkit-details-marker { display: none; }
.fx-panel > summary::before {
  content: "▸";
  color: var(--surf);
  font-weight: 800;
  transition: transform 0.15s ease;
}
.fx-panel[open] > summary::before { transform: rotate(90deg); }
.fx-panel > summary:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; border-radius: 16px; }
.fx-summary-title {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.fx-summary-hint { color: var(--muted); font-size: 13px; font-weight: 400; }
.fx-summary-title + .fx-summary-hint { flex: 1 1 240px; }
.fx-save-status { color: var(--muted); font-size: 12px; font-weight: 800; }
.fx-panel-body {
  display: grid;
  gap: 16px;
  padding: 4px 18px 18px;
  border-top: 1px solid var(--line);
}
.fx-panel-body > :first-child { margin-top: 14px; }
.fx-subhead {
  margin: 4px 0 0;
  color: var(--midnight);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.fx-muted { margin: 0; color: var(--muted); font-size: 13px; }

/* Embedded in app.js's S00 fold-out bar: no second fold, no second card. */
.fx-panel.fx-embedded { margin: 0; border: 0; border-radius: 0; background: transparent; }
.fx-embedded-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 14px; }
.fx-embedded > .fx-panel-body { padding: 12px 0 0; border-top: 0; }
.fx-embedded > .fx-panel-body > :first-child { margin-top: 0; }

/* Fields --------------------------------------------------------------- */
.fx-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px 18px; }
.fx-field { display: grid; align-content: start; gap: 5px; min-width: 0; }
.fx-field > span:first-child { color: var(--midnight); font-size: 13px; font-weight: 800; }
.fx-field > small { color: var(--muted); font-size: 12px; font-weight: 400; line-height: 1.35; }
.fx-input {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 220px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--white, #fff);
}
.fx-input:focus-within { border-color: var(--surf); outline: 2px solid var(--orange); outline-offset: 1px; }
.fx-input i { color: var(--muted); font-size: 14px; font-style: normal; font-weight: 800; }
/* Read-only targets (set by Onda per client): plain values, not inputs. */
.fx-locked .fx-input { min-height: 40px; border-style: dashed; background: transparent; }
.fx-locked .fx-input b { color: var(--midnight); font-size: 15px; font-weight: 800; }
.fx-locked-note { margin: 0 0 12px; padding: 8px 12px; border-radius: 10px; background: #EEF6FA; color: var(--midnight); font-size: 13px; line-height: 1.4; }
.fx-input input,
.fx-field select,
.fx-field input[type="text"] {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  border: 0;
  background: transparent;
  color: var(--midnight);
  font: 400 16px/1.2 "Nunito", sans-serif; /* 16px: no zoom on iOS */
}
.fx-input input:focus { outline: none; }
.fx-field select,
.fx-field input[type="text"] {
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--white, #fff);
}
.fx-field select:focus-visible,
.fx-field input[type="text"]:focus-visible { border-color: var(--surf); outline: 2px solid var(--orange); outline-offset: 1px; }
.fx-input:has(input[aria-invalid="true"]) { border-color: var(--pink-text); }

.fx-band-inputs { display: flex; gap: 10px; }
.fx-band-inputs .fx-field > span:first-child { color: var(--muted); font-size: 12px; }

/* Stroud range targets */
.fx-targets { display: grid; gap: 0; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.fx-target-row {
  display: grid;
  grid-template-columns: minmax(200px, 1.6fr) repeat(2, minmax(120px, 1fr));
  align-items: end;
  gap: 10px 16px;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
}
.fx-target-row:first-child { border-top: 0; }
.fx-target-row:nth-child(even) { background: var(--panel, #f7fbfd); }
.fx-target-name { display: grid; gap: 2px; align-self: center; font-size: 14px; font-weight: 800; }
.fx-target-name small { color: var(--muted); font-size: 11px; font-weight: 400; }
.fx-target-row .fx-field > span:first-child { color: var(--muted); font-size: 11px; letter-spacing: 0.05em; text-transform: uppercase; }

/* Buttons and chips */
.fx-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.fx-button {
  min-height: 40px;
  padding: 0 18px;
  border: 1px solid var(--tide, #78c3eb);
  border-radius: 999px;
  background: var(--tide, #78c3eb);
  color: var(--midnight);
  font: 800 13px/1 "Nunito", sans-serif;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
}
.fx-button:hover { background: #8fcdee; }
.fx-button.secondary { background: transparent; border-color: var(--midnight); }
.fx-button.secondary:hover { background: var(--soft-blue); }
.fx-button:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }

.fx-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.fx-chip { display: inline-flex; align-items: stretch; border: 1px solid var(--tide, #78c3eb); border-radius: 999px; background: var(--soft-blue); overflow: hidden; }
.fx-chip button {
  min-height: 34px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: var(--midnight);
  font: 800 13px/1 "Nunito", sans-serif;
  cursor: pointer;
}
.fx-chip button:hover { background: #d6eefa; }
.fx-chip button:focus-visible { outline: 2px solid var(--orange); outline-offset: -2px; }
.fx-chip .fx-chip-delete { padding: 0 10px; border-left: 1px solid var(--tide, #78c3eb); color: var(--pink-text); font-size: 16px; }

/* Compare metrics */
.fx-compare-pickers { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 16px; }
.fx-compare-chart .chart-card { margin: 0; }
.fx-save-row { display: flex; flex-wrap: wrap; align-items: end; gap: 10px 14px; }
.fx-save-row .fx-field { flex: 1 1 260px; max-width: 420px; }

/* Tables (Contribution, Amazon, Campaigns and flows) ------------------- */
.fx-table-scroll { border: 1px solid var(--line); border-top: 3px solid var(--surf); border-radius: 0 0 14px 14px; }
.fx-email-slide .fx-table-scroll { max-height: 560px; }
.fx-table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  color: var(--midnight);
  font-size: clamp(12px, 0.78vw, 14px);
}
.fx-email-table { min-width: 940px; }
.fx-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 10px 10px;
  border-bottom: 2px solid var(--line);
  background: var(--panel-strong, #eef7fb);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-align: right;
  text-transform: uppercase;
  white-space: nowrap;
}
.fx-table thead th[data-nonmetric] { text-align: left; }
.fx-table thead th:first-child { left: 0; z-index: 3; }
.fx-table tbody th,
.fx-table tbody td,
.fx-table tfoot th,
.fx-table tfoot td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--line);
  font-weight: 800;
  text-align: right;
  white-space: nowrap;
}
.fx-table tbody th,
.fx-table tfoot th {
  position: sticky;
  left: 0;
  z-index: 1;
  max-width: 280px;
  overflow: hidden;
  background: var(--white, #fff);
  text-align: left;
  text-overflow: ellipsis;
}
.fx-table td.fx-text { color: var(--muted); font-weight: 400; text-align: left; }
.fx-table tbody tr:nth-child(even) td { background: rgba(234, 246, 252, 0.45); }
.fx-table tbody tr:hover td,
.fx-table tbody tr:hover th { background: var(--soft-blue); }
.fx-table tfoot th,
.fx-table tfoot td { border-top: 2px solid var(--midnight); border-bottom: 0; background: var(--panel, #f7fbfd); }
.fx-table td.negative { color: var(--pink-text); }
.fx-table td.fx-state { color: var(--orange-text); font-size: 11px; letter-spacing: 0.05em; }
.fx-table-note { margin: 8px 0 0; color: var(--muted); font-size: 12px; font-weight: 400; line-height: 1.4; }

/* Contribution margin */
.fx-profit { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.fx-profit > * { min-width: 0; }
.fx-cogs-control {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 8px 18px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--soft-blue);
}
.fx-cogs-control .fx-field { flex: 0 0 auto; }
.fx-cogs-control p { flex: 1 1 200px; min-width: 0; margin: 0; color: var(--midnight); font-size: 13px; font-weight: 400; line-height: 1.4; }

/* Amazon layout preview badge (scope line) */
.fx-progress-badge {
  display: inline-block;
  margin-left: 10px;
  padding: 3px 10px;
  border: 1px solid var(--orange);
  border-radius: 999px;
  background: var(--soft-orange);
  color: var(--orange-text);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1.4;
  text-transform: uppercase;
  white-space: nowrap;
}
.fx-amazon-slide .slide-body > .chart-card { margin-bottom: 16px; }

/* Phone ----------------------------------------------------------------- */
@media (max-width: 767px) {
  .fx-panel > summary { padding: 12px 14px; }
  .fx-panel-body { padding: 4px 14px 14px; }
  .fx-summary-hint { font-size: 12px; }
  .fx-compare-pickers { grid-template-columns: 1fr; }
  .fx-target-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fx-target-name { grid-column: 1 / -1; }
  .fx-input { max-width: none; }
  .fx-save-row .fx-field { max-width: none; }
  .fx-save-row .fx-button { width: 100%; }
  .fx-progress-badge { margin: 4px 0 0; white-space: normal; }
}

@media print {
  .fx-panel { display: none; }
  .fx-table-scroll { max-height: none !important; overflow: visible; }
}

/* V2.2: the NEEDS COGS % state wraps instead of being cut off on narrow cards. */
.fx-contribution-slide .kpi > strong.compact-value { white-space: normal; overflow: visible; text-overflow: clip; }

/* Compare metrics layout switch (V2.2 rev: actual values, no indexing) */
.fx-compare-layout { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 4px 0 10px; }
.fx-segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.fx-segmented button { border: 0; background: transparent; color: var(--midnight); font: inherit; font-size: 13px; font-weight: 800; padding: 6px 14px; cursor: pointer; }
.fx-segmented button + button { border-left: 1px solid var(--line); }
.fx-segmented button[aria-pressed="true"] { background: var(--midnight); color: #fff; }
.fx-segmented button:focus-visible, .fx-link-button:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }
.fx-compare-hint { flex: 1 1 260px; min-width: 0; margin: 0; color: var(--orange-text); font-size: 13px; font-weight: 400; line-height: 1.4; }
.fx-link-button { border: 0; background: none; padding: 0; color: var(--surf); font: inherit; font-weight: 800; text-decoration: underline; cursor: pointer; }
.fx-saved-head { margin: 0 0 6px; color: var(--muted); font-size: 12.5px; font-weight: 400; }
.fx-saved-head strong { color: var(--midnight); font-weight: 800; }

/* Net sales target line on the R02 card (monthly goal prorated to the window). */
.kpi .kpi-target { margin: 6px 0 0; color: var(--muted); font-size: 12px; font-weight: 400; line-height: 1.35; }
.kpi .kpi-target b { font-weight: 800; letter-spacing: 0.02em; }
.kpi .kpi-target.is-ahead b { color: var(--green); }
.kpi .kpi-target.is-behind b { color: var(--pink-text); }
