/* nav.css – Modelos 303 / 130 + resumen – panel lateral (<nav>).
 * Todo cuelga de .fx y usa el prefijo fx- para no chocar con los estilos de la app. */

.fx {
  --fx-g: #8aae4b;
  --fx-g-dark: #4f6d22;
  --fx-g-soft: #eef3e2;
  --fx-line: #d6dccb;
  --fx-txt: #222;
  --fx-muted: #6b6b6b;
  --fx-calc: #f3f6ec;
  --fx-neg: #a23b2a;
  --fx-focus: rgba(138, 174, 75, .35);
  --fx-col-tipo: 86px;
  --fx-font: 13px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --fx-mono: 600 11px/1 ui-monospace, Menlo, Consolas, monospace;

  box-sizing: border-box;
  width: 100%;
  padding: 8px;
  font: var(--fx-font);
  color: var(--fx-txt);
  text-align: left;
}
.fx *, .fx *::before, .fx *::after { box-sizing: inherit; }
.fx [hidden] { display: none !important; }
.fx input, .fx select, .fx button { font: inherit; color: inherit; margin: 0; }

/* ---------- Cabecera del modelo ---------- */
.fx-hd { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.fx-badge {
  flex: none; padding: 7px 9px; border-radius: 6px;
  background: var(--fx-g-soft);
  font: 700 20px/1 system-ui, sans-serif;
}
.fx-h1 { font-weight: 700; color: var(--fx-g-dark); }
.fx-h2 { font-size: 12px; color: var(--fx-muted); }

/* ---------- Apartados plegables ---------- */
.fx-sec {
  border: 1px solid var(--fx-line); border-radius: 6px;
  background: #fff; margin-bottom: 8px; overflow: hidden;
}
/* Misma rejilla que el cuerpo: el resultado de la cabecera cae sobre su casilla */
.fx-head,
.fx-cols,
.fx-row.fx-inl {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--fx-col-tipo) minmax(0, 1fr);
  gap: 6px;
}
.fx .fx-head {
  align-items: center;
  width: 100%; min-height: 40px;
  padding: 5px 10px; border: 0; border-radius: 0;
  background: var(--fx-g); color: #fff;
  font-weight: 600; text-align: left; cursor: pointer;
}
.fx-head:focus-visible { outline: 2px solid var(--fx-g-dark); outline-offset: -2px; }
.fx-title { grid-column: 1 / 3; display: flex; align-items: center; gap: 8px; min-width: 0; }
.fx-title::before {
  content: ""; flex: none;
  width: 7px; height: 7px; margin: 0 2px 0 1px;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
}
.fx-ready .fx-title::before { transition: transform .2s; }
.fx-open > .fx-head .fx-title::before { transform: rotate(45deg); }
.fx-sub { margin: 0 0 8px; }
.fx .fx-sub > .fx-head { background: var(--fx-g-soft); color: var(--fx-g-dark); min-height: 38px; }

.fx-body { display: grid; grid-template-rows: 0fr; visibility: hidden; }
.fx-open > .fx-body { grid-template-rows: 1fr; visibility: visible; }
/* animación solo tras la carga (.fx-ready la pone el JS) */
.fx-ready .fx-body { transition: grid-template-rows .2s ease, visibility 0s linear .2s; }
.fx-ready .fx-open > .fx-body { transition: grid-template-rows .2s ease, visibility 0s; }
.fx-inner { overflow: hidden; min-height: 0; }
.fx-pad { padding: 8px 10px; }

/* ---------- Casillas ---------- */
.fx-row { padding: 6px 0; border-bottom: 1px dashed var(--fx-line); }
.fx-row:last-child { border-bottom: 0; }
.fx-lbl { display: block; margin-bottom: 4px; }
.fx-lbl small { display: block; margin-top: 1px; font-size: 11px; font-weight: 400; color: var(--fx-muted); }

.fx-cols + .fx-cols { margin-top: 5px; }
.fx-colhead { font-size: 11px; color: var(--fx-muted); margin-bottom: 2px; }
.fx-colhead span { text-align: center; }
.fx-colhead.fx-sm { margin: 0 0 3px; }

/* Fila en línea: texto a la izquierda, casilla en la columna de cuota */
.fx-row.fx-inl { align-items: center; }
.fx-inl > .fx-lbl { grid-column: 1 / 3; margin: 0; }
.fx-inl > .fx-lbl.fx-l1 { grid-column: 1; }
.fx-inl > .fx-fld { grid-column: 3; }
.fx-inl > .fx-fld.fx-c2 { grid-column: 2; }
.fx-inl > .fx-c23 { grid-column: 2 / 4; }

/* .fx-fld = casilla editable; .fx-sum = la misma casilla mostrada en una cabecera */
.fx-fld, .fx-sum {
  display: flex; align-items: stretch;
  border: 1px solid var(--fx-line); border-radius: 4px;
  background: #fff; overflow: hidden; margin: 0;
}
.fx-n {
  flex: none; display: flex; align-items: center; justify-content: center;
  min-width: 26px; padding: 0 4px;
  background: var(--fx-g-soft); color: var(--fx-g-dark);
  font: var(--fx-mono); white-space: nowrap;
}
.fx .fx-fld input, .fx-val {
  flex: 1; min-width: 0; width: 100%; height: auto;
  border: 0; outline: 0; box-shadow: none; border-radius: 0;
  padding: 5px 6px;
  background: transparent; text-align: right;
  font-variant-numeric: tabular-nums;
}
.fx-val { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fx-val:empty::after { content: "—"; opacity: .4; }
.fx .fx-cols > .fx-fld:nth-child(2) input, .fx .fx-c2 input { padding: 5px 4px; }
.fx-fld:focus-within { border-color: var(--fx-g-dark); box-shadow: 0 0 0 2px var(--fx-focus); }

.fx-calc, .fx-sum { background: var(--fx-calc); border-style: dashed; }
.fx-calc .fx-n, .fx-sum .fx-n { background: transparent; }
.fx .fx-calc input, .fx-calc .fx-val, .fx-sum .fx-val { color: var(--fx-g-dark); cursor: default; }
.fx-calc:focus-within { box-shadow: none; border-color: var(--fx-line); }
.fx .fx-neg input, .fx-neg .fx-val { color: var(--fx-neg); }
.fx-err { border-color: var(--fx-neg); }
.fx .fx-err input { color: var(--fx-neg); }

.fx-sum { grid-column: 3; display: none; font-weight: 600; }
.fx-sec:not(.fx-open) > .fx-head .fx-sum { display: flex; }

.fx-total .fx-lbl { font-weight: 600; }
.fx .fx-total .fx-fld input, .fx-total .fx-val { font-weight: 600; }
.fx-final { border-top: 2px solid var(--fx-g); border-bottom: 0; margin-top: 4px; padding-top: 8px; }
.fx .fx-final .fx-fld input, .fx-final .fx-val { font-weight: 700; }

/* Resumen: filas que llevan a la casilla */
.fx-link { cursor: pointer; }
.fx-link:hover .fx-lbl { color: var(--fx-g-dark); text-decoration: underline; }
.fx-gran-total { padding: 8px 10px; border: 1px solid var(--fx-line); border-top: 2px solid var(--fx-g); border-radius: 6px; background: #fff; margin: 0 0 8px; }

/* ---------- Estado del resultado ---------- */
.fx-estado {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin: 8px 0 0; padding: 6px 8px; border-radius: 4px;
  background: var(--fx-g-soft); color: var(--fx-g-dark); font-weight: 600;
}
.fx-estado-txt { margin-left: auto; }
.fx-estado[data-fx-estado="compensar"],
.fx-estado[data-fx-estado="devolver"],
.fx-estado[data-fx-estado="deducir"] { color: var(--fx-neg); }
.fx-estado[data-fx-estado="negativa"],
.fx-estado[data-fx-estado="cero"],
.fx-estado[data-fx-estado="sin_actividad"] { color: var(--fx-muted); }

/* Selector compensar / devolver dentro de la barra */
.fx-opt { display: none; cursor: pointer; }
.fx-estado.fx-neg .fx-opt { display: inline-flex; }
.fx-estado.fx-neg .fx-estado-txt { display: none; }
.fx .fx-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.fx-opt span { color: #9a9a9a; font-weight: 500; }
.fx-opt span::after { content: attr(data-off); }
.fx-opt:hover span { color: var(--fx-muted); }
.fx-opt input:checked + span { color: var(--fx-neg); font-weight: 600; }
.fx-opt input:checked + span::after { content: attr(data-on); }
.fx-opt input:focus-visible + span { outline: 2px solid var(--fx-g-dark); outline-offset: 2px; border-radius: 2px; }

/* ---------- Campos de texto ---------- */
.fx-tf { display: block; margin-bottom: 8px; }
.fx-tf > span { display: block; font-size: 12px; color: var(--fx-muted); margin-bottom: 3px; }
.fx .fx-tf input[type="text"], .fx .fx-tf input[type="date"], .fx .fx-tf select {
  width: 100%; height: auto; padding: 6px 8px;
  border: 1px solid var(--fx-line); border-radius: 4px;
  background: #fff; box-shadow: none;
}
.fx .fx-tf input:focus, .fx .fx-tf select:focus { outline: 0; border-color: var(--fx-g-dark); box-shadow: 0 0 0 2px var(--fx-focus); }
.fx-tf.fx-inl { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 8px; align-items: center; margin: 6px 0 0; }
.fx-tf.fx-inl > span { margin: 0; }
.fx-idrow { display: grid; grid-template-columns: 64px 70px minmax(0, 1fr); gap: 8px; }

.fx-radios { display: flex; gap: 16px; }
.fx-radios.fx-vert { flex-direction: column; gap: 4px; }
.fx-radios label { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }
.fx .fx-radios input { accent-color: var(--fx-g-dark); }

.fx-note { margin: 8px 0 4px; font-size: 12px; color: var(--fx-muted); }

/* ---------- Toggles SÍ / NO ---------- */
.fx-tglist { border-top: 1px solid var(--fx-line); }
.fx-tg {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 6px 0; border-bottom: 1px dashed var(--fx-line);
}
.fx-tgsub {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 16px; align-items: start;
  padding: 8px 0 0 12px;
  border-left: 3px solid var(--fx-g-soft); border-bottom: 1px dashed var(--fx-line);
}
.fx-switch { flex: none; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.fx .fx-switch input {
  appearance: none; -webkit-appearance: none;
  display: inline-block; position: relative; flex: none;
  width: 36px; height: 20px; padding: 0; border: 0;
  border-radius: 10px; background: #c9c9c9;
  cursor: pointer; transition: background .15s;
}
.fx .fx-switch input::before {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
  transition: transform .15s;
}
.fx .fx-switch input:checked { background: var(--fx-g); }
.fx .fx-switch input:checked::before { transform: translateX(16px); }
.fx .fx-switch input:disabled { cursor: default; opacity: .75; }
.fx .fx-switch input:focus-visible { outline: 2px solid var(--fx-g-dark); outline-offset: 2px; }
.fx-st { width: 20px; font-size: 11px; font-weight: 600; color: var(--fx-muted); }
.fx-st::after { content: "NO"; }
.fx-switch input:checked + .fx-st { color: var(--fx-g-dark); }
.fx-switch input:checked + .fx-st::after { content: "SÍ"; }

/* ---------- Botones globales ---------- */
.fx-actions { display: flex; gap: 6px; justify-content: flex-end; }
.fx .fx-actions button {
  padding: 4px 10px;
  border: 1px solid var(--fx-line); border-radius: 4px;
  background: #fff; color: var(--fx-g-dark);
  font-size: 12px; cursor: pointer;
}
.fx .fx-actions button:hover { background: var(--fx-g-soft); }
