/* AUTIQ · Cobranzas — estilos compartidos (login + panel) */

:root {
  /* Marca: 3 colores base por empresa (se sobrescriben desde JS); el resto se deriva */
  --rail: #15234a;
  --action: #2347c9;
  --accent: #d1890f;
  --rail-2: color-mix(in oklab, var(--rail), white 9%);
  --rail-3: color-mix(in oklab, var(--rail), white 20%);
  --rail-ink: color-mix(in oklab, white 92%, var(--rail));
  --rail-ink-2: color-mix(in oklab, white 70%, var(--rail));
  --rail-ink-3: color-mix(in oklab, white 55%, var(--rail));

  /* Suelo: estante de acero */
  --ground: #e8ebf0;
  --surface: #ffffff;
  --surface-2: #f4f6f9;
  --surface-3: #eceff4;
  --line: #d7dce5;
  --line-2: #e5e9ef;
  --ink: #131a2c;
  --ink-2: #434d66;
  --ink-3: #626c86;

  /* Único color de acción */
  --action-hover: color-mix(in oklab, var(--action), black 16%);
  --action-soft: color-mix(in oklab, var(--action) 10%, white);
  --action-ring: color-mix(in srgb, var(--action) 18%, transparent);

  /* Estados (colores de archivador) */
  --s-vencido: #c8372d;  --s-vencido-bg: #fbeae8;  --s-vencido-ink: #a32a21;
  --s-parcial: #d1890f;  --s-parcial-bg: #fdf2dc;  --s-parcial-ink: #8a5600;
  --s-pagado:  #2f8a4c;  --s-pagado-bg:  #e3f2e7;  --s-pagado-ink:  #1f6b37;
  --s-hoy:     #6b4fd0;  --s-hoy-bg:     #eeeafb;  --s-hoy-ink:     #4f35b0;
  --s-pendiente: #9aa5c0; --s-pendiente-bg: #eef1f6; --s-pendiente-ink: #4a5675;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-1: 0 1px 2px rgba(19, 26, 44, .06), 0 2px 6px rgba(19, 26, 44, .04);
  --shadow-2: 0 8px 24px rgba(19, 26, 44, .12), 0 2px 6px rgba(19, 26, 44, .06);
  --shadow-sheet: -24px 0 60px rgba(13, 21, 46, .22);
  --ease-out: cubic-bezier(.16, 1, .3, 1);

  --font: "Archivo", ui-sans-serif, system-ui, "Segoe UI", sans-serif;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 400 14px/1.45 var(--font);
  font-variation-settings: "wdth" 100;
  caret-color: var(--action);
  accent-color: var(--action);
}
::selection { background: color-mix(in oklab, var(--action) 22%, white); color: var(--ink); }
h1, h2, h3, h4 { margin: 0; line-height: 1.15; text-wrap: balance; }
p { margin: 0; }
a { color: var(--action); text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
.num, td.num, .tabular { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: #b9c1d1 transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: #b9c1d1; border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background-color: #98a2b8; }

:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; border-radius: 6px; }

.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 15px; height: 15px; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink);
  font-weight: 550; font-size: 13.5px; white-space: nowrap;
  cursor: pointer; text-decoration: none;
  transition: background-color .15s, border-color .15s, color .15s, transform .15s var(--ease-out);
}
.btn:hover { background: var(--surface-2); border-color: #c4cbd8; }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--action); border-color: var(--action); color: #fff; }
.btn.primary:hover { background: var(--action-hover); border-color: var(--action-hover); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-3); color: var(--ink); }
.btn.danger { color: var(--s-vencido-ink); }
.btn.danger:hover { background: var(--s-vencido-bg); border-color: #efc4bf; }
.btn.danger.solid { background: var(--s-vencido); border-color: var(--s-vencido); color: #fff; }
.btn.sm { height: 32px; padding: 0 10px; font-size: 13px; }
.btn.icon-only { width: 34px; padding: 0; }
.btn.sm.icon-only { width: 32px; }
.btn.block { width: 100%; }

/* ---------- Campos ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field small { color: var(--ink-3); font-size: 12px; }
.input, .field input, .field select, .field textarea, select.input {
  width: 100%; height: 40px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.field textarea { height: auto; min-height: 76px; padding: 10px 12px; resize: vertical; }
.input::placeholder, .field input::placeholder, .field textarea::placeholder { color: #69728a; }
.input:hover, .field input:hover, .field select:hover, .field textarea:hover { border-color: #bcc4d3; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--action); box-shadow: 0 0 0 3px var(--action-ring); }
.field input[readonly] { background: var(--surface-2); color: var(--ink-2); }
.field input:user-invalid, .field select:user-invalid { border-color: var(--s-vencido); }
.field .hint-err { color: var(--s-vencido-ink); font-size: 12px; font-weight: 550; }

/* ---------- Etiquetas de estado ---------- */
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 9px; border-radius: 6px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--surface-3); color: var(--ink-2);
}
.tag::before { content: ""; width: 7px; height: 7px; border-radius: 2px; background: currentColor; opacity: .9; }
.tag.plain::before { display: none; }
.tag.Vencido { background: var(--s-vencido-bg); color: var(--s-vencido-ink); }
.tag.Parcial { background: var(--s-parcial-bg); color: var(--s-parcial-ink); }
.tag.Pagado { background: var(--s-pagado-bg); color: var(--s-pagado-ink); }
.tag.Hoy { background: var(--s-hoy-bg); color: var(--s-hoy-ink); }
.tag.Pendiente { background: var(--s-pendiente-bg); color: var(--s-pendiente-ink); }
.tag.Pendiente::before { background: transparent; box-shadow: inset 0 0 0 1.5px currentColor; }
.tag.Anulado { background: var(--surface-3); color: var(--ink-3); text-decoration: line-through; }
.tag.AlDia { background: var(--s-pagado-bg); color: var(--s-pagado-ink); }
.tag.Cancelado { background: #e6e9f4; color: #3d4f86; }

/* Color de lomo por estado de contrato */
:root {
  --spine-Vencido: var(--s-vencido); --spine-Hoy: var(--s-hoy); --spine-Parcial: var(--s-parcial);
  --spine-AlDia: var(--s-pagado); --spine-Cancelado: #3d4f86; --spine-none: #7f8db1;
}

/* =========================================================
   LOGIN
   ========================================================= */
.login-page { min-height: 100dvh; display: grid; grid-template-columns: minmax(380px, 1.05fr) minmax(400px, 1fr); background: var(--surface); }
.login-aside {
  position: relative; overflow: hidden;
  background: var(--rail); color: var(--rail-ink);
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 48px 56px 0;
}
.wordmark { display: flex; align-items: baseline; gap: 2px; font-weight: 800; font-size: 26px; letter-spacing: .14em; font-variation-settings: "wdth" 112; color: #fff; }
.wordmark i { width: 9px; height: 9px; border-radius: 2px; background: var(--accent); display: inline-block; margin-left: 4px; flex: none; }
.wordmark { min-width: 0; }
.wordmark span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wordmark img { height: 34px; width: auto; max-width: 140px; object-fit: contain; border-radius: 6px; background: #fff; padding: 3px; margin-right: 10px; flex: none; align-self: center; }
.login-aside .tagline { margin-top: 12px; color: var(--rail-ink-2); font-size: 14px; max-width: 34ch; }
.login-aside h1 { margin-top: 64px; font-size: clamp(30px, 3.2vw, 44px); font-weight: 700; letter-spacing: -.02em; font-variation-settings: "wdth" 90; color: #fff; max-width: 15ch; }
.login-aside .lead { margin-top: 16px; color: var(--rail-ink-2); max-width: 44ch; font-size: 15px; }

/* El estante del login: lomos de archivador */
.shelf-art { margin-top: auto; padding-top: 40px; }
.shelf-art .row { display: flex; align-items: flex-end; gap: 6px; padding: 0 4px; }
.shelf-art .board { height: 14px; margin: 0 -56px; background: linear-gradient(color-mix(in oklab, var(--rail), white 24%), color-mix(in oklab, var(--rail), white 12%)); box-shadow: 0 -1px 0 color-mix(in oklab, var(--rail), white 34%) inset; }
.mini-spine {
  position: relative; flex: none; width: 38px; border-radius: 3px 3px 0 0;
  background: var(--c, #7286c1);
  box-shadow: inset -5px 0 0 rgba(0, 0, 0, .12), inset 1px 0 0 rgba(255, 255, 255, .18);
  transform-origin: bottom center;
  animation: spineIn .9s var(--ease-out) both;
  animation-delay: calc(var(--i) * 45ms);
}
.mini-spine::before { content: ""; position: absolute; left: 6px; right: 7px; top: 14px; height: 46%; background: #f7f8fb; border-radius: 2px; }
.mini-spine::after { content: ""; position: absolute; left: 50%; bottom: 14px; width: 14px; height: 14px; margin-left: -8px; border-radius: 50%; background: var(--rail); box-shadow: inset 0 2px 3px rgba(0, 0, 0, .35); }
.mini-spine.lean { transform: rotate(-7deg); transform-origin: bottom left; animation: none; }
@keyframes spineIn { from { transform: translateY(18px); opacity: 0; } }

.login-main { display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: var(--surface); }
.login-card { width: 100%; max-width: 400px; }
.login-card h2 { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.login-card > p { margin-top: 8px; color: var(--ink-3); }
.login-form { margin-top: 28px; display: grid; gap: 18px; }
.pass-wrap { position: relative; display: block; }
.pass-wrap input { padding-right: 46px; }
.pass-wrap .btn { position: absolute; right: 3px; top: 3px; height: 34px; width: 38px; }
.login-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--ink-2); }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 16px; height: 16px; margin: 0; }
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 11px 13px; border-radius: var(--radius-sm); font-size: 13px; background: var(--s-vencido-bg); color: var(--s-vencido-ink); }
.alert.info { background: var(--surface-2); color: var(--ink-2); }
.alert .icon { margin-top: 1px; }
.alert[hidden] { display: none; }
.caps { color: var(--s-parcial-ink); font-size: 12px; font-weight: 600; }
.login-submit { height: 44px; font-size: 14.5px; }
.login-submit .spinner { display: none; }
.login-submit.loading .spinner { display: inline-block; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .4); border-top-color: #fff; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.avatar { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; font-weight: 700; font-size: 12.5px; color: #fff; background: var(--rail-3); flex: none; }
.login-foot { margin-top: 28px; font-size: 12px; color: var(--ink-3); }

/* =========================================================
   PANEL
   ========================================================= */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100dvh; }
.rail {
  position: sticky; top: 0; height: 100dvh;
  display: flex; flex-direction: column;
  background: var(--rail); color: var(--rail-ink);
  padding: 26px 16px 18px;
}
.rail .wordmark { font-size: 21px; padding: 0 10px; }
.rail .tagline { padding: 0 10px; margin-top: 6px; font-size: 12px; color: var(--rail-ink-2); }
.nav { margin-top: 34px; display: grid; gap: 2px; }
.nav-sep { margin: 18px 10px 8px; font-size: 11.5px; font-weight: 600; color: var(--rail-ink-3); }
.nav a {
  position: relative; display: flex; align-items: center; gap: 12px;
  height: 40px; padding: 0 10px; border-radius: 8px;
  color: var(--rail-ink-2); text-decoration: none; font-weight: 500;
  transition: background-color .15s, color .15s;
}
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav a[aria-current="page"] { background: var(--rail-2); color: #fff; }
.nav a[aria-current="page"]::after { content: ""; position: absolute; right: 10px; width: 6px; height: 6px; border-radius: 2px; background: var(--accent); }
.nav .count { margin-left: auto; min-width: 22px; height: 20px; padding: 0 6px; border-radius: 6px; background: rgba(200, 55, 45, .9); color: #fff; font-size: 11.5px; font-weight: 650; display: grid; place-items: center; }
.nav a[aria-current="page"] .count { margin-right: 14px; }
.rail-user { margin-top: auto; display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 12px 10px 0; border-top: 1px solid rgba(255, 255, 255, .1); }
.rail-user b { display: block; font-size: 13px; font-weight: 600; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-user small { font-size: 12px; color: var(--rail-ink-2); }
.rail-user .avatar { background: var(--rail-3); }
.rail-user .btn { color: var(--rail-ink-2); }
.rail-user .btn:hover { background: rgba(255, 255, 255, .08); color: #fff; }

.main { min-width: 0; padding: 26px 36px 40px; max-width: 1560px; width: 100%; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.topbar h1 { font-size: 28px; font-weight: 700; letter-spacing: -.02em; font-variation-settings: "wdth" 92; }
.topbar p { margin-top: 6px; color: var(--ink-3); }
.topbar .actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.panel { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-1); }
.panel-head { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line-2); flex-wrap: wrap; }
.panel-head h2 { font-size: 15.5px; font-weight: 650; }
.panel-head .sub { color: var(--ink-3); font-size: 12.5px; }
.panel-head .end { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.panel-body { padding: 18px; }
.stack { display: grid; gap: 20px; }

/* Banda de etiquetas de lomo (cifras) */
.labels { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.label-card { position: relative; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-1); padding: 0 18px 16px; overflow: hidden; }
.label-card .band { height: 5px; margin: 0 -18px 14px; background: var(--band, var(--rail)); }
.label-card .k { display: flex; align-items: center; justify-content: space-between; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.label-card .k .icon { color: var(--ink-3); }
.label-card .v { margin-top: 10px; font-size: 27px; font-weight: 700; letter-spacing: -.02em; font-variation-settings: "wdth" 88; font-variant-numeric: tabular-nums; }
.label-card .d { margin-top: 4px; font-size: 12.5px; color: var(--ink-3); }
.label-card .d b { color: var(--ink-2); font-weight: 600; }
.delta-up { color: var(--s-pagado-ink) !important; }
.delta-down { color: var(--s-vencido-ink) !important; }

/* ---------- Estante de cartera (movimiento firma) ---------- */
.dash-grid { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(320px, 1fr); gap: 20px; align-items: start; }
.shelf-wrap { padding: 20px 18px 6px; }
.shelf { display: grid; gap: 26px; }
.shelf-row { position: relative; display: flex; align-items: flex-end; gap: 7px; padding: 0 10px; min-height: 196px; }
.shelf-row::after {
  content: ""; position: absolute; left: -2px; right: -2px; bottom: -12px; height: 12px;
  background: linear-gradient(#cfd5df, #b7bfcc); border-radius: 2px;
  box-shadow: 0 6px 10px -6px rgba(19, 26, 44, .35);
}
.spine {
  --c: var(--s-pendiente);
  position: relative; flex: none; width: 50px; height: 188px;
  border: 0; padding: 0; cursor: pointer;
  border-radius: 4px 4px 1px 1px;
  background: var(--c);
  box-shadow: inset -7px 0 0 rgba(0, 0, 0, .13), inset 1px 0 0 rgba(255, 255, 255, .22), 0 1px 1px rgba(19, 26, 44, .2);
  transition: transform .35s var(--ease-out), box-shadow .35s var(--ease-out);
}
.spine:hover, .spine:focus-visible { transform: translateY(-10px); box-shadow: inset -7px 0 0 rgba(0, 0, 0, .13), inset 1px 0 0 rgba(255, 255, 255, .22), 0 12px 18px -8px rgba(19, 26, 44, .45); }
.spine:focus-visible { outline-offset: 3px; }
.spine.pulled { transform: translateY(-34px); transition-duration: .28s; }
.spine[data-s="Vencido"] { --c: var(--s-vencido); }
.spine[data-s="Parcial"] { --c: var(--s-parcial); }
.spine[data-s="Hoy"] { --c: var(--s-hoy); }
.spine[data-s="AlDia"] { --c: var(--s-pagado); }
.spine[data-s="Cancelado"] { --c: #3d4f86; }
.spine .lbl {
  position: absolute; left: 7px; right: 10px; top: 12px; bottom: 50px;
  background: #fbfbfd; border-radius: 2px;
  display: flex; flex-direction: column; align-items: center; overflow: hidden;
}
.spine .lbl .no { width: 100%; padding: 4px 0 3px; border-bottom: 1px solid #d9dde6; font-size: 9.5px; font-weight: 700; color: var(--ink-2); font-variation-settings: "wdth" 75; text-align: center; font-variant-numeric: tabular-nums; }
.spine .lbl .nm {
  flex: 1; writing-mode: vertical-rl; transform: rotate(180deg);
  padding: 6px 0; font-size: 12px; font-weight: 650; color: var(--ink);
  font-variation-settings: "wdth" 72; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-height: 100%;
}
.spine .lbl .fill { position: absolute; left: 0; bottom: 0; width: 100%; height: 4px; background: #e2e6ee; }
.spine .lbl .fill i { display: block; height: 100%; width: var(--p, 0%); background: var(--ink-2); }
.spine .ring { position: absolute; left: 50%; bottom: 16px; width: 18px; height: 18px; margin-left: -11px; border-radius: 50%; background: var(--surface-2); box-shadow: inset 0 2px 4px rgba(0, 0, 0, .35), 0 0 0 2px rgba(255, 255, 255, .25); }
.shelf-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 22px 6px 14px; font-size: 12.5px; color: var(--ink-2); }
.shelf-legend span { display: inline-flex; align-items: center; gap: 7px; }
.shelf-legend i { width: 10px; height: 14px; border-radius: 2px 2px 0 0; background: var(--c); }
.shelf-empty { padding: 30px 10px; color: var(--ink-3); text-align: center; }

/* Cola de prioridad */
.queue { list-style: none; margin: 0; padding: 6px 0; }
.queue li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 12px 18px; border-bottom: 1px solid var(--line-2); }
.queue li:last-child { border-bottom: 0; }
.queue .who { min-width: 0; }
.queue .who b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue .who small { color: var(--ink-3); font-size: 12.5px; }
.queue .amt { text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; }
.queue .amt small { display: block; font-weight: 500; color: var(--s-vencido-ink); font-size: 12px; }
.queue .acts { grid-column: 1 / -1; display: flex; gap: 6px; margin-top: 6px; }

/* Gráficas */
.charts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; margin-top: 20px; }
.bars { display: grid; gap: 10px; }
.hbar { display: grid; grid-template-columns: 82px minmax(0, 1fr) 96px; align-items: center; gap: 10px; font-size: 12.5px; }
.hbar .t { color: var(--ink-2); }
.hbar .track { height: 14px; border-radius: 0 4px 4px 0; background: var(--surface-2); }
.hbar .track i { display: block; height: 100%; border-radius: 0 4px 4px 0; background: var(--c); }
.hbar .val { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.vbars { position: relative; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; align-items: end; height: 150px; padding-top: 18px; border-bottom: 1px solid var(--line); }
.vbar { position: relative; height: 100%; display: flex; align-items: flex-end; justify-content: center; cursor: default; }
.vbar i { display: block; width: 62%; max-width: 34px; height: var(--h); min-height: 2px; border-radius: 4px 4px 0 0; background: #a9b5da; transition: background-color .15s; }
.vbar.now i { background: var(--rail); }
.vbar:hover i { background: var(--rail-3); }
.vbar .tip { position: absolute; bottom: calc(var(--h) + 8px); left: 50%; transform: translateX(-50%); padding: 5px 8px; border-radius: 6px; background: var(--ink); color: #fff; font-size: 12px; font-weight: 600; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .12s; z-index: 2; font-variant-numeric: tabular-nums; }
.vbar:hover .tip, .vbar:focus-visible .tip { opacity: 1; }
.vlabels { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; margin-top: 8px; font-size: 12px; color: var(--ink-3); text-align: center; text-transform: capitalize; }
.mini-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.mini-table td, .mini-table th { padding: 9px 0; border-bottom: 1px solid var(--line-2); text-align: left; }
.mini-table th { font-size: 12px; font-weight: 600; color: var(--ink-3); }
.mini-table td.num, .mini-table th.num { text-align: right; }
.mini-table tr:last-child td { border-bottom: 0; }

/* ---------- Herramientas y tablas ---------- */
.tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 14px 18px; border-bottom: 1px solid var(--line-2); }
.search { position: relative; flex: 1 1 280px; max-width: 380px; }
.search .icon { position: absolute; left: 11px; top: 11px; color: var(--ink-3); pointer-events: none; }
.search input { padding-left: 36px; }
.tools select.input { width: auto; min-width: 150px; }
.tools .end { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 11px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
  font-size: 13px; font-weight: 550; color: var(--ink-2); cursor: pointer;
  transition: background-color .15s, border-color .15s, color .15s;
}
.chip:hover { border-color: #bcc4d3; color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--rail); border-color: var(--rail); color: #fff; }
.chip .n { font-variant-numeric: tabular-nums; font-size: 12px; opacity: .75; }
.chip .dot { width: 8px; height: 8px; border-radius: 2px; background: var(--c); }

.table-wrap { overflow: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  position: sticky; top: 0; z-index: 1;
  padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--line);
  text-align: left; font-size: 12px; font-weight: 600; color: var(--ink-3); white-space: nowrap;
}
table.data th button { all: unset; cursor: pointer; display: inline-flex; gap: 4px; align-items: center; }
table.data th button:hover { color: var(--ink); }
table.data th button:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; border-radius: 4px; }
table.data td { padding: 12px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; white-space: nowrap; }
table.data tbody tr { transition: background-color .12s; }
table.data tbody tr:hover { background: #f8f9fc; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td .t1 { font-weight: 600; color: var(--ink); }
table.data td .t2 { display: block; color: var(--ink-3); font-size: 12.5px; margin-top: 2px; }
table.data td.act { text-align: right; }
table.data td.act .btn + .btn { margin-left: 4px; }
table.data tr.voided td { color: var(--ink-3); }
table.data tr.voided td .t1, table.data tr.voided td.num { text-decoration: line-through; }
.link-btn { all: unset; cursor: pointer; font-weight: 600; color: var(--ink); }
.link-btn:hover { color: var(--action); text-decoration: underline; text-underline-offset: 3px; }
.link-btn:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; border-radius: 4px; }
.late { font-weight: 600; color: var(--s-vencido-ink); font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.empty { padding: 44px 20px; text-align: center; color: var(--ink-3); }
.empty b { display: block; color: var(--ink-2); font-size: 14.5px; margin-bottom: 4px; }
.empty .btn { margin-top: 14px; }
.table-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 18px; font-size: 12.5px; color: var(--ink-3); }
.entry-cell { display: grid; gap: 4px; }
.entry-cell .amt { font-variant-numeric: tabular-nums; font-size: 13px; }
.meter { display: block; margin-top: 6px; width: 120px; height: 5px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.meter i { display: block; height: 100%; width: var(--p); background: var(--c, var(--s-pagado)); }

/* Tira de cuotas */
.strip { display: flex; flex-wrap: wrap; gap: 3px; }
.strip i { width: 12px; height: 16px; border-radius: 2px; background: var(--c); }
.strip i[data-s="Pagado"] { --c: var(--s-pagado); }
.strip i[data-s="Vencido"] { --c: var(--s-vencido); }
.strip i[data-s="Parcial"] { --c: var(--s-parcial); }
.strip i[data-s="Hoy"] { --c: var(--s-hoy); }
.strip i[data-s="Pendiente"] { --c: transparent; box-shadow: inset 0 0 0 1.5px #aab3c8; }
.strip.lg i { width: 16px; height: 22px; }

/* Calculadora */
.calc { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, 1fr); gap: 20px; align-items: start; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.result-label { border-radius: var(--radius); overflow: hidden; background: var(--surface); box-shadow: var(--shadow-1); position: sticky; top: 20px; }
.result-label .head { background: var(--rail); color: #fff; padding: 16px 18px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.result-label .head small { color: var(--rail-ink-2); display: block; font-size: 12px; }
.result-label .head b { font-size: 15px; font-weight: 650; }
.result-label .code { font: 700 13px/1 var(--font); font-variation-settings: "wdth" 80; background: #fff; color: var(--rail); padding: 6px 8px; border-radius: 4px; font-variant-numeric: tabular-nums; }
.kv { display: grid; }
.kv div { display: flex; justify-content: space-between; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line-2); }
.kv div span { color: var(--ink-2); }
.kv div b { font-variant-numeric: tabular-nums; font-weight: 650; }
.kv div.big { padding: 16px 18px; background: var(--surface-2); }
.kv div.big b { font-size: 22px; letter-spacing: -.01em; }
.note { font-size: 12.5px; color: var(--ink-3); padding: 14px 18px; }
.preview-dates { padding: 0 18px 16px; font-size: 12.5px; color: var(--ink-2); }
.preview-dates ol { margin: 8px 0 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.preview-dates li { padding: 6px 8px; background: var(--surface-2); border-radius: 6px; font-variant-numeric: tabular-nums; }
.preview-dates li b { color: var(--ink-3); font-weight: 600; margin-right: 4px; }

/* Expediente / cronograma */
.file-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 16px; align-items: center; }
.file-tab { width: 46px; height: 64px; border-radius: 4px 4px 1px 1px; background: var(--c, var(--s-pendiente)); position: relative; box-shadow: inset -6px 0 0 rgba(0, 0, 0, .13); }
.file-tab::before { content: ""; position: absolute; left: 6px; right: 9px; top: 8px; height: 26px; background: #fbfbfd; border-radius: 2px; }
.file-tab::after { content: ""; position: absolute; left: 50%; bottom: 8px; width: 12px; height: 12px; margin-left: -8px; border-radius: 50%; background: var(--surface-2); box-shadow: inset 0 2px 3px rgba(0, 0, 0, .35); }
.file-head h2 { font-size: 21px; font-weight: 700; letter-spacing: -.01em; }
.file-head .meta { margin-top: 4px; color: var(--ink-3); font-size: 13px; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--line-2); }
.facts > div { padding: 14px 18px; border-right: 1px solid var(--line-2); }
.facts > div:last-child { border-right: 0; }
.facts span { display: block; font-size: 12px; color: var(--ink-3); font-weight: 550; }
.facts b { display: block; margin-top: 4px; font-size: 17px; font-weight: 650; font-variant-numeric: tabular-nums; }
.progress { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.progress i { display: block; height: 100%; width: var(--p); background: var(--s-pagado); border-radius: 4px; }

/* ---------- Hoja lateral (expediente sacado del estante) ---------- */
dialog.sheet {
  position: fixed; inset: 0 0 0 auto; margin: 0;
  width: min(620px, 100vw); max-width: none; height: 100dvh; max-height: none;
  padding: 0; border: 0; background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-sheet); overflow: hidden;
}
dialog.sheet.wide { width: min(780px, 100vw); }
dialog.sheet[open] { display: flex; flex-direction: column; animation: sheetIn .42s var(--ease-out); }
dialog.sheet.closing { animation: sheetOut .22s ease-in forwards; }
dialog.sheet::backdrop { background: rgba(13, 21, 46, .38); animation: fadeIn .3s ease-out; }
@keyframes sheetIn { from { transform: translateX(48px); opacity: 0; } }
@keyframes sheetOut { to { transform: translateX(40px); opacity: 0; } }
@keyframes fadeIn { from { opacity: 0; } }
.sheet-head { display: flex; align-items: flex-start; gap: 12px; padding: 20px 22px 16px; border-bottom: 1px solid var(--line-2); }
.sheet-head h2 { font-size: 19px; font-weight: 700; letter-spacing: -.01em; }
.sheet-head p { margin-top: 4px; color: var(--ink-3); font-size: 13px; }
.sheet-head .btn { margin-left: auto; }
.sheet-body { flex: 1; overflow: auto; padding: 20px 22px 28px; display: grid; gap: 22px; align-content: start; grid-auto-rows: max-content; }
.sheet-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 22px; border-top: 1px solid var(--line-2); background: var(--surface); }
.section h3 { font-size: 14px; font-weight: 650; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.section h3 .end { margin-left: auto; }
.box { border: 1px solid var(--line-2); border-radius: var(--radius-sm); }
.box + .box { margin-top: 10px; }
.box-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line-2); flex-wrap: wrap; }
.box-row:last-child { border-bottom: 0; }
.box-row .grow { flex: 1; min-width: 0; }
.box-row b { font-weight: 600; }
.box-row small { display: block; color: var(--ink-3); font-size: 12.5px; }
.pay-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line-2); border-radius: var(--radius-sm); overflow: hidden; }
.pay-summary div { background: var(--surface-2); padding: 12px 14px; }
.pay-summary span { font-size: 12px; color: var(--ink-3); }
.pay-summary b { display: block; margin-top: 3px; font-size: 16px; font-variant-numeric: tabular-nums; }
.inline-form { display: grid; gap: 14px; padding: 16px; background: var(--surface-2); border-radius: var(--radius-sm); }
.inline-form .row-actions { display: flex; justify-content: flex-end; gap: 8px; }
.warn-box { display: flex; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--s-parcial-bg); color: var(--s-parcial-ink); font-size: 13px; }
.ok-box { display: flex; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--s-pagado-bg); color: var(--s-pagado-ink); font-size: 13px; font-weight: 550; }
.alloc { font-size: 12.5px; color: var(--ink-2); }
.alloc li { font-variant-numeric: tabular-nums; }

.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.timeline li { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.timeline li:last-child { border-bottom: 0; }
.timeline .ic { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-3); color: var(--ink-2); }
.timeline .ic.promesa { background: var(--s-hoy-bg); color: var(--s-hoy-ink); }
.timeline b { font-weight: 600; font-size: 13px; }
.timeline p { color: var(--ink-2); font-size: 13px; margin-top: 2px; white-space: pre-wrap; }
.timeline small { color: var(--ink-3); font-size: 12px; }

/* Recibo */
.receipt { border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.receipt .rh { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px; background: var(--rail); color: #fff; }
.receipt .rh .wordmark { font-size: 18px; }
.receipt .rh small { color: var(--rail-ink-2); display: block; font-size: 12px; text-align: right; }
.receipt .rh b { font-variant-numeric: tabular-nums; }
.receipt .rb { padding: 16px 18px; display: grid; gap: 10px; }
.receipt .line { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; }
.receipt .line span { color: var(--ink-3); }
.receipt .total { display: flex; justify-content: space-between; padding: 14px 18px; border-top: 1px dashed var(--line); font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.receipt .stamp { justify-self: start; margin-top: 4px; padding: 4px 10px; border: 2px solid var(--s-pagado); color: var(--s-pagado-ink); border-radius: 4px; font-weight: 800; letter-spacing: .12em; font-size: 12px; transform: rotate(-3deg); }
.receipt .stamp.void { border-color: var(--s-vencido); color: var(--s-vencido-ink); }

/* Toasts */
.toasts { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 100; justify-items: center; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 14px; border-radius: 10px; background: var(--ink); color: #fff; box-shadow: var(--shadow-2); font-size: 13.5px; pointer-events: auto; animation: toastIn .35s var(--ease-out); }
.toast .icon { color: #8fd3a6; }
.toast.err .icon { color: #ff9a8f; }
.toast button { all: unset; cursor: pointer; font-weight: 650; color: #b9c8ff; padding: 4px 6px; border-radius: 6px; }
.toast button:hover { background: rgba(255, 255, 255, .1); }
.toast.out { animation: toastOut .2s ease-in forwards; }
@keyframes toastIn { from { transform: translateY(12px); opacity: 0; } }
@keyframes toastOut { to { transform: translateY(8px); opacity: 0; } }

/* Confirmación */
dialog.confirm { border: 0; border-radius: 14px; padding: 0; width: min(440px, calc(100vw - 32px)); box-shadow: var(--shadow-2); color: var(--ink); }
dialog.confirm::backdrop { background: rgba(13, 21, 46, .38); }
dialog.confirm[open] { animation: popIn .25s var(--ease-out); }
@keyframes popIn { from { transform: scale(.97); opacity: 0; } }
dialog.confirm .c-body { padding: 22px 22px 6px; display: grid; gap: 10px; }
dialog.confirm h2 { font-size: 17px; font-weight: 700; }
dialog.confirm p { color: var(--ink-2); }
dialog.confirm .c-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 22px 20px; }

/* Print-only */
.print-head { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
  .charts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .dash-grid, .calc { grid-template-columns: minmax(0, 1fr); }
  .labels { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .result-label { position: static; }
}
@media (max-width: 900px) {
  .login-page { grid-template-columns: 1fr; }
  .login-aside { padding: 28px 24px 0; }
  .login-aside h1 { margin-top: 28px; font-size: 28px; }
  .login-aside .lead { display: none; }
  .shelf-art .board { margin: 0 -24px; }
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .rail { position: sticky; z-index: 20; height: auto; flex-direction: row; align-items: center; gap: 12px; padding: 10px 16px; min-width: 0; }
  .rail .wordmark { flex: none; font-size: 18px; padding: 0; }
  .rail .tagline, .nav-sep, .rail-user > div { display: none; }
  .nav { margin: 0; display: flex; overflow-x: auto; gap: 2px; flex: 1; min-width: 0; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { flex: none; height: 36px; }
  .nav a[aria-current="page"]::after { display: none; }
  .rail-user { margin: 0; padding: 0; border: 0; grid-template-columns: auto auto; }
  .main { padding: 18px 16px 32px; }
  .topbar { flex-direction: column; align-items: flex-start; }
  .topbar .actions { justify-content: flex-start; }
  .charts { grid-template-columns: minmax(0, 1fr); }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .facts > div:nth-child(2) { border-right: 0; }
  .facts > div:nth-child(-n+2) { border-bottom: 1px solid var(--line-2); }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .search { max-width: none; }
}
@media (max-width: 560px) {
  .labels { grid-template-columns: minmax(0, 1fr); }
  .label-card .v { font-size: 23px; }
  .pay-summary { grid-template-columns: 1fr; }
  .preview-dates ol { grid-template-columns: repeat(2, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- Impresión ---------- */
@media print {
  body { background: #fff; font-size: 12px; }
  .rail, .topbar .actions, .demo-strip, .tools, .no-print, .toasts, .btn { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; max-width: none; }
  .panel, .label-card { box-shadow: none; border: 1px solid #ccc; }
  .print-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
  .print-head .wordmark { color: var(--rail); }
  .print-head .wordmark i { background: var(--rail); }
  table.data th { position: static; }
  table.data td, table.data th { padding: 6px 8px; }
  body.print-sheet .shell { display: none; }
  body.print-sheet dialog.sheet { position: static; width: 100%; height: auto; box-shadow: none; display: block; animation: none; }
  body.print-sheet dialog.sheet::backdrop { display: none; }
  body.print-sheet .sheet-head .btn, body.print-sheet .sheet-foot { display: none; }
  body.print-sheet .sheet-body { overflow: visible; }
  .tag { border: 1px solid currentColor; }
}

/* =========================================================
   MARCA / PERSONALIZACIÓN
   ========================================================= */
.wordmark.long { letter-spacing: .01em; font-variation-settings: "wdth" 88; }
.rail .wordmark.long { font-size: 18px; }
.login-aside .wordmark.long { font-size: 22px; }

.brand-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(340px, 440px); gap: 20px; align-items: start; }
.presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px; }
.preset {
  display: grid; gap: 8px; padding: 10px; text-align: left; cursor: pointer;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface);
  font-size: 12.5px; font-weight: 600; color: var(--ink-2);
  transition: border-color .15s, box-shadow .15s;
}
.preset:hover { border-color: #bcc4d3; }
.preset[aria-pressed="true"] { border-color: var(--action); box-shadow: 0 0 0 3px var(--action-ring); color: var(--ink); }
.preset .sw { display: flex; height: 26px; border-radius: 5px; overflow: hidden; }
.preset .sw i { flex: 3; } .preset .sw i + i { flex: 2; } .preset .sw i + i + i { flex: 1; }
.color-field { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 10px; align-items: center; }
.color-field input[type="color"] { width: 44px; height: 40px; padding: 3px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; }
.color-field input[type="text"] { font-variant-numeric: tabular-nums; text-transform: lowercase; }
.contrast { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; }
.contrast.ok { color: var(--s-pagado-ink); }
.contrast.bad { color: var(--s-vencido-ink); }
.logo-drop { display: flex; align-items: center; gap: 14px; padding: 12px; border: 1px dashed #c3cad8; border-radius: var(--radius-sm); background: var(--surface-2); }
.logo-drop .thumb { width: 64px; height: 64px; border-radius: 10px; display: grid; place-items: center; background: var(--rail); color: #fff; font-weight: 800; overflow: hidden; flex: none; }
.logo-drop .thumb img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.logo-drop .grow { flex: 1; min-width: 0; font-size: 12.5px; color: var(--ink-3); }
.logo-drop .grow b { display: block; color: var(--ink-2); font-size: 13px; }

/* Vista previa: mini panel + mini login */
.preview { border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-1); background: var(--surface); position: sticky; top: 20px; }
.preview .pv-head { padding: 12px 16px; font-size: 12.5px; font-weight: 600; color: var(--ink-3); border-bottom: 1px solid var(--line-2); }
.pv-app { display: grid; grid-template-columns: 112px 1fr; height: 214px; background: var(--ground); }
.pv-rail { background: var(--pv-rail); padding: 14px 10px; display: grid; gap: 6px; align-content: start; }
.pv-rail .wm { display: flex; align-items: center; gap: 4px; color: #fff; font-weight: 800; font-size: 11px; letter-spacing: .06em; margin-bottom: 8px; overflow: hidden; white-space: nowrap; }
.pv-rail .wm i { width: 5px; height: 5px; border-radius: 1px; background: var(--pv-accent); flex: none; }
.pv-rail span { height: 18px; border-radius: 4px; background: color-mix(in oklab, var(--pv-rail), white 8%); }
.pv-rail span.on { position: relative; background: color-mix(in oklab, var(--pv-rail), white 16%); }
.pv-rail span.on::after { content: ""; position: absolute; right: 6px; top: 50%; width: 4px; height: 4px; margin-top: -2px; border-radius: 1px; background: var(--pv-accent); }
.pv-main { padding: 14px; display: grid; gap: 8px; align-content: start; }
.pv-main .bar { height: 10px; width: 55%; border-radius: 3px; background: #cdd3de; }
.pv-main .cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.pv-main .cards i { height: 40px; border-radius: 6px; overflow: hidden; background: linear-gradient(var(--pv-rail) 0 3px, #fff 3px); }
.pv-main .btnp { justify-self: start; padding: 6px 12px; border-radius: 6px; background: var(--pv-action); color: #fff; font-size: 11px; font-weight: 700; }
.pv-main .rows { display: grid; gap: 5px; }
.pv-main .rows i { height: 12px; border-radius: 3px; background: #fff; }
.pv-login { display: grid; grid-template-columns: 1fr 1fr; height: 150px; border-top: 1px solid var(--line-2); }
.pv-login .l { background: var(--pv-rail); color: #fff; padding: 14px; display: grid; align-content: space-between; }
.pv-login .l b { font-size: 12px; letter-spacing: .06em; display: flex; align-items: center; gap: 4px; overflow: hidden; white-space: nowrap; }
.pv-login .l b i { width: 5px; height: 5px; border-radius: 1px; background: var(--pv-accent); flex: none; }
.pv-login .l small { font-size: 10px; opacity: .75; line-height: 1.35; }
.pv-login .r { padding: 16px 14px; display: grid; gap: 6px; align-content: center; background: #fff; }
.pv-login .r i { height: 14px; border-radius: 4px; border: 1px solid var(--line); }
.pv-login .r em { height: 18px; border-radius: 4px; background: var(--pv-action); }

/* =========================================================
   PANEL DE PLATAFORMA
   ========================================================= */
.co-cell { display: flex; align-items: center; gap: 12px; min-width: 0; }
.co-swatch { width: 14px; height: 34px; border-radius: 3px 3px 1px 1px; flex: none; background: var(--c); box-shadow: inset -3px 0 0 rgba(0, 0, 0, .15); position: relative; }
.co-swatch::after { content: ""; position: absolute; left: 3px; right: 4px; top: 4px; height: 10px; background: #fff; border-radius: 1px; }
.online { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; font-variant-numeric: tabular-nums; }
.online::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #b7bfcd; }
.online.on { color: var(--s-pagado-ink); }
.online.on::before { background: var(--s-pagado); box-shadow: 0 0 0 3px color-mix(in oklab, var(--s-pagado) 22%, transparent); animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px color-mix(in oklab, var(--s-pagado) 0%, transparent); } }
.tag.Suspendida { background: var(--s-vencido-bg); color: var(--s-vencido-ink); }
.tag.Activa { background: var(--s-pagado-bg); color: var(--s-pagado-ink); }
tr.suspended td { background: #fdf7f6; }
.secret { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line); }
.secret code { flex: 1; font: 600 16px/1.2 ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: .04em; }
.kv-list { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; font-size: 13.5px; }
.kv-list dt { color: var(--ink-3); }
.kv-list dd { margin: 0; font-weight: 550; }
.login-company { display: grid; gap: 6px; margin-top: 28px; }
.change-co { font-size: 12.5px; }
@media (max-width: 1100px) {
  .brand-grid { grid-template-columns: minmax(0, 1fr); }
  .preview { position: static; }
}

/* =========================================================
   FLUJO MCG: formulario por secciones y paginación
   ========================================================= */
.req { font-style: normal; color: var(--s-vencido); font-weight: 600; }
.section h3 .step { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 6px; background: var(--action-soft); color: var(--action); font-size: 11.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.pager { display: flex; align-items: center; gap: 8px; }
.pager span { color: var(--ink-3); font-size: 12.5px; }
.field input:disabled, .field select:disabled { background: var(--surface-2); color: var(--ink-3); cursor: not-allowed; }
.table-foot { flex-wrap: wrap; }
.section .chips .tag { margin: 0; }

/* Avatar del cliente (GIF por sexo con iniciales de respaldo) y búsqueda de DNI */
.person-cell { display: flex; align-items: center; gap: 11px; min-width: 0; }
.person-cell > div { min-width: 0; }
.cavatar { position: relative; flex: none; width: 36px; height: 36px; border-radius: 50%; overflow: hidden; display: grid; place-items: center; background: var(--surface-3); color: var(--ink-2); font-size: 12px; font-weight: 700; letter-spacing: .02em; }
.cavatar[data-sex="M"] { background: #e3ebfb; color: #2a4593; }
.cavatar[data-sex="F"] { background: #fbe6ef; color: #9a2c58; }
.cavatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #fff; }
.cavatar.lg { width: 52px; height: 52px; font-size: 16px; }
.dni-wrap { display: flex; gap: 6px; }
.dni-wrap input { flex: 1; min-width: 0; }
.dni-wrap .btn { height: 40px; }

/* =========================================================
   COMPONENTES DE FORMULARIO PROPIOS (assets/js/ui.js)
   ========================================================= */
.cs-native { position: absolute !important; width: 1px !important; height: 1px !important; margin: 0 !important; padding: 0 !important; border: 0 !important; opacity: 0; pointer-events: none; clip: rect(0 0 0 0); }

/* Desplegable */
.cselect, .ccombo { position: relative; min-width: 0; }
.cs-btn {
  display: flex; align-items: center; gap: 8px; width: 100%; height: 40px; padding: 0 10px 0 12px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink);
  font: inherit; text-align: left; cursor: pointer; transition: border-color .15s, box-shadow .15s, background-color .15s;
}
.cs-btn:hover { border-color: #bcc4d3; }
.cs-btn:focus-visible, .cselect.is-open .cs-btn { outline: none; border-color: var(--action); box-shadow: 0 0 0 3px var(--action-ring); }
.cs-btn:disabled { background: var(--surface-2); color: var(--ink-3); cursor: not-allowed; border-color: var(--line); box-shadow: none; }
.cs-val { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cselect.is-empty .cs-val { color: #69728a; }
.cs-btn .icon { color: var(--ink-3); transition: transform .22s var(--ease-out); }
.cselect.is-open .cs-btn .icon { transform: rotate(180deg); color: var(--action); }
.cselect[data-compact] .cs-btn { height: 34px; font-size: 13px; }
.tools .cselect { min-width: 170px; }
.tools .cselect .cs-btn { height: 40px; }

.cs-pop {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 60; min-width: 220px;
  padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 12px 32px rgba(19, 26, 44, .16), 0 2px 6px rgba(19, 26, 44, .06);
  transform-origin: top center; animation: csIn .16s var(--ease-out);
}
.drop-up > .cs-pop { top: auto; bottom: calc(100% + 6px); transform-origin: bottom center; }
@keyframes csIn { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.cs-list { max-height: 264px; overflow: auto; overscroll-behavior: contain; }
.cs-opt { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 36px; padding: 8px 10px; border-radius: 6px; color: var(--ink); font-size: 13.5px; cursor: pointer; }
.cs-opt span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-opt.is-act { background: var(--surface-2); }
.cs-opt.is-sel { color: var(--action); font-weight: 600; }
.cs-opt.is-sel .icon { color: var(--action); }
.cs-opt.is-dis { opacity: .45; cursor: not-allowed; }
.cs-search { padding: 0 0 6px; margin-bottom: 4px; border-bottom: 1px solid var(--line-2); }
.cs-search input { width: 100%; height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 6px; font: inherit; font-size: 13px; background: var(--surface-2); }
.cs-search input:focus { outline: none; border-color: var(--action); background: var(--surface); }
.cs-empty { padding: 12px 10px; color: var(--ink-3); font-size: 13px; }
.ccombo.is-open input { border-color: var(--action); box-shadow: 0 0 0 3px var(--action-ring); }

/* Selector segmentado */
.seg { display: inline-flex; flex-wrap: wrap; gap: 3px; padding: 3px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); max-width: 100%; }
.field .seg { align-self: flex-start; }
.seg button {
  display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 14px; border: 0; border-radius: 6px;
  background: transparent; color: var(--ink-2); font: inherit; font-size: 13px; font-weight: 550; white-space: nowrap; cursor: pointer;
  transition: background-color .15s, color .15s, box-shadow .15s;
}
.seg button:hover:not(:disabled) { color: var(--ink); background: rgba(255, 255, 255, .6); }
.seg button[aria-checked="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(19, 26, 44, .1), 0 1px 4px rgba(19, 26, 44, .06); }
.seg button:focus-visible { outline: 2px solid var(--action); outline-offset: 1px; }
.seg button:disabled { cursor: not-allowed; opacity: .55; }
/* Sexo: punto con el color del avatar */
.seg button[data-v="M"]::before, .seg button[data-v="F"]::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #2a4593; }
.seg button[data-v="F"]::before { background: #9a2c58; }
/* Medio de pago con muchas opciones: chips en varias filas */
.form-grid .seg { width: 100%; }
.form-grid .seg button { flex: 1 1 auto; justify-content: center; }

/* Campos nativos con el estilo del sistema */
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button, input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="date"]::-webkit-calendar-picker-indicator { opacity: .5; cursor: pointer; border-radius: 4px; padding: 2px; transition: opacity .15s, background-color .15s; }
input[type="date"]::-webkit-calendar-picker-indicator:hover { opacity: 1; background-color: var(--surface-3); }
input[type="file"]::file-selector-button {
  height: 30px; margin-right: 12px; padding: 0 12px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--surface); color: var(--ink); font: inherit; font-size: 13px; font-weight: 550; cursor: pointer;
}
input[type="file"]::file-selector-button:hover { background: var(--surface-2); }
