/* =====================================================================
   Lavadero Pro - Hoja de estilos
   Paleta azul/gris · mobile-first · sin dependencias externas
   Índice:
     1. Variables y base          8. Tablas
     2. Utilidades                9. Badges, chips y alertas
     3. Layout (sidebar/topbar)  10. Panel (stats, gráficos, agenda)
     4. Autenticación            11. Ventas y cobros
     5. Encabezados y grillas    12. Comprobante
     6. Tarjetas                 13. Páginas especiales
     7. Botones y formularios    14. Responsive (escritorio) e impresión
   ===================================================================== */

/* 1. Variables y base ------------------------------------------------- */
:root {
    --primary: #1d4ed8;
    --primary-600: #1e40af;
    --primary-50: #eff6ff;
    --primary-100: #dbeafe;
    --primary-200: #bfdbfe;

    --gray-900: #0f172a;
    --gray-800: #1e293b;
    --gray-700: #334155;
    --gray-600: #475569;
    --gray-500: #64748b;
    --gray-400: #94a3b8;
    --gray-300: #cbd5e1;
    --gray-200: #e2e8f0;
    --gray-100: #f1f5f9;
    --gray-50: #f8fafc;

    --success: #15803d;
    --success-bg: #dcfce7;
    --warning: #b45309;
    --warning-bg: #fef3c7;
    --danger: #b91c1c;
    --danger-bg: #fee2e2;
    --info: #0369a1;
    --info-bg: #e0f2fe;

    --bg: #f1f5f9;
    --surface: #ffffff;
    --text: var(--gray-800);
    --muted: var(--gray-500);
    --border: var(--gray-200);

    --radius: 10px;
    --radius-sm: 6px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
    --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 4px 12px rgba(15, 23, 42, .04);
    --shadow-lg: 0 10px 30px rgba(15, 23, 42, .15);

    --sidebar-w: 248px;
    --topbar-h: 60px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; line-height: 1.25; color: var(--gray-900); }
h1 { font-size: 1.4rem; font-weight: 700; }
h2 { font-size: 1.1rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0 0 .75rem; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: .85em; background: var(--gray-100); padding: .1em .35em; border-radius: 4px; }
img { max-width: 100%; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.icon { width: 18px; height: 18px; flex-shrink: 0; vertical-align: -3px; }
.icon-lg { width: 36px; height: 36px; }
.icon-xl { width: 48px; height: 48px; }

/* 2. Utilidades ------------------------------------------------------- */
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.text-center { text-align: center; }
.text-danger { color: var(--danger) !important; }
.d-block { display: block; }
.inline { display: inline; }
.req { color: var(--danger); }
.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;
}
.stack { display: grid; gap: 1rem; align-content: start; }
.hide-sm { display: none; }

/* 3. Layout ----------------------------------------------------------- */
.app { min-height: 100vh; }

.sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 50;
    width: var(--sidebar-w); max-width: 85vw;
    display: flex; flex-direction: column;
    background: var(--gray-900); color: var(--gray-300);
    transform: translateX(-100%);
    transition: transform .25s ease;
}
body.sidebar-open .sidebar { transform: translateX(0); box-shadow: var(--shadow-lg); }

.sidebar-backdrop {
    position: fixed; inset: 0; z-index: 40;
    background: rgba(15, 23, 42, .5);
    opacity: 0; pointer-events: none; transition: opacity .25s;
}
body.sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }

.sidebar-brand {
    display: flex; align-items: center; justify-content: space-between;
    height: var(--topbar-h); padding: 0 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.brand { display: flex; align-items: center; gap: .6rem; color: #fff; font-weight: 700; font-size: 1.05rem; }
.brand:hover { text-decoration: none; }
.brand-logo {
    display: grid; place-items: center; width: 34px; height: 34px;
    border-radius: 9px; background: var(--primary); color: #fff;
}
.sidebar-close { background: none; border: 0; color: var(--gray-400); cursor: pointer; padding: .4rem; border-radius: 6px; }
.sidebar-close:hover { color: #fff; background: rgba(255, 255, 255, .08); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: .75rem .6rem; }
.nav-group { margin-bottom: 1rem; }
.nav-group-title {
    display: block; padding: .25rem .75rem; margin-bottom: .2rem;
    font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--gray-500);
}
.nav-link {
    display: flex; align-items: center; gap: .7rem;
    padding: .55rem .75rem; margin-bottom: 2px;
    border-radius: 8px; color: var(--gray-300); font-size: .92rem; font-weight: 500;
    transition: background .15s, color .15s;
}
.nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.nav-link.active { background: var(--primary); color: #fff; }
.nav-badge {
    margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 10px;
    background: var(--danger); color: #fff; font-size: .72rem; font-weight: 700; text-align: center; line-height: 20px;
}
.sidebar-footer { padding: .75rem 1rem; border-top: 1px solid rgba(255, 255, 255, .08); }

.main { display: flex; flex-direction: column; min-height: 100vh; min-width: 0; }

.topbar {
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; gap: .75rem;
    height: var(--topbar-h); padding: 0 1rem;
    background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar-toggle {
    display: grid; place-items: center; width: 40px; height: 40px;
    background: none; border: 1px solid var(--border); border-radius: 8px; color: var(--gray-700); cursor: pointer;
}
.topbar-title { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-user { display: flex; align-items: center; gap: .5rem; }
.user-chip { display: flex; align-items: center; gap: .5rem; color: var(--text); padding: .25rem; border-radius: 8px; }
.user-chip:hover { background: var(--gray-100); text-decoration: none; }
.user-avatar {
    display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
    background: var(--primary-100); color: var(--primary); font-weight: 700;
}
.user-info { display: none; flex-direction: column; line-height: 1.2; }
.user-info small { color: var(--muted); font-size: .75rem; }

.content { flex: 1; width: 100%; max-width: 1400px; margin: 0 auto; padding: 1rem; }

.app-footer {
    display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
    padding: 1rem; font-size: .8rem; color: var(--muted); border-top: 1px solid var(--border);
}

/* 4. Autenticación ---------------------------------------------------- */
.layout-auth {
    background: linear-gradient(135deg, var(--primary-600) 0%, var(--primary) 45%, #3b82f6 100%);
}
.auth-wrap {
    min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 1.5rem 1rem;
}
.auth-wrap .flash-stack { width: 100%; max-width: 400px; }
.auth-card { width: 100%; max-width: 400px; padding: 2rem 1.5rem; box-shadow: var(--shadow-lg); }
.auth-header { text-align: center; margin-bottom: 1.5rem; }
.auth-header h1 { margin: .75rem 0 .25rem; }
.auth-logo { max-height: 72px; max-width: 200px; }
.auth-logo-icon {
    display: inline-grid; place-items: center; width: 72px; height: 72px; border-radius: 18px;
    background: var(--primary-50); color: var(--primary);
}
.auth-footer { text-align: center; margin: 1.25rem 0 0; }

/* 5. Encabezados y grillas -------------------------------------------- */
.page-header {
    display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: .75rem;
    margin-bottom: 1.25rem;
}
.page-header p { margin: .25rem 0 0; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; }

.grid { display: grid; gap: 1rem; margin-bottom: 1rem; grid-template-columns: minmax(0, 1fr); }
.grid > * { min-width: 0; }
.align-start { align-items: start; }

/* 6. Tarjetas --------------------------------------------------------- */
.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-sm); margin-bottom: 1rem;
}
.grid > .card, .stack > .card { margin-bottom: 0; }
.card-header {
    display: flex; align-items: center; justify-content: space-between; gap: .75rem;
    padding: .85rem 1rem; border-bottom: 1px solid var(--border);
}
.card-title { display: flex; align-items: center; gap: .5rem; font-size: 1rem; }
.card-title .icon { color: var(--primary); }
.card-body { padding: 1rem; }
.card-footer { padding: .85rem 1rem; border-top: 1px solid var(--border); background: var(--gray-50); border-radius: 0 0 var(--radius) var(--radius); }
.card-narrow { max-width: 760px; }
.card-danger { border-color: #fecaca; }
.card-danger .card-header { background: var(--danger-bg); color: var(--danger); border-radius: var(--radius) var(--radius) 0 0; }
.card-danger .card-title, .card-danger .card-title .icon { color: var(--danger); }
.card-link { display: block; color: inherit; transition: transform .15s, box-shadow .15s, border-color .15s; }
.card-link:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--primary-200); }
.card-link .card-title { margin: .75rem 0 .35rem; }
.card-link-icon {
    display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 10px;
    background: var(--primary-50); color: var(--primary);
}

/* 7. Botones y formularios -------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    min-height: 40px; padding: .5rem 1rem;
    font: inherit; font-size: .9rem; font-weight: 600; line-height: 1.2; white-space: nowrap;
    border: 1px solid transparent; border-radius: 8px; cursor: pointer;
    transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .05s;
    text-decoration: none !important; user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.is-loading { opacity: .65; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-600); }
.btn-secondary { background: var(--surface); color: var(--gray-700); border-color: var(--gray-300); }
.btn-secondary:hover { background: var(--gray-50); border-color: var(--gray-400); color: var(--gray-900); }
.btn-ghost { background: transparent; color: var(--gray-600); }
.btn-ghost:hover { background: var(--gray-100); color: var(--gray-900); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #166534; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #991b1b; }
.btn-sm { min-height: 34px; padding: .35rem .7rem; font-size: .83rem; }
.btn-xs { min-height: 28px; padding: .2rem .55rem; font-size: .78rem; border-radius: 6px; }
.btn-lg { min-height: 48px; padding: .7rem 1.3rem; font-size: 1rem; }
.btn-block { width: 100%; }

.form { margin: 0; }
.form-grid { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr); }
.field { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.field label, .field > span:first-child { font-size: .85rem; font-weight: 600; color: var(--gray-700); }
.fieldset { border: 0; padding: 0; margin: 0 0 1.25rem; }
.fieldset legend {
    width: 100%; padding-bottom: .4rem; margin-bottom: .9rem;
    font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em;
    color: var(--primary); border-bottom: 1px solid var(--border);
}

.input {
    width: 100%; min-height: 42px; padding: .55rem .75rem;
    font: inherit; font-size: 16px; /* evita zoom en iOS */
    color: var(--text); background: var(--surface);
    border: 1px solid var(--gray-300); border-radius: 8px;
    transition: border-color .15s, box-shadow .15s;
}
textarea.input { min-height: 80px; resize: vertical; }
select.input { padding-right: 2rem; }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(29, 78, 216, .15); }
.input[readonly] { background: var(--gray-50); }
.input-upper { text-transform: uppercase; }
.input-money { text-align: right; font-variant-numeric: tabular-nums; }
.input-qty { width: 80px; text-align: center; }
.input-static { margin: 0; min-height: 42px; display: flex; align-items: center; gap: .75rem; }
.has-error .input, .input.is-invalid { border-color: var(--danger); }
.has-error .input:focus { box-shadow: 0 0 0 3px rgba(185, 28, 28, .15); }
.field-error { color: var(--danger); font-size: .8rem; font-weight: 500; }
.hint { color: var(--muted); font-size: .8rem; }

.input-icon { position: relative; }
.input-icon > .icon { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--gray-400); pointer-events: none; }
.input-icon .input { padding-left: 2.4rem; }
.input-action {
    position: absolute; right: .35rem; top: 50%; transform: translateY(-50%);
    background: none; border: 0; padding: .4rem; border-radius: 6px; color: var(--gray-500); cursor: pointer;
}
.input-action:hover { color: var(--primary); background: var(--gray-100); }
.input-icon .input-action ~ .input, .input-icon .input:has(+ .input-action) { padding-right: 2.6rem; }

.input-suffix { display: flex; }
.input-suffix .input { border-radius: 8px 0 0 8px; }
.input-suffix > span {
    display: grid; place-items: center; padding: 0 .8rem;
    background: var(--gray-100); border: 1px solid var(--gray-300); border-left: 0; border-radius: 0 8px 8px 0;
    color: var(--gray-600); font-size: .9rem;
}
.input-group { display: flex; gap: .5rem; }
.input-group .input { flex: 1; min-width: 0; }

.check { display: inline-flex; align-items: center; gap: .55rem; cursor: pointer; font-weight: 500 !important; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.check-inline { min-height: 42px; }

.form-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .5rem; margin-top: 1.25rem; }
.card-footer.form-actions { margin-top: 0; }
.form-actions-stack { flex-direction: column; align-items: stretch; }

.filters {
    display: grid; gap: .75rem; padding: 1rem; grid-template-columns: minmax(0, 1fr);
    align-items: end;
}
.filters-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.quick-ranges { display: inline-flex; gap: .25rem; flex-wrap: wrap; }

/* 8. Tablas ----------------------------------------------------------- */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th {
    padding: .65rem 1rem; text-align: left; white-space: nowrap;
    font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
    color: var(--gray-500); background: var(--gray-50); border-bottom: 1px solid var(--border);
}
.table td { padding: .7rem 1rem; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
.table th.num, .table td.num { text-align: right; }
.table tbody tr:last-child td { border-bottom: 0; }
.table-hover tbody tr { transition: background .1s; }
.table-hover tbody tr:hover { background: var(--primary-50); }
.table-compact th { padding: .5rem .75rem; }
.table-compact td { padding: .5rem .75rem; }
.table tfoot td { padding: .6rem 1rem; border-top: 1px solid var(--border); background: var(--gray-50); font-weight: 500; }
.table-compact tfoot td { padding: .5rem .75rem; }
.row-total td { font-weight: 700 !important; color: var(--gray-900); font-size: 1rem; }
.row-warning { background: #fffbeb; }
.row-warning:hover { background: #fef3c7 !important; }
tr[data-href] { cursor: pointer; }
.actions-col { text-align: right; white-space: nowrap; width: 1%; }
.actions-col .btn + .btn, .actions-col .btn + form, .actions-col form + .btn { margin-left: .15rem; }
.check-col { width: 40px; text-align: center !important; }
.check-col input { width: 18px; height: 18px; accent-color: var(--primary); }

.stock-pill {
    display: inline-flex; align-items: center; gap: .25rem;
    padding: .1rem .55rem; border-radius: 999px; font-weight: 600;
    background: var(--gray-100); color: var(--gray-700);
}
.stock-pill.is-low { background: var(--danger-bg); color: var(--danger); }
.stock-pill .icon { width: 14px; height: 14px; }

/* Tablas responsivas: en móvil cada fila se muestra como tarjeta */
@media (max-width: 767px) {
    .table-responsive thead { display: none; }
    .table-responsive, .table-responsive tbody, .table-responsive tr, .table-responsive td { display: block; width: 100%; }
    .table-responsive tfoot { display: table; width: 100%; }
    .table-responsive tbody tr { padding: .6rem .9rem; border-bottom: 1px solid var(--border); }
    .table-responsive tbody td {
        display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem;
        padding: .3rem 0; border: 0; text-align: right;
    }
    .table-responsive tbody td::before {
        content: attr(data-label);
        flex-shrink: 0; text-align: left;
        font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--muted);
    }
    .table-responsive tbody td:not([data-label])::before { content: none; }
    .table-responsive tbody td > *:only-child { margin-left: auto; }
    .table-responsive td.actions-col { justify-content: flex-end; width: 100%; padding-top: .5rem; }
    .table-responsive td.check-col { justify-content: flex-start; }
    .table-responsive .d-block { text-align: right; }
}

/* 9. Badges, chips y alertas ------------------------------------------ */
.badge {
    display: inline-flex; align-items: center; padding: .15rem .55rem; border-radius: 999px;
    font-size: .74rem; font-weight: 600; line-height: 1.5; white-space: nowrap; vertical-align: middle;
}
.badge-primary { background: var(--primary-100); color: var(--primary-600); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-muted { background: var(--gray-100); color: var(--gray-600); }

.chips { display: flex; flex-wrap: wrap; gap: .4rem; padding: .75rem 1rem; }
.chips-lg { padding: 0; margin-bottom: 1rem; }
.chip {
    display: inline-flex; align-items: center; gap: .3rem;
    padding: .3rem .75rem; border-radius: 999px; font-size: .82rem;
    background: var(--surface); border: 1px solid var(--border); color: var(--gray-600);
}
a.chip:hover { text-decoration: none; border-color: var(--gray-400); }
.chip strong { color: var(--gray-900); }
.chip-pendiente { background: var(--warning-bg); border-color: #fde68a; }
.chip-en_proceso { background: var(--info-bg); border-color: #bae6fd; }
.chip-finalizado { background: var(--success-bg); border-color: #bbf7d0; }
.chip-cancelado { background: var(--gray-100); }

.flash-stack { display: grid; gap: .5rem; margin-bottom: 1rem; }
.alert {
    display: flex; align-items: flex-start; gap: .65rem;
    padding: .8rem 1rem; margin-bottom: 1rem; border-radius: var(--radius);
    border: 1px solid transparent; font-size: .92rem;
    animation: alert-in .25s ease;
}
.flash-stack .alert { margin-bottom: 0; }
.alert-icon { margin-top: 1px; }
.alert-text { flex: 1; }
.alert-success { background: var(--success-bg); border-color: #bbf7d0; color: #14532d; }
.alert-error { background: var(--danger-bg); border-color: #fecaca; color: #7f1d1d; }
.alert-warning { background: var(--warning-bg); border-color: #fde68a; color: #78350f; }
.alert-info { background: var(--info-bg); border-color: #bae6fd; color: #0c4a6e; }
.alert-close { background: none; border: 0; padding: .1rem; cursor: pointer; color: inherit; opacity: .6; border-radius: 4px; }
.alert-close:hover { opacity: 1; }
@keyframes alert-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.empty { padding: 2.5rem 1rem; text-align: center; color: var(--muted); }
.empty .icon { color: var(--gray-300); margin-bottom: .5rem; }
.empty p { margin-bottom: .75rem; }
.empty-sm { padding: 1.25rem 1rem; }
.empty-sm p { margin: 0; }

/* 10. Panel ------------------------------------------------------------ */
.stats { margin-bottom: 1rem; }
.stat {
    position: relative; display: flex; flex-direction: column; gap: .2rem;
    padding: 1rem 1.1rem; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm);
    border-left: 4px solid var(--gray-300);
}
.stat-primary { border-left-color: var(--primary); }
.stat-success { border-left-color: var(--success); }
.stat-warning { border-left-color: #f59e0b; }
.stat-danger { border-left-color: var(--danger); }
.stat-icon {
    position: absolute; top: 1rem; right: 1rem; display: grid; place-items: center;
    width: 36px; height: 36px; border-radius: 9px; background: var(--primary-50); color: var(--primary);
}
.stat-danger .stat-icon { background: var(--danger-bg); color: var(--danger); }
.stat-warning .stat-icon { background: var(--warning-bg); color: var(--warning); }
.stat-success .stat-icon { background: var(--success-bg); color: var(--success); }
.stat-label { font-size: .8rem; font-weight: 600; color: var(--muted); padding-right: 2.75rem; }
.stat-value { font-size: 1.5rem; font-weight: 700; color: var(--gray-900); font-variant-numeric: tabular-nums; }
.stat-value-sm { font-size: 1.05rem; }
.stat-hint { font-size: .8rem; color: var(--muted); }
.stat-link { font-size: .82rem; font-weight: 600; }

.bar-chart { display: flex; align-items: flex-end; gap: .5rem; height: 200px; padding-top: 1.25rem; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.bar {
    width: 100%; max-width: 48px; height: var(--h, 0%); min-height: 3px;
    background: linear-gradient(180deg, #60a5fa, var(--primary));
    border-radius: 6px 6px 2px 2px; transition: height .4s ease;
}
.bar-col.is-today .bar { background: linear-gradient(180deg, #34d399, var(--success)); }
.bar-col:hover .bar { filter: brightness(1.1); }
.bar-value { font-size: .65rem; color: var(--muted); margin-bottom: .25rem; white-space: nowrap; }
.bar-label { font-size: .75rem; color: var(--gray-600); margin-top: .35rem; white-space: nowrap; }
.bar-chart-wide { overflow-x: auto; gap: 3px; }
.bar-chart-wide .bar-col { min-width: 18px; }
.bar-chart-wide .bar-label { font-size: .62rem; writing-mode: vertical-rl; transform: rotate(180deg); }

.progress-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .85rem; }
.progress-head { display: flex; justify-content: space-between; font-size: .88rem; margin-bottom: .3rem; }
.progress { height: 8px; background: var(--gray-100); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; width: var(--p, 0%); background: var(--primary); border-radius: 999px; }
.progress-inline { display: inline-block; width: calc(100% - 3.5rem); vertical-align: middle; margin-right: .4rem; }

.agenda { list-style: none; margin: 0; padding: 0; }
.agenda-item {
    display: grid; grid-template-columns: 52px 1fr; gap: .25rem .75rem; align-items: center;
    padding: .75rem 1rem; border-top: 1px solid var(--gray-100); border-left: 3px solid transparent;
}
.agenda-item.estado-pendiente { border-left-color: #f59e0b; }
.agenda-item.estado-en_proceso { border-left-color: #0ea5e9; background: #f0f9ff; }
.agenda-item.estado-finalizado { border-left-color: var(--success); opacity: .8; }
.agenda-item.estado-cancelado { border-left-color: var(--gray-300); opacity: .55; }
.agenda-time { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--gray-900); }
.agenda-body { display: flex; flex-direction: column; min-width: 0; }
.agenda-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; justify-content: flex-end; }

.day-nav { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .6rem; }
.day-nav-form { display: flex; align-items: center; gap: .5rem; }
.day-nav-form .input { width: auto; }

.timeline { display: grid; gap: .75rem; }
.timeline-item {
    display: grid; grid-template-columns: 64px 1fr; gap: .5rem 1rem; padding: 1rem; margin: 0;
    border-left: 4px solid var(--gray-300);
}
.timeline-item.estado-pendiente { border-left-color: #f59e0b; }
.timeline-item.estado-en_proceso { border-left-color: #0ea5e9; }
.timeline-item.estado-finalizado { border-left-color: var(--success); }
.timeline-item.estado-cancelado { border-left-color: var(--gray-300); opacity: .65; }
.timeline-time { display: flex; flex-direction: column; }
.timeline-time strong { font-size: 1.15rem; color: var(--gray-900); font-variant-numeric: tabular-nums; }
.timeline-head { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: .25rem; }
.timeline-meta { display: flex; flex-wrap: wrap; gap: .35rem 1rem; margin: 0; color: var(--gray-600); font-size: .88rem; }
.timeline-meta span { display: inline-flex; align-items: center; gap: .3rem; }
.timeline-meta .icon { width: 15px; height: 15px; color: var(--gray-400); }
.timeline-notes { margin: .5rem 0 0; padding: .5rem .75rem; background: var(--gray-50); border-radius: 6px; font-size: .85rem; color: var(--gray-600); }
.timeline-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: .4rem; justify-content: flex-end; }

.data-list { display: grid; grid-template-columns: minmax(110px, auto) 1fr; gap: .5rem 1rem; margin: 0; }
.data-list dt { color: var(--muted); font-size: .85rem; }
.data-list dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.pagination-bar {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem;
    padding: .75rem 1rem; border-top: 1px solid var(--border);
}
.pagination { display: flex; gap: .25rem; flex-wrap: wrap; }
.page-link {
    display: grid; place-items: center; min-width: 34px; height: 34px; padding: 0 .5rem;
    border-radius: 7px; border: 1px solid var(--border); background: var(--surface);
    color: var(--gray-700); font-size: .85rem; font-weight: 600;
}
.page-link:hover { background: var(--gray-50); text-decoration: none; }
.page-link.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-link.disabled { opacity: .4; pointer-events: none; }
.page-link.dots { border: 0; background: none; }

/* 11. Ventas y cobros -------------------------------------------------- */
.add-row { display: flex; gap: .5rem; align-items: flex-end; margin-bottom: .75rem; }
.add-row .field { flex: 1; }
.table-items { margin: .5rem 0 1rem; }
.table-items .item-tipo { margin-right: .35rem; }

.totales { display: grid; gap: .55rem; margin: 0; }
.totales > div { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.totales dt { color: var(--gray-600); }
.totales dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 600; }
.totales-descuento dd { max-width: 150px; }
.totales-total { padding-top: .6rem; border-top: 2px solid var(--gray-200); }
.totales-total dt { font-weight: 700; color: var(--gray-900); }
.totales-total dd { font-size: 1.5rem; font-weight: 800; color: var(--primary); }

.pagos-head { display: none; }
.pagos-rows { display: grid; gap: .6rem; }
.pago-row {
    display: grid; grid-template-columns: 1fr 1fr auto; gap: .5rem; align-items: start;
    padding: .6rem; border: 1px solid var(--border); border-radius: 8px; background: var(--gray-50);
}
.pago-row .field:nth-child(3) { grid-column: 1 / 3; }
.pago-row [data-pago-quitar] { grid-row: 1; grid-column: 3; }
.pagos-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin: .75rem 0; }
.pagos-resumen {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin: 0 0 .5rem;
    padding: .75rem; background: var(--primary-50); border-radius: 8px; text-align: center;
}
.pagos-resumen dt { font-size: .72rem; text-transform: uppercase; color: var(--gray-500); font-weight: 600; }
.pagos-resumen dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.pagos-restante dd { color: var(--warning); }
.pagos.is-ok .pagos-restante dd { color: var(--success); }
.pagos.is-over .pagos-restante dd { color: var(--danger); }
.pagos-error { color: var(--danger); font-weight: 600; font-size: .88rem; margin: .25rem 0 .5rem; }

.sticky { position: static; }

.share-box { max-width: 820px; margin: 0 auto 1rem; }
.share-box label { display: block; margin-bottom: .3rem; }
.actions-bar { display: flex; justify-content: center; gap: .5rem; margin: 1rem 0; }

.logo-box {
    display: grid; place-items: center; min-height: 160px; padding: 1rem; margin-bottom: 1rem;
    border: 2px dashed var(--gray-300); border-radius: var(--radius); background: var(--gray-50);
}
.logo-box img { max-height: 140px; object-fit: contain; }

/* 12. Comprobante ------------------------------------------------------ */
.comprobante-wrap { display: flex; justify-content: center; }
.comprobante {
    position: relative; width: 100%; max-width: 820px; padding: 1.25rem;
    background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
    color: var(--gray-800); overflow: hidden;
}
.comprobante-sello {
    position: absolute; top: 42%; left: 50%; transform: translate(-50%, -50%) rotate(-22deg);
    font-size: clamp(3rem, 12vw, 6.5rem); font-weight: 900; letter-spacing: .1em;
    color: rgba(220, 38, 38, .14); border: 6px solid rgba(220, 38, 38, .14); padding: 0 1.5rem;
    pointer-events: none; white-space: nowrap;
}
.comprobante-header {
    display: flex; flex-direction: column; gap: 1rem; padding-bottom: 1rem; margin-bottom: 1rem;
    border-bottom: 3px solid var(--primary);
}
.comprobante-empresa { display: flex; gap: 1rem; align-items: flex-start; }
.comprobante-empresa h2 { color: var(--primary); font-size: 1.25rem; margin-bottom: .25rem; }
.comprobante-empresa p { margin: 0; font-size: .85rem; color: var(--gray-600); }
.comprobante-logo { max-width: 110px; max-height: 70px; object-fit: contain; }
.comprobante-numero { display: flex; flex-direction: column; text-align: left; }
.comprobante-numero span:first-child { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.comprobante-numero strong { font-size: 1.35rem; font-family: var(--mono); color: var(--gray-900); }
.comprobante-numero span:last-child { font-size: .85rem; color: var(--gray-600); }

.comprobante-datos { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem 1rem; margin-bottom: 1rem; }
.comprobante-datos div { display: flex; flex-direction: column; }
.comprobante-datos span { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }

.comprobante-items { width: 100%; border-collapse: collapse; margin-bottom: 1rem; font-size: .9rem; }
.comprobante-items th {
    padding: .5rem; text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em;
    color: var(--primary-600); background: var(--primary-50); border-bottom: 1px solid var(--primary-200);
}
.comprobante-items td { padding: .55rem .5rem; border-bottom: 1px solid var(--gray-100); }
.comprobante-items .num { text-align: right; }

.comprobante-pie { display: flex; flex-direction: column-reverse; gap: 1rem; }
.comprobante-qr { display: flex; flex-direction: column; align-items: center; gap: .25rem; text-align: center; }
.comprobante-qr img { width: 120px; height: 120px; }
.comprobante-qr small { font-size: .7rem; color: var(--muted); max-width: 140px; }
.comprobante-totales { flex: 1; }
.comprobante-totales dl { margin: 0; display: grid; gap: .3rem; }
.comprobante-totales dl > div { display: flex; justify-content: space-between; gap: 1rem; }
.comprobante-totales dd { margin: 0; font-variant-numeric: tabular-nums; }
.comprobante-total { padding-top: .5rem; margin-top: .25rem; border-top: 2px solid var(--gray-800); font-size: 1.25rem; font-weight: 800; }
.comprobante-pagos-titulo { margin: .9rem 0 .3rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.comprobante-pagos { font-size: .9rem; }
.comprobante-footer {
    margin-top: 1.25rem; padding-top: .75rem; border-top: 1px dashed var(--gray-300);
    text-align: center; font-size: .85rem; color: var(--gray-600);
}
.comprobante-footer p { margin: 0 0 .2rem; }
.comprobante-legal { font-size: .75rem; color: var(--muted); }

/* 13. Páginas especiales ---------------------------------------------- */
.layout-publico { background: var(--gray-100); }
.publico-wrap { max-width: 860px; margin: 0 auto; padding: 1rem; }
.publico-toolbar { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; margin-bottom: 1rem; }

.error-page { display: grid; place-items: center; min-height: 60vh; padding: 1rem; }
.error-card { max-width: 460px; width: 100%; padding: 2rem 1.5rem; text-align: center; }
.error-icon { color: var(--primary); margin-bottom: .5rem; }
.error-code { margin: 0; font-size: 3rem; font-weight: 800; color: var(--primary); line-height: 1; }
.error-card h1 { margin: .5rem 0; }
.error-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem; margin-top: 1.25rem; }
.layout-auth .error-page { min-height: 100vh; }

.toast {
    position: fixed; left: 50%; bottom: 1.5rem; z-index: 100; transform: translate(-50%, 20px);
    padding: .7rem 1.1rem; border-radius: 8px; background: var(--gray-900); color: #fff;
    font-size: .9rem; box-shadow: var(--shadow-lg); opacity: 0; transition: opacity .2s, transform .2s;
    pointer-events: none;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* 14. Responsive: tablet y escritorio --------------------------------- */
@media (min-width: 576px) {
    .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .field-full { grid-column: 1 / -1; }
    .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .comprobante { padding: 2rem; }
    .comprobante-header { flex-direction: row; justify-content: space-between; }
    .comprobante-numero { text-align: right; }
    .comprobante-datos { grid-template-columns: repeat(4, auto); justify-content: start; gap: .6rem 2rem; }
    .comprobante-pie { flex-direction: row; align-items: flex-start; }
    .hide-sm { display: inline; }
    .pagos-head {
        display: grid; grid-template-columns: 1fr 1fr 1.4fr 40px; gap: .5rem;
        font-size: .72rem; font-weight: 600; text-transform: uppercase; color: var(--muted); padding: 0 .1rem .3rem;
    }
    .pago-row { grid-template-columns: 1fr 1fr 1.4fr 40px; padding: 0; border: 0; background: none; }
    .pago-row .field:nth-child(3) { grid-column: auto; }
    .pago-row [data-pago-quitar] { grid-row: auto; grid-column: auto; }
    .timeline-item { grid-template-columns: 72px 1fr auto; align-items: center; }
    .timeline-actions { grid-column: auto; }
    .agenda-item { grid-template-columns: 52px 1fr auto; }
    .agenda-actions { grid-column: auto; }
}

@media (min-width: 768px) {
    body { font-size: 15px; }
    .content { padding: 1.5rem; }
    h1 { font-size: 1.6rem; }
    .user-info { display: flex; }
    .filters { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
    .filters-actions { grid-column: auto; }
    .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 1024px) {
    .sidebar { transform: none; box-shadow: none; }
    .sidebar-close, .topbar-toggle, .sidebar-backdrop { display: none; }
    .main { margin-left: var(--sidebar-w); }
    .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .grid-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
    .grid-1-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
    .sticky { position: sticky; top: calc(var(--topbar-h) + 1rem); }
    .venta-form .pago-row { grid-template-columns: 1fr 1fr 40px; }
    .venta-form .pagos-head { grid-template-columns: 1fr 1fr 40px; }
    .venta-form .pagos-head span:nth-child(3) { display: none; }
    .venta-form .pago-row .field:nth-child(3) { grid-column: 1 / 3; grid-row: 2; }
    .venta-form .pago-row [data-pago-quitar] { grid-column: 3; grid-row: 1; }
}

/* Impresión ------------------------------------------------------------ */
@media print {
    @page { size: A4 portrait; margin: 12mm; }
    body { background: #fff !important; font-size: 11pt; }
    .sidebar, .sidebar-backdrop, .topbar, .app-footer, .flash-stack, .no-print,
    .page-header .actions, .btn, .pagination-bar, .filters, .toast { display: none !important; }
    .main { margin: 0 !important; }
    .content, .publico-wrap { padding: 0 !important; max-width: none !important; }
    .card, .comprobante { box-shadow: none !important; border: 0 !important; }
    .comprobante { max-width: none; padding: 0; }
    .comprobante-header { flex-direction: row; justify-content: space-between; }
    .comprobante-numero { text-align: right; }
    .comprobante-datos { grid-template-columns: repeat(4, auto); justify-content: start; gap: .4rem 2rem; }
    .comprobante-pie { flex-direction: row; }
    .comprobante-items th, .comprobante-sello { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    a { color: inherit; text-decoration: none; }
    tr, .comprobante-pie { page-break-inside: avoid; }
}

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

/* ===================================================================
   v2: clientes, vehículos, catálogo de taller y timbrados
   =================================================================== */
.text-success { color: var(--success) !important; }
.text-warning { color: var(--warning) !important; }

/* Selector segmentado (tipo de producto) */
.segmented { display: flex; flex-wrap: wrap; gap: .4rem; }
.segmented label { position: relative; cursor: pointer; font-weight: 500; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
    display: inline-block; padding: .45rem .9rem; border: 1px solid var(--border); border-radius: 999px;
    background: var(--surface); color: var(--gray-700); font-size: .9rem; transition: background .15s, border-color .15s;
}
.segmented input:checked + span { background: var(--primary); border-color: var(--primary); color: #fff; }
.segmented input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Documento + dígito verificador */
.input-group-doc { display: flex; align-items: center; gap: .4rem; }
.input-group-doc > .input { flex: 1; min-width: 0; }
.doc-dv { display: inline-flex; align-items: center; gap: .4rem; color: var(--muted); }
.input-dv { width: 3.2rem; text-align: center; font-weight: 700; background: var(--gray-50, #f8fafc); }

/* Placa destacada */
.chip-placa { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .06em; font-size: .95em; vertical-align: middle; }

/* Historial de un vehículo */
.historial { list-style: none; margin: 0; padding: .5rem 1rem 1rem; display: grid; gap: .75rem; }
.historial-item { border-left: 3px solid var(--primary); padding: .25rem 0 .25rem .85rem; }
.historial-item p { margin: .25rem 0 0; }
.historial-head { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .6rem; }
.historial-total { margin-left: auto; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }

/* ===================================================================
   v2 Etapa 3: órdenes de trabajo
   =================================================================== */
.chip-activo { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip-activo strong { color: #fff; }
.input-sm { padding: .35rem .5rem; font-size: .9rem; min-height: 0; }
.ot-pickers { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr); }
.ot-items .input-money { width: 120px; }
.ot-items select.input-sm { min-width: 140px; }
.ot-totales { display: flex; justify-content: flex-end; }
.ot-totales .totales { width: 100%; max-width: 380px; }
.ot-acciones .card-body { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.ot-cancelar { margin-left: auto; }
.ot-cancelar summary { list-style: none; }
.ot-cancelar summary::-webkit-details-marker { display: none; }
.ot-cancelar[open] form { margin-top: .5rem; min-width: min(420px, 80vw); }
@media (min-width: 900px) { .ot-pickers { grid-template-columns: 1fr 1fr; } }

/* Autocompletar */
.autocomplete { position: relative; }
.autocomplete-list {
    position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: .25rem 0;
    list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
    box-shadow: var(--shadow-md, 0 8px 24px rgba(15, 23, 42, .12)); max-height: 280px; overflow-y: auto;
}
.autocomplete-list li { padding: .5rem .75rem; cursor: pointer; display: flex; flex-direction: column; }
.autocomplete-list li small { color: var(--muted); }
.autocomplete-list li[role="option"]:hover, .autocomplete-list li:focus { background: var(--primary-50, #eff6ff); }

/* Hoja imprimible de la orden */
.ot-hoja-wrap { display: flex; justify-content: center; }
.ot-hoja {
    background: #fff; width: 100%; max-width: 820px; padding: 2rem; border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-sm); font-size: .92rem; color: #1e293b;
}
.ot-hoja table { width: 100%; border-collapse: collapse; }
.ot-hoja .h-head td { vertical-align: top; }
.ot-hoja .h-logo { max-width: 150px; max-height: 70px; margin-bottom: .4rem; }
.ot-hoja .h-empresa { font-size: 1.2rem; font-weight: 700; color: var(--primary); }
.ot-hoja .h-muted { color: #64748b; font-size: .8rem; }
.ot-hoja .h-numero { text-align: right; }
.ot-hoja .h-label { font-size: .75rem; letter-spacing: .06em; color: #64748b; font-weight: 700; }
.ot-hoja .h-valor { font-size: 1.4rem; font-weight: 800; }
.ot-hoja .h-linea { border-top: 2px solid var(--primary); margin: 1rem 0; }
.ot-hoja .h-datos td { vertical-align: top; width: 50%; padding-right: 1rem; line-height: 1.5; }
.ot-hoja .h-sub { font-size: .7rem; text-transform: uppercase; color: #64748b; font-weight: 700; }
.ot-hoja .h-texto { margin: .6rem 0; }
.ot-hoja .h-items { margin-top: 1rem; }
.ot-hoja .h-items th { background: #eff6ff; color: #1e3a8a; font-size: .72rem; text-transform: uppercase; text-align: left; padding: .45rem; border-bottom: 1px solid #bfdbfe; }
.ot-hoja .h-items td { padding: .45rem; border-bottom: 1px solid #e2e8f0; }
.ot-hoja .n, .ot-hoja .h-items th.n { text-align: right; white-space: nowrap; }
.ot-hoja .h-totales { width: 45%; margin: .6rem 0 0 auto; }
.ot-hoja .h-totales td { padding: .3rem .45rem; }
.ot-hoja .h-total td { font-size: 1.15rem; font-weight: 800; color: var(--primary); border-top: 2px solid var(--primary); }
.ot-hoja .h-legal { margin-top: 1.5rem; font-size: .75rem; color: #64748b; }
.ot-hoja .h-firmas { margin-top: 3rem; }
.ot-hoja .h-firmas td { width: 50%; padding: 0 1.5rem; }
.ot-hoja .h-firma { border-top: 1px solid #475569; text-align: center; padding-top: .3rem; font-size: .8rem; color: #475569; }
@media (max-width: 640px) {
    .ot-hoja { padding: 1rem; }
    .ot-hoja .h-head td, .ot-hoja .h-datos td { display: block; width: 100%; text-align: left; padding: 0 0 .6rem; }
    .ot-hoja .h-totales { width: 100%; }
}
@media print {
    .ot-hoja { border: 0; box-shadow: none; padding: 0; max-width: none; }
    .ot-hoja .h-items th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ===================================================================
   v2 Etapa 4: facturación
   =================================================================== */
.row-muted td { opacity: .6; }
.tipo-doc { display: grid; gap: .5rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) { .tipo-doc { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.tipo-doc-opcion { position: relative; cursor: pointer; }
.tipo-doc-opcion input { position: absolute; opacity: 0; pointer-events: none; }
.tipo-doc-opcion > span {
    display: flex; flex-direction: column; gap: .15rem; height: 100%; padding: .7rem .85rem;
    border: 1.5px solid var(--border); border-radius: 10px; background: var(--surface); transition: border-color .15s, background .15s;
}
.tipo-doc-opcion small { color: var(--muted); font-weight: 400; font-size: .78rem; }
.tipo-doc-opcion input:checked + span { border-color: var(--primary); background: var(--primary-50, #eff6ff); box-shadow: 0 0 0 3px rgba(29, 78, 216, .12); }
.tipo-doc-opcion input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.tipo-doc-opcion.is-disabled { cursor: not-allowed; opacity: .55; }

/* Documento (factura / remisión / sin factura) */
.doc-wrap { display: flex; justify-content: center; margin-bottom: 1rem; overflow-x: auto; }
.doc-hoja {
    position: relative; background: #fff; color: #0f172a; width: 100%; max-width: 860px; padding: 1rem;
    border: 1px solid #94a3b8; border-radius: 6px; font-size: .86rem;
}
.doc-hoja table { width: 100%; border-collapse: collapse; }
.doc-sello {
    position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%) rotate(-18deg); font-size: 4rem; font-weight: 800;
    color: rgba(220, 38, 38, .2); border: 6px solid rgba(220, 38, 38, .2); padding: .2rem 1.5rem; border-radius: 12px; pointer-events: none;
}
.doc-hoja .d-head td { vertical-align: top; padding: .5rem; }
.doc-hoja .d-emisor { width: 58%; border-right: 1px solid #94a3b8; }
.doc-hoja .d-fiscal { text-align: center; line-height: 1.6; }
.doc-hoja .d-logo { max-width: 140px; max-height: 64px; margin-bottom: .3rem; }
.doc-hoja .d-empresa { font-size: 1.15rem; font-weight: 700; color: var(--primary); }
.doc-hoja .d-muted { color: #64748b; font-size: .78rem; }
.doc-hoja .d-titulo { font-size: 1.05rem; font-weight: 800; margin-top: .2rem; }
.doc-hoja .d-numero { font-size: 1.1rem; font-weight: 800; color: var(--primary); }
.doc-hoja .d-datos { margin-top: .5rem; border-top: 1px solid #94a3b8; border-bottom: 1px solid #94a3b8; }
.doc-hoja .d-datos td { padding: .3rem .5rem; width: 50%; }
.doc-hoja .d-k { color: #475569; }
.doc-hoja .d-items { margin-top: .6rem; }
.doc-hoja .d-items th { background: #e2e8f0; font-size: .74rem; text-transform: uppercase; text-align: left; padding: .4rem; border: 1px solid #94a3b8; }
.doc-hoja .d-items td { padding: .35rem .4rem; border-left: 1px solid #94a3b8; border-right: 1px solid #94a3b8; }
.doc-hoja .d-items tbody td { border-bottom: 1px solid #e2e8f0; }
.doc-hoja .d-items tfoot td { border: 1px solid #94a3b8; font-weight: 700; }
.doc-hoja .d-letras { font-weight: 400; font-size: .76rem; }
.doc-hoja .d-iva td { font-weight: 400; }
.doc-hoja .n, .doc-hoja .d-items th.n { text-align: right; white-space: nowrap; }
.doc-hoja .d-firmas { margin-top: 2.5rem; }
.doc-hoja .d-firmas td { width: 50%; padding: 0 1.5rem; }
.doc-hoja .d-firma { border-top: 1px solid #475569; text-align: center; padding-top: .3rem; font-size: .78rem; }
.doc-hoja .d-pie { margin: .6rem 0 0; font-size: .74rem; color: #64748b; }
@media (max-width: 640px) {
    .doc-hoja .d-head td, .doc-hoja .d-datos td { display: block; width: 100%; border-right: 0; }
    .doc-hoja .d-items { min-width: 560px; }
}
@media print {
    .doc-wrap { overflow: visible; }
    .doc-hoja { max-width: none; border-radius: 0; }
    .doc-hoja .d-items th, .doc-sello { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
.lista-docs { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.section-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 1.25rem 0 .6rem; }

/* ===================================================================
   Inicio de sesión: pantalla dividida (marca del taller + formulario)
   =================================================================== */
.layout-login {
    --login-dark: #0f2a2c;
    --login-dark-2: #143638;
    --login-accent: #1f7a7a;
    --login-accent-600: #186464;
    --login-line: rgba(255, 255, 255, .22);
    background: #fff;
}
.login { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }

.login-hero {
    position: relative; overflow: hidden; color: #e6f0ef;
    display: flex; flex-direction: column; gap: 1.5rem; padding: 1.5rem 1.25rem;
    background: var(--login-dark);
}
.login-hero::after { /* resplandor inferior derecho */
    content: ""; position: absolute; right: -120px; bottom: -160px; width: 460px; height: 460px; border-radius: 50%;
    background: radial-gradient(circle, rgba(46, 125, 115, .45) 0%, rgba(46, 125, 115, 0) 70%); pointer-events: none;
}
.login-hero > * { position: relative; z-index: 1; }

.login-brand { display: flex; align-items: center; gap: .9rem; }
.login-brand-logo {
    flex: none; width: 48px; height: 48px; border-radius: 12px; background: #fff;
    display: grid; place-items: center; overflow: hidden; box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
}
.login-brand-logo img { width: 100%; height: 100%; object-fit: contain; padding: 4px; }
.login-brand-iniciales { font-weight: 800; color: var(--login-accent); font-size: 1.05rem; letter-spacing: .02em; }
.login-brand-nombre { font-weight: 700; font-size: .95rem; letter-spacing: .01em; color: #fff; line-height: 1.3; }

.login-pitch { display: none; }
.login-pitch h1 { font-size: clamp(1.9rem, 3.2vw, 2.6rem); line-height: 1.15; color: #fff; margin: 0 0 1rem; font-weight: 800; letter-spacing: -.01em; }
.login-pitch p { max-width: 560px; color: #c6d6d4; margin: 0 0 1.4rem; line-height: 1.55; }
.login-chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .5rem; }
.login-chips li { border: 1px solid var(--login-line); border-radius: 999px; padding: .4rem .85rem; font-size: .82rem; color: #dbe7e5; }
.login-version { display: none; margin: 0; font-size: .78rem; color: #8fb0ad; }

.login-panel { display: flex; align-items: flex-start; justify-content: center; padding: 2rem 1.25rem 3rem; background: #fff; }
.login-form-wrap { width: 100%; max-width: 410px; }
.login-form-wrap .flash-stack { margin-bottom: 1rem; }
.login-form-wrap h2 { font-size: 1.6rem; margin: 0 0 .3rem; color: var(--login-dark); }
.login-sub { color: #3f6463; margin: 0 0 1.4rem; font-size: .92rem; }
.login-form .field { margin-bottom: 1rem; }
.login-form label { color: var(--login-dark); font-weight: 600; font-size: .86rem; }
.login-form .input { border-color: #c9d9d7; border-radius: 8px; min-height: 44px; }
.login-form .input:focus { border-color: var(--login-accent); box-shadow: 0 0 0 3px rgba(31, 122, 122, .18); outline: 0; }
.login-form .has-error .input { border-color: var(--danger); }
.input-icon-end .input { padding-left: .75rem; padding-right: 2.6rem; }
.login-form .input-action:hover { color: var(--login-accent); }
.login-btn {
    width: 100%; min-height: 46px; margin-top: .4rem; border: 0; border-radius: 8px; cursor: pointer;
    background: var(--login-accent); color: #fff; font: inherit; font-weight: 700; font-size: 1rem;
    transition: background .15s;
}
.login-btn:hover { background: var(--login-accent-600); }
.login-btn:focus-visible { outline: 3px solid rgba(31, 122, 122, .35); outline-offset: 2px; }
.login-btn:disabled { opacity: .75; cursor: progress; }
.login-help { margin: 1.6rem 0 0; font-size: .8rem; color: #3f6463; line-height: 1.5; }

@media (min-width: 900px) {
    .login { grid-template-columns: minmax(0, 1.6fr) minmax(380px, 1fr); grid-template-rows: 1fr; }
    .login-hero { justify-content: space-between; padding: 3rem 2.5rem; min-height: 100vh; min-height: 100dvh; }
    .login-pitch, .login-version { display: block; }
    .login-panel { align-items: center; padding: 2rem 2.5rem; }
}
@media (min-width: 1280px) { .login-hero { padding: 3rem 3.5rem; } }
