/* Esitel Telefonía. Base: the firmador additions on top of the inventory styles.css + themes.css (same variables, so light/dark follow along),
   then what billing needs: invoice cards, the client form with its preview, tariffs. */
html[data-estilo] { --client: #2563eb; --client-soft: rgb(37 99 235 / 0.13); }
html[data-estilo][data-theme='dark'] { --client: #60a5fa; --client-soft: rgb(96 165 250 / 0.16); }

main.wide { max-width: 1440px; }
h1 .badge { vertical-align: middle; margin-left: 4px; }
h2 { font-family: var(--display); }
.panel h2 { margin-top: 0; font-size: 1rem; }
.panel.flush { padding: 0; overflow: hidden; }
.panel.flush table th:first-child, .panel.flush table td:first-child { padding-left: 16px; }
.panel.empty { text-align: center; padding: 40px 20px; display: grid; gap: 10px; justify-items: center; }
.panel.empty h2 { margin: 0; }
table.docs td a { color: var(--text); text-decoration: none; }
table.docs td a:hover { color: var(--accent); }
.back { display: inline-block; font-size: .85rem; color: var(--muted); text-decoration: none; margin-bottom: 6px; }
.back:hover { color: var(--accent); }
.eyebrow { font-size: .72rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); margin: 0 0 4px; }
.stack { display: grid; gap: 8px; margin: 12px 0 6px; }
.status-msg { font-size: .88rem; min-height: 1.3em; margin: 6px 0 0; }
.status-msg[data-kind='error'] { color: var(--danger); font-weight: 600; }
.login-error:empty { display: none; }
.form-error { margin: 0 0 12px; }
.danger-link { color: var(--danger); margin-top: 10px; }
.menu form { margin: 0; }
.page-head > div { min-width: 0; }

/* Login extras: second-factor enrolment and the "link expired" card share the login panel */
.totp-qr { width: 190px; margin: 4px auto 10px; background: #fff; padding: 6px; border-radius: var(--radius); border: 1px solid var(--border); }
.totp-qr svg { display: block; width: 100%; height: auto; }
.totp-secret { text-align: center; word-break: break-all; margin-bottom: 14px; }
.login.msg { text-align: center; }

/* Upload */
.drop { position: relative; display: grid; gap: 4px; justify-items: center; text-align: center; padding: 36px 16px; margin-bottom: 16px;
  border: 2px dashed var(--border); border-radius: var(--radius-lg); background: var(--surface-soft); cursor: pointer; font-weight: 400;
  transition: border-color .15s ease, background-color .15s ease; }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop:hover, .drop.is-over { border-color: var(--accent); }
.drop.has-file { border-style: solid; border-color: var(--ok); }
.drop-title { font: 700 1rem var(--display); }
.drop-file { font-weight: 700; color: var(--ok); }

/* Document page */
.doc-grid { display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 18px; align-items: start; }
.side { position: sticky; top: 70px; max-height: calc(100vh - 86px); overflow-y: auto; scrollbar-width: thin; }
.side .panel { margin-bottom: 12px; }
.side .btn { width: 100%; }
.who-tools { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0 8px; }
.who-tool { font: inherit; font-weight: 700; font-size: .88rem; min-height: 36px; border-radius: var(--radius); cursor: pointer;
  background: var(--surface); border: 2px solid var(--border); color: var(--muted); }
.who--esitel.is-on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.who--client.is-on { border-color: var(--client); color: var(--client); background: var(--client-soft); }
.link-box { display: flex; gap: 6px; margin-top: 10px; }
.link-box[hidden] { display: none; }
.link-box input { font-size: .82rem; }
.link-box .btn { width: auto; flex: none; }
.files { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.signers { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 10px 0 14px; }
.signers dt { font-weight: 700; }
.signers dd { margin: 0; color: var(--muted); }
.audit-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; font-size: .88rem; }
.audit-list li { display: grid; gap: 1px; border-left: 2px solid var(--border); padding-left: 10px; }
.audit-list time { font-size: .76rem; color: var(--muted); }
.audit-list .note { font-size: .78rem; word-break: break-word; }
.how { margin: 0 0 4px; padding-left: 20px; display: grid; gap: 6px; }
.swatch { display: inline-block; width: 18px; height: 11px; vertical-align: -1px; border: 2px solid var(--client); background: var(--client-soft); }

.viewer { display: grid; gap: 22px; min-width: 0; padding-bottom: 20px; }
.loading { padding: 40px; text-align: center; }
.page { position: relative; width: 100%; max-width: 900px; margin-inline: auto; background: #fff; border-radius: 2px;
  box-shadow: 0 1px 3px rgba(0,0,0,.1), 0 8px 24px rgba(0,0,0,.06); }
.page canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.overlay { position: absolute; inset: 0; touch-action: pan-y; }
.overlay.is-editable { cursor: crosshair; touch-action: none; }
.page-no { position: absolute; right: 0; bottom: -18px; font-size: 11px; color: var(--muted); }
.box { position: absolute; border: 2px solid; display: flex; align-items: flex-start; justify-content: space-between; user-select: none; border-radius: 2px; }
.box--esitel { border-color: #d5121c; background: rgb(213 18 28 / .1); }
.box--client { border-color: #2563eb; background: rgb(37 99 235 / .12); }
.box.is-ghost { border-style: dashed; pointer-events: none; }
.box-label { font: 700 11px var(--font); color: #fff; padding: 1px 6px; white-space: nowrap; }
.box--esitel .box-label { background: #d5121c; }
.box--client .box-label { background: #2563eb; }
.is-editable .box { cursor: move; }
.box-del { border: 0; background: rgba(0,0,0,.65); color: #fff; width: 22px; height: 22px; line-height: 1; font-size: 16px; cursor: pointer; padding: 0; }
.box-del:hover { background: #d5121c; }
.box-resize { position: absolute; right: -5px; bottom: -5px; width: 12px; height: 12px; background: #fff; border: 2px solid currentColor; cursor: nwse-resize; }
.box--esitel .box-resize { color: #d5121c; }
.box--client .box-resize { color: #2563eb; }
.page-client .box--client { animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 50% { background: rgb(37 99 235 / .24); } }

@media (max-width: 900px) {
  .doc-grid { grid-template-columns: 1fr; }
  .side { position: static; max-height: none; overflow: visible; }
}
@media (max-width: 640px) { .hide-sm { display: none; } }
@media (prefers-reduced-motion: reduce) { .page-client .box--client { animation: none; } }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.info { background: var(--client-soft); color: var(--client); }
.overlay .box .box-label { color: #fff; }
.side .link-btn { margin-top: 2px; }
/* themes.css paints text with html[data-estilo] :is(p, span, dd, li…) { color: inherit } (specificity 0,2,1): colour rules on
   those elements need the same prefix to win. */
html[data-estilo] .eyebrow { color: var(--accent); }
html[data-estilo] .status-msg[data-kind='error'], html[data-estilo] .login-error, html[data-estilo] .danger-link { color: var(--danger); }
html[data-estilo] .drop-file { color: var(--ok); }
html[data-estilo] .signers dd, html[data-estilo] .page-no, html[data-estilo] .note { color: var(--muted); }
html[data-estilo] .badge.ok { color: var(--ok); } html[data-estilo] .badge.warn { color: var(--warn); } html[data-estilo] .badge.info { color: var(--client); }

/* The inventory's `html, body { overflow-x: hidden }` turns body into the scroll container, which breaks the sticky
   side column on the document page. `clip` keeps the same visual result without creating a scroll container. */
html, body { overflow-x: clip; }

/* Accounts */
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; align-items: start; margin-bottom: 18px; }
.cols > .panel { margin: 0; }
.login-alt { text-align: center; margin: 14px 0 0; font-size: .88rem; }
.login-alt a { color: var(--muted); }
.login-alt a:hover { color: var(--accent); }
html[data-estilo] .ok-text { color: var(--ok); }
html[data-estilo] .status-msg[data-kind='ok'] { color: var(--ok); font-weight: 600; }
.danger-zone { border-top: 1px solid var(--border); padding-top: 14px; margin-top: 16px; }
.danger-zone .btn { width: auto; justify-self: start; }
.panel .stack .btn { justify-self: start; }
.side .panel .stack .btn { justify-self: stretch; }
html[data-estilo] .login-error[data-kind='ok'] { color: var(--ok); }
.login.msg.cert-step { max-width: 460px; text-align: left; }
.cert-step h1, .cert-step .login-lead { text-align: left; }
.cert-id { background: var(--surface-soft); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.cert-step form { margin: 14px 0 0; }
.cert-step .btn:not(.login-btn) { width: auto; }
.cert-tips { font-size: .9rem; margin: 10px 0 14px; }
.cert-banner { border-left: 4px solid var(--warn); margin-bottom: 16px; }
.cert-banner.is-expired { border-left-color: var(--danger); }
html[data-estilo] .hint[data-kind='ok'] { color: var(--ok); } html[data-estilo] .hint[data-kind='error'] { color: var(--danger); }
/* Nuevo documento: the five fields on one row on desktop; the inventory grid takes over below that width. */
@media (min-width: 1000px) {
  .form-grid.one-row { grid-template-columns: 1.5fr 1.3fr 1.5fr .9fr 1.4fr; }
}
.row-hint { margin: -4px 0 14px; }
/* Documents list filters and pager */
.doc-filters { margin: 0 0 12px; }
.doc-filters select { width: auto; flex: 0 1 220px; }
.pager .btn { text-decoration: none; min-width: 32px; text-align: center; }
.pager .is-off { opacity: .45; pointer-events: none; }
.pager .page-size { width: auto; }
.row-del { width: 44px; text-align: right; }
.icon-del { border: 0; background: none; color: var(--muted); padding: 6px; border-radius: var(--radius); cursor: pointer; line-height: 0; }
.icon-del svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-del:hover, .icon-del:focus-visible { color: var(--danger); background: var(--surface-soft); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (max-width: 640px) { .doc-filters select { flex: 1 1 calc(50% - 4px); } .doc-filters .btn { flex: 1 1 auto; } }
/* Configuración: tabs and the stamp editor */
.config-tabs { margin: 0 0 18px; }
.config-tabs a { background: var(--surface-hover); border: 1px solid transparent; border-bottom: 0; border-radius: 8px 8px 0 0; padding: 9px 14px; font-weight: 600; color: var(--muted); text-decoration: none; white-space: nowrap; }
.config-tabs a[aria-current='page'] { background: var(--surface); color: var(--text); border-color: var(--border); box-shadow: inset 0 3px 0 var(--accent); }
.stamp-grid { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 18px; align-items: start; }
.stamp-edit > .panel { margin-bottom: 14px; }
.stamp-kind-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.stamp-kind-head h2 { margin: 0; }
.stamp-kind textarea { width: 100%; font: .9rem/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; resize: vertical; margin-top: 6px; }
.stamp-vars { margin-top: 8px; }
.stamp-vars .chip { font: .78rem ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; cursor: pointer; }
.stamp-preview { position: sticky; top: 70px; }
.stamp-fig { margin: 0 0 16px; }
.stamp-fig figcaption { font-weight: 700; font-size: .85rem; margin-bottom: 6px; }
.stamp-box { background: #fff; border: 1px dashed var(--border); border-radius: var(--radius); aspect-ratio: 190 / 72; display: grid; place-items: center; overflow: hidden; transition: opacity .15s ease; }
.stamp-box img { width: 100%; height: 100%; object-fit: contain; display: block; }
.stamp-fig.is-loading .stamp-box { opacity: .55; }
.stamp-grid .actions { margin-bottom: 6px; }
.stamp-save { position: sticky; bottom: 0; z-index: 5; background: var(--bg, #f6f7f9); padding: 12px 0; border-top: 1px solid var(--border); }
.status-msg[data-kind='warn'] { color: var(--warn); font-weight: 600; }
@media (max-width: 1000px) { .stamp-grid { grid-template-columns: 1fr; } .stamp-preview { position: static; } }
.fallback { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.fallback h3 { margin: 0 0 6px; font-size: .95rem; }
.hint[data-kind='warn'], .method-warn { color: var(--warn); }
/* public verification page */
.verify { max-width: 680px; margin: 0 auto; display: grid; gap: 16px; padding: 8px 0 24px; }
.verify h1 { margin: 0 0 10px; font-size: 1.35rem; }
.v-state { display: inline-block; padding: 4px 12px; border-radius: 999px; font-weight: 700; font-size: .85rem; background: var(--surface-2, #f1f3f5); }
.v-state[data-kind='ok'] { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.v-state[data-kind='warn'] { color: var(--warn); background: var(--warn-bg); }
.v-data { display: grid; gap: 10px; margin: 18px 0 0; }
.v-row { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 12px; }
.v-row dt { color: var(--muted); font-size: .85rem; }
.v-row dd { margin: 0; font-weight: 600; }
.v-row .mono { font: .8rem ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; word-break: break-all; font-weight: 500; }
.v-signs { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 12px; }
.v-signs li { display: grid; gap: 2px; padding-left: 14px; border-left: 3px solid var(--ok); }
.v-file { cursor: pointer; }
.v-result { margin: 12px 0 0; font-weight: 600; word-break: break-word; }
.v-result[data-kind='ok'] { color: var(--ok); } .v-result[data-kind='warn'] { color: var(--warn); } .v-result[data-kind='error'] { color: var(--danger); }
.v-foot { text-align: center; }
@media (max-width: 560px) { .v-row { grid-template-columns: 1fr; gap: 2px; } }
.v-sub { display: block; font: .78rem/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; margin-top: 2px; }
.sign-places { margin: 0 0 14px; padding: 12px 14px; border-radius: var(--radius, 8px); background: var(--accent-soft, #fdebec); }
.sign-places p { margin: 0; }
.sign-places ol { margin: 6px 0 6px; padding-left: 20px; display: grid; gap: 2px; }
.sign-places .hint { margin-top: 2px; }

/* ---------- Telefonía ---------- */
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.panel h2.mt { margin-top: 26px; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.danger { background: var(--danger-bg); color: var(--danger); }
tr.is-off td { opacity: .6; }
.notice { margin: 10px 0 0; }
.panel.attn { border-color: var(--warn); }
.assign { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.assign select { width: auto; min-width: 200px; }
.actions-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.actions-bar .status-msg { flex-basis: 100%; margin: 0; }
.file-btn { position: relative; overflow: hidden; cursor: pointer; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop-files:empty { display: none; }
.drop-files { color: var(--text); font-weight: 600; }

/* Invoice cards */
.inv-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.inv-head h2 { margin: 0 0 2px; font-size: 1.15rem; }
.inv-head h2 a { color: var(--text); text-decoration: none; }
.inv-head h2 a:hover { color: var(--accent); }
.inv-head .note { margin: 0; }
.inv-total { display: grid; justify-items: end; }
.inv-total b { font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.inv.is-skip { opacity: .7; }
.inv.is-skip .inv-total b { text-decoration: line-through; }
.inv-controls { display: grid; gap: 0 14px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); margin: 14px 0 4px; }
.inv-controls .field { margin-bottom: 8px; }
.inv-controls.is-busy, .inv.is-busy { opacity: .6; pointer-events: none; }
.inv-table { margin-top: 6px; }
.inv-table tfoot td { border-bottom: 0; padding-top: 4px; padding-bottom: 4px; text-align: right; }
.inv-table tfoot td.num { width: 1%; }
.inv-table tfoot tr.total td { font-weight: 800; font-size: 1.05rem; border-top: 1px solid var(--border); }
.inv-table tr.warn-row td { color: var(--warn); }
.inv .actions { margin-top: 10px; }

/* Client form */
.client-cols { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.client-cols > div > .panel:last-child { margin-bottom: 0; }
.field.wide { grid-column: 1 / -1; }
.estimate { position: sticky; top: 76px; margin: 0; }
.estimate table { margin: 6px 0; }
.estimate .big { font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; margin: 4px 0 0; }
.numbers { margin-bottom: 8px; }
.numbers td { padding: 4px 6px 4px 0; vertical-align: middle; }
.numbers th { padding-left: 0; }
.numbers td:last-child { width: 1%; }
.numbers input { min-width: 0; }
.ibtn { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 1rem; padding: 6px 8px; border-radius: 6px; }
.ibtn:hover { background: var(--danger-bg); color: var(--danger); }
.client-form:not(.per-number) .per-number, .client-form:not(.per-number) .per-number-note { display: none; }
.client-form.per-number .joint-only { display: none; }
.check { display: inline-flex; gap: 8px; align-items: center; font-weight: 600; margin-left: auto; }
.check input { width: auto; }
.tariff-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
h3 { font-size: .95rem; margin: 18px 0 4px; }
@media (max-width: 900px) {
  .client-cols { grid-template-columns: 1fr; }
  .estimate { position: static; }
  .numbers thead { display: none; }
  .numbers tr { display: grid; grid-template-columns: 1fr 1fr auto; gap: 4px; padding: 6px 0; border-bottom: 1px solid var(--border); }
  .numbers td { padding: 0; border: 0; }
}
.numbers:has(tbody:empty) { display: none; }
.csv-files td { vertical-align: middle; }
.csv-files tbody tr, .inv-table tbody tr, .numbers tbody tr { cursor: default; }
