/* =========================================================
   NOVASOFT · Acceso y panel de facturación · v13
   Tema oscuro (predeterminado) y tema claro, con los colores de la web.
   La factura se muestra siempre como papel blanco y se imprime igual.
   ========================================================= */

@font-face { font-family: 'Sora'; src: url('/assets/fonts/sora.woff2') format('woff2'); font-weight: 100 800; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('/assets/fonts/inter.woff2') format('woff2'); font-weight: 100 900; font-display: swap; }
@font-face { font-family: 'JetBrains Mono'; src: url('/assets/fonts/jetbrains-mono.woff2') format('woff2'); font-weight: 100 800; font-display: swap; }
@property --angle { syntax: '<angle>'; inherits: false; initial-value: 0deg; }

:root {
  --radius: 18px;
  --ease: cubic-bezier(.16, 1, .3, 1);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --display: 'Sora', 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-family: var(--font);
  font-size: 16px;
  color: var(--text);
  -webkit-text-size-adjust: 100%;
}
/* Tema oscuro (predeterminado): los mismos colores que la web */
:root {
  color-scheme: dark;
  --bg: #060a15;
  --bg-1: #0b1121;
  --surface: #0f1729;
  --surface-2: #141e33;
  --bg-rgb: 6 10 21;
  --fg-rgb: 255 255 255;
  --line-rgb: 160 205 245;
  --line: rgb(var(--line-rgb) / .1);
  --line-2: rgb(var(--line-rgb) / .17);
  --line-3: rgb(var(--line-rgb) / .29);
  --text: #f2f6fb;
  --text-2: #bdc9d7;
  --text-3: #8e9eb2;
  --muted: #8e9eb2;
  --turq: #14d6e6;
  --turq-2: #62f1f9;
  --petrol: #0a8796;
  --orange: #ff9a2e;
  --orange-2: #ff6c12;
  --orange-ink: #1c1206;
  --blue: #9cc2ff;
  --coral: #ff8a80;
  --late: #ffb46b;
  --turq-rgb: 20 214 230;
  --turq2-rgb: 98 241 249;
  --orange-rgb: 255 154 46;
  --blue-rgb: 52 128 255;
  --shadow-rgb: 0 0 0;
  --shadow-k: 1;
  --surface-rgb: 16 24 40;
  --card-hi-rgb: 20 30 50;
  --card-lo-rgb: 10 15 27;
  --side-rgb: 9 14 25;
  --dialog-1: #111a2b;
  --dialog-2: #0b111d;
  --preview-bg: #070b14;
  --field: rgb(4 7 14 / .55);
  --field-focus: rgb(4 7 14 / .8);
  --placeholder: #7f90a6;
  --link-hover: #a4f6fb;
  --error-text: #ffc2bc;
  --toast-bg: rgb(12 30 40 / .96);
  --toast-danger-bg: rgb(48 20 20 / .96);
}
/* Tema claro */
:root[data-theme="claro"] {
  color-scheme: light;
  --bg: #f3f6fb;
  --bg-1: #ffffff;
  --surface: #ffffff;
  --surface-2: #f4f7fb;
  --bg-rgb: 243 246 251;
  --fg-rgb: 14 36 68;
  --line-rgb: 18 48 88;
  --line: rgb(var(--line-rgb) / .11);
  --line-2: rgb(var(--line-rgb) / .18);
  --line-3: rgb(var(--line-rgb) / .3);
  --text: #09121f;
  --text-2: #37475c;
  --text-3: #53637a;
  --muted: #53637a;
  --turq: #06b6cc;
  --turq-2: #06707f;
  --petrol: #08788a;
  --orange: #c2410c;
  --orange-2: #f26a0c;
  --blue: #2c5fb3;
  --coral: #c0392b;
  --late: #b0520c;
  --turq-rgb: 6 182 204;
  --turq2-rgb: 0 150 176;
  --orange-rgb: 247 120 22;
  --blue-rgb: 37 99 235;
  --shadow-rgb: 16 36 66;
  --shadow-k: .3;
  --surface-rgb: 255 255 255;
  --card-hi-rgb: 255 255 255;
  --card-lo-rgb: 250 252 255;
  --side-rgb: 255 255 255;
  --dialog-1: #ffffff;
  --dialog-2: #f6f9fc;
  --preview-bg: #e9eff6;
  --field: #ffffff;
  --field-focus: #ffffff;
  --placeholder: #6b7a8e;
  --link-hover: #045e6c;
  --error-text: #a3261b;
  --toast-bg: rgb(255 255 255 / .97);
  --toast-danger-bg: rgb(255 240 238 / .98);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; min-height: 100vh; min-height: 100dvh; background: transparent; color: var(--text); line-height: 1.5; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body::before { content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none; background: radial-gradient(900px 620px at -8% -12%, rgb(var(--turq-rgb) / .12), transparent 62%), radial-gradient(760px 560px at 108% 112%, rgb(var(--orange-rgb) / .07), transparent 60%), radial-gradient(700px 500px at 70% -20%, rgb(var(--blue-rgb) / .08), transparent 60%); }
a { color: var(--turq-2); text-decoration: none; }
a:hover { color: var(--link-hover); }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .6; }
:focus-visible { outline: 2px solid var(--turq); outline-offset: 3px; }
:focus:not(:focus-visible) { outline: none; }
h1, h2, h3 { font-family: var(--display); color: var(--text); margin: 0; }
h1 { font-size: clamp(30px, 3.4vw, 40px); font-weight: 700; letter-spacing: -.035em; line-height: 1.08; margin: 0 0 8px; }
h2 { font-size: 21px; font-weight: 650; letter-spacing: -.02em; line-height: 1.25; margin: 0 0 18px; }
h3 { font-size: 16px; font-weight: 650; letter-spacing: -.01em; margin: 0 0 14px; }
p { line-height: 1.6; }
small, .muted { color: var(--text-3); }
strong { font-weight: 650; }
[hidden] { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 1em; height: 1em; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.eyebrow { display: inline-flex; align-items: center; gap: 10px; margin: 0 0 12px; font-family: var(--mono); font-size: 11.5px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--turq-2); }
.eyebrow::before { content: ""; width: 22px; height: 1px; background: linear-gradient(90deg, var(--orange), rgb(var(--orange-rgb) / 0)); }
.small-text { font-size: 14px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
p a, .field-note a { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgb(var(--turq2-rgb) / .45); }

/* ---------- Botones y enlaces ---------- */
.button { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 18px; border-radius: 12px; border: 1px solid var(--line-2); background: rgb(var(--fg-rgb) / .04); color: var(--text); font-size: 14.5px; font-weight: 600; line-height: 1.2; white-space: nowrap; text-decoration: none; transition: background .2s, border-color .2s, transform .2s var(--ease), box-shadow .2s, filter .2s; }
.button:hover { background: rgb(var(--fg-rgb) / .08); border-color: var(--line-3); color: var(--text); }
.button:active { transform: translateY(1px); }
.button .icon { width: 18px; height: 18px; }
.button.primary, .primary { background: linear-gradient(180deg, #ffb45a, #ff9433); border-color: transparent; color: var(--orange-ink); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .45), 0 10px 26px -12px rgba(255, 140, 40, .85); }
.button.primary:hover { color: var(--orange-ink); background: linear-gradient(180deg, #ffbd6a, #ff9d40); transform: translateY(-1px); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .5), 0 16px 32px -12px rgba(255, 140, 40, .9); }
.button.green, .green { background: linear-gradient(180deg, #37d3de, #16b3c1); border-color: transparent; color: #04171b; }
.button.small, .small.button { min-height: 36px; padding: 7px 12px; border-radius: 10px; font-size: 13.5px; }
.button.small .icon { width: 16px; height: 16px; }
.button.block { width: 100%; }
.button.ghost { background: transparent; }
.danger { color: var(--coral) !important; }
.light-link { display: inline-flex; align-items: center; gap: 6px; padding: 6px 2px; border: 0; background: none; color: var(--turq-2); font-size: 14px; font-weight: 500; text-decoration: underline; text-decoration-color: rgb(var(--turq2-rgb) / .38); text-underline-offset: 4px; }
.light-link:hover { color: var(--link-hover); text-decoration-color: currentColor; }
.light-link.danger { text-decoration-color: rgba(255, 138, 128, .4); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* ---------- Formularios ---------- */
label { display: block; font-size: 13px; font-weight: 600; letter-spacing: .01em; color: var(--text-2); }
input, textarea, select { display: block; width: 100%; min-height: 46px; margin-top: 8px; padding: 11px 14px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--field); color: var(--text); font-size: 16px; font-weight: 400; line-height: 1.4; transition: border-color .2s, box-shadow .2s, background .2s; }
textarea { resize: vertical; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--placeholder); opacity: 1; }
input:hover, textarea:hover, select:hover { border-color: var(--line-3); }
input:focus, textarea:focus, select:focus { outline: none; border-color: rgb(var(--turq-rgb) / .75); box-shadow: 0 0 0 4px rgb(var(--turq-rgb) / .16); background: var(--field-focus); }
input[readonly] { color: var(--text-2); background: rgb(var(--fg-rgb) / .025); cursor: default; }
input[readonly]:focus { box-shadow: none; border-color: var(--line-3); }
select { appearance: none; -webkit-appearance: none; padding-right: 42px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238c98a6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; background-size: 16px; cursor: pointer; }
select option, select optgroup { background: var(--surface); color: var(--text); }
input[type=date] { min-height: 46px; }
input[type=date]::-webkit-calendar-picker-indicator { filter: invert(.8) sepia(1) hue-rotate(140deg) saturate(3); opacity: .8; cursor: pointer; }
input[type=number] { font-variant-numeric: tabular-nums; }
input[type=search]::-webkit-search-cancel-button { filter: invert(.7); }
.field, .search { position: relative; display: block; margin-top: 8px; }
.field input, .search input { margin-top: 0; padding-left: 44px; }
.field > .icon, .search > .icon { position: absolute; left: 15px; top: 50%; width: 18px; height: 18px; translate: 0 -50%; color: var(--text-3); pointer-events: none; transition: color .2s; }
.field > .field-end { left: auto; right: 15px; width: 16px; height: 16px; opacity: .7; }
.field:focus-within > .icon:first-child, .search:focus-within > .icon { color: var(--turq-2); }
.search { margin-top: 0; flex: 1; max-width: 440px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid3 { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
.stack { display: grid; gap: 20px; }
.field-note { display: block; margin: 6px 0 0; font-size: 12.5px; font-weight: 400; line-height: 1.55; color: var(--text-3); }
fieldset { min-width: 0; }

/* ---------- Tarjetas, avisos y estados ---------- */
.card { position: relative; border-radius: var(--radius); padding: 24px; background: linear-gradient(180deg, rgb(var(--card-hi-rgb) / .72), rgb(var(--card-lo-rgb) / .8)); border: 1px solid var(--line); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .04), 0 24px 60px -36px rgb(var(--shadow-rgb) / calc(.9 * var(--shadow-k))); }
.notice { margin: 0; padding: 13px 16px; border-radius: 12px; border: 1px solid rgb(var(--turq-rgb) / .22); background: rgb(var(--turq-rgb) / .07); color: var(--text-2); font-size: 14px; line-height: 1.6; }
.notice.error, .error { border-color: rgba(255, 107, 95, .3); background: rgba(255, 107, 95, .08); color: var(--error-text); }
.notice.loading { position: relative; overflow: hidden; }
.notice.loading:not(.error)::after { content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 30%, rgb(var(--fg-rgb) / .07) 50%, transparent 70%); background-size: 220% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { from { background-position: 120% 0; } to { background-position: -120% 0; } }
.status { min-height: 20px; margin: 0; font-size: 14px; line-height: 1.5; color: var(--text-2); }
.status:empty { min-height: 0; }
.badge { display: inline-flex; align-items: center; gap: 7px; margin: 0; padding: 4px 10px 4px 9px; border-radius: 999px; border: 1px solid rgb(var(--fg-rgb) / .1); background: rgb(var(--fg-rgb) / .05); color: var(--text-2); font-size: 12px; font-weight: 600; line-height: 1.4; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; box-shadow: 0 0 8px currentColor; }
.badge.issued { color: var(--blue); background: rgba(120, 170, 255, .1); border-color: rgba(120, 170, 255, .24); }
.badge.late { color: var(--late); background: rgb(var(--orange-rgb) / .1); border-color: rgb(var(--orange-rgb) / .26); }
.badge.paid { color: var(--turq-2); background: rgb(var(--turq-rgb) / .1); border-color: rgb(var(--turq-rgb) / .28); }
.badge.void { color: var(--coral); background: rgba(255, 107, 95, .09); border-color: rgba(255, 107, 95, .24); }
.empty { padding: 52px 20px 56px; text-align: center; }
.empty h2, .empty h3 { margin: 18px 0 8px; }
.empty p { max-width: 420px; margin: 0 auto 22px; color: var(--text-3); }
.empty-icon { display: grid; place-items: center; width: 64px; height: 64px; margin: 0 auto; border-radius: 20px; font-size: 28px; color: var(--turq-2); background: radial-gradient(circle at 50% 30%, rgb(var(--turq-rgb) / .26), rgb(var(--turq-rgb) / .05)); border: 1px solid rgb(var(--turq-rgb) / .26); box-shadow: 0 0 44px -10px rgb(var(--turq-rgb) / .55); }
#toast { position: fixed; left: 50%; bottom: 28px; z-index: 60; display: flex; align-items: center; gap: 12px; max-width: min(92vw, 520px); padding: 13px 18px 13px 16px; border-radius: 14px; border: 1px solid var(--line-2); background: rgb(var(--surface-rgb) / .95); color: var(--text); font-size: 14px; line-height: 1.45; box-shadow: 0 24px 60px -24px rgb(var(--shadow-rgb) / calc(.95 * var(--shadow-k))); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); translate: -50% 0; animation: toastIn .4s var(--ease); }
#toast::before { content: ""; width: 8px; height: 8px; flex-shrink: 0; border-radius: 50%; background: var(--turq); box-shadow: 0 0 12px var(--turq); }
@keyframes toastIn { from { opacity: 0; translate: -50% 14px; } }

/* =========================================================
   Acceso administrativo
   ========================================================= */
.auth-page { overflow-x: hidden; }
.auth-page::before { display: none; }
.auth-sky { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.auth-sky .glow { position: absolute; border-radius: 50%; }
.auth-sky .g1 { width: 1000px; height: 1000px; left: -380px; top: -460px; background: radial-gradient(closest-side, rgb(var(--turq-rgb) / .22), rgb(var(--turq-rgb) / 0)); animation: drift 26s ease-in-out infinite alternate; }
.auth-sky .g2 { width: 820px; height: 820px; right: -300px; bottom: -420px; background: radial-gradient(closest-side, rgb(var(--orange-rgb) / .14), rgb(var(--orange-rgb) / 0)); animation: drift 32s ease-in-out infinite alternate-reverse; }
.auth-sky .grid { position: absolute; inset: 0; background-image: linear-gradient(rgb(var(--line-rgb) / .045) 1px, transparent 1px), linear-gradient(90deg, rgb(var(--line-rgb) / .045) 1px, transparent 1px); background-size: 56px 56px; -webkit-mask-image: radial-gradient(ellipse 70% 60% at 28% 30%, #000 20%, transparent 75%); mask-image: radial-gradient(ellipse 70% 60% at 28% 30%, #000 20%, transparent 75%); }
@keyframes drift { to { translate: 80px 60px; } }
.auth { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 452px); grid-template-areas: "hero card" "back card"; align-items: center; column-gap: clamp(40px, 7vw, 110px); max-width: 1180px; min-height: 100vh; min-height: 100dvh; margin: 0 auto; padding: 40px clamp(20px, 5vw, 56px); }
.auth-hero { grid-area: hero; align-self: end; animation: rise .9s var(--ease) backwards; }
.auth-logo { display: inline-block; }
.auth-logo img { display: block; width: 172px; height: auto; }
.orbit { display: block; width: min(320px, 70%); height: auto; margin: 22px 0 6px -18px; overflow: visible; }
.orbit .orbit-halo { transform-origin: 200px 200px; animation: halo 6s ease-in-out infinite alternate; }
.orbit .still { display: none; }
@keyframes halo { from { opacity: .7; } to { opacity: 1; } }
.auth-hero h1 { margin: 0 0 14px; font-size: clamp(40px, 4.6vw, 60px); letter-spacing: -.045em; line-height: 1.02; }
.grad { white-space: nowrap; background: linear-gradient(100deg, #b8f3f7, #6ee3ec 35%, #1cc6d3 70%, #12aebf); -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-fill-color: transparent; }
.grad .dot { color: var(--orange); -webkit-text-fill-color: var(--orange); }
.auth-hero .lead { max-width: 440px; margin: 0; font-size: 17px; color: var(--text-2); }
.auth-points { display: grid; gap: 12px; margin: 30px 0 0; padding: 0; list-style: none; }
.auth-points li { display: flex; align-items: center; gap: 14px; font-size: 15px; color: var(--text-2); }
.auth-points .ico { display: grid; place-items: center; width: 38px; height: 38px; flex-shrink: 0; border-radius: 12px; color: var(--turq-2); background: rgb(var(--turq-rgb) / .08); border: 1px solid rgb(var(--turq-rgb) / .2); }
.auth-points .icon { width: 19px; height: 19px; }
.auth-card { grid-area: card; position: relative; padding: 32px; border-radius: 26px; background: linear-gradient(180deg, rgb(var(--card-hi-rgb) / .84), rgb(var(--card-lo-rgb) / .88)); border: 1px solid var(--line-2); box-shadow: 0 50px 110px -45px rgb(var(--shadow-rgb) / calc(.95 * var(--shadow-k))), inset 0 1px 0 rgba(255, 255, 255, .06); -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px); animation: rise .9s .12s var(--ease) backwards; }
.auth-card::before { content: ""; position: absolute; inset: -1px; border-radius: inherit; padding: 1px; pointer-events: none; background: conic-gradient(from var(--angle), rgb(var(--turq2-rgb) / 0) 0deg, rgb(var(--turq2-rgb) / .75) 60deg, rgb(var(--turq2-rgb) / 0) 130deg, rgb(var(--orange-rgb) / 0) 190deg, rgb(var(--orange-rgb) / .7) 250deg, rgb(var(--orange-rgb) / 0) 320deg); -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; animation: spinBorder 12s linear infinite; }
@keyframes spinBorder { to { --angle: 360deg; } }
@keyframes rise { from { opacity: 0; translate: 0 18px; } }
.auth-card-head { display: flex; align-items: center; gap: 14px; margin-bottom: 4px; }
.auth-card-head h2 { margin: 0; font-size: 22px; }
.auth-card-head p { margin: 2px 0 0; font-size: 14px; }
.auth-badge { display: grid; place-items: center; width: 46px; height: 46px; flex-shrink: 0; border-radius: 14px; color: var(--turq-2); background: radial-gradient(circle at 50% 20%, rgb(var(--turq-rgb) / .3), rgb(var(--turq-rgb) / .06)); border: 1px solid rgb(var(--turq-rgb) / .3); box-shadow: 0 0 30px -8px rgb(var(--turq-rgb) / .55); }
.auth-badge .icon { width: 22px; height: 22px; }
#recovery { display: grid; gap: 18px; }
#recovery .muted { margin: 0; font-size: 14.5px; }
#recovery strong { color: var(--text); }
#flow-title { outline: none; }
.field-help { margin-top: -10px; }
.otp { font-family: var(--mono); font-size: 22px; letter-spacing: .38em; text-align: center; }
.otp::placeholder { font-family: var(--font); font-size: 15px; letter-spacing: 0; }
#reset-password .light-link { justify-self: center; }
.back-link { justify-self: start; text-decoration: none; }
.access-links { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 4px 20px; padding-top: 10px; border-top: 1px solid var(--line); }
.access-links a { display: inline-flex; align-items: center; min-height: 44px; font-size: 14px; font-weight: 500; text-decoration: underline; text-decoration-color: rgb(var(--turq2-rgb) / .35); text-underline-offset: 4px; }
.access-links a:hover { text-decoration-color: currentColor; }
#access-status:not(:empty) { margin-top: 18px; padding: 12px 14px; border-radius: 12px; border: 1px solid rgb(var(--turq-rgb) / .24); background: rgb(var(--turq-rgb) / .07); color: var(--text); }
#access-status.danger:not(:empty) { color: var(--error-text) !important; border-color: rgba(255, 107, 95, .32); background: rgba(255, 107, 95, .09); }
.auth-note { display: flex; gap: 10px; margin: 20px 0 0; padding-top: 18px; border-top: 1px solid var(--line); font-size: 12.5px; line-height: 1.55; color: var(--text-3); }
.auth-note .icon { width: 15px; height: 15px; margin-top: 2px; color: var(--turq-2); }
.auth-back { grid-area: back; align-self: start; justify-self: start; display: inline-flex; align-items: center; gap: 8px; margin-top: 30px; padding: 8px 0; font-size: 14px; font-weight: 500; color: var(--text-2); }
.auth-back:hover { color: var(--text); }
.auth-back .icon { width: 16px; height: 16px; }

/* Página de error de un enlace de factura (la genera el servidor) */
.access { max-width: 520px; margin: 14vh auto; padding: 36px; text-align: left; }
.access h1 { font-size: 28px; margin: 0 0 10px; }
.access p { color: var(--text-2); }

/* =========================================================
   Panel
   ========================================================= */
.app-page { --side-w: 256px; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 30; display: flex; flex-direction: column; width: var(--side-w); padding: 26px 18px 22px; border-right: 1px solid var(--line); background: linear-gradient(180deg, rgb(var(--side-rgb) / .92), rgb(var(--bg-rgb) / .92)); -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px); }
.brand { display: inline-block; }
.brand img { display: block; width: 158px; height: auto; }
.sidebar .brand { margin: 0 0 34px 8px; }
.side-label { margin: 0 0 10px 12px; font-family: var(--mono); font-size: 10.5px; font-weight: 600; letter-spacing: .18em; text-transform: uppercase; color: var(--text-3); }
.tabs { display: grid; gap: 4px; }
.tabs button { position: relative; display: flex; align-items: center; gap: 12px; width: 100%; min-height: 46px; padding: 10px 14px; border: 1px solid transparent; border-radius: 12px; background: none; color: var(--text-2); font-size: 14.5px; font-weight: 550; text-align: left; transition: background .2s, color .2s, border-color .2s; }
.tabs button .icon { width: 20px; height: 20px; color: var(--text-3); transition: color .2s; }
.tabs button:hover { background: rgb(var(--fg-rgb) / .04); color: var(--text); }
.tabs button[aria-selected=true] { color: var(--text); background: linear-gradient(90deg, rgb(var(--turq-rgb) / .14), rgb(var(--turq-rgb) / .03)); border-color: rgb(var(--turq-rgb) / .18); }
.tabs button[aria-selected=true] .icon { color: var(--turq-2); }
.tabs button[aria-selected=true]::before { content: ""; position: absolute; left: -18px; top: 11px; bottom: 11px; width: 3px; border-radius: 0 3px 3px 0; background: var(--turq); box-shadow: 0 0 14px var(--turq); }
.tab-short { display: none; }
.side-foot { margin-top: auto; padding: 16px 12px 0; border-top: 1px solid var(--line); }
.side-link { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; color: var(--text-2); }
.side-link .icon { width: 16px; height: 16px; }
.side-note { margin: 10px 0 0; font-size: 12px; color: var(--text-3); }
.app-main { min-height: 100vh; min-height: 100dvh; margin-left: var(--side-w); }
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 66px; padding: 12px 40px; border-bottom: 1px solid var(--line); background: rgb(var(--bg-rgb) / .72); -webkit-backdrop-filter: blur(18px) saturate(1.3); backdrop-filter: blur(18px) saturate(1.3); }
.brand-mobile { display: none; }
.top-crumb { margin: 0; font-size: 13.5px; color: var(--text-3); }
.top-crumb strong { color: var(--text); font-weight: 600; }
.top-right { display: flex; align-items: center; gap: 16px; font-size: 14px; }
.user { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar { display: grid; place-items: center; width: 36px; height: 36px; flex-shrink: 0; border-radius: 12px; font-family: var(--display); font-size: 13px; font-weight: 700; color: #04171b; background: linear-gradient(135deg, #6ee3ec, #12aebf); box-shadow: 0 6px 18px -8px rgb(var(--turq-rgb) / .8); }
.email { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.signout { color: var(--text-2); }
.control-link { color: var(--text-2); text-decoration: none; }
.layout { max-width: 1240px; margin: 0 auto; padding: 34px 40px 80px; }
.page-title { display: flex; gap: 20px; justify-content: space-between; align-items: flex-end; margin-bottom: 28px; }
.page-title > div { min-width: 0; }
.page-title p { margin: 0; color: var(--text-3); }
.page-title h2 { margin: 0 0 6px; }
#load-status { margin-bottom: 24px; }
/* En Clientes, Servicios y Empresa queda una sola acción principal */
.layout:has(#documents-tab[hidden]) #new-document { display: none; }
#load-status .button { margin-left: 12px; }

/* Resumen */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-bottom: 22px; }
.stat { --accent: var(--late); --tile: rgb(var(--orange-rgb) / .1); --tile-line: rgb(var(--orange-rgb) / .24); --glow: rgb(var(--orange-rgb) / .12); position: relative; overflow: hidden; min-height: 132px; padding: 22px 24px; border-radius: var(--radius); border: 1px solid var(--line); background: radial-gradient(260px 160px at 100% 0%, var(--glow), transparent 70%), linear-gradient(180deg, rgb(var(--card-hi-rgb) / .72), rgb(var(--card-lo-rgb) / .8)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .04); animation: rise .7s var(--ease) backwards; }
.stat:nth-child(2) { --accent: var(--turq-2); --tile: rgb(var(--turq-rgb) / .1); --tile-line: rgb(var(--turq-rgb) / .26); --glow: rgb(var(--turq-rgb) / .12); animation-delay: .06s; }
.stat:nth-child(3) { --accent: var(--blue); --tile: rgba(120, 170, 255, .1); --tile-line: rgba(120, 170, 255, .24); --glow: rgba(120, 170, 255, .1); animation-delay: .12s; }
.stat::after { content: ""; position: absolute; top: 20px; right: 20px; width: 40px; height: 40px; border-radius: 12px; background: var(--tile); border: 1px solid var(--tile-line); }
.stat::before { content: ""; position: absolute; z-index: 1; top: 30px; right: 30px; width: 20px; height: 20px; background: var(--accent); -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat; }
.stat:nth-child(1) { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='8.5'/%3E%3Cpath d='M12 7.5V12l3 2'/%3E%3C/svg%3E"); }
.stat:nth-child(2) { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 7.6A2.6 2.6 0 0 1 6.6 5H17v3'/%3E%3Crect x='4' y='8' width='16.5' height='11.5' rx='2.5'/%3E%3Cpath d='M16.3 13.8h.01'/%3E%3C/svg%3E"); }
.stat:nth-child(3) { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6.5 3.5h7.5l4 4v13h-11.5Z'/%3E%3Cpath d='M14 3.5v4h4M9.3 12h5.8M9.3 15.6h5.8'/%3E%3C/svg%3E"); }
.stat span:not(.currency-summary) { display: block; padding-right: 52px; font-size: 13.5px; font-weight: 500; color: var(--text-2); }
.stat strong { display: block; margin: 14px 0 0; font-family: var(--display); font-size: 28px; font-weight: 650; letter-spacing: -.03em; line-height: 1.15; color: var(--text); }
.currency-summary { display: block; font-size: 21px; line-height: 1.3; }
.currency-summary + .currency-summary { margin-top: 2px; font-size: 16px; font-weight: 550; color: var(--text-2); }

/* Documentos */
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px 20px; margin-bottom: 18px; }
.card-head h2 { margin: 0; }
.toolbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.card-head .toolbar { flex: 1; justify-content: flex-end; margin: 0; }
.toolbar select { width: auto; min-width: 200px; margin-top: 0; }
.toolbar input { margin-top: 0; }
.table-wrap { overflow-x: auto; margin: 0 -8px; padding: 0 8px; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th { padding: 12px 12px; font-family: var(--mono); font-size: 10.5px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--text-3); border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 16px 12px; font-size: 14px; color: var(--text-2); border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr { transition: background .2s; }
tbody tr:hover { background: rgb(var(--fg-rgb) / .025); }
tbody tr:last-child td { border-bottom: 0; }
td strong { display: block; margin-bottom: 3px; color: var(--text); font-weight: 600; }
td small { display: block; font-size: 12px; color: var(--text-3); }
.right { text-align: right; }
#documents td:first-child strong { font-family: var(--mono); font-size: 12.5px; font-weight: 600; letter-spacing: .02em; color: var(--turq-2); }
#documents td:first-child { color: var(--text); font-weight: 500; }
#documents td:nth-child(3) { font-family: var(--mono); font-size: 12.5px; white-space: nowrap; }
#documents td:nth-child(5) strong { font-size: 15px; font-variant-numeric: tabular-nums; }
#documents td:last-child { width: 1%; text-align: right; }
#documents tr:has(.badge.void) td:nth-child(5) strong { color: var(--text-3); text-decoration: line-through; text-decoration-color: rgba(255, 138, 128, .5); }
footer { margin-top: 22px; font-size: 12.5px; color: var(--text-3); }

/* Clientes */
.client-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.client-card:last-child { border-bottom: 0; }
.client-card > div { position: relative; min-width: 0; padding-left: 58px; }
.client-card > div::before { content: ""; position: absolute; left: 0; top: 50%; width: 42px; height: 42px; translate: 0 -50%; border-radius: 14px; background: linear-gradient(135deg, rgb(var(--turq-rgb) / .22), rgba(10, 135, 150, .08)); border: 1px solid rgb(var(--turq-rgb) / .26); }
.client-card > div::after { content: ""; position: absolute; left: 11px; top: 50%; width: 20px; height: 20px; translate: 0 -50%; background: var(--turq-2); -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4.5 20.5v-15l8-2v17M12.5 8.5h7v12'/%3E%3Cpath d='M3 20.5h18M7.5 8.5h2M7.5 12h2M7.5 15.5h2M15.5 12h1.5M15.5 15.5h1.5'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4.5 20.5v-15l8-2v17M12.5 8.5h7v12'/%3E%3Cpath d='M3 20.5h18M7.5 8.5h2M7.5 12h2M7.5 15.5h2M15.5 12h1.5M15.5 15.5h1.5'/%3E%3C/svg%3E") center / contain no-repeat; }
.client-card strong { font-size: 15px; color: var(--text); }
.client-card p { margin: 3px 0 0; font-size: 13.5px; color: var(--text-3); overflow-wrap: break-word; }

/* Datos de empresa y cuentas */
.settings { max-width: 920px; }
.settings h2 { margin: 0 0 4px; }
.settings > div > .muted { margin: 0; font-size: 14px; }
.bank-settings { padding-top: 22px; border-top: 1px solid var(--line); }
.bank-settings h3 { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.bank-settings h3 .icon { width: 20px; height: 20px; color: var(--turq-2); }
.bank-settings > .field-note { margin: 0 0 16px; }
.bank-settings #add-bank { margin-top: 14px; }
.bank-settings #banks-empty { margin: 0; font-size: 14px; }
.bank-fields { position: relative; margin: 0; padding: 18px 18px 14px; border: 1px solid var(--line); border-radius: 14px; background: rgb(var(--fg-rgb) / .02); overflow: hidden; }
.bank-fields::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: linear-gradient(90deg, var(--turq), rgb(var(--turq-rgb) / 0)); }
.bank-fields legend { float: left; width: 100%; margin: 0 0 14px; padding: 0; font-family: var(--mono); font-size: 11px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--turq-2); }
.bank-fields legend + * { clear: both; }
.bank-fields .remove-bank { margin-top: 10px; font-size: 13px; }

/* =========================================================
   Diálogos
   ========================================================= */
dialog { width: 600px; max-width: calc(100vw - 28px); max-height: 90vh; max-height: 90dvh; padding: 0; border: 1px solid var(--line-2); border-radius: 22px; background: linear-gradient(180deg, var(--dialog-1), var(--dialog-2)); color: var(--text); box-shadow: 0 50px 120px -30px rgb(var(--shadow-rgb) / calc(.95 * var(--shadow-k))), inset 0 1px 0 rgba(255, 255, 255, .05); }
dialog[open] { animation: dialogIn .38s var(--ease); }
dialog::backdrop { background: rgba(4, 6, 9, .72); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
dialog[open]::backdrop { animation: fadeIn .3s ease; }
@keyframes dialogIn { from { opacity: 0; translate: 0 18px; scale: .985; } }
@keyframes fadeIn { from { opacity: 0; } }
dialog.wide { width: 1140px; }
.dialog-head { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px 26px; border-bottom: 1px solid var(--line); background: var(--dialog-1); }
.dialog-head h2 { margin: 0; font-size: 19px; }
#preview-title { font-family: var(--mono); font-size: 16px; letter-spacing: .02em; color: var(--turq-2); }
.dialog-body { padding: 24px 26px 28px; }
.dialog-body > p:first-child { margin-top: 0; }
.close { display: grid; place-items: center; width: 38px; height: 38px; flex-shrink: 0; border: 1px solid var(--line-2); border-radius: 12px; background: rgb(var(--fg-rgb) / .04); color: var(--text-2); font-size: 22px; line-height: 1; transition: background .2s, color .2s; }
.close:hover { background: rgb(var(--fg-rgb) / .09); color: var(--text); }
.editor-layout { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(280px, .8fr); gap: 28px; }
.editor-layout h3 { margin-bottom: 12px; }
.editor-summary { position: sticky; top: 90px; align-self: start; padding: 22px; border-radius: 18px; border: 1px solid var(--line); background: radial-gradient(300px 200px at 100% 0%, rgb(var(--turq-rgb) / .1), transparent 70%), rgb(var(--fg-rgb) / .025); }
.editor-summary .field-note { margin-bottom: 0; }
.totals { display: grid; gap: 12px; margin-top: 22px; }
.totals div { display: flex; justify-content: space-between; gap: 20px; font-size: 14px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.totals div span:last-child, .totals div strong:last-child { font-family: var(--mono); font-size: 13.5px; color: var(--text); }
.totals .total { margin-top: 4px; padding-top: 16px; border-top: 1px solid var(--line-2); font-family: var(--display); font-size: 20px; font-weight: 650; color: var(--text); }
.totals .total span:last-child { font-family: var(--display); font-size: 22px; letter-spacing: -.02em; color: var(--text); }
.section-divider { margin: 22px 0; border: 0; border-top: 1px solid var(--line); }
.line-row { display: grid; grid-template-columns: minmax(150px, 1fr) 92px 132px 40px; gap: 10px; align-items: start; margin-bottom: 14px; padding: 14px; border-radius: 14px; border: 1px solid var(--line); background: rgb(var(--fg-rgb) / .02); }
.line-row input, .line-row textarea { font-size: 15px; }
.line-row .remove { display: grid; place-items: center; width: 40px; height: 46px; margin-top: 27px; border: 1px solid transparent; border-radius: 12px; background: none; color: var(--coral); font-size: 22px; }
.line-row .remove:hover { background: rgba(255, 107, 95, .1); border-color: rgba(255, 107, 95, .25); }
.row-end { display: flex; justify-content: flex-end; gap: 12px; margin-top: 24px; }
.document-actions { margin-bottom: 18px; }
.document-actions .button.small, #share-dialog .actions .button { min-height: 44px; padding: 10px 16px; font-size: 14.5px; border-radius: 12px; }
#document-actions:empty { display: none; }
#invoice-preview { padding: 26px; border-radius: 18px; background: radial-gradient(600px 300px at 50% 0%, rgb(var(--turq-rgb) / .08), transparent 70%), var(--preview-bg); border: 1px solid var(--line); }
#payment-history { margin-top: 24px; }
#payment-history:empty { display: none; }
#payment-history h3 { margin-bottom: 8px; }
.payment-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); font-size: 14px; color: var(--text-2); }
.payment-row strong { font-family: var(--mono); color: var(--text); }
.payment-row p { font-size: 13px; }
#payment-balance { font-family: var(--mono); font-size: 15px; color: var(--text); }
#currency-change-summary { margin: 0; font-size: 15px; }

/* =========================================================
   Factura (papel blanco, igual en pantalla, enlace e impresión)
   ========================================================= */
.invoice, .invoice.card { --text: #1d2530; --text-2: #3b4653; --text-3: #5b6674; --muted: #5b6674; --line: #e3e8ee; --line-2: #d3dbe3; --turq-2: #087a88; position: relative; overflow: hidden; max-width: 860px; margin: 0 auto; padding: 44px 46px 36px; border: 0; border-radius: 16px; background: #fff; color: var(--text); box-shadow: 0 40px 90px -40px rgb(var(--shadow-rgb) / calc(.9 * var(--shadow-k))), 0 0 0 1px rgba(255, 255, 255, .06); color-scheme: light; }
.invoice::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 6px; background: linear-gradient(90deg, #0a8796, #1cc6d3 62%, #6ee3ec 84%, transparent 84%, transparent 86.5%, #ff9e37 86.5%); -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.invoice h2, .invoice h3 { color: var(--text); }
.invoice h3 { margin: 26px 0 8px; font-size: 15px; }
.invoice p { margin: 4px 0; font-size: 14px; color: var(--text-2); }
.invoice small { font-size: 13px; line-height: 1.6; color: var(--text-3); }
.invoice .eyebrow { margin-bottom: 8px; font-size: 10.5px; color: #087a88; }
.invoice .eyebrow::before { width: 14px; }
.invoice-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 26px; margin-bottom: 24px; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.invoice-top > div:first-child { min-width: 0; }
.invoice-top p strong { color: var(--text); }
.invoice-logo { position: relative; overflow: hidden; width: 260px; max-width: 100%; height: auto; aspect-ratio: 1216 / 320; margin: 0 0 14px -4px; }
.invoice-logo img { position: absolute; display: block; filter: brightness(1.012) contrast(1.02); width: 105.263158%; max-width: none; height: auto; left: -2.631579%; top: -91.25%; }
.invoice-title { text-align: right; }
.invoice-title h2 { margin: 0 0 6px; font-size: 30px; font-weight: 700; letter-spacing: -.035em; }
.invoice-title > strong { display: block; margin-bottom: 12px; font-family: var(--mono); font-size: 14px; font-weight: 600; letter-spacing: .03em; color: var(--text-2); }
.invoice .badge { font-size: 12px; background: #eef1f4; border-color: #dfe5eb; color: #4a5563; }
.invoice .badge::before { box-shadow: none; }
.invoice .badge.issued { color: #2c5fb3; background: #eaf1ff; border-color: #cfdcf7; }
.invoice .badge.late { color: #b0520c; background: #fff1e3; border-color: #f8d6b4; }
.invoice .badge.paid { color: #07707c; background: #e3f7f9; border-color: #bfe8ed; }
.invoice .badge.void { color: #b3342b; background: #fdecea; border-color: #f4c9c4; }
.invoice .grid2 { gap: 16px 24px; }
.invoice .grid2 .right p { color: var(--text-3); }
.invoice .grid2 .right strong { font-family: var(--mono); font-size: 13.5px; color: var(--text); white-space: nowrap; }
.invoice table { margin: 14px 0 6px; }
.invoice th { padding: 11px 8px; font-size: 10px; color: var(--text-3); border-bottom: 1.5px solid var(--text); }
.invoice td { padding: 13px 8px; font-size: 14px; color: var(--text); border-bottom: 1px solid var(--line); vertical-align: top; }
.invoice td.right { font-family: var(--mono); font-size: 13px; white-space: nowrap; }
.invoice tbody tr:hover { background: none; }
.invoice tbody tr:last-child td { border-bottom: 1px solid var(--line); }
.invoice .totals { max-width: 340px; margin: 20px 0 22px auto; padding: 18px 20px; border-radius: 14px; background: #f4f7f9; }
.invoice .totals div { color: var(--text-2); }
.invoice .totals div span:last-child, .invoice .totals div strong:last-child { color: var(--text); }
.invoice .totals .total { border-top-color: var(--line-2); }
.invoice .totals .total span:last-child { color: var(--text); }
.invoice .totals .total ~ div:last-child { margin-top: 2px; padding-top: 12px; border-top: 1px dashed var(--line-2); }
.invoice .totals .total ~ div:last-child strong { font-family: var(--display); font-size: 16px; color: var(--text); }
.invoice .totals .total ~ div:last-child strong:last-child { font-size: 18px; letter-spacing: -.01em; }
.prewrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.invoice-foot { margin-top: 26px; padding-top: 16px; border-top: 1px solid var(--line); }
.invoice-foot small { font-size: 12px; }
.invoice-banks { margin: 26px 0; }
.invoice-banks h3 { margin: 0 0 4px; }
.invoice-banks .bank-intro { margin: 0 0 14px; color: var(--text-3); }
.bank-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.bank-card { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; min-width: 0; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: #fff; overflow: hidden; break-inside: avoid; }
.bank-card::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: linear-gradient(90deg, #1cc6d3, #0a8796); -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.bank-name { font-size: 15px; color: var(--text); overflow-wrap: anywhere; }
.bank-type, .bank-holder { font-size: 12px; line-height: 1.5; color: var(--text-3); overflow-wrap: anywhere; }
.bank-number { max-width: 100%; margin: 4px 0 8px; font-family: var(--mono); font-size: 17px; font-weight: 700; letter-spacing: .03em; color: var(--text); overflow-wrap: anywhere; user-select: all; -webkit-user-select: all; }
.copy-account { width: 100%; margin-top: auto; background: #fff; border-color: #bfe3e8; color: #087a88; }
.copy-account:hover { background: #eefafb; border-color: #8fd3dc; color: #065e69; }
.bank-copy-status:empty { display: none; }
.bank-copy-status { display: block; min-height: 18px; font-size: 12px; line-height: 1.4; color: #087a88; }

/* Página del enlace del cliente (/factura/…) */
body > main.layout { padding-top: 28px; }
body > main.layout > .actions.no-print { padding-bottom: 20px; border-bottom: 1px solid var(--line); }
body > main.layout > p { color: var(--text-2); }
.wordmark { display: inline-flex; align-items: center; font-family: var(--display); font-size: 22px; font-weight: 800; letter-spacing: -.02em; color: var(--text); }
.wordmark::before { content: ""; width: 34px; height: 34px; margin-right: 10px; background: url('/assets/img/icon-192.png') center / contain no-repeat; }
.wordmark b { font-weight: 800; color: var(--turq); }
.wordmark:hover { color: var(--text); }

/* =========================================================
   Adaptación a tabletas y móviles
   ========================================================= */
@media (max-width: 1180px) {
  .layout { padding: 30px 28px 80px; }
  .top { padding: 12px 28px; }
  .stat strong { font-size: 24px; }
  .currency-summary { font-size: 18px; }
}

@media (max-width: 1023px) {
  .app-page { --side-w: 0px; }
  .sidebar { inset: auto 0 0 0; width: auto; padding: 6px 10px calc(6px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line); background: rgb(var(--side-rgb) / .92); }
  .sidebar .brand, .side-label, .side-foot { display: none; }
  .tabs { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 2px; }
  .tabs button { flex-direction: column; justify-content: center; gap: 4px; min-height: 56px; padding: 6px 4px; border-radius: 12px; font-size: 11.5px; font-weight: 600; text-align: center; }
  .tabs button .icon { width: 22px; height: 22px; }
  .tabs button[aria-selected=true] { background: rgb(var(--turq-rgb) / .1); border-color: transparent; color: var(--turq-2); }
  .tabs button[aria-selected=true]::before { left: 30%; right: 30%; top: -7px; bottom: auto; width: auto; height: 3px; border-radius: 0 0 3px 3px; }
  .tab-long { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .tab-short { display: inline; }
  .top { padding: 10px 20px; padding-top: max(10px, env(safe-area-inset-top)); }
  .brand-mobile { display: inline-block; }
  .brand-mobile img { width: 132px; }
  .top-crumb { display: none; }
  .layout { padding: 26px 20px calc(110px + env(safe-area-inset-bottom)); }
  #toast { bottom: calc(86px + env(safe-area-inset-bottom)); }
  .editor-layout { grid-template-columns: 1fr; }
  .editor-summary { position: static; }
}

@media (max-width: 900px) {
  .auth { grid-template-columns: minmax(0, 1fr); grid-template-areas: "hero" "card" "back"; max-width: 560px; align-content: start; padding-top: max(18px, env(safe-area-inset-top)); padding-bottom: 36px; }
  .auth-hero { align-self: auto; text-align: center; }
  .auth-logo img { width: 136px; margin: 0 auto; }
  .orbit { width: 176px; margin: -14px auto -26px; }
  .auth-hero .eyebrow { justify-content: center; }
  .auth-hero .eyebrow { margin-bottom: 8px; }
  .auth-hero h1 { margin-bottom: 10px; font-size: clamp(34px, 9.4vw, 46px); }
  .auth-hero .lead { max-width: 330px; margin: 0 auto; font-size: 15.5px; line-height: 1.5; }
  .auth-points { display: none; }
  .auth-card { margin-top: 24px; padding: 22px 20px; border-radius: 22px; -webkit-backdrop-filter: none; backdrop-filter: none; }
  .auth-card-head { gap: 12px; }
  .auth-badge { width: 42px; height: 42px; border-radius: 13px; }
  .auth-card-head h2 { font-size: 20px; }
  .auth-card-head p { font-size: 13.5px; }
  .auth-card .stack { gap: 16px; }
  .auth-back { justify-self: center; margin-top: 22px; }
  #access-status:not(:empty) { position: fixed; left: 14px; right: 14px; bottom: max(14px, env(safe-area-inset-bottom)); z-index: 50; margin: 0; background: var(--toast-bg); box-shadow: 0 24px 60px -20px rgb(var(--shadow-rgb) / calc(.95 * var(--shadow-k))); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); animation: toastIn2 .35s var(--ease); }
  #access-status.danger:not(:empty) { background: var(--toast-danger-bg); }
  .auth-page:has(#access-status:not(:empty)) .auth { padding-bottom: 150px; }
  @keyframes toastIn2 { from { opacity: 0; translate: 0 14px; } }
}

@media (max-width: 760px) {
  .page-title { align-items: flex-start; }
  .page-title h1 { font-size: 30px; }
  .stats { grid-auto-flow: column; grid-auto-columns: 74%; grid-template-columns: none; gap: 12px; overflow-x: auto; margin: 0 -20px 18px; padding: 2px 20px 6px; scroll-snap-type: x mandatory; scroll-padding: 0 20px; scrollbar-width: none; }
  .stats::-webkit-scrollbar { display: none; }
  .stat { min-height: 118px; padding: 18px 20px; scroll-snap-align: start; }
  .stat strong { font-size: 24px; }
  .card { padding: 18px; border-radius: 16px; }
  .card-head { align-items: stretch; flex-direction: column; }
  .card-head .toolbar, .toolbar { flex-direction: column; align-items: stretch; }
  .search { max-width: none; }
  .toolbar select { width: 100%; }
  /* La tabla de documentos se convierte en tarjetas */
  #documents .table-wrap { overflow: visible; margin: 0; padding: 0; }
  #documents table, #documents tbody { display: block; }
  #documents thead { display: none; }
  #documents tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; margin-bottom: 12px; padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: rgb(var(--fg-rgb) / .025); }
  #documents tr:last-child { margin-bottom: 0; }
  #documents td { display: block; padding: 0; border: 0; min-width: 0; }
  #documents td:nth-child(1) { grid-column: 1 / -1; grid-row: 1; }
  #documents td:nth-child(1) strong { margin-bottom: 6px; }
  #documents td:nth-child(2) { grid-column: 1 / -1; grid-row: 2; font-size: 14px; color: var(--text-2); }
  #documents td:nth-child(3) { grid-column: 1; grid-row: 3; align-self: end; font-size: 12.5px; color: var(--text-3); }
  #documents td:nth-child(3)::before { content: "Vence "; font-family: var(--font); }
  #documents td:nth-child(4) { grid-column: 2; grid-row: 1; align-self: start; justify-self: end; }
  #documents td:nth-child(5) { grid-column: 2; grid-row: 3; }
  #documents td:nth-child(6) { grid-column: 1 / -1; grid-row: 4; width: auto; padding-top: 6px; }
  #documents td:nth-child(6) .button { width: 100%; }
  .client-card { flex-wrap: wrap; row-gap: 10px; }
  .client-card > .button { margin-left: 58px; }
  .grid3 { grid-template-columns: 1fr 1fr; }
  .grid3 > label:first-child { grid-column: 1 / -1; }
  /* Diálogos como hojas que suben desde abajo */
  dialog { width: 100%; max-width: 100%; max-height: 94vh; max-height: 94dvh; margin: auto 0 0; border-radius: 24px 24px 0 0; border-bottom: 0; }
  dialog.wide { width: 100%; height: 94vh; height: 94dvh; }
  dialog[open] { animation: sheetIn .42s var(--ease); }
  @keyframes sheetIn { from { translate: 0 60px; opacity: .4; } }
  .dialog-head { padding: 16px 18px; }
  .dialog-body { padding: 20px 18px calc(28px + env(safe-area-inset-bottom)); }
  #invoice-preview { padding: 10px; margin: 0 -8px; border-radius: 16px; }
  .document-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .document-actions > .primary { order: -1; grid-column: 1 / -1; }
  .button.small { min-height: 44px; }
  .light-link { min-height: 40px; }
  .close { width: 44px; height: 44px; }
  .document-actions > * { width: 100%; min-height: 44px; white-space: normal; }
  .document-actions > .light-link { justify-content: center; }
  .line-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 40px; padding: 12px; }
  .line-row label:first-child { grid-column: 1 / -1; }
  .invoice, .invoice.card { padding: 30px 20px 24px; border-radius: 12px; }
  .invoice-top { flex-direction: column; gap: 14px; }
  .invoice-title { text-align: left; }
  .invoice-title h2 { font-size: 24px; }
  .invoice-logo { width: 220px; }
  .invoice .grid2 { grid-template-columns: 1fr 1fr; gap: 12px; }
  .invoice thead { display: none; }
  .invoice table, .invoice tbody { display: block; }
  .invoice tbody tr { display: grid; grid-template-columns: auto auto minmax(0, 1fr); grid-template-areas: "desc desc desc" "qty price amount"; gap: 4px 6px; padding: 12px 0; border-bottom: 1px solid var(--line); }
  .invoice tbody tr:first-child { border-top: 1.5px solid var(--text); }
  .invoice tbody td { display: block; padding: 0; border: 0 !important; }
  .invoice tbody td:nth-child(1) { grid-area: desc; font-size: 14px; font-weight: 500; }
  .invoice tbody td:nth-child(2) { grid-area: qty; font-size: 12.5px; color: var(--text-3); }
  .invoice tbody td:nth-child(2)::after { content: " ×"; }
  .invoice tbody td:nth-child(3) { grid-area: price; font-size: 12.5px; color: var(--text-3); text-align: left; }
  .invoice tbody td:nth-child(4) { grid-area: amount; font-size: 13px; font-weight: 600; }
  .invoice .totals { max-width: none; }
  .bank-grid { grid-template-columns: 1fr; }
  .bank-copy-status:empty { display: none; }
  .copy-account { min-height: 44px; }
  body > main.layout { padding: 20px 14px 40px; }
  body > main.layout > .actions.no-print { flex-wrap: nowrap; }
  body > main.layout > .actions.no-print .button { padding: 9px 14px; font-size: 14px; }
  .wordmark { font-size: 18px; }
  .wordmark::before { width: 28px; height: 28px; }
}

@media (max-width: 520px) {
  .page-title { flex-direction: column; align-items: stretch; margin-bottom: 20px; }
  #new-document { width: 100%; min-height: 48px; }
  .layout:has(#documents-tab[hidden]) > .page-title > div > p:not(.eyebrow) { display: none; }
  .layout:has(#documents-tab[hidden]) > .page-title { margin-bottom: 16px; }
  .grid2 { grid-template-columns: 1fr; }
  .grid3 { grid-template-columns: 1fr; }
  .user .email { display: none; }
  .control-link span { display: none; }
  .top-right { gap: 10px; }
  .button { white-space: normal; }
  .access { margin: 28px 16px; padding: 26px; }
  .client-card > div { padding-left: 52px; }
  .client-card > .button { margin-left: 52px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .orbit .moving { display: none; }
  .orbit .still { display: inline; }
}

/* =========================================================
   Impresión: solo la factura, en blanco y negro legible
   ========================================================= */
@media print {
  @page { margin: 14mm; }
  :root { color-scheme: light; }
  html, body { background: #fff !important; color: #000; }
  body::before { display: none !important; }
  body > *:not(dialog) { display: none !important; }
  body > main.layout { display: block !important; max-width: none !important; padding: 0 !important; }
  dialog, dialog.wide { display: block !important; position: static; inset: 0 auto auto 0; width: 100% !important; max-width: none !important; max-height: none !important; height: auto !important; margin: 0 !important; padding: 0; border: 0; border-radius: 0; background: #fff; color: #000; box-shadow: none; overflow: visible !important; animation: none !important; }
  dialog:not(#preview-dialog) { display: none !important; }
  dialog::backdrop { display: none; }
  .dialog-head, .document-actions, .no-print, #preview-status { display: none !important; }
  .dialog-body, #invoice-preview { padding: 0; margin: 0; border: 0; background: none; }
  .invoice, .invoice.card { max-width: none; padding: 18px 0 0; border-radius: 0; box-shadow: none; }
  .invoice-foot, .totals, tr, .invoice-banks { break-inside: avoid; }
  .bank-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .bank-number { font-size: 14px; }
}

/* =========================================================
   Tema claro y oscuro: interruptor, logos y ajustes
   ========================================================= */
.theme-toggle { display: none; place-items: center; width: 40px; height: 40px; flex-shrink: 0; padding: 0; border-radius: 12px; border: 1px solid var(--line-2); background: rgb(var(--fg-rgb) / .045); color: var(--text); overflow: hidden; transition: border-color .2s, background-color .2s, transform .3s var(--ease); }
.con-tema .theme-toggle { display: grid; }
.theme-toggle:hover { border-color: rgb(var(--orange-rgb) / .55); background: rgb(var(--orange-rgb) / .09); }
.theme-toggle:active { transform: scale(.92); }
.theme-toggle .icon { grid-area: 1 / 1; width: 19px; height: 19px; transition: transform .6s var(--ease), opacity .3s; }
.ico-sol { color: var(--orange); }
.ico-luna { color: var(--turq-2); opacity: 0; transform: rotate(-120deg) scale(.3); }
:root[data-theme="claro"] .ico-sol { opacity: 0; transform: rotate(120deg) scale(.3); }
:root[data-theme="claro"] .ico-luna { opacity: 1; transform: none; }
.auth-theme { position: fixed; top: max(18px, env(safe-area-inset-top)); right: 18px; z-index: 40; width: 44px; height: 44px; border-radius: 14px; }
.logo-claro { display: none !important; }
:root[data-theme="claro"] .logo-claro { display: block !important; }
:root[data-theme="claro"] .logo-oscuro { display: none !important; }
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
::view-transition-new(root) { z-index: 2; }

:root[data-theme="claro"] .grad { background-image: linear-gradient(100deg, #0e7490, #0891b2 35%, #06b6d4 70%, #0284c7); }
:root[data-theme="claro"] .grad .dot { color: #f26a0c; -webkit-text-fill-color: #f26a0c; }
:root[data-theme="claro"] #orbit-line stop:nth-child(-n+2) { stop-color: #0891b2; }
:root[data-theme="claro"] .orbit ellipse { stroke: #0891b2; stroke-opacity: .35; }
:root[data-theme="claro"] .orbit circle[fill="#6ee3ec"] { fill: #06b6cc; }
:root[data-theme="claro"] .auth-card { box-shadow: 0 40px 90px -50px rgb(16 36 66 / .45), inset 0 1px 0 #fff; }
:root[data-theme="claro"] .theme-toggle { background: #fff; box-shadow: 0 6px 16px -10px rgb(16 36 66 / .35); }
:root[data-theme="claro"] .card, :root[data-theme="claro"] .stat { box-shadow: 0 1px 2px rgb(16 36 66 / .05), 0 22px 44px -30px rgb(16 36 66 / .3); }
:root[data-theme="claro"] .sidebar { box-shadow: 1px 0 0 rgb(16 36 66 / .04), 12px 0 40px -30px rgb(16 36 66 / .25); }
:root[data-theme="claro"] .top { background: rgb(255 255 255 / .78); }
:root[data-theme="claro"] dialog::backdrop { background: rgb(16 36 66 / .38); }
:root[data-theme="claro"] input[type=date]::-webkit-calendar-picker-indicator { filter: sepia(1) hue-rotate(140deg) saturate(2.5); opacity: .75; }
:root[data-theme="claro"] input[type=search]::-webkit-search-cancel-button { filter: none; }
:root[data-theme="claro"] .badge.issued { background: #eaf1ff; border-color: #cfdcf7; }
:root[data-theme="claro"] .badge.void { background: #fdecea; border-color: #f4c9c4; }
:root[data-theme="claro"] .badge.late { background: #fff1e3; border-color: #f8d6b4; }
:root[data-theme="claro"] .badge.paid { background: #e3f7f9; border-color: #bfe8ed; }
:root[data-theme="claro"] .badge::before { box-shadow: none; }
:root[data-theme="claro"] .notice.error, :root[data-theme="claro"] .error { background: #fdecea; border-color: #f4c9c4; }
:root[data-theme="claro"] #access-status.danger:not(:empty) { background: #fdecea; border-color: #f4c9c4; }
@media (max-width: 1023px) {
  .top-right .theme-toggle { width: 38px; height: 38px; }
  :root[data-theme="claro"] .sidebar { background: rgb(255 255 255 / .94); box-shadow: 0 -10px 30px -20px rgb(16 36 66 / .3); }
}
@media (max-width: 900px) {
  .auth-theme { top: max(12px, env(safe-area-inset-top)); right: 12px; width: 42px; height: 42px; }
}
@media print {
  .theme-toggle { display: none !important; }
}
