/*
 * Cobranzas UI. Depends on tokens.css. No inline styles anywhere (strict CSP): dynamic widths use
 * the .w-0 … .w-100 utilities, <progress>/<meter>, or SVG presentation attributes.
 */

/* ---------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, h5 { margin: 0 0 var(--sp-3); line-height: var(--lh-tight); font-weight: var(--fw-semibold); color: var(--text); }
h1 { font-size: var(--fs-2xl); letter-spacing: -0.01em; }
h2 { font-size: var(--fs-xl); letter-spacing: -0.01em; }
h3 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs-md); }
h5 { font-size: var(--fs-base); }
p { margin: 0 0 var(--sp-3); }
ul, ol { margin: 0 0 var(--sp-3); padding-left: var(--sp-5); }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
small, .text-sm { font-size: var(--fs-sm); }
.text-xs { font-size: var(--fs-xs); }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--sp-6) 0; }
code, kbd, .mono { font-family: var(--font-mono); font-size: 0.92em; }
kbd {
  display: inline-block; min-width: 1.5em; padding: 0 0.35em; border: 1px solid var(--border-strong);
  border-bottom-width: 2px; border-radius: 4px; background: var(--surface-2); color: var(--text);
  font-size: var(--fs-xs); line-height: 1.6; text-align: center;
}
img, svg { vertical-align: middle; }
dl { margin: 0; }
dt { color: var(--muted); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.04em; }
dd { margin: 0; }
details > summary { cursor: pointer; color: var(--link); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
::selection { background: var(--primary-soft); color: var(--text); }

.icon { width: 1.15em; height: 1.15em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-lg { width: 1.5em; height: 1.5em; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link { position: absolute; left: var(--sp-4); top: -100px; z-index: 100; padding: var(--sp-2) var(--sp-4); background: var(--primary); color: var(--on-primary); border-radius: var(--radius-sm); }
.skip-link:focus { top: var(--sp-3); }

/* ---------------------------------------------------------------- utilities */
.muted { color: var(--muted); }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tabular { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.hidden, [hidden] { display: none !important; }
.stack { display: flex; flex-direction: column; gap: var(--sp-4); }
.stack-sm { display: flex; flex-direction: column; gap: var(--sp-2); }
.row { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; }
.grow { flex: 1 1 auto; }
.mt-0 { margin-top: 0; } .mt-2 { margin-top: var(--sp-2); } .mt-4 { margin-top: var(--sp-4); } .mt-6 { margin-top: var(--sp-6); }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: var(--sp-2); } .mb-4 { margin-bottom: var(--sp-4); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-4); }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: var(--sp-4); }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.text-success { color: var(--success); } .text-danger { color: var(--danger); } .text-warning { color: var(--warning); }

/* Width utilities for CSS bars (no inline styles under the CSP). */
.w-0 { width: 0; } .w-5 { width: 5%; } .w-10 { width: 10%; } .w-15 { width: 15%; } .w-20 { width: 20%; }
.w-25 { width: 25%; } .w-30 { width: 30%; } .w-35 { width: 35%; } .w-40 { width: 40%; } .w-45 { width: 45%; }
.w-50 { width: 50%; } .w-55 { width: 55%; } .w-60 { width: 60%; } .w-65 { width: 65%; } .w-70 { width: 70%; }
.w-75 { width: 75%; } .w-80 { width: 80%; } .w-85 { width: 85%; } .w-90 { width: 90%; } .w-95 { width: 95%; }
.w-100 { width: 100%; }
/* Same scale for vertical bars. */
.h-0 { height: 0; } .h-5 { height: 5%; } .h-10 { height: 10%; } .h-15 { height: 15%; } .h-20 { height: 20%; }
.h-25 { height: 25%; } .h-30 { height: 30%; } .h-35 { height: 35%; } .h-40 { height: 40%; } .h-45 { height: 45%; }
.h-50 { height: 50%; } .h-55 { height: 55%; } .h-60 { height: 60%; } .h-65 { height: 65%; } .h-70 { height: 70%; }
.h-75 { height: 75%; } .h-80 { height: 80%; } .h-85 { height: 85%; } .h-90 { height: 90%; } .h-95 { height: 95%; }
.h-100 { height: 100%; }

/* ---------------------------------------------------------------- app shell */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
html[data-sidebar="collapsed"] .app { grid-template-columns: var(--sidebar-w-collapsed) minmax(0, 1fr); }

.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--side-bg) 0%, var(--side-bg-2) 100%);
  border-right: 1px solid var(--side-border); color: var(--side-text); z-index: 40;
}
.sidebar-brand { display: flex; align-items: center; gap: var(--sp-3); height: var(--topbar-h); padding: 0 var(--sp-4); border-bottom: 1px solid var(--side-border); }
.sidebar-brand a { display: flex; align-items: center; gap: var(--sp-3); color: #fff; text-decoration: none; }
.sidebar-brand img { height: 32px; width: auto; }
.brand-mark { height: 32px; width: 32px; }
.brand-word { font-weight: var(--fw-bold); font-size: var(--fs-md); letter-spacing: -0.01em; }
.sidebar-nav { flex: 1 1 auto; overflow-y: auto; padding: var(--sp-4) var(--sp-3); }
.nav-label { padding: 0 var(--sp-3); margin: 0 0 var(--sp-2); color: var(--side-muted); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.08em; }
.nav-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: flex; align-items: center; gap: var(--sp-3); padding: 0.55rem var(--sp-3); border-radius: var(--radius-sm);
  color: var(--side-text); font-weight: var(--fw-medium); text-decoration: none; transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.nav-link:hover { background: rgba(255, 255, 255, 0.06); color: #fff; text-decoration: none; }
.nav-link[aria-current="page"] { background: var(--side-active-bg); color: var(--side-active-text); box-shadow: inset 3px 0 0 #60a5fa; }
.nav-link .icon { width: 1.25rem; height: 1.25rem; }
.sidebar-foot { border-top: 1px solid var(--side-border); padding: var(--sp-3); display: flex; flex-direction: column; gap: var(--sp-2); }
.user-chip { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2); border-radius: var(--radius-sm); min-width: 0; }
.avatar {
  flex: none; display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #0ea5e9); color: #fff; font-weight: var(--fw-bold); font-size: var(--fs-sm); text-transform: uppercase;
}
.user-meta { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.user-name { color: #fff; font-weight: var(--fw-semibold); font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-actions { display: flex; gap: var(--sp-2); }
.sidebar-actions form { flex: 1 1 auto; margin: 0; }
.side-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2); width: 100%; min-height: 36px;
  padding: 0 var(--sp-3); border: 1px solid var(--side-border); border-radius: var(--radius-sm); background: transparent;
  color: var(--side-text); font: inherit; font-size: var(--fs-sm); cursor: pointer;
}
.side-btn:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.side-btn.icon-only { width: 36px; flex: none; padding: 0; }
.sidebar .theme-dark-only, .sidebar .theme-light-only { display: none; }

html[data-sidebar="collapsed"] .sidebar .brand-word,
html[data-sidebar="collapsed"] .sidebar .nav-text,
html[data-sidebar="collapsed"] .sidebar .nav-label,
html[data-sidebar="collapsed"] .sidebar .user-meta,
html[data-sidebar="collapsed"] .sidebar .side-btn-text { display: none; }
html[data-sidebar="collapsed"] .sidebar .nav-link { justify-content: center; }
html[data-sidebar="collapsed"] .sidebar-actions { flex-direction: column; }
html[data-sidebar="collapsed"] .sidebar-brand { justify-content: center; padding: 0; }
html[data-sidebar="collapsed"] .user-chip { justify-content: center; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h); display: flex; align-items: center; gap: var(--sp-3);
  padding: 0 var(--sp-6); background: color-mix(in srgb, var(--surface) 88%, transparent); border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(1.4) blur(8px);
}
.topbar-title { display: flex; flex-direction: column; min-width: 0; }
.breadcrumbs { display: flex; gap: var(--sp-2); align-items: center; color: var(--muted); font-size: var(--fs-xs); list-style: none; margin: 0; padding: 0; }
.breadcrumbs li + li::before { content: "/"; margin-right: var(--sp-2); color: var(--border-strong); }
.page-title { margin: 0; font-size: var(--fs-md); font-weight: var(--fw-semibold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: var(--sp-2); }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer; padding: 0;
}
.icon-btn:hover { background: var(--surface-2); }
.nav-toggle-mobile { display: none; }
.content { width: 100%; max-width: var(--content-max); margin: 0 auto; padding: var(--sp-6); flex: 1 1 auto; }
.scrim { display: none; }

@media (max-width: 960px) {
  .app, html[data-sidebar="collapsed"] .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: min(84vw, var(--sidebar-w)); transform: translateX(-100%); transition: transform 220ms var(--ease); box-shadow: var(--shadow-lg); }
  html.nav-open .sidebar { transform: none; }
  html.nav-open .scrim { display: block; position: fixed; inset: 0; background: var(--overlay); z-index: 35; }
  html[data-sidebar="collapsed"] .sidebar .brand-word,
  html[data-sidebar="collapsed"] .sidebar .nav-text,
  html[data-sidebar="collapsed"] .sidebar .nav-label,
  html[data-sidebar="collapsed"] .sidebar .user-meta,
  html[data-sidebar="collapsed"] .sidebar .side-btn-text { display: revert; }
  html[data-sidebar="collapsed"] .sidebar .nav-link { justify-content: flex-start; }
  .nav-toggle-mobile { display: inline-grid; }
  .nav-collapse { display: none; }
  .topbar { padding: 0 var(--sp-4); }
  .content { padding: var(--sp-4); }
}

/* Page heading inside content */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--sp-4); flex-wrap: wrap; margin-bottom: var(--sp-5); }
.page-head h1, .page-head h2 { margin: 0; }
.page-sub { margin: var(--sp-1) 0 0; color: var(--muted); }
.page-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }
.section-title { display: flex; align-items: center; gap: var(--sp-2); margin: var(--sp-6) 0 var(--sp-3); font-size: var(--fs-md); }

/* ---------------------------------------------------------------- buttons */
/* :where() keeps the base at zero specificity so variant classes (.secondary, .btn-wa…) win. */
:where(button, .btn, a[role="button"], input[type="submit"]) {
  --btn-bg: var(--primary); --btn-fg: var(--on-primary); --btn-border: var(--primary); --btn-hover: var(--primary-hover);
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: 38px; padding: 0 var(--sp-4); border: 1px solid var(--btn-border); border-radius: var(--radius-sm);
  background: var(--btn-bg); color: var(--btn-fg); font: inherit; font-weight: var(--fw-semibold); font-size: var(--fs-sm);
  line-height: 1; white-space: nowrap; cursor: pointer; text-decoration: none; user-select: none;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform 60ms;
}
a[role="button"], a[role="button"]:hover, a[role="button"]:visited { color: var(--btn-fg); text-decoration: none; }
button:hover, .btn:hover, a[role="button"]:hover { background: var(--btn-hover); border-color: var(--btn-hover); text-decoration: none; }
button:active, .btn:active, a[role="button"]:active { transform: translateY(1px); }
button:focus-visible, .btn:focus-visible, a[role="button"]:focus-visible { outline: none; box-shadow: var(--focus-ring); }
button:disabled, .btn[aria-disabled="true"], fieldset:disabled button { opacity: 0.55; cursor: not-allowed; transform: none; }
.secondary, .btn-secondary, .outline {
  --btn-bg: var(--surface); --btn-fg: var(--text); --btn-border: var(--border-strong); --btn-hover: var(--surface-2);
}
.secondary:hover, .btn-secondary:hover, .outline:hover { border-color: var(--border-strong); }
.ghost, .btn-ghost { --btn-bg: transparent; --btn-fg: var(--text-soft); --btn-border: transparent; --btn-hover: var(--surface-3); }
.danger, .btn-danger, .contrast { --btn-bg: #dc2626; --btn-fg: #fff; --btn-border: #dc2626; --btn-hover: #b91c1c; }
/* Fixed fills so white text keeps AA contrast in both themes. */
.btn-success { --btn-bg: #15803d; --btn-fg: #fff; --btn-border: #15803d; --btn-hover: #166534; }
.btn-wa { --btn-bg: var(--whatsapp); --btn-fg: #fff; --btn-border: var(--whatsapp); --btn-hover: var(--whatsapp-hover); }
.small, .btn-sm { min-height: 30px; padding: 0 var(--sp-3); font-size: var(--fs-xs); }
.btn-lg { min-height: 48px; padding: 0 var(--sp-6); font-size: var(--fs-md); border-radius: var(--radius); }
.btn-xl { min-height: 56px; padding: 0 var(--sp-6); font-size: var(--fs-md); border-radius: var(--radius); }
.btn-block { width: 100%; }
.btn-group { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
/* htmx loading state: the requesting element gets .htmx-request. */
button.htmx-request, .btn.htmx-request { color: transparent; pointer-events: none; }
button.htmx-request::after, .btn.htmx-request::after {
  content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--btn-fg); border-right-color: transparent; animation: spin 0.7s linear infinite;
}
.inline-form { display: inline; margin: 0; }

/* ---------------------------------------------------------------- forms */
form { margin: 0; }
label { display: flex; flex-direction: column; gap: var(--sp-1); font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--text-soft); margin-bottom: var(--sp-3); }
label > small { font-weight: 400; color: var(--muted); }
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="hidden"]), select, textarea {
  width: 100%; min-height: 40px; padding: 0.5rem 0.75rem; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit; font-size: var(--fs-base); font-weight: 400;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
textarea { min-height: 72px; resize: vertical; line-height: var(--lh-base); }
select {
  appearance: none; padding-right: 2.25rem; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%; background-size: 5px 5px; background-repeat: no-repeat;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: var(--focus-ring); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.85; }
input:disabled, select:disabled, textarea:disabled, fieldset:disabled input, fieldset:disabled select, fieldset:disabled textarea { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--danger); }
input[type="checkbox"], input[type="radio"] { width: 1.05rem; height: 1.05rem; accent-color: var(--primary); margin: 0; }
label.check, .check { flex-direction: row; align-items: center; gap: var(--sp-2); font-weight: 400; }
fieldset { border: 0; margin: 0 0 var(--sp-3); padding: 0; min-width: 0; }
legend { font-size: var(--fs-sm); font-weight: var(--fw-semibold); margin-bottom: var(--sp-2); padding: 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 0 var(--sp-4); }
.grid-params { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 0 var(--sp-4); }
.form-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; margin-top: var(--sp-2); }
.day-picker { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-4); }
.day-picker legend { width: 100%; }
.day-picker label { flex-direction: row; align-items: center; gap: var(--sp-2); margin: 0; padding: 0.35rem 0.7rem; border: 1px solid var(--border); border-radius: var(--radius-pill); background: var(--surface-2); font-weight: 400; }
.num-input { max-width: 6.5rem; text-align: right; }
input[type="range"] { width: 100%; accent-color: var(--primary); margin: 0; }
.field-hint { font-size: var(--fs-xs); color: var(--muted); font-weight: 400; }

/* Native file input styled as a dropzone */
.dropzone {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--sp-2);
  padding: var(--sp-8) var(--sp-4); border: 2px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface-2);
  text-align: center; color: var(--muted); transition: border-color var(--dur), background var(--dur);
}
.dropzone:hover, .dropzone:focus-within, .dropzone.is-dragover { border-color: var(--primary); background: var(--primary-soft); }
.dropzone .icon { width: 2rem; height: 2rem; color: var(--primary); }
.dropzone strong { color: var(--text); }
.dropzone input[type="file"] { width: 100%; max-width: 22rem; font: inherit; font-size: var(--fs-sm); color: var(--text); }
.dropzone input[type="file"]::file-selector-button {
  margin-right: var(--sp-3); padding: 0.45rem 0.9rem; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit; font-weight: var(--fw-semibold); cursor: pointer;
}

/* Password field with show/hide */
.input-affix { position: relative; display: flex; }
.input-affix input { padding-right: 2.75rem !important; }
.affix-btn {
  --btn-bg: transparent; --btn-fg: var(--muted); --btn-border: transparent; --btn-hover: var(--surface-3);
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%); min-height: 32px; width: 34px; padding: 0;
}
.affix-btn:active { transform: translateY(-50%); }

/* ---------------------------------------------------------------- cards */
.card, .panel, article {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); padding: var(--sp-5); margin: 0 0 var(--sp-4); min-width: 0;
}
.card-head, article > header {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap;
  margin: calc(var(--sp-5) * -1) calc(var(--sp-5) * -1) var(--sp-4); padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border);
}
.card-head h2, .card-head h3, .card-head h4, .panel > h4:first-child { margin: 0; font-size: var(--fs-md); }
.panel > h4:first-child { margin-bottom: var(--sp-3); }
.card-sub { color: var(--muted); font-size: var(--fs-sm); margin: 0; }
.card-flush { padding: 0; }
.card-flush > .card-head { margin: 0; }
.card-flush .table-wrap { border: 0; border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.card-elevated { box-shadow: var(--shadow); }
.eyebrow { font-size: var(--fs-xs); font-weight: var(--fw-semibold); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 0 0 var(--sp-1); }

/* ---------------------------------------------------------------- tables */
.table-wrap, .overflow-auto { overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); max-height: 70vh; }
.card .table-wrap, .panel .table-wrap, article .overflow-auto { max-height: 60vh; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-sm); }
th, td { padding: 0.6rem 0.85rem; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border); }
thead th {
  position: sticky; top: 0; z-index: 1; background: var(--surface-2); color: var(--muted); font-size: var(--fs-xs);
  font-weight: var(--fw-semibold); text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap;
}
tbody tr:last-child td { border-bottom: 0; }
table.striped tbody tr:nth-child(even) td, .table-zebra tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
tbody tr:hover td { background: var(--primary-soft) !important; }
.table-compact th, .table-compact td { padding: 0.4rem 0.65rem; }
td.empty, tr.empty td { text-align: center; color: var(--muted); padding: var(--sp-8); }
.errors-row td { font-size: var(--fs-xs); background: var(--surface-2); }
.errors-row ul { margin: var(--sp-2) 0 0; }
tfoot td { font-weight: var(--fw-semibold); background: var(--surface-2); }

/* ---------------------------------------------------------------- badges */
.badge {
  display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.15rem 0.55rem; border-radius: var(--radius-pill);
  font-size: var(--fs-xs); font-weight: var(--fw-semibold); line-height: 1.5; white-space: nowrap;
  background: var(--neutral-soft); color: var(--neutral-soft-text); border: 1px solid transparent;
}
.badge-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok, .badge-ok, .badge-cumplido, .badge-elegible, .badge-gestionado, .badge-activo, .badge-success { background: var(--success-soft); color: var(--success-soft-text); }
.badge.off, .badge.error, .badge-off, .badge-error, .badge-incumplido, .badge-vencido, .badge-equivocado,
.badge-excluido, .badge-fallecido, .badge-danger, .badge-judicial { background: var(--danger-soft); color: var(--danger-soft-text); }
.badge.procesando, .badge.pendiente, .badge-pendiente, .badge-vence_hoy, .badge-diferido, .badge-bloqueado,
.badge-warning, .badge-apagado { background: var(--warning-soft); color: var(--warning-soft-text); }
.badge-pdp, .badge-info, .badge-proximo, .badge-why { background: var(--primary-soft); color: var(--primary-soft-text); }
.badge-admin { background: var(--violet-soft); color: var(--violet-soft-text); }
.badge-supervisor { background: var(--info-soft); color: var(--info-soft-text); }
.badge-agente { background: var(--primary-soft); color: var(--primary-soft-text); }
.sidebar .badge-admin, .sidebar .badge-supervisor, .sidebar .badge-agente { border-color: rgba(255, 255, 255, 0.08); }
.chip {
  display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.3rem 0.7rem; border-radius: var(--radius-pill);
  background: var(--surface-2); border: 1px solid var(--border); font-size: var(--fs-sm); color: var(--text-soft);
}
.chip .up { color: var(--success); font-weight: var(--fw-bold); }
.chip-list { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: var(--sp-2); }

/* ---------------------------------------------------------------- alerts + toasts */
.alert, .notice, .error {
  display: flex; align-items: flex-start; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); margin: 0 0 var(--sp-4);
  border-radius: var(--radius); border: 1px solid transparent; font-size: var(--fs-sm); font-weight: var(--fw-medium);
}
.alert .icon { margin-top: 2px; }
.alert-success, .notice { background: var(--success-soft); color: var(--success-soft-text); border-color: color-mix(in srgb, var(--success) 30%, transparent); }
.alert-danger, .error { background: var(--danger-soft); color: var(--danger-soft-text); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.alert-warning { background: var(--warning-soft); color: var(--warning-soft-text); border-color: color-mix(in srgb, var(--warning) 30%, transparent); }
.alert-info { background: var(--info-soft); color: var(--info-soft-text); border-color: color-mix(in srgb, var(--info) 30%, transparent); }
.toast-region { position: fixed; right: var(--sp-5); bottom: var(--sp-5); z-index: 80; display: flex; flex-direction: column; gap: var(--sp-2); max-width: min(420px, calc(100vw - 2rem)); }
.toast {
  display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-radius: var(--radius);
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-left: 4px solid var(--success);
  box-shadow: var(--shadow-lg); font-size: var(--fs-sm); animation: toast-in 240ms var(--ease), toast-out 400ms var(--ease) 6s forwards;
}
.toast .icon { color: var(--success); }
.toast-close { --btn-bg: transparent; --btn-fg: var(--muted); --btn-border: transparent; --btn-hover: var(--surface-2); min-height: 28px; width: 28px; padding: 0; margin-left: auto; }

/* ---------------------------------------------------------------- KPI tiles */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr)); gap: var(--sp-4); margin-bottom: var(--sp-4); }
.kpi-tile {
  position: relative; display: flex; flex-direction: column; gap: var(--sp-1); padding: var(--sp-4) var(--sp-5);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); min-width: 0;
}
.kpi-tile.accent { background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%); border-color: transparent; color: #fff; }
.kpi-tile.accent .kpi-label, .kpi-tile.accent .kpi-sub { color: rgba(255, 255, 255, 0.82); }
.kpi-tile.accent .kpi-value { color: #fff; }
.kpi-label { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-xs); font-weight: var(--fw-semibold); text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.kpi-value { font-size: var(--fs-2xl); font-weight: var(--fw-bold); line-height: 1.1; letter-spacing: -0.02em; color: var(--text); font-variant-numeric: tabular-nums; }
.kpi-value small { font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--muted); }
.kpi-sub { font-size: var(--fs-xs); color: var(--muted); }
.kpi-delta { display: inline-flex; align-items: center; gap: 0.2rem; font-size: var(--fs-xs); font-weight: var(--fw-bold); }
.kpi-delta.up, .delta-up { color: var(--success); }
.kpi-delta.down, .delta-down { color: var(--danger); }
.kpi-tile progress { margin-top: var(--sp-2); }
/* Legacy inline KPI row (kept for small summaries). */
.kpi-row { display: flex; flex-wrap: wrap; gap: var(--sp-6); }
.kpi { display: flex; flex-direction: column; }

/* ---------------------------------------------------------------- progress / meter / bars */
progress, meter {
  -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 8px; border: 0;
  border-radius: var(--radius-pill); background: var(--surface-3); overflow: hidden;
}
progress::-webkit-progress-bar { background: var(--surface-3); border-radius: var(--radius-pill); }
progress::-webkit-progress-value { background: linear-gradient(90deg, var(--primary), #38bdf8); border-radius: var(--radius-pill); }
progress::-moz-progress-bar { background: linear-gradient(90deg, var(--primary), #38bdf8); border-radius: var(--radius-pill); }
progress.lg { height: 12px; }
progress.success::-webkit-progress-value { background: var(--success); }
progress.success::-moz-progress-bar { background: var(--success); }
meter::-webkit-meter-bar { background: var(--surface-3); border: 0; border-radius: var(--radius-pill); height: 8px; }
meter::-webkit-meter-optimum-value { background: var(--success); border-radius: var(--radius-pill); }
meter::-webkit-meter-suboptimum-value { background: var(--warning); border-radius: var(--radius-pill); }
meter::-webkit-meter-even-less-good-value { background: var(--danger); border-radius: var(--radius-pill); }
meter:-moz-meter-optimum::-moz-meter-bar { background: var(--success); }
meter:-moz-meter-sub-optimum::-moz-meter-bar { background: var(--warning); }
meter:-moz-meter-sub-sub-optimum::-moz-meter-bar { background: var(--danger); }

.bar { position: relative; height: 8px; border-radius: var(--radius-pill); background: var(--surface-3); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: inherit; background: var(--primary); }
.bar.success > span { background: var(--success); }
.bar.warning > span { background: var(--warning); }
.bar.danger > span { background: var(--danger); }
.bar.muted-bar > span { background: var(--border-strong); }
.bar.thin { height: 6px; }

/* Horizontal bar chart (label | bar | value) */
.hbars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--sp-2); }
.hbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--sp-1) var(--sp-3); align-items: center; font-size: var(--fs-sm); }
.hbar .bar { grid-column: 1 / -1; }
.hbar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-soft); }
.hbar-value { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.hbar .bar { height: 10px; }

/* Vertical column chart (per hour) */
.vchart { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; align-items: end; height: 180px; padding-top: var(--sp-4); }
.vcol { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; min-width: 0; }
.vcol-track { position: relative; width: 100%; max-width: 28px; flex: 1 1 auto; display: flex; align-items: flex-end; }
.vcol-bar { width: 100%; min-height: 2px; border-radius: 4px 4px 0 0; background: linear-gradient(180deg, #38bdf8, var(--primary)); }
.vcol-bar.is-zero { background: var(--surface-3); }
.vcol-val { font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }
.vcol-lbl { font-size: 10px; color: var(--muted); }

/* Deciles mini chart (pesos preview) */
.decile-chart { display: grid; grid-template-columns: 4.5rem repeat(10, minmax(0, 1fr)); gap: 6px var(--sp-2); align-items: center; font-size: var(--fs-xs); }
.decile-chart .dc-head { color: var(--muted); text-align: center; }
.decile-cell { display: flex; flex-direction: column; gap: 2px; }
.decile-cell .bar { height: 18px; border-radius: 4px; }
.decile-cell .bar > span { border-radius: 4px; }
.decile-cell.old .bar > span { background: var(--border-strong); }
.decile-num { text-align: center; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Score ring (SVG with presentation attributes) */
.ring { position: relative; width: 84px; height: 84px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: var(--surface-3); stroke-width: 3.2; }
.ring-value { fill: none; stroke: var(--primary); stroke-width: 3.2; stroke-linecap: round; }
.ring-label { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; line-height: 1; }
.ring-label strong { font-size: var(--fs-xl); font-variant-numeric: tabular-nums; }
.ring-label small { display: block; font-size: 10px; color: var(--muted); margin-top: 2px; }

/* ---------------------------------------------------------------- tabs */
.tabs { display: flex; gap: var(--sp-1); border-bottom: 1px solid var(--border); margin-bottom: var(--sp-4); overflow-x: auto; }
.tabs a, .tabs button {
  --btn-bg: transparent; --btn-fg: var(--muted); --btn-border: transparent; --btn-hover: transparent;
  display: inline-flex; align-items: center; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4); border: 0; border-bottom: 2px solid transparent;
  border-radius: 0; color: var(--muted); font-weight: var(--fw-semibold); font-size: var(--fs-sm); text-decoration: none; white-space: nowrap;
}
.tabs a:hover, .tabs button:hover { color: var(--text); text-decoration: none; }
.tabs [aria-current="page"], .tabs [aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------------------------------------------------------------- empty states, spinner, skeleton */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: var(--sp-3); padding: var(--sp-10) var(--sp-6); color: var(--muted); }
.empty-state .empty-icon { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); }
.empty-state .empty-icon .icon { width: 30px; height: 30px; }
.empty-state h2, .empty-state h3 { color: var(--text); margin: 0; }
.empty-state p { margin: 0; max-width: 34rem; }
.spinner { display: inline-block; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border-strong); border-right-color: var(--primary); animation: spin 0.7s linear infinite; vertical-align: middle; }
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline-flex; align-items: center; gap: var(--sp-2); }
.skeleton { display: block; height: 0.9rem; border-radius: 4px; background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 37%, var(--surface-3) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; }
.skeleton + .skeleton { margin-top: var(--sp-2); }
.is-swapping { opacity: 0.6; transition: opacity var(--dur); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); visibility: hidden; } }

/* ---------------------------------------------------------------- login */
.auth-body { background: var(--bg); }
.auth { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); min-height: 100vh; }
.auth-brand {
  position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; gap: var(--sp-8);
  padding: var(--sp-10) var(--sp-12); color: #e6eeff;
  background:
    radial-gradient(1200px 500px at -10% -20%, rgba(56, 189, 248, 0.28), transparent 60%),
    radial-gradient(900px 600px at 120% 120%, rgba(37, 99, 235, 0.45), transparent 60%),
    linear-gradient(160deg, #0b1630 0%, #0f2350 55%, #12306e 100%);
}
.auth-brand::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0.18;
  background-image: linear-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, 0.07) 1px, transparent 1px);
  background-size: 40px 40px;
}
.auth-brand > * { position: relative; z-index: 1; }
.auth-logo img { height: 44px; width: auto; }
.auth-pitch h1 { color: #fff; font-size: var(--fs-3xl); line-height: 1.15; letter-spacing: -0.02em; max-width: 30rem; margin-bottom: var(--sp-4); }
.auth-pitch p { color: #b9c8ea; font-size: var(--fs-md); max-width: 30rem; }
.auth-points { list-style: none; padding: 0; margin: var(--sp-6) 0 0; display: flex; flex-direction: column; gap: var(--sp-4); }
.auth-points li { display: flex; gap: var(--sp-3); align-items: flex-start; max-width: 30rem; }
.auth-points .pt-icon { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--radius); background: rgba(255, 255, 255, 0.1); color: #7dd3fc; }
.auth-points strong { display: block; color: #fff; }
.auth-points span { color: #b9c8ea; font-size: var(--fs-sm); }
.auth-foot { color: #8fa3cc; font-size: var(--fs-xs); }
.auth-main { display: flex; align-items: center; justify-content: center; padding: var(--sp-8) var(--sp-6); }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h2 { font-size: var(--fs-2xl); margin-bottom: var(--sp-1); }
.auth-card .card-sub { margin-bottom: var(--sp-6); }
.auth-card form button[type="submit"] { width: 100%; min-height: 46px; font-size: var(--fs-base); margin-top: var(--sp-2); }
.auth-theme { position: absolute; top: var(--sp-4); right: var(--sp-4); }
.auth-main { position: relative; }
.auth-mobile-logo { display: none; margin-bottom: var(--sp-6); }
.auth-mobile-logo img { height: 36px; }
.auth-secure { display: flex; align-items: center; gap: var(--sp-2); justify-content: center; margin-top: var(--sp-6); color: var(--muted); font-size: var(--fs-xs); }
@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-brand { padding: var(--sp-8) var(--sp-6); gap: var(--sp-6); }
  .auth-pitch h1 { font-size: var(--fs-xl); }
  .auth-points { display: none; }
  .auth-foot { display: none; }
}

/* Theme toggle icon swap */
.theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: inline; }

/* ---------------------------------------------------------------- home */
.hero-cta {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-6); flex-wrap: wrap; padding: var(--sp-8);
  border-radius: var(--radius-lg); color: #fff; margin-bottom: var(--sp-5);
  background: radial-gradient(700px 300px at 100% 0, rgba(56, 189, 248, 0.35), transparent 60%), linear-gradient(135deg, #0f2350 0%, #1d4ed8 100%);
}
.hero-cta h2 { color: #fff; font-size: var(--fs-2xl); margin-bottom: var(--sp-2); }
.hero-cta p { color: #cfdcff; margin: 0; max-width: 36rem; }
.hero-cta .btn-xl { --btn-bg: #fff; --btn-fg: #0f2350; --btn-border: #fff; --btn-hover: #e6eeff; }
.link-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: var(--sp-4); }
.link-tile {
  display: flex; gap: var(--sp-3); align-items: flex-start; padding: var(--sp-4) var(--sp-5); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg); color: var(--text); box-shadow: var(--shadow-sm);
  transition: border-color var(--dur), box-shadow var(--dur), transform var(--dur);
}
.link-tile:hover { border-color: var(--primary); box-shadow: var(--shadow); text-decoration: none; transform: translateY(-1px); }
.link-tile .tile-icon { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: var(--radius); background: var(--primary-soft); color: var(--primary); }
.link-tile strong { display: block; }
.link-tile span { color: var(--muted); font-size: var(--fs-sm); }

/* ---------------------------------------------------------------- gestionar */
.gestionar-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 400px); gap: var(--sp-5); align-items: start; }
.gestionar-side { position: sticky; top: calc(var(--topbar-h) + var(--sp-4)); display: flex; flex-direction: column; gap: var(--sp-4); max-height: calc(100vh - var(--topbar-h) - var(--sp-8)); overflow-y: auto; padding-bottom: var(--sp-2); }
.gestionar-side > * { margin-bottom: 0; }
@media (max-width: 1100px) { .gestionar-layout { grid-template-columns: 1fr; } .gestionar-side { position: static; max-height: none; overflow: visible; } }
.lead-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--sp-4); flex-wrap: wrap; margin-bottom: var(--sp-4); }
.lead-name { display: block; font-size: var(--fs-xl); font-weight: var(--fw-bold); letter-spacing: -0.01em; line-height: 1.2; }
.lead-dni { display: inline-flex; gap: var(--sp-2); align-items: center; color: var(--muted); font-size: var(--fs-sm); font-family: var(--font-mono); }
.lead-amounts { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: var(--sp-3); margin-bottom: var(--sp-4); }
.amount-tile { padding: var(--sp-3) var(--sp-4); border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); }
.amount-tile.primary { background: var(--primary-soft); border-color: transparent; }
.amount-tile dt { margin-bottom: var(--sp-1); }
.amount-tile dd { font-size: var(--fs-xl); font-weight: var(--fw-bold); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.amount-tile.primary dd { color: var(--primary-soft-text); }
.lead-facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: var(--sp-3) var(--sp-4); }
.lead-facts dd { font-weight: var(--fw-semibold); font-size: var(--fs-sm); }
.lead-compromisos { margin-top: var(--sp-4); padding-top: var(--sp-3); border-top: 1px dashed var(--border); }
.lead-compromisos ul { list-style: none; padding: 0; margin: var(--sp-2) 0 0; display: flex; flex-wrap: wrap; gap: var(--sp-2); }

.why { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: var(--sp-5); }
@media (max-width: 760px) { .why { grid-template-columns: 1fr; } }
.why h4 { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-base); }
.why-summary { display: flex; align-items: center; gap: var(--sp-4); margin-bottom: var(--sp-3); }
.why-position strong { display: block; font-size: var(--fs-xl); font-variant-numeric: tabular-nums; }
.why-context { list-style: none; padding: 0; margin: 0 0 var(--sp-3); display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.why-reasons { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.why-reason { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.3rem 0.7rem; border-radius: var(--radius-pill); background: var(--success-soft); color: var(--success-soft-text); font-size: var(--fs-sm); font-weight: var(--fw-medium); }
.why-reason small { color: inherit; opacity: 0.8; }
.why-phone { padding-left: var(--sp-5); border-left: 1px solid var(--border); font-size: var(--fs-sm); }
@media (max-width: 760px) { .why-phone { padding-left: 0; border-left: 0; padding-top: var(--sp-4); border-top: 1px solid var(--border); } }

.best-phone { border: 0; color: #fff; background: radial-gradient(500px 200px at 100% 0, rgba(56, 189, 248, 0.3), transparent 60%), linear-gradient(150deg, #0f2350 0%, #1e40af 100%); box-shadow: var(--shadow); }
.best-phone .eyebrow { color: #a9c3ff; }
.best-number { display: block; font-size: 2rem; font-weight: var(--fw-bold); letter-spacing: 0.01em; font-variant-numeric: tabular-nums; margin: var(--sp-1) 0 var(--sp-3); color: #fff; font-family: var(--font-mono); }
.best-actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.best-actions .btn-call { --btn-bg: #fff; --btn-fg: #0f2350; --btn-border: #fff; --btn-hover: #e6eeff; }
.best-meta { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2) var(--sp-4); font-size: var(--fs-sm); }
.best-meta dt { color: #a9c3ff; }
.best-meta dd { color: #fff; font-weight: var(--fw-semibold); }
.best-meta .span-2 { grid-column: span 2; }
.best-phone meter { margin-top: var(--sp-1); }
.best-phone meter::-webkit-meter-bar { background: rgba(255, 255, 255, 0.18); }
.best-phone .badge { background: rgba(255, 255, 255, 0.14); color: #fff; }
.best-phone .badge-off { background: #7f1d1d; color: #fff; }

.phone-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; }
.phone-item { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; padding: var(--sp-2) 0; border-bottom: 1px solid var(--border); font-size: var(--fs-sm); }
.phone-item:last-child { border-bottom: 0; }
.phone-number { font-family: var(--font-mono); font-weight: var(--fw-semibold); }
.phone-source { color: var(--muted); font-size: var(--fs-xs); }
.phone-score { font-variant-numeric: tabular-nums; color: var(--muted); font-size: var(--fs-xs); }
.phone-actions { margin-left: auto; display: flex; gap: var(--sp-1); }

.tip-form textarea { min-height: 64px; }
.tip-cascade { display: grid; grid-template-columns: 1fr; gap: 0; }
.tip-cascade:empty { display: none; }
.tip-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 0 var(--sp-3); padding: var(--sp-3); margin-bottom: var(--sp-3); border-radius: var(--radius); background: var(--warning-soft); }
.tip-fields label { color: var(--warning-soft-text); }
.btn-save { width: 100%; min-height: 48px; font-size: var(--fs-base); }
.shortcut-legend { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-3); margin: var(--sp-3) 0 0; padding: 0; list-style: none; color: var(--muted); font-size: var(--fs-xs); }
.shortcut-legend li { display: inline-flex; align-items: center; gap: var(--sp-1); }

.compromiso-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; }
.compromiso-item { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-3); align-items: center; padding: var(--sp-2) 0; border-bottom: 1px solid var(--border); font-size: var(--fs-sm); }
.compromiso-item:last-child { border-bottom: 0; }
.compromiso-item .amount { font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums; }
.compromiso-item form { margin-left: auto; }
.compromiso-item.is-vencido { box-shadow: inset 3px 0 0 var(--danger); padding-left: var(--sp-3); }
.compromiso-item.is-vence_hoy { box-shadow: inset 3px 0 0 var(--warning); padding-left: var(--sp-3); }

/* ---------------------------------------------------------------- pesos */
.weight-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(8rem, 1fr) 7rem 7rem; gap: var(--sp-3); align-items: center; padding: var(--sp-3) 0; border-bottom: 1px solid var(--border); }
.weight-row:last-child { border-bottom: 0; }
.weight-row .wr-label strong { display: block; }
.weight-row .wr-label small { color: var(--muted); }
.weight-row input { margin: 0; }
.weight-head { color: var(--muted); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.05em; font-weight: var(--fw-semibold); padding-top: 0; }
@media (max-width: 760px) { .weight-row { grid-template-columns: 1fr 6rem; } .weight-row .wr-range { grid-column: 1 / -1; } .weight-head { display: none; } }
.sticky-actions { position: sticky; bottom: 0; z-index: 5; display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: center; padding: var(--sp-3) var(--sp-4); margin: 0 0 var(--sp-4); background: color-mix(in srgb, var(--surface) 92%, transparent); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); backdrop-filter: blur(6px); }
.sticky-actions input[type="text"] { max-width: 22rem; }
.contrib { display: flex; align-items: center; gap: var(--sp-2); min-width: 8rem; }
.contrib .bar { flex: 1 1 auto; }

/* ---------------------------------------------------------------- dashboard / reports */
.dash-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: var(--sp-4); }
@media (max-width: 1100px) { .dash-grid { grid-template-columns: 1fr; } }
.live-dot { display: inline-flex; align-items: center; gap: var(--sp-2); color: var(--muted); font-size: var(--fs-xs); }
.live-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6); animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5); } 70% { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); } 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); } }
.capacity-result { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: var(--sp-3); margin-top: var(--sp-3); }
.capacity-result div { padding: var(--sp-3); border-radius: var(--radius); background: var(--surface-2); }
.capacity-result strong { display: block; font-size: var(--fs-lg); font-variant-numeric: tabular-nums; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr)); gap: 0 var(--sp-3); align-items: end; }
.filters .form-actions { margin-bottom: var(--sp-3); }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-top: 1px solid var(--border); font-size: var(--fs-sm); color: var(--muted); flex-wrap: wrap; }
.pagination .btn-group a[aria-disabled="true"] { pointer-events: none; opacity: 0.5; }
.audit-details { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--muted); max-width: 32rem; word-break: break-word; }

/* ---------------------------------------------------------------- error page */
.error-page { max-width: 520px; margin: var(--sp-12) auto; text-align: center; }
.error-code { font-size: 4rem; font-weight: 800; line-height: 1; letter-spacing: -0.04em; background: linear-gradient(135deg, var(--primary), #38bdf8); -webkit-background-clip: text; background-clip: text; color: transparent; margin-bottom: var(--sp-3); }

/* ---------------------------------------------------------------- motion preferences */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
  .toast { animation: none; }
}

@media print {
  .sidebar, .topbar, .toast-region, .page-actions, .sticky-actions { display: none !important; }
  .app { display: block; }
  .card, .panel, article { box-shadow: none; break-inside: avoid; }
}
.pad { padding: var(--sp-4) var(--sp-5); margin: 0; }
.other-phones details summary { font-size: var(--fs-sm); padding-top: var(--sp-2); }
.kpi-tile.accent .kpi-value small { color: rgba(255, 255, 255, 0.85); }

/* --- confirmation dialog (replaces window.confirm; wired in app.js) ------------------------------ */
.confirm-dialog {
  width: min(92vw, 440px); padding: 0; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
.confirm-dialog::backdrop { background: rgba(15, 23, 42, 0.55); backdrop-filter: blur(2px); }
.confirm-dialog[open] { animation: confirm-in 140ms var(--ease); }
.confirm-box { display: grid; gap: var(--sp-4); padding: var(--sp-6); margin: 0; }
.confirm-title { margin: 0; font-size: var(--fs-md); }
.confirm-message { margin: 0; color: var(--text-soft); white-space: pre-line; }
.confirm-actions { display: flex; justify-content: flex-end; gap: var(--sp-3); flex-wrap: wrap; }
@keyframes confirm-in { from { opacity: 0; transform: translateY(6px) scale(0.98); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .confirm-dialog[open] { animation: none; } }
