:root {
    --navy: #102a43;
    --navy-2: #173f5f;
    --teal: #0f8b8d;
    --teal-dark: #087174;
    --mint: #e9f7f5;
    --amber: #f2a541;
    --red: #d65c5c;
    --ink: #203040;
    --muted: #6c7b88;
    --line: #dfe7ec;
    --background: #f4f7f8;
    --white: #fff;
    --shadow: 0 8px 30px rgba(16, 42, 67, .07);
    --radius: 16px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--background); font: 14px/1.5 'DM Sans', system-ui, sans-serif; }
button, input, select, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, strong { font-family: 'Manrope', 'DM Sans', sans-serif; }
h1, h2, p { margin-top: 0; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 244px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 25px 18px 20px; color: #d9e6ee; background: linear-gradient(175deg, #102a43 0%, #0b2136 100%); z-index: 20; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 10px 30px; color: white; }
.brand-mark { width: 40px; height: 40px; display: inline-grid; place-items: center; flex: 0 0 auto; border-radius: 12px; color: white; background: var(--teal); font: 800 14px 'Manrope'; letter-spacing: .06em; box-shadow: 0 7px 18px rgba(15,139,141,.35); }
.brand-mark.large { width: 58px; height: 58px; border-radius: 17px; font-size: 19px; }
.brand-logo { width: 42px; height: 42px; flex: 0 0 auto; object-fit: contain; padding: 3px; background: white; border-radius: 12px; }
.brand strong, .sidebar-user strong { display: block; font-size: 15px; }
.brand > span:last-child { min-width: 0; }.brand > span:last-child strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand small, .sidebar-user small { display: block; color: #8fa9ba; font-size: 11px; }
.sidebar nav { display: flex; flex-direction: column; gap: 5px; }
.sidebar nav > a { display: flex; align-items: center; gap: 12px; padding: 11px 13px; border-radius: 10px; color: #b6c8d4; font-weight: 600; transition: .18s ease; }
.sidebar nav > a:hover { background: rgba(255,255,255,.055); color: white; }
.sidebar nav > a.active { color: white; background: rgba(15,139,141,.23); box-shadow: inset 3px 0 var(--teal); }
.nav-icon { width: 20px; text-align: center; font-size: 17px; }
.nav-label { margin: 22px 13px 7px; color: #68879b; font-size: 10px; letter-spacing: .13em; text-transform: uppercase; }
.sidebar-user { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid rgba(255,255,255,.09); display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 9px; }
.avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: #294c67; color: white; font-weight: 700; }
.sidebar-user strong { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user > a { color: #8fa9ba; font-size: 18px; }

.main { min-width: 0; }
.topbar { min-height: 96px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 20px 34px; background: white; border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 2px 0 0; color: var(--navy); font-size: 25px; line-height: 1.1; }
.eyebrow { color: var(--teal); font-size: 10px; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; }
.topbar-date { color: var(--muted); font-size: 13px; }
.menu-button { display: none; border: 0; background: transparent; font-size: 23px; color: var(--navy); }
.content { max-width: 1580px; margin: 0 auto; padding: 28px 34px 45px; }
.page-actions { min-height: 42px; display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.page-actions > div { display: flex; gap: 8px; }
.page-intro { margin: 0; color: var(--muted); font-size: 14px; }

.btn { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; padding: 9px 16px; border: 1px solid transparent; border-radius: 9px; cursor: pointer; font-weight: 700; transition: .18s; }
.btn-primary { color: white; background: var(--teal); box-shadow: 0 6px 14px rgba(15,139,141,.16); }
.btn-primary:hover { background: var(--teal-dark); transform: translateY(-1px); }
.btn-secondary { color: var(--navy); background: white; border-color: #cbd8df; }
.btn-ghost { color: #547080; background: transparent; border-color: #d8e1e6; }
.btn-wide { width: 100%; }

.alert { margin-bottom: 18px; padding: 12px 15px; border-radius: 9px; font-weight: 600; }
.alert-success { color: #11665c; background: #e3f5f0; border: 1px solid #bde5da; }
.alert-error { color: #9b3535; background: #fff0f0; border: 1px solid #f0c6c6; }

/* Flex con salto de línea, no una rejilla de columnas fijas. La rejilla anterior exigía
   ~1300 px de ancho mínimo y se desbordaba, porque los cortes de @media miden la VENTANA
   mientras que el contenido dispone de 244 px menos por la barra lateral: entre ~1250 y
   ~1600 px no había ningún corte que lo atrapara. Así los campos se reacomodan solos a
   cualquier ancho y la página nunca desplaza en horizontal. */
.filter-panel { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 10px; margin-bottom: 20px; padding: 16px; background: white; border: 1px solid var(--line); border-radius: 13px; box-shadow: 0 3px 12px rgba(16,42,67,.035); }
.filter-panel > label { flex: 1 1 128px; min-width: 0; }
.filter-panel > label.grow { flex: 2.2 1 190px; }
/* Los input[type=date] traen un ancho mínimo propio del navegador que `width:100%` no
   vence; sin esto podrían impedir que su columna se encoja y reaparecería el desborde. */
.filter-panel input, .filter-panel select { min-width: 0; }
label { display: flex; flex-direction: column; gap: 6px; }
label > span { color: #586e7c; font-size: 11px; font-weight: 700; }
input, select, textarea { width: 100%; min-height: 40px; padding: 9px 11px; color: var(--ink); background: white; border: 1px solid #cfdbe2; border-radius: 8px; outline: 0; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(15,139,141,.1); }
.filter-actions { display: flex; flex: 0 0 auto; gap: 6px; margin-left: auto; }
.input-year { min-width: 80px; }
.client-autocomplete { position: relative; }
.client-suggestions { position: absolute; top: calc(100% + 5px); left: 0; z-index: 40; width: min(420px, calc(100vw - 40px)); max-height: 300px; overflow-y: auto; padding: 5px; background: white; border: 1px solid #cfdbe2; border-radius: 10px; box-shadow: 0 14px 34px rgba(16,42,67,.16); }
.client-suggestion { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 11px; color: var(--ink); background: transparent; border: 0; border-radius: 7px; cursor: pointer; text-align: left; }
.client-suggestion:hover, .client-suggestion.active { color: var(--navy); background: var(--mint); }
.client-suggestion strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.client-suggestion small { flex: 0 0 auto; color: var(--muted); font-size: 11px; }
.client-suggestion-empty { padding: 10px 11px; color: var(--muted); font-size: 12px; }

.kpi-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 15px; margin-bottom: 16px; }
.kpi-card { min-height: 130px; padding: 21px; background: white; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.kpi-card span { display: block; color: #647887; font-size: 12px; font-weight: 600; }
.kpi-card strong { display: block; margin: 10px 0 3px; color: var(--navy); font-size: clamp(24px,2vw,32px); line-height: 1.15; }
.kpi-card small { color: #82929e; }
.kpi-card.featured { color: white; background: linear-gradient(135deg, var(--navy) 0%, #194c68 100%); border-color: transparent; }
.kpi-card.featured span, .kpi-card.featured small { color: #b8cdd9; }
.kpi-card.featured strong { color: white; }

.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr .8fr; gap: 16px; }
/* Los elementos de rejilla y flex traen `min-width: auto`, así que se niegan a encogerse
   por debajo del contenido más ancho que tengan dentro. Con un <canvas> eso es fatal: su
   atributo `width` (en píxeles de dispositivo, ~929) cuenta como anchura intrínseca y
   forzaba la columna a ~467px, desbordando la pantalla en el teléfono. */
.dashboard-grid > *, .kpi-grid > *, .summary-strip > * { min-width: 0; }
.span-2 { grid-column: span 2; }
.panel { background: white; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.chart-panel { min-height: 360px; }
.panel-heading { min-height: 72px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 20px; padding: 18px 21px; border-bottom: 1px solid #ebf0f3; }
.panel-heading h2 { margin: 2px 0 0; color: var(--navy); font-size: 17px; }
.panel-heading > a { color: var(--teal); font-weight: 700; font-size: 12px; }
.chart { width: 100%; max-width: 100%; height: 270px; display: block; padding: 8px 15px 15px; }
.donut-wrap { display: flex; flex-direction: column; align-items: center; padding: 20px; }
.donut { width: 175px; height: 175px; }
.legend { width: 100%; margin-top: 14px; }
.legend > div { display: grid; grid-template-columns: 12px 1fr auto; align-items: center; gap: 8px; padding: 6px 0; color: var(--muted); font-size: 12px; }
.legend-color { width: 9px; height: 9px; border-radius: 3px; background: var(--teal); }
.legend-color.c1 { background: var(--amber); }.legend-color.c2 { background: var(--navy-2); }.legend-color.c3 { background: #aab7bf; }.legend-color.c4 { background: #d65c5c; }
.aging-list { padding: 21px; display: flex; flex-direction: column; gap: 20px; }
.aging-list span { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 12px; }
.aging-list strong { color: var(--ink); font-size: 12px; }
.progress { height: 7px; margin-top: 7px; overflow: hidden; background: #edf2f4; border-radius: 5px; }
.progress i { display: block; min-width: 2px; height: 100%; background: var(--teal); border-radius: inherit; }
.progress .warn { background: #dcb64a; }.progress .orange { background: #e88a45; }.progress .late { background: #dc6a4a; }.progress .severe { background: #d84d4d; }.progress .danger { background: #a91f2d; }

.summary-strip { display: flex; flex-wrap: wrap; gap: 1px; margin-bottom: 16px; overflow: hidden; background: var(--line); border: 1px solid var(--line); border-radius: 13px; }
.summary-strip > div { flex: 1; min-width: 180px; padding: 15px 20px; background: white; }
.summary-strip span { display: block; color: var(--muted); font-size: 11px; }
.summary-strip strong { display: block; margin-top: 3px; color: var(--navy); font-size: 19px; }
.table-panel { overflow: hidden; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 13px 16px; color: #71838f; background: #f8fafb; border-bottom: 1px solid var(--line); font-size: 10px; letter-spacing: .055em; text-align: left; text-transform: uppercase; white-space: nowrap; }
td { padding: 13px 16px; border-bottom: 1px solid #edf1f3; color: #425866; vertical-align: middle; }
.table-sort { display: inline-flex; align-items: center; gap: 5px; color: inherit; }
.table-sort:hover, .table-sort.active { color: var(--teal); }
.table-sort span { font-size: 13px; line-height: 1; }
.client-filter-link { display: block; border-radius: 5px; }
.client-filter-link:hover strong { color: var(--teal); text-decoration: underline; text-underline-offset: 2px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fbfdfd; }
td strong { display: block; color: var(--ink); font-size: 12px; }
td small { display: block; margin-top: 2px; color: #87959e; font-size: 10px; }
.number { text-align: right; white-space: nowrap; }
.amount { color: var(--navy); font-weight: 700; }
.overdue { color: #c93434 !important; font-weight: 800; white-space: nowrap; }
.on-time { color: #6e858f; font-weight: 700; white-space: nowrap; }
.actions { text-align: right; white-space: nowrap; }
.table-action { color: var(--teal); font-size: 11px; font-weight: 700; }
.edit-action { margin-left: 11px; padding-left: 11px; border-left: 1px solid var(--line); }
.contact-value { font-family: 'DM Sans',system-ui,sans-serif; font-weight: 600; }
.link-button { padding: 0; border: 0; background: transparent; cursor: pointer; }
.muted { color: #a0acb4; font-size: 11px; }
.empty { padding: 40px; color: var(--muted); text-align: center; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border-radius: 20px; background: #fff4e1; color: #9b6616; font-size: 10px; font-weight: 700; white-space: nowrap; }
.badge i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-paid { color: #14746a; background: #e3f5f1; }.badge-partial { color: #976a15; background: #fff3d5; }.badge-cancelled { color: #6f7f89; background: #edf1f3; }.badge-pending { color: #ae6329; background: #fff0e5; }
.pagination { display: flex; align-items: center; justify-content: space-between; padding: 13px 17px; color: var(--muted); border-top: 1px solid var(--line); font-size: 11px; }
.pagination > div { display: flex; gap: 7px; }

.form-card { max-width: 980px; margin: 0 auto; padding: 0; overflow: hidden; }
.form-card.compact { max-width: 760px; margin-bottom: 20px; padding: 25px; overflow: visible; }
.form-card.compact h2 { margin-bottom: 20px; color: var(--navy); font-size: 20px; }
.client-form { max-width: 860px; }
.form-section { display: grid; grid-template-columns: 230px 1fr; gap: 35px; padding: 30px; border-bottom: 1px solid var(--line); }
.form-section h2 { margin: 5px 0; color: var(--navy); font-size: 18px; }
.form-section p { color: var(--muted); font-size: 12px; }
.step { color: var(--teal); font-size: 11px; font-weight: 800; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 17px; }
.form-grid .span-2 { grid-column: span 2; }
.form-footer { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 19px 30px; background: #fafcfc; }
.compact .form-footer { margin: 23px -25px -25px; }
.payment-layout { display: grid; grid-template-columns: 330px 1fr; gap: 18px; max-width: 1020px; margin: 0 auto 20px; }
.document-summary { padding: 27px; }
.document-summary h2 { margin: 8px 0 4px; color: var(--navy); font-size: 23px; }
.document-summary p { color: var(--muted); }
.document-summary dl { margin: 25px 0 0; }
.document-summary dl > div { display: flex; justify-content: space-between; gap: 12px; padding: 13px 0; border-top: 1px solid var(--line); }
.document-summary dt { color: var(--muted); }.document-summary dd { margin: 0; color: var(--navy); font-weight: 700; }
.document-summary .highlight dd { color: var(--teal); font-size: 18px; }
.search-bar { display: flex; gap: 8px; max-width: 520px; margin-bottom: 18px; }
.future-banner { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 18px; padding: 19px 22px; color: #235a61; background: linear-gradient(120deg,#e5f5f2,#eef8f6); border: 1px solid #c9e7e2; border-radius: 13px; }
.future-banner > span { font-size: 25px; }.future-banner strong { display: block; margin-bottom: 3px; color: var(--navy); }.future-banner p { margin: 0; font-size: 12px; }
.details-cell { max-width: 350px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.system-company-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 20px; margin-top: 24px; padding: 16px 2px 0; color: #8998a2; border-top: 1px solid var(--line); font-size: 10px; }
.system-company-footer strong { color: #667c89; font-size: 10px; }
.company-settings-layout { display: grid; grid-template-columns: 260px 1fr; gap: 18px; align-items: start; }
.company-brand-card { padding: 24px; text-align: center; }
.company-logo-preview { width: 160px; height: 110px; display: grid; place-items: center; margin: 0 auto 18px; overflow: hidden; color: var(--teal); background: #f4f9f8; border: 1px solid #d9e7e6; border-radius: 14px; font: 800 24px 'Manrope',sans-serif; }
.company-logo-preview img { width: 100%; height: 100%; object-fit: contain; padding: 10px; }
.company-brand-card h2 { margin-bottom: 5px; color: var(--navy); font-size: 16px; }.company-brand-card p { color: var(--muted); font-size: 11px; }
.settings-form { max-width: none; margin: 0; }
.settings-section { padding: 25px; border-bottom: 1px solid var(--line); }.settings-section:last-of-type { border-bottom: 0; }
.settings-section h2 { margin-bottom: 5px; color: var(--navy); font-size: 17px; }.settings-section > p { margin-bottom: 18px; color: var(--muted); font-size: 11px; }
.logo-help { display: block; margin-top: 9px; color: var(--muted); font-size: 10px; }
.checkbox-field { flex-direction: row; align-items: center; gap: 9px; }
.checkbox-field input { width: 17px; height: 17px; margin: 0; flex: 0 0 auto; accent-color: var(--teal); }
.checkbox-field span { margin: 0; font-size: 13px; font-weight: 600; color: var(--navy); text-transform: none; letter-spacing: 0; }

.import-steps { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; margin-bottom: 18px; }
.import-steps article { display: flex; gap: 13px; padding: 17px; background: white; border: 1px solid var(--line); border-radius: 13px; }
.import-steps article > span { width: 30px; height: 30px; display: grid; place-items: center; flex: 0 0 auto; color: white; background: var(--teal); border-radius: 9px; font: 800 12px 'Manrope',sans-serif; }
.import-steps strong { display: block; margin-bottom: 3px; color: var(--navy); font-size: 12px; }
.import-steps p { margin: 0; color: var(--muted); font-size: 11px; }
.upload-panel { max-width: 900px; margin: 0 auto 20px; padding: 22px; }
.drop-zone { min-height: 260px; display: grid; place-items: center; align-content: center; gap: 7px; padding: 32px; background: #f8fbfb; border: 2px dashed #b8d2d4; border-radius: 13px; cursor: pointer; text-align: center; transition: .18s; }
.drop-zone:hover { background: #f0f8f7; border-color: var(--teal); }
.drop-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.drop-zone strong { color: var(--navy); font-size: 17px; }.drop-zone small { color: var(--muted); }
.upload-icon { width: 52px; height: 52px; display: grid; place-items: center; margin-bottom: 5px; color: var(--teal); background: var(--mint); border-radius: 16px; font-size: 27px; }
.upload-footer { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding-top: 17px; }
.upload-footer strong,.upload-footer span { display: block; }.upload-footer strong { color: var(--navy); font-size: 11px; }.upload-footer span { color: var(--muted); font-size: 10px; }
.import-preview { overflow: hidden; margin-bottom: 20px; }
.format-pill { padding: 6px 10px; color: #176b69; background: var(--mint); border-radius: 20px; font-size: 10px; font-weight: 700; }
.import-summary { display: grid; grid-template-columns: repeat(6,1fr); border-bottom: 1px solid var(--line); }
.import-summary > div { padding: 17px; border-right: 1px solid var(--line); }.import-summary > div:last-child { border-right: 0; }
.import-summary span { display: block; color: var(--muted); font-size: 10px; }.import-summary strong { display: block; margin-top: 4px; color: var(--navy); font-size: 18px; }
.import-summary .success strong { color: var(--teal); }.import-summary .warning strong { color: #bd791b; }.import-summary .danger strong { color: var(--red); }
.preview-note { margin: 0; padding: 12px 18px; color: var(--muted); background: #fafcfc; border-top: 1px solid var(--line); font-size: 11px; }
.preview-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 16px 20px; border-top: 1px solid var(--line); }
.preview-actions form { margin: 0; }.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.import-history { margin-top: 20px; }

.login-page { min-height: 100vh; display: grid; grid-template-columns: minmax(420px, .9fr) minmax(480px, 1.1fr); background: white; }
/* Misma paleta de siempre; el degradado se agranda solo para poder desplazarlo. */
.login-brand-panel { position: relative; display: grid; place-items: center; overflow: hidden; padding: 60px; color: white; background: linear-gradient(145deg,#102a43,#0c3146 60%,#0f676a); background-size: 180% 180%; animation: brandAurora 26s ease-in-out infinite; }
.login-brand-panel::before, .login-brand-panel::after { content: ''; position: absolute; width: 340px; height: 340px; border-radius: 50%; border: 1px solid rgba(255,255,255,.08); }
.login-brand-panel::before { top: -140px; right: -120px; animation: brandDrift 24s ease-in-out infinite; }
.login-brand-panel::after { bottom: -170px; left: -100px; width: 430px; height: 430px; animation: brandDrift 34s ease-in-out infinite reverse; }
.login-brand-content { position: relative; z-index: 1; max-width: 430px; }
/* El logo llega ya recortado por company_logo_trimmed_path() (&trim=1), sin el margen blanco
   del JPEG. El radio en dos ejes redondea lo que queda: la insignia de este logo tiene las
   esquinas curvas y, sin esto, asomarían cuatro triángulos blancos. 15%/18.5% es el radio
   medido sobre la propia imagen (≈62 px de 422 de ancho y 336 de alto). */
.login-logo { display: block; height: 92px; width: auto; max-width: 250px; border-radius: 15% / 18.5%; box-shadow: 0 14px 34px rgba(0,0,0,.34); }
.login-brand-content .eyebrow { margin: 40px 0 12px; color: #75d3cb; }
.login-brand-content h1 { margin-bottom: 20px; font-size: clamp(38px,5vw,61px); line-height: 1.05; letter-spacing: -.035em; }
.login-brand-content > p { color: #bdd0db; font-size: 16px; }
.login-points { margin: 34px 0 0; padding: 0; list-style: none; display: grid; gap: 15px; }
.login-points li { position: relative; padding-left: 31px; color: #cfe0ea; font-size: 15px; line-height: 1.45; }
.login-points li::before { content: ''; position: absolute; left: 0; top: 2px; width: 18px; height: 18px; border-radius: 50%; background: rgba(116,212,204,.14); border: 1px solid rgba(116,212,204,.5); }
.login-points li::after { content: ''; position: absolute; left: 6px; top: 6px; width: 5px; height: 9px; border: solid #74d4cc; border-width: 0 2px 2px 0; transform: rotate(45deg); }
/* Tecleo: el fantasma reserva el alto exacto de la línea y lo escrito va encima, para que
   el panel no salte mientras se escribe. Los crea app.js; sin JS no existe ninguno. */
.login-points .tw-ghost { visibility: hidden; }
.login-points .tw-text { position: absolute; left: 31px; right: 0; top: 0; }
/* Los vistos arrancan ocultos SOLO si app.js tomó el control (.is-typing en la lista), y
   cada uno aparece cuando su propia línea termina de escribirse. */
.login-points.is-typing li::before, .login-points.is-typing li::after { opacity: 0; transition: opacity .45s ease; }
.login-points.is-typing li.is-done::before, .login-points.is-typing li.is-done::after { opacity: 1; }
/* Sólido mientras teclea; parpadea 3 veces al cerrar línea y sin fin tras la última. */
.tw-caret { color: #74d4cc; font-weight: 700; }
.tw-caret.is-blinking { animation: twBlink .53s linear 3; }
.tw-caret.is-idle { animation: twBlink .53s linear infinite; }
@keyframes twBlink { 0%,49.9% { opacity: 1; } 50%,100% { opacity: 0; } }

/* Gráfico de marca: barras que crecen y una flecha que sube con ellas. Ciclo de 9 s. */
.login-chart { margin: 36px 0 0; max-width: 320px; }
.login-chart svg { display: block; width: 100%; height: auto; }
.lc-base { stroke: rgba(255,255,255,.12); stroke-width: 1; }
.lc-bars rect { fill: url(#lcBar); transform-box: fill-box; transform-origin: bottom; animation: lcBar 9s cubic-bezier(.33,.9,.35,1) infinite; }
.lc-bars rect:nth-child(2) { animation-delay: .12s; }.lc-bars rect:nth-child(3) { animation-delay: .24s; }
.lc-bars rect:nth-child(4) { animation-delay: .36s; }.lc-bars rect:nth-child(5) { animation-delay: .48s; }
.lc-bars rect:nth-child(6) { animation-delay: .6s; }
.lc-line, .lc-head { fill: none; stroke: #74d4cc; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
/* Estado inicial explícito: sin él se ve un fotograma con todo ya dibujado antes de arrancar. */
.lc-line { stroke-dasharray: 220; stroke-dashoffset: 220; animation: lcDraw 9s cubic-bezier(.33,.9,.35,1) infinite; }
.lc-head { opacity: 0; animation: lcHead 9s ease-in-out infinite; }
@keyframes lcBar { 0% { transform: scaleY(.04); opacity: 0; } 4% { opacity: 1; } 20% { transform: scaleY(1); } 84% { transform: scaleY(1); opacity: 1; } 93%,100% { opacity: 0; } }
@keyframes lcDraw { 0%,8% { stroke-dashoffset: 220; opacity: 1; } 42%,84% { stroke-dashoffset: 0; opacity: 1; } 93%,100% { stroke-dashoffset: 0; opacity: 0; } }
@keyframes lcHead { 0%,40% { opacity: 0; } 52%,84% { opacity: .95; } 93%,100% { opacity: 0; } }
/* En pantallas bajas el panel recorta: el gráfico es lo prescindible. */
@media (max-height: 780px) { .login-chart { display: none; } }

/* Entrada escalonada + latido de la marca. El degradado y los aros se mueven en bucle. */
.login-brand-content .eyebrow, .login-brand-content h1, .login-brand-content > p, .login-points li, .login-chart { animation: riseIn .7s cubic-bezier(.22,.61,.36,1) both; }
.login-brand-content .brand-mark, .login-logo { animation: riseIn .7s cubic-bezier(.22,.61,.36,1) .05s both, markGlow 5s ease-in-out 1.2s infinite; }
.login-brand-content .eyebrow { animation-delay: .14s; }
.login-brand-content h1 { animation-delay: .22s; }
.login-brand-content > p { animation-delay: .34s; }
.login-points li:nth-child(1) { animation-delay: .46s; }
.login-points li:nth-child(2) { animation-delay: .56s; }
.login-points li:nth-child(3) { animation-delay: .66s; }
.login-chart { animation-delay: .78s; }
@keyframes brandAurora { 0%,100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }
@keyframes brandDrift { 0%,100% { transform: translate3d(0,0,0) scale(1); } 50% { transform: translate3d(26px,-24px,0) scale(1.07); } }
@keyframes riseIn { from { opacity: 0; transform: translateY(17px); } to { opacity: 1; transform: none; } }
@keyframes markGlow { 0%,100% { box-shadow: 0 7px 18px rgba(15,139,141,.35); } 50% { box-shadow: 0 10px 32px rgba(116,212,204,.55); } }
/* Quien pidió menos movimiento en su sistema no debe recibir ninguno. */
@media (prefers-reduced-motion: reduce) {
    .login-brand-panel, .login-brand-panel::before, .login-brand-panel::after,
    .login-brand-content .brand-mark, .login-logo, .login-brand-content .eyebrow, .login-brand-content h1,
    .login-brand-content > p, .login-points li, .login-chart,
    .lc-bars rect, .lc-line, .lc-head { animation: none; }
    /* Sin animación hay que dejar el gráfico dibujado, no a medio construir. */
    .lc-line { stroke-dashoffset: 0; }.lc-head { opacity: .95; }
}
.login-form-panel { display: grid; place-items: center; padding: 50px; }
.login-card { width: min(400px,100%); }
.login-card h2 { margin: 8px 0 4px; color: var(--navy); font-size: 34px; }
.login-card > p { color: var(--muted); margin-bottom: 28px; }
.login-card label { margin-bottom: 16px; }
.login-card input { min-height: 48px; }
.login-card .btn { min-height: 48px; margin-top: 4px; }
.login-card > small { display: block; margin-top: 20px; color: #9aa6ad; text-align: center; }
.login-alert { position: fixed; top: 15px; left: 50%; z-index: 50; transform: translateX(-50%); }
.otp-input { font-size: 25px; font-weight: 700; letter-spacing: .35em; text-align: center; }
.auth-link { color: var(--teal); font-size: inherit; }
.login-card small a { color: var(--teal); }
.auth-mode-panel { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 20px; padding: 24px; }
.auth-mode-panel h2 { margin: 3px 0 6px; color: var(--navy); }.auth-mode-panel p { margin: 0; color: var(--muted); }
.auth-mode-panel form { flex: 0 0 auto; }
.contingency-banner { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; padding: 12px 16px; color: #6c4310; background: #fff4dc; border: 1px solid #efd39d; border-radius: 9px; }
.contingency-banner strong { white-space: nowrap; }.contingency-banner span { font-size: 12px; }

@media (max-width: 1250px) {
    /* El panel de filtros ya no necesita corte: reparte solo con flex-wrap. */
    .dashboard-grid { grid-template-columns: 1fr 1fr; }.dashboard-grid > .span-2 { grid-column: span 2; }
}
@media (max-width: 900px) {
    .app-shell { display: block; }
    .sidebar { position: fixed; left: -260px; width: 244px; transition: left .2s; }.sidebar.open { left: 0; box-shadow: 15px 0 40px rgba(0,0,0,.2); }
    .menu-button { display: block; }.topbar { justify-content: flex-start; padding: 18px 20px; }.topbar-date { margin-left: auto; }
    .content { padding: 22px 20px 35px; }.kpi-grid { grid-template-columns: 1fr 1fr; }
    .login-page { grid-template-columns: 1fr; }.login-brand-panel { display: none; }
    .import-summary { grid-template-columns: repeat(3,1fr); }.import-summary > div { border-bottom: 1px solid var(--line); }
    .company-settings-layout { grid-template-columns: 1fr; }.company-brand-card { display: grid; grid-template-columns: 140px 1fr; text-align: left; }.company-logo-preview { width: 130px; height: 90px; margin: 0; }
}
@media (max-width: 650px) {
    .topbar-date { display: none; }.topbar h1 { font-size: 21px; }.page-actions { align-items: flex-start; flex-direction: column; }
    .filter-panel > label, .filter-panel > label.grow { flex-basis: calc(50% - 5px); }
    .filter-actions { flex: 1 1 100%; margin-left: 0; }.filter-actions .btn { flex: 1; }
    .kpi-grid, .dashboard-grid { grid-template-columns: 1fr; }.dashboard-grid > .span-2 { grid-column: span 1; }
    .kpi-card { min-height: 110px; }.form-section { grid-template-columns: 1fr; gap: 10px; padding: 23px; }
    .form-grid { grid-template-columns: 1fr; }.form-grid .span-2 { grid-column: span 1; }.payment-layout { grid-template-columns: 1fr; }
    .login-form-panel { padding: 32px 22px; }.summary-strip { display: grid; grid-template-columns: 1fr; }
    .import-steps { grid-template-columns: 1fr; }.upload-footer,.preview-actions { align-items: stretch; flex-direction: column; }.upload-footer .btn,.preview-actions .btn { width: 100%; }.import-summary { grid-template-columns: 1fr 1fr; }
    .system-company-footer { align-items: flex-start; flex-direction: column; gap: 3px; }.company-brand-card { display: block; text-align: center; }.company-logo-preview { margin: 0 auto 16px; }
    .auth-mode-panel,.contingency-banner { align-items: stretch; flex-direction: column; }.auth-mode-panel .btn { width: 100%; }
}

/* Visto bueno de completitud de la ficha del cliente, junto a su nombre.
   verde = los cuatro datos · amarillo = teléfono y correo · rojo = falta uno de esos dos. */
.data-check { display: inline-flex; align-items: center; justify-content: center; width: 17px; height: 17px; margin-left: 7px; border-radius: 50%; font-size: 11px; font-weight: 700; line-height: 1; vertical-align: middle; cursor: help; }
.data-check.is-complete { color: #14746a; background: #d9f2ec; }
.data-check.is-partial { color: #976a15; background: #fff3d5; }
.data-check.is-missing { color: #9b3535; background: #fdeaea; }


/* Franja de datos de clientes. A todo el ancho y en dos bloques: a la izquierda el texto
   con sus acciones debajo, a la derecha los contadores. Antes las acciones caían solas en
   una segunda línea alineada a la derecha, con un hueco a la izquierda que se veía sucio. */
.client-data-bar { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 16px 26px; margin-bottom: 18px; padding: 18px 21px; }
.cdb-main { flex: 1 1 420px; min-width: 270px; }
.cdb-main h2 { margin: 3px 0 4px; color: var(--navy); font-size: 17px; }
.cdb-main p { margin: 0 0 14px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.cdb-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; }
/* El input de archivo nativo se ve distinto en cada navegador y trunca el nombre; se
   esconde dentro de una etiqueta con aspecto de botón, que sigue abriendo el selector. */
/* Sin display propio: hereda el inline-flex de .btn, que es lo que centra el texto
   vertical y horizontalmente. Ponerle inline-block lo descentraba. El recorte del
   nombre largo va en el span interior, no en la etiqueta. */
/* Este botón es un <label>, y arriba hay una regla global `label { display:flex;
   flex-direction:column; gap:6px }` para los campos de formulario. `.btn` gana en `display`
   por especificidad, pero NO define `flex-direction`, así que la flecha quedaba encima del
   texto. Hay que devolver la fila, quitar el gap y anular `label > span`, que además
   achicaba y agrisaba el texto. */
.cdb-file { position: relative; cursor: pointer; max-width: 270px; flex-direction: row; gap: 0; }
.cdb-file > span { color: inherit; font-size: inherit; font-weight: inherit; }
.cdb-file [data-file-name] { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.cdb-file input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.cdb-file.has-file { color: var(--navy); border-color: var(--teal); background: var(--mint); }
.cdb-counts { display: flex; gap: 1px; overflow: hidden; background: var(--line); border: 1px solid var(--line); border-radius: 11px; }
.cdb-counts > div { min-width: 108px; padding: 9px 14px; background: white; text-align: center; }
.cdb-counts strong { display: block; font-size: 23px; line-height: 1.15; }
.cdb-counts span { display: block; margin-top: 1px; color: var(--muted); font-size: 11px; }
.client-data-preview { margin-bottom: 18px; padding: 19px 21px; }
.client-data-preview .table-wrap { max-height: 380px; overflow-y: auto; }
/* Crédito del desarrollador, presente en los cuatro pies del sistema. */
.system-credit { flex-basis: 100%; margin-top: 2px; color: #93a2ac; font-size: 10px; }
.setup-credit { color: #1668c1; font-weight: 700; }
.setup-credit:hover { text-decoration: underline; }
.auth-credit { margin: 22px 0 0; color: #9aa6ad; font-size: 11px; text-align: center; line-height: 1.5; }

/* Cada tramo de mora del panel es un enlace a la lista de documentos de ese tramo. El margen
   negativo compensa el relleno para que la separación visual quede igual que antes. */
.aging-list .aging-row { display: block; padding: 7px 9px; margin: -7px -9px; color: inherit; text-decoration: none; border-radius: 9px; transition: background .18s ease; }
.aging-list .aging-row:hover, .aging-list .aging-row:focus-visible { background: #eef4f6; outline: none; }
.aging-list .aging-row:hover span, .aging-list .aging-row:focus-visible span { color: var(--ink); }
/* Aviso del filtro que llega desde el panel, con su salida a la vista. */
.active-filter { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin: 14px 0 -6px; padding: 11px 15px; background: #eef4f6; border: 1px solid #d6e4e9; border-radius: 10px; color: var(--muted); font-size: 13px; }
.active-filter strong { color: var(--ink); }
.active-filter a { color: var(--teal); font-weight: 600; text-decoration: none; }
.active-filter a:hover { text-decoration: underline; }
