/* ==========================================================================
   d2.css — Sistema visual del portal cliente3.
   Replica el diseño de la app POS (/dashboard2, Flutter): fuente Manrope,
   azul de marca #004B87, fondo slate-50, tarjetas blancas con borde fino,
   íconos sobre fondo tintado, chips y navegación con "pastilla".

   Responsive:
     < 600px   → celular: barra inferior, cabecera azul a sangre, 2 columnas
     600–1023  → tablet: barra inferior, contenido centrado, 3 columnas
     ≥ 1024px  → escritorio: riel lateral, contenido a 2 columnas, 4 columnas
   Tema: claro / oscuro / sistema (html[data-theme]).
   ========================================================================== */

@font-face { font-family: 'Manrope'; font-weight: 500; font-style: normal; font-display: swap; src: url('Manrope-Medium.woff2') format('woff2'), url('Manrope-Medium.ttf') format('truetype'); }
@font-face { font-family: 'Manrope'; font-weight: 600; font-style: normal; font-display: swap; src: url('Manrope-SemiBold.woff2') format('woff2'), url('Manrope-SemiBold.ttf') format('truetype'); }
@font-face { font-family: 'Manrope'; font-weight: 700; font-style: normal; font-display: swap; src: url('Manrope-Bold.woff2') format('woff2'), url('Manrope-Bold.ttf') format('truetype'); }
@font-face { font-family: 'Manrope'; font-weight: 800; font-style: normal; font-display: swap; src: url('Manrope-ExtraBold.woff2') format('woff2'), url('Manrope-ExtraBold.ttf') format('truetype'); }

/* ---------- Tokens ---------- */
:root {
    --d2-brand: #004B87;
    --d2-brand-2: #0066B3;
    --d2-brand-ink: #FFFFFF;
    --d2-hero: #004B87;
    --d2-accent: #4D9EFF;
    --d2-accent-hover: #3B8CF0;
    --d2-accent-ink: #FFFFFF;
    --d2-accent-soft: #EFF6FF;
    --d2-accent-disabled: #BFDBFE;

    --d2-bg: #F8FAFC;
    --d2-surface: #FFFFFF;
    --d2-surface-2: #F3F4F6;
    --d2-surface-3: #EEF1F4;
    --d2-border: #E2E8F0;
    --d2-border-strong: #CBD5E1;
    --d2-text: #0F172A;
    --d2-text-2: #334155;
    --d2-muted: #64748B;
    --d2-faint: #94A3B8;

    --d2-success: #129534;
    --d2-success-soft: #F0FDF4;
    --d2-success-on-brand: #7EF0A0;
    --d2-warn: #92400E;
    --d2-warn-soft: #FFF4D6;
    --d2-danger: #DC2626;
    --d2-danger-soft: #FEF2F2;
    --d2-info: #0369A1;
    --d2-info-soft: #E0F2FE;

    /* Tintes de íconos (fondo / trazo), iguales a la app */
    --t-blue-bg: #EFF6FF;   --t-blue: #3B82F6;
    --t-violet-bg: #F5F3FF; --t-violet: #8B5CF6;
    --t-amber-bg: #FFF7ED;  --t-amber: #F59E0B;
    --t-cyan-bg: #ECFEFF;   --t-cyan: #06B6D4;
    --t-pink-bg: #FDF2F8;   --t-pink: #EC4899;
    --t-green-bg: #F0FDF4;  --t-green: #22C55E;
    --t-yellow-bg: #FFF4D6; --t-yellow: #713F12;
    --t-slate-bg: #F1F5F9;  --t-slate: #475569;

    --d2-radius: 12px;
    --d2-radius-sm: 10px;
    --d2-radius-xs: 8px;
    --d2-shadow: 0 1px 2px rgba(15, 23, 42, .04);
    --d2-shadow-lg: 0 18px 50px rgba(15, 23, 42, .18);
    --d2-nav-h: 60px;
    --d2-rail-w: 84px;
    --d2-topbar-h: 52px;
    --d2-gutter: 12px;
    --d2-max: 1080px;
    --d2-font: 'Manrope', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --d2-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    color-scheme: light;
}

/* Oscuro: por elección o por sistema */
html[data-theme="dark"] {
    --d2-hero: #0B3358;
    --d2-accent: #6AAEFF;
    --d2-accent-hover: #86BDFF;
    --d2-accent-ink: #0B1220;
    --d2-accent-soft: #16263F;
    --d2-accent-disabled: #1E3A5F;
    --d2-bg: #0B1220;
    --d2-surface: #111A2B;
    --d2-surface-2: #1A2436;
    --d2-surface-3: #1F2B40;
    --d2-border: #223047;
    --d2-border-strong: #334155;
    --d2-text: #E6EDF7;
    --d2-text-2: #CBD5E1;
    --d2-muted: #94A3B8;
    --d2-faint: #64748B;
    --d2-success: #34D399;
    --d2-earn-bg: #15803D;
    --d2-success-soft: #0F2A21;
    --d2-warn: #FBBF24;
    --d2-warn-soft: #2B2211;
    --d2-danger: #F87171;
    --d2-danger-soft: #2C1518;
    --d2-info: #7DD3FC;
    --d2-info-soft: #0E2536;
    --t-blue-bg: #14243D;   --t-blue: #60A5FA;
    --t-violet-bg: #211A3A; --t-violet: #A78BFA;
    --t-amber-bg: #2B1F0E;  --t-amber: #FBBF24;
    --t-cyan-bg: #0D2A30;   --t-cyan: #22D3EE;
    --t-pink-bg: #2E1424;   --t-pink: #F472B6;
    --t-green-bg: #0F2A1B;  --t-green: #4ADE80;
    --t-yellow-bg: #2B2410; --t-yellow: #FDE68A;
    --t-slate-bg: #1A2436;  --t-slate: #CBD5E1;
    --d2-shadow: none;
    --d2-shadow-lg: 0 18px 50px rgba(0, 0, 0, .5);
    color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body.d2 {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    font-family: var(--d2-font);
    font-weight: 500;
    font-size: 15px;
    line-height: 1.45;
    color: var(--d2-text);
    background: var(--d2-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
}

:where(.d2) :where(h1, h2, h3, h4) { margin: 0; font-weight: 700; letter-spacing: -.01em; color: inherit; }
:where(.d2) :where(p) { margin: 0; }
:where(.d2) :where(a) { color: var(--d2-accent); text-decoration: none; }
:where(.d2) :where(a):hover { text-decoration: underline; }
:where(.d2) :where(img, svg) { max-width: 100%; }
:where(.d2) :where(button, input, select, textarea) { font: inherit; color: inherit; }
.d2 :focus-visible { outline: 3px solid color-mix(in srgb, var(--d2-accent) 55%, transparent); outline-offset: 2px; border-radius: 6px; }

.d2-ico { width: 24px; height: 24px; flex: none; display: inline-block; vertical-align: middle; }
.d2-ico--sm { width: 18px; height: 18px; }
.d2-ico--lg { width: 28px; height: 28px; }

.d2-sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.d2-num { font-variant-numeric: tabular-nums; }
.d2-mono { font-family: var(--d2-mono); font-size: .92em; }
.d2-muted { color: var(--d2-muted); }
.d2-ok { color: var(--d2-success); }
.d2-bad { color: var(--d2-danger); }

/* Utilidades heredadas del portal */
.solo-movil { display: none !important; }
@media (max-width: 768px) {
    .solo-movil { display: revert !important; }
    .solo-escritorio { display: none !important; }
}

/* ---------- Estructura ---------- */
.d2-app {
    min-height: 100vh;
    min-height: 100dvh;
    padding-bottom: calc(var(--d2-nav-h) + env(safe-area-inset-bottom, 0px));
}
.d2-app--sin-nav { padding-bottom: 0; }

.d2-main {
    width: 100%;
    max-width: var(--d2-max);
    margin: 0 auto;
    padding: var(--d2-gutter);
    padding-left: max(var(--d2-gutter), env(safe-area-inset-left, 0px));
    padding-right: max(var(--d2-gutter), env(safe-area-inset-right, 0px));
}
.d2-main--narrow { max-width: 760px; }

.d2-stack { display: flex; flex-direction: column; gap: 12px; }
.d2-stack--sm { gap: 8px; }
.d2-row-flex { display: flex; align-items: center; gap: 10px; }
.d2-spacer { flex: 1; }

.d2-cols { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); align-items: start; }

.d2-section-title {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    font-size: 14.5px; font-weight: 700; color: var(--d2-text);
    margin: 2px 2px 8px;
}
.d2-section-title a { font-size: 14px; font-weight: 700; }

/* ---------- Barra superior (páginas internas) ---------- */
.d2-topbar {
    position: sticky; top: 0; z-index: 400;
    display: flex; align-items: center; gap: 8px;
    min-height: var(--d2-topbar-h);
    padding: 4px 8px;
    padding-top: calc(4px + env(safe-area-inset-top, 0px));
    background: var(--d2-surface);
    border-bottom: 1px solid var(--d2-border);
}
.d2-topbar__title { flex: 1; min-width: 0; font-size: 18px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.d2-topbar__right { display: flex; align-items: center; gap: 6px; color: var(--d2-muted); font-size: 13px; font-weight: 600; }
.d2-topbar__saldo { white-space: nowrap; }

.d2-iconbtn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; flex: none;
    border: 0; border-radius: 50%;
    background: transparent; color: var(--d2-text);
    cursor: pointer; text-decoration: none !important;
    transition: background .15s;
}
.d2-iconbtn:hover { background: var(--d2-surface-2); }
.d2-iconbtn--on-brand, a.d2-iconbtn--on-brand { color: #fff; }
.d2-iconbtn--on-brand:hover { background: rgba(255, 255, 255, .14); }

/* ---------- Modo claro / oscuro ---------- */
.d2-theme-toggle .d2-ico-sol { display: none; }
html[data-theme="dark"] .d2-theme-toggle .d2-ico-luna { display: none; }
html[data-theme="dark"] .d2-theme-toggle .d2-ico-sol { display: inline-block; }
.d2-theme-toggle--flota {
    position: absolute; top: calc(12px + env(safe-area-inset-top, 0px)); right: 12px; z-index: 5;
    background: rgba(255, 255, 255, .14);
}
html.d2-tema-anim, html.d2-tema-anim * { transition: background-color .25s ease, border-color .25s ease, color .25s ease !important; }

/* ---------- Cabecera azul (inicio) ---------- */
.d2-hero {
    background: var(--d2-hero);
    color: var(--d2-brand-ink);
    padding: 10px var(--d2-gutter) 12px;
    padding-top: calc(10px + env(safe-area-inset-top, 0px));
}
.d2-hero__inner { max-width: var(--d2-max); margin: 0 auto; }
.d2-hero__top { display: flex; align-items: center; gap: 10px; }
.d2-hero__logo {
    width: 40px; height: 40px; flex: none; border-radius: 12px; background: #fff;
    display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.d2-hero__logo img { width: 30px; height: 30px; }
.d2-hero__name { font-size: 16.5px; font-weight: 800; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.d2-hero__code { font-size: 12.5px; font-weight: 600; opacity: .72; }
.d2-hero__user {
    display: inline-flex; align-items: center; gap: 5px; max-width: 100%; margin-top: 5px;
    padding: 2px 10px 2px 7px; border-radius: 999px; background: rgba(255, 255, 255, .16);
    font-size: 12.5px; font-weight: 700; line-height: 1.5;
}
.d2-hero__user .d2-ico { width: 14px; height: 14px; }
.d2-hero__user span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.d2-hero__status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; opacity: .9; white-space: nowrap; }
.d2-dot { width: 9px; height: 9px; border-radius: 50%; background: #22C55E; flex: none; }
.d2-dot--off { background: #F59E0B; }
.d2-hero__bottom { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; margin-top: 10px; }
.d2-hero__label { font-size: 12.5px; font-weight: 600; opacity: .82; }
.d2-hero__saldo { font-size: clamp(24px, 7vw, 36px); font-weight: 800; line-height: 1.05; letter-spacing: -.02em; white-space: nowrap; }
.d2-hero__today { text-align: right; margin-left: auto; min-width: 0; }
.d2-hero__today-amt { font-size: clamp(16px, 4.6vw, 21px); font-weight: 800; line-height: 1.15; white-space: nowrap; }
.d2-hero__today-sub { font-size: 12.5px; font-weight: 700; color: var(--d2-success-on-brand); white-space: nowrap; }
.d2-hero__meta { margin-top: 6px; font-size: 12px; font-weight: 600; opacity: .7; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.d2-pill-alert {
    display: inline-flex; align-items: center; gap: 6px;
    background: #FEF3C7; color: #92400E; border-radius: 999px;
    padding: 3px 10px; font-size: 11px; font-weight: 800; letter-spacing: .04em;
}

/* ---------- Tarjetas ---------- */
.d2-card {
    background: var(--d2-surface);
    border: 1px solid var(--d2-border);
    border-radius: var(--d2-radius);
    box-shadow: var(--d2-shadow);
}
.d2-card--pad { padding: 14px; }
.d2-card--pad-lg { padding: 16px; }
.d2-card__head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--d2-border); }
.d2-card__title { font-size: 16px; font-weight: 700; }
.d2-card__sub { font-size: 13px; color: var(--d2-muted); }

/* Mosaico de accesos (igual al grid de categorías de la app) */
.d2-tiles { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.d2-tile {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
    min-height: 94px; padding: 12px 8px;
    background: var(--d2-surface);
    border: 1px solid var(--d2-border);
    border-radius: var(--d2-radius);
    color: var(--d2-text) !important;
    text-align: center; text-decoration: none !important;
    font-size: 14px; font-weight: 600; line-height: 1.2;
    cursor: pointer;
    transition: border-color .15s, transform .15s, box-shadow .15s;
    -webkit-user-select: none; user-select: none;
}
.d2-tile:hover { border-color: var(--d2-border-strong); box-shadow: 0 4px 16px rgba(15, 23, 42, .06); }
.d2-tile:active { transform: scale(.98); }
.d2-tile__sub { display: block; margin-top: 3px; font-size: 12px; font-weight: 600; color: var(--d2-muted); }
.d2-tile--wide { grid-column: 1 / -1; flex-direction: row; justify-content: flex-start; text-align: left; min-height: 0; padding: 12px 14px; }

.d2-badge-ico {
    width: 40px; height: 40px; flex: none; border-radius: 11px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--t-blue-bg); color: var(--t-blue);
}
.d2-badge-ico--lg { width: 48px; height: 48px; border-radius: 13px; }
.d2-badge-ico--sm { width: 34px; height: 34px; border-radius: 9px; }
.t-blue   { background: var(--t-blue-bg);   color: var(--t-blue); }
.t-violet { background: var(--t-violet-bg); color: var(--t-violet); }
.t-amber  { background: var(--t-amber-bg);  color: var(--t-amber); }
.t-cyan   { background: var(--t-cyan-bg);   color: var(--t-cyan); }
.t-pink   { background: var(--t-pink-bg);   color: var(--t-pink); }
.t-green  { background: var(--t-green-bg);  color: var(--t-green); }
.t-yellow { background: var(--t-yellow-bg); color: var(--t-yellow); }
.t-slate  { background: var(--t-slate-bg);  color: var(--t-slate); }

/* ---------- Listas (historial, ajustes) ---------- */
.d2-list { list-style: none; margin: 0; padding: 0; }
.d2-list > li + li, .d2-list > .d2-item + .d2-item { border-top: 1px solid var(--d2-border); }
.d2-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px; min-height: 56px;
    color: var(--d2-text) !important; text-decoration: none !important;
    background: none; border: 0; width: 100%; text-align: left; cursor: pointer;
}
a.d2-item:hover, button.d2-item:hover { background: var(--d2-surface-2); }
.d2-item__body { flex: 1; min-width: 0; }
.d2-item__title { font-size: 14.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.d2-item__sub { font-size: 12.5px; color: var(--d2-muted); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.d2-item__end { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; text-align: right; flex: none; }
.d2-item__amt { font-size: 15px; font-weight: 800; white-space: nowrap; }
.d2-item__chev { color: var(--d2-faint); flex: none; }
.d2-item--danger, .d2-item--danger .d2-item__title { color: var(--d2-danger) !important; }
.d2-item--wrap .d2-item__title, .d2-item--wrap .d2-item__sub { white-space: normal; }

/* ---------- Estados ---------- */
.d2-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 8px; border-radius: 6px;
    font-size: 12px; font-weight: 700; line-height: 1.5; white-space: nowrap;
    background: var(--d2-surface-2); color: var(--d2-text-2);
}
.d2-badge--ok { background: var(--d2-success-soft); color: var(--d2-success); }
.d2-badge--warn { background: var(--d2-warn-soft); color: var(--d2-warn); }
.d2-badge--bad { background: var(--d2-danger-soft); color: var(--d2-danger); }
.d2-badge--info { background: var(--d2-info-soft); color: var(--d2-info); }

/* ---------- Chips (filtros) ---------- */
.d2-chips {
    display: flex; gap: 6px;
    overflow-x: auto; scrollbar-width: none;
    margin: 0 calc(-1 * var(--d2-gutter)); padding: 2px var(--d2-gutter);
    scroll-snap-type: x proximity;
}
.d2-chips::-webkit-scrollbar { display: none; }
.d2-chip {
    flex: none; scroll-snap-align: start;
    display: inline-flex; align-items: center; gap: 6px;
    height: 34px; padding: 0 13px;
    border: 0; border-radius: 9px;
    background: var(--d2-surface-3); color: var(--d2-text-2);
    font-size: 13.5px; font-weight: 600; white-space: nowrap;
    cursor: pointer; text-decoration: none !important;
    transition: background .15s, color .15s;
}
.d2-chip:hover { background: var(--d2-border); }
.d2-chip.is-active, .d2-chip[aria-pressed="true"], .d2-chip[aria-selected="true"] { background: var(--d2-accent); color: var(--d2-accent-ink); }
.d2-chip--outline { background: var(--d2-surface); border: 1px solid var(--d2-border); }
.d2-chip--round { border-radius: 999px; }

/* Segmentado (Sistema / Claro / Oscuro) */
.d2-seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; }
.d2-seg button, .d2-seg a {
    display: flex; align-items: center; justify-content: center; text-decoration: none !important;
    height: 40px; border: 0; border-radius: 10px; cursor: pointer;
    background: var(--d2-surface-3); color: var(--d2-text-2); font-weight: 600; font-size: 14.5px;
}
.d2-seg a { color: var(--d2-text-2); }
.d2-seg button.is-active, .d2-seg a.is-active, .d2-seg a[aria-current="page"] { background: var(--d2-accent); color: var(--d2-accent-ink); }

/* ---------- Botones ---------- */
.d2-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 44px; padding: 0 18px;
    border: 1px solid transparent; border-radius: var(--d2-radius-sm);
    background: var(--d2-accent); color: var(--d2-accent-ink) !important;
    font-size: 16px; font-weight: 700; line-height: 1.1;
    text-decoration: none !important; cursor: pointer;
    transition: background .15s, transform .1s, opacity .15s;
}
.d2-btn:hover { background: var(--d2-accent-hover); }
.d2-btn:active { transform: scale(.985); }
.d2-btn:disabled, .d2-btn[aria-disabled="true"] { background: var(--d2-accent-disabled); color: #fff !important; cursor: not-allowed; transform: none; }
.d2-btn--block { display: flex; width: 100%; }
.d2-btn--brand { background: var(--d2-brand); color: #fff !important; }
.d2-btn--brand:hover { background: var(--d2-brand-2); }
.d2-btn--outline { background: var(--d2-surface); border-color: var(--d2-border); color: var(--d2-brand) !important; }
html[data-theme="dark"] .d2-btn--outline { color: var(--d2-accent) !important; }
.d2-btn--outline:hover { background: var(--d2-surface-2); }
.d2-btn--ghost { background: transparent; color: var(--d2-accent) !important; }
.d2-btn--ghost:hover { background: var(--d2-accent-soft); }
.d2-btn--success { background: var(--d2-success); color: #fff !important; }
.d2-btn--success:hover { filter: brightness(1.05); background: var(--d2-success); }
.d2-btn--danger { background: var(--d2-danger); color: #fff !important; }
.d2-btn--wa { background: #25D366; color: #fff !important; }
.d2-btn--wa:hover { background: #1EBE5A; }
.d2-btn--sm { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 9px; }

/* ---------- Formularios ---------- */
.d2-field { display: flex; flex-direction: column; gap: 5px; }
.d2-label { font-size: 14px; font-weight: 600; color: var(--d2-text-2); }
.d2-help { font-size: 12.5px; color: var(--d2-muted); font-weight: 500; }
.d2-input, .d2-select, .d2-textarea {
    width: 100%; min-height: 46px; padding: 10px 12px;
    background: var(--d2-surface); color: var(--d2-text);
    border: 1px solid var(--d2-border); border-radius: var(--d2-radius-sm);
    font-size: 16px; font-weight: 600;
    transition: border-color .15s, box-shadow .15s;
    -webkit-appearance: none; appearance: none;
}
.d2-textarea { min-height: 96px; resize: vertical; }
.d2-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2364748B' 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 12px center; padding-right: 40px;
}
.d2-input::placeholder, .d2-textarea::placeholder { color: var(--d2-faint); font-weight: 500; }
.d2-input:focus, .d2-select:focus, .d2-textarea:focus {
    outline: none; border-color: var(--d2-accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--d2-accent) 22%, transparent);
}
.d2-input[aria-invalid="true"] { border-color: var(--d2-danger); }
.d2-input-wrap { position: relative; }
.d2-input-wrap .d2-input { padding-right: 48px; }
.d2-input-wrap__btn {
    position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
    width: 44px; height: 44px; border: 0; background: none; color: var(--d2-muted); cursor: pointer; border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center;
}
.d2-search {
    display: flex; align-items: center; gap: 10px;
    height: 44px; padding: 0 12px;
    background: var(--d2-surface-2); border-radius: 11px; color: var(--d2-muted);
}
.d2-search input { flex: 1; min-width: 0; border: 0; background: none; outline: none; font-size: 16px; font-weight: 500; color: var(--d2-text); }
.d2-search input::placeholder { color: var(--d2-muted); }

/* Montos rápidos */
.d2-amounts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.d2-amount {
    height: 44px; border: 0; border-radius: 10px; cursor: pointer;
    background: var(--d2-surface-3); color: var(--d2-text); font-size: 15px; font-weight: 700;
}
.d2-amount.is-active { background: var(--d2-accent); color: var(--d2-accent-ink); }

/* Interruptor */
.d2-switch { position: relative; width: 52px; height: 32px; flex: none; }
.d2-switch input { position: absolute; inset: 0; opacity: 0; cursor: pointer; margin: 0; }
.d2-switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--d2-border-strong); transition: background .2s; pointer-events: none; }
.d2-switch span::after { content: ''; position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.d2-switch input:checked + span { background: var(--d2-accent); }
.d2-switch input:checked + span::after { transform: translateX(20px); }

/* ---------- Avisos ---------- */
.d2-banner {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 11px 13px; border-radius: 11px;
    background: var(--d2-accent-soft); color: var(--d2-text-2);
    font-size: 13.5px; font-weight: 600;
}
.d2-banner .d2-ico { color: var(--d2-accent); }
.d2-banner--ok { background: var(--d2-success-soft); }
.d2-banner--ok .d2-ico { color: var(--d2-success); }
.d2-banner--warn { background: var(--d2-warn-soft); }
.d2-banner--warn .d2-ico { color: var(--d2-warn); }
.d2-banner--bad { background: var(--d2-danger-soft); color: var(--d2-danger); }
.d2-banner--bad .d2-ico { color: var(--d2-danger); }
.d2-banner__body { flex: 1; min-width: 0; }
.d2-banner__body strong { display: block; color: var(--d2-text); }

.d2-impersonando {
    position: sticky; top: 0; z-index: 950;
    display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; justify-content: center;
    padding: 10px 16px; background: #B45309; color: #fff; font-size: 13px; font-weight: 700; text-align: center;
}
.d2-impersonando a { color: #fff; text-decoration: underline; }

/* ---------- Métricas ---------- */
.d2-earn {
    background: var(--d2-earn-bg, #129534); color: #fff;
    border-radius: var(--d2-radius); padding: 14px 16px;
}
.d2-earn__label { font-size: 13px; font-weight: 600; opacity: .9; }
.d2-earn__amt { font-size: clamp(27px, 7.4vw, 34px); font-weight: 800; line-height: 1.1; margin: 6px 0 4px; letter-spacing: -.02em; }
.d2-earn__sub { font-size: 13px; font-weight: 600; opacity: .9; }
.d2-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.d2-stat { background: var(--d2-surface); border: 1px solid var(--d2-border); border-radius: 11px; padding: 9px 11px; min-width: 0; }
.d2-stat__label { font-size: 12.5px; color: var(--d2-muted); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.d2-stat__value { font-size: 17px; font-weight: 800; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Barras "últimos 7 días" */
.d2-bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; align-items: end; height: 92px; padding: 12px 12px 0; }
.d2-bar { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; height: 100%; }
.d2-bar i { display: block; width: 100%; max-width: 38px; min-height: 4px; border-radius: 4px 4px 2px 2px; background: var(--d2-accent-disabled); }
.d2-bar.is-hoy i { background: var(--d2-accent); }
.d2-bar b { font-size: 11px; font-weight: 700; color: var(--d2-muted); padding-bottom: 10px; }
.d2-bar.is-hoy b { color: var(--d2-text); }

/* ---------- Tabla responsive (tarjetas en móvil) ---------- */
.d2-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.d2-table th { text-align: left; font-size: 12px; font-weight: 700; color: var(--d2-muted); text-transform: uppercase; letter-spacing: .04em; padding: 10px 14px; border-bottom: 1px solid var(--d2-border); background: var(--d2-surface-2); }
.d2-table td { padding: 12px 14px; border-bottom: 1px solid var(--d2-border); vertical-align: middle; }
.d2-table tr:last-child td { border-bottom: 0; }
.d2-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 719px) {
    .d2-table--cards thead { display: none; }
    .d2-table--cards, .d2-table--cards tbody, .d2-table--cards tr, .d2-table--cards td { display: block; width: 100%; }
    .d2-table--cards tr { padding: 10px 14px; border-bottom: 1px solid var(--d2-border); }
    .d2-table--cards tr:last-child { border-bottom: 0; }
    .d2-table--cards td { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border: 0; text-align: right; }
    .d2-table--cards td::before { content: attr(data-label); color: var(--d2-muted); font-weight: 600; font-size: 13px; text-align: left; }
    .d2-table--cards td[data-label=""]::before { content: none; }
}

/* ---------- Vacío / carga ---------- */
.d2-empty { text-align: center; padding: 28px 16px; color: var(--d2-muted); }
.d2-empty .d2-badge-ico { margin: 0 auto 12px; }
.d2-empty h3 { color: var(--d2-text); font-size: 16px; margin-bottom: 4px; }
.d2-spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--d2-border); border-top-color: var(--d2-accent); animation: d2-spin .8s linear infinite; margin: 0 auto; }
.d2-loading { padding: 26px 16px; text-align: center; color: var(--d2-muted); font-weight: 600; }
.d2-loading .d2-spinner { margin-bottom: 12px; }
.d2-skel { border-radius: 8px; background: linear-gradient(90deg, var(--d2-surface-2) 25%, var(--d2-surface-3) 50%, var(--d2-surface-2) 75%); background-size: 200% 100%; animation: d2-shimmer 1.2s infinite; }
.d2-hero .d2-skel { background: rgba(255,255,255,.18); animation: none; }
@keyframes d2-spin { to { transform: rotate(360deg); } }
@keyframes d2-shimmer { to { background-position: -200% 0; } }

.d2-footer { text-align: center; padding: 16px 16px 6px; font-size: 13px; color: var(--d2-muted); font-weight: 600; }
.d2-footer b { color: var(--d2-success); font-weight: 800; }
.d2-footer small { display: block; margin-top: 4px; font-size: 12px; color: var(--d2-faint); }

/* ---------- Hoja modal (recargas) ---------- */
.d2-sheet {
    position: fixed; inset: 0; z-index: 1000;
    display: none; align-items: stretch; justify-content: center;
    background: rgba(15, 23, 42, .55);
}
.d2-sheet.active { display: flex; }
.d2-sheet__panel {
    display: flex; flex-direction: column;
    width: 100%; height: 100%;
    background: var(--d2-surface);
    animation: d2-up .22s ease-out;
}
.d2-sheet__head {
    display: flex; align-items: center; gap: 8px;
    padding: 4px 8px; padding-top: calc(4px + env(safe-area-inset-top, 0px));
    border-bottom: 1px solid var(--d2-border);
}
.d2-sheet__title { flex: 1; font-size: 18px; font-weight: 700; }
.d2-sheet__body { position: relative; flex: 1; min-height: 0; background: #fff; }
.d2-sheet__body iframe { width: 100%; height: 100%; border: 0; display: block; }
.d2-sheet__body .d2-loading { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; background: var(--d2-surface); }
@keyframes d2-up { from { transform: translateY(24px); opacity: .4; } to { transform: none; opacity: 1; } }

/* ---------- Toast ---------- */
.d2-toast {
    position: fixed; left: 50%; bottom: calc(var(--d2-nav-h) + 16px + env(safe-area-inset-bottom, 0px));
    transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
    background: #0F172A; color: #fff; padding: 12px 18px; border-radius: 12px;
    font-size: 14px; font-weight: 600; z-index: 1200; max-width: calc(100vw - 32px);
    transition: opacity .2s, transform .2s;
}
.d2-toast.visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Navegación (inferior en móvil, riel en escritorio) ---------- */
.d2-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 900;
    display: flex; align-items: stretch; justify-content: space-around;
    height: calc(var(--d2-nav-h) + env(safe-area-inset-bottom, 0px));
    padding: 0 max(4px, env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(4px, env(safe-area-inset-left, 0px));
    background: var(--d2-surface);
    border-top: 1px solid var(--d2-border);
}
.d2-nav__brand { display: none; }
.d2-nav__item {
    flex: 1; min-width: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    color: var(--d2-muted) !important; text-decoration: none !important;
    font-size: 11.5px; font-weight: 600; letter-spacing: .01em;
    -webkit-tap-highlight-color: transparent;
}
.d2-nav__pill {
    display: flex; align-items: center; justify-content: center;
    width: 56px; height: 30px; border-radius: 15px;
    transition: background .2s;
}
.d2-nav__item:hover .d2-nav__pill { background: var(--d2-surface-2); }
.d2-nav__item.is-activa { color: var(--d2-brand) !important; font-weight: 800; }
html[data-theme="dark"] .d2-nav__item.is-activa { color: var(--d2-accent) !important; }
.d2-nav__item.is-activa .d2-nav__pill { background: var(--d2-accent-soft); }
.d2-nav__label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; padding: 0 2px; }

/* Aviso para instalar */
.d2-install {
    display: none; position: fixed; left: 12px; right: 12px; z-index: 880;
    bottom: calc(var(--d2-nav-h) + 12px + env(safe-area-inset-bottom, 0px));
    align-items: center; gap: 10px; padding: 12px 14px;
    background: var(--d2-brand); color: #fff; border-radius: 14px; box-shadow: var(--d2-shadow-lg);
    font-size: 14px;
}
.d2-install.visible { display: flex; }
.d2-install strong { display: block; font-size: 15px; }
.d2-install .txt { flex: 1; line-height: 1.3; }
.d2-install button { border: 0; border-radius: 10px; padding: 9px 14px; font-weight: 800; cursor: pointer; }
.d2-install .si { background: #fff; color: var(--d2-brand); }
.d2-install .no { background: rgba(255,255,255,.16); color: #fff; padding: 9px 11px; }

/* ---------- Pantallas de acceso (login / registro) ---------- */
.d2-auth { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; background: var(--d2-bg); }
.d2-auth__brand {
    position: relative;
    background: var(--d2-hero); color: #fff; text-align: center;
    padding: calc(20px + env(safe-area-inset-top, 0px)) 20px 54px;
}
.d2-auth__logo {
    width: 76px; height: 76px; margin: 0 auto 10px; border-radius: 50%; background: #fff;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 12px 30px rgba(0, 0, 0, .25);
}
.d2-auth__logo img { width: 52px; height: 52px; }
.d2-auth__name { font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.d2-auth__tag { font-size: 15px; font-weight: 600; opacity: .8; margin-top: 2px; }
.d2-auth__points { display: none; }
.d2-auth__panel { flex: 1; display: flex; justify-content: center; padding: 0 12px 20px; margin-top: -36px; }
.d2-auth__card {
    width: 100%; max-width: 440px;
    background: var(--d2-surface); border: 1px solid var(--d2-border); border-radius: 18px;
    padding: 20px 16px; box-shadow: var(--d2-shadow-lg);
    align-self: flex-start;
}
.d2-auth__title { font-size: 22px; font-weight: 800; }
.d2-auth__sub { color: var(--d2-muted); font-size: 13.5px; margin: 2px 0 16px; }
.d2-divider { display: flex; align-items: center; gap: 12px; color: var(--d2-faint); font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; margin: 14px 0; }
.d2-divider::before, .d2-divider::after { content: ''; flex: 1; height: 1px; background: var(--d2-border); }
.d2-btn--google { background: var(--d2-surface); color: var(--d2-text) !important; border-color: var(--d2-border); }
.d2-btn--google:hover { background: var(--d2-surface-2); }

/* ==========================================================================
   Tablet
   ========================================================================== */
@media (min-width: 600px) {
    :root { --d2-gutter: 18px; }
    .d2-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
    .d2-tile { min-height: 104px; }
    .d2-hero { padding-bottom: 16px; }
    .d2-chips { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; }
    .d2-nav__label { font-size: 12.5px; }
    .d2-amounts { grid-template-columns: repeat(6, minmax(0, 1fr)); }
    .d2-toast { bottom: calc(var(--d2-nav-h) + 24px); }
    .d2-install { left: auto; right: 20px; max-width: 380px; }
    .d2-auth__card { padding: 24px 22px; }
    .d2-sheet { align-items: center; padding: 24px; }
    .d2-sheet__panel { width: min(980px, 100%); height: min(860px, 100%); border-radius: 18px; overflow: hidden; box-shadow: var(--d2-shadow-lg); }
    .d2-sheet__head { padding-top: 8px; }
}

/* ==========================================================================
   Escritorio: riel lateral
   ========================================================================== */
@media (min-width: 1024px) {
    :root { --d2-gutter: 24px; --d2-topbar-h: 56px; }
    .d2-app { padding-bottom: 0; padding-left: var(--d2-rail-w); }
    .d2-app--sin-nav { padding-left: 0; }

    .d2-nav {
        top: 0; right: auto; bottom: 0; left: 0;
        width: var(--d2-rail-w); height: auto;
        flex-direction: column; justify-content: flex-start; gap: 4px;
        padding: 14px 0;
        border-top: 0; border-right: 1px solid var(--d2-border);
    }
    .d2-nav__brand {
        display: flex; align-items: center; justify-content: center;
        width: 46px; height: 46px; margin: 0 auto 14px; border-radius: 13px;
        background: var(--d2-accent-soft);
    }
    .d2-nav__brand img { width: 32px; height: 32px; }
    .d2-nav__item { flex: none; height: 62px; }
    .d2-nav__pill { width: 52px; height: 30px; }

    .d2-topbar { padding-left: var(--d2-gutter); padding-right: var(--d2-gutter); }
    .d2-topbar__title { font-size: 20px; }

    /* La cabecera azul pasa a ser una tarjeta dentro del contenido */
    .d2-hero { background: transparent; padding: 16px var(--d2-gutter) 0; }
    .d2-hero__inner { background: var(--d2-hero); border-radius: 16px; padding: 16px 20px; }
    .d2-hero__saldo { font-size: 38px; }

    .d2-cols--2 { grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr); gap: 18px; }
    .d2-cols--2-even { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
    .d2-cols--form { grid-template-columns: minmax(0, 1fr) minmax(300px, 360px); gap: 18px; }
    .d2-sticky { position: sticky; top: 72px; }
    .d2-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
    .d2-tile { min-height: 108px; font-size: 14.5px; }

    .d2-toast { bottom: 28px; left: calc(50% + var(--d2-rail-w) / 2); }
    .d2-install { bottom: 24px; }

    /* Acceso: pantalla dividida */
    .d2-auth { flex-direction: row; }
    .d2-auth__brand {
        flex: 0 0 44%; display: flex; flex-direction: column; align-items: center; justify-content: center;
        padding: 48px; position: sticky; top: 0; height: 100vh;
    }
    .d2-auth__logo { width: 120px; height: 120px; }
    .d2-auth__logo img { width: 82px; height: 82px; }
    .d2-auth__name { font-size: 38px; }
    .d2-auth__tag { font-size: 18px; }
    .d2-auth__points { display: grid; gap: 14px; margin-top: 40px; text-align: left; max-width: 340px; }
    .d2-auth__points div { display: flex; gap: 12px; align-items: center; font-weight: 600; font-size: 15px; opacity: .92; }
    .d2-auth__points .d2-ico { width: 38px; height: 38px; padding: 8px; border-radius: 10px; background: rgba(255,255,255,.12); }
    .d2-auth__panel { align-items: center; margin-top: 0; padding: 40px; }
    .d2-auth__card { align-self: center; box-shadow: none; }
}

@media (min-width: 1440px) {
    .d2-tiles--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* Pantallas muy angostas (≤ 360px) */
@media (max-width: 360px) {
    :root { --d2-gutter: 10px; }
    .d2-tiles { gap: 8px; }
    .d2-tile { min-height: 88px; font-size: 13.5px; padding: 10px 6px; }
    .d2-nav__pill { width: 46px; }
    .d2-nav__label { font-size: 11px; }
    .d2-stats { gap: 8px; }
    .d2-stat { padding: 10px; }
    .d2-stat__value { font-size: 17px; }
    .d2-hero__today-sub { white-space: normal; }
}

/* Horizontal en celular: barra más baja */
@media (max-height: 480px) and (orientation: landscape) and (max-width: 1023px) {
    :root { --d2-nav-h: 56px; }
    .d2-nav__label { display: none; }
}

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

@media print {
    .d2-nav, .d2-topbar .d2-iconbtn, .d2-install, .d2-toast { display: none !important; }
    .d2-app { padding: 0 !important; }
    body.d2 { background: #fff; }
}

/* ==========================================================================
   Venta integrada (venta.js) — mismo flujo que la app, sin iframe
   ========================================================================== */
.d2-sheet--venta .d2-sheet__panel { background: var(--d2-bg); }
.d2-sheet--venta .d2-sheet__head { background: var(--d2-surface); }
.v-body { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 12px; }
.v-foot {
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
    background: var(--d2-surface); border-top: 1px solid var(--d2-border);
}
.v-logo { width: 42px; height: 42px; border-radius: 11px; object-fit: contain; background: #fff; border: 1px solid var(--d2-border); flex: none; }
.v-ops .d2-tile { min-height: 94px; font-size: 13.5px; font-weight: 700; }
.v-nota { margin-top: 14px; text-align: center; font-size: 13px; color: var(--d2-muted); }
.v-opciones { display: grid; gap: 8px; margin-top: 10px; }
.v-opcion {
    display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; cursor: pointer;
    padding: 10px 13px; min-height: 54px;
    background: var(--d2-surface); color: var(--d2-text);
    border: 1.5px solid var(--d2-border); border-radius: 11px;
    transition: border-color .15s, background .15s;
}
.v-opcion:hover { border-color: var(--d2-border-strong); }
.v-opcion.is-active { border-color: var(--d2-accent); background: var(--d2-accent-soft); }
.v-opcion__body { flex: 1; min-width: 0; }
.v-opcion__body strong { display: block; font-size: 15px; }
.v-opcion__body small { display: block; font-size: 13px; color: var(--d2-muted); font-weight: 500; }
.v-opcion__precio { font-size: 16px; font-weight: 800; white-space: nowrap; }
.v-opciones + *, #vOpciones .d2-banner, #vTitular .d2-banner { margin-top: 10px; }
.v-confirma__top { display: flex; align-items: center; gap: 12px; }
.v-confirma__monto { font-size: clamp(28px, 8vw, 36px); font-weight: 800; letter-spacing: -.02em; margin: 12px 0 6px; }
.v-kv { display: grid; grid-template-columns: auto 1fr; gap: 7px 14px; margin: 0; font-size: 14px; }
.v-kv dt { color: var(--d2-muted); font-weight: 600; }
.v-kv dd { margin: 0; text-align: right; font-weight: 700; word-break: break-word; }
.v-ficha .v-kv { margin-top: 6px; gap: 4px 12px; font-size: 13.5px; }
.v-ficha .v-kv dd { text-align: left; color: var(--d2-text); }
.v-res { text-align: center; padding: 12px 8px 12px; }
.v-res h3 { font-size: 19px; margin-top: 14px; }
.v-res p { color: var(--d2-muted); margin-top: 6px; }
.v-res__monto { font-size: clamp(30px, 8.5vw, 38px); font-weight: 800; letter-spacing: -.02em; margin-top: 6px; }
.v-res__aviso { margin: 14px auto 0; max-width: 360px; padding: 10px 14px; border-radius: 10px; background: var(--d2-warn-soft); color: var(--d2-warn) !important; font-weight: 700; font-size: 14px; }
.v-res__ico { width: 64px; height: 64px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; }
.v-res__ico .d2-ico { width: 34px; height: 34px; }
.v-res__ico--ok { background: var(--d2-success-soft); color: var(--d2-success); }
.v-res__ico--warn { background: var(--d2-warn-soft); color: var(--d2-warn); }
.v-res__ico--bad { background: var(--d2-danger-soft); color: var(--d2-danger); }
.v-spin { width: 56px; height: 56px; border-width: 4px; }
.v-token {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 10px 14px; margin-bottom: 10px; border-radius: 12px;
    background: var(--d2-surface); border: 1.5px dashed var(--d2-success);
}
.v-token strong { display: block; font-family: var(--d2-mono); font-size: clamp(18px, 5.4vw, 24px); letter-spacing: .06em; margin-top: 2px; }
.v-acciones { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.v-body .d2-card + .d2-card { margin-top: 12px; }
#d2Recibo { display: none; }

@media (min-width: 600px) {
    .d2-sheet--venta .d2-sheet__panel { width: min(600px, 100%); height: min(860px, 100%); }
    .v-body { padding: 16px 20px; }
    .v-foot { padding: 12px 20px; }
    .v-ops { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media print {
    body.d2-imprimiendo > * { display: none !important; }
    body.d2-imprimiendo > #d2Recibo {
        display: block !important; margin: 0 auto; width: 72mm; padding: 4mm 0;
        font: 12px/1.45 var(--d2-mono); color: #000; white-space: pre-wrap; text-align: left;
    }
}
