/* ============================================================
   COTIZADOR EXPRESS — sistema visual
   Adaptado de la referencia freeScheduller/horarios (Inter, slate,
   tarjetas con sombra suave, sidebar fija colapsable, badges y KPIs),
   aplicado a una herramienta comercial.
   ============================================================ */

:root {
    --bg-primary: #f5f7fb;
    --bg-secondary: #ffffff;
    --bg-tertiary: #eef2f7;
    --bg-hover: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --border-strong: #cbd5e1;
    --accent-primary: #2563eb;
    --accent-secondary: #7c3aed;
    --accent-success: #10b981;
    --accent-warning: #f59e0b;
    --accent-danger: #ef4444;
    --accent-info: #0ea5e9;
    --shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, .05);
    --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, .09), 0 2px 4px -1px rgba(15, 23, 42, .05);
    --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, .11), 0 4px 6px -2px rgba(15, 23, 42, .05);
    --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, .13), 0 10px 10px -5px rgba(15, 23, 42, .05);
    --radius-sm: 6px;
    --radius-md: 9px;
    --radius-lg: 13px;
    --radius-xl: 18px;
    --transition: all .18s cubic-bezier(.4, 0, .2, 1);
    --sidebar-width: 250px;
    --sidebar-collapsed: 74px;
    --header-height: 60px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
}

[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1a2436;
    --bg-tertiary: #233045;
    --bg-hover: #233045;
    --text-primary: #e9eef6;
    --text-secondary: #b6c2d4;
    --text-muted: #7c8aa0;
    --border-color: #2b394f;
    --border-strong: #3b4c66;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, .35);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, .45);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, .5);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, .55);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.55;
    font-size: 15px;
    transition: var(--transition);
}

a {
    color: var(--accent-primary);
}

/* ============================================================
   Barra lateral
   ============================================================ */

.navbar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    padding: 1.1rem .8rem;
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    height: 100vh;
    overflow-y: auto;
    transition: var(--transition);
    z-index: 60;
    box-shadow: var(--shadow-sm);
}

.navbar.collapsed {
    width: var(--sidebar-collapsed);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: 0 .5rem .2rem;
    margin-bottom: 1.2rem;
    line-height: 1.2;
}

.nav-brand .brand-mark {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: .95rem;
    box-shadow: var(--shadow-md);
}

.nav-brand .brand-text {
    font-size: .92rem;
    font-weight: 800;
    letter-spacing: .01em;
    color: var(--text-primary);
}

.nav-brand .brand-text small {
    display: block;
    font-size: .72rem;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: .02em;
}

.navbar.collapsed .brand-text,
.navbar.collapsed .nav-label,
.navbar.collapsed .nav-section-title,
.navbar.collapsed .nav-user-text {
    display: none;
}

.nav-menu {
    list-style: none;
    margin-bottom: .8rem;
}

.nav-menu li {
    margin-bottom: .2rem;
}

.nav-menu a {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .62rem .75rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: .92rem;
    transition: var(--transition);
    position: relative;
}

.nav-menu a .ico {
    width: 22px;
    flex-shrink: 0;
    text-align: center;
    font-size: 1.05rem;
}

.nav-menu a:hover {
    background: var(--bg-tertiary);
    color: var(--accent-primary);
}

.nav-menu a.active {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: #fff;
    box-shadow: var(--shadow-md);
    font-weight: 600;
}

.nav-menu a .pill {
    margin-left: auto;
    background: var(--accent-danger);
    color: #fff;
    border-radius: 999px;
    font-size: .68rem;
    font-weight: 700;
    padding: .1rem .42rem;
    min-width: 20px;
    text-align: center;
}

.nav-menu a.active .pill {
    background: rgba(255, 255, 255, .28);
}

.nav-section {
    margin-top: .6rem;
    padding-top: .7rem;
    border-top: 1px solid var(--border-color);
}

.nav-section-title {
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--text-muted);
    padding: 0 .75rem .4rem;
}

.nav-foot {
    margin-top: auto;
    padding-top: .8rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: .4rem;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .5rem .6rem;
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
}

.avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: .78rem;
    flex-shrink: 0;
}

.nav-user-text {
    min-width: 0;
}

.nav-user-text b {
    display: block;
    font-size: .82rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-user-text span {
    font-size: .72rem;
    color: var(--text-muted);
}

.icon-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    padding: .5rem .6rem;
    cursor: pointer;
    font-size: .95rem;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
}

.icon-btn:hover {
    background: var(--accent-primary);
    color: #fff;
    border-color: var(--accent-primary);
}

/* ============================================================
   Zona de trabajo
   ============================================================ */

.container {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    transition: var(--transition);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.navbar.collapsed ~ .container {
    margin-left: var(--sidebar-collapsed);
    width: calc(100% - var(--sidebar-collapsed));
}

.topbar {
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: .8rem;
    padding: 0 1.4rem;
    position: sticky;
    top: 0;
    z-index: 40;
}

.topbar h1 {
    font-size: 1.06rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar .spacer {
    flex: 1;
}

.work {
    padding: 1.4rem;
    flex: 1;
    animation: fadeIn .25s ease-in;
}

.work.narrow {
    max-width: 1000px;
    margin: 0 auto;
    width: 100%;
}

.work.wide {
    max-width: 1500px;
    margin: 0 auto;
    width: 100%;
}

/* ============================================================
   Tarjetas
   ============================================================ */

.card {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 1.35rem;
    margin-bottom: 1.2rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.card.flush {
    padding: 0;
    overflow: hidden;
}

.card-head {
    display: flex;
    align-items: center;
    gap: .7rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.card-head h2,
.card-head h3 {
    font-size: 1.05rem;
    font-weight: 700;
}

.card-head h3 {
    font-size: .96rem;
    font-weight: 600;
}

.card-head p {
    color: var(--text-secondary);
    font-size: .85rem;
}

.card-head .spacer {
    flex: 1;
}

.card-sub {
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    margin: 1.4rem 0 .8rem;
    padding-bottom: .4rem;
    border-bottom: 1px solid var(--border-color);
}

.grid {
    display: grid;
    gap: 1.2rem;
}

.grid.cols-2 {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.grid.cols-3 {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 1.2rem;
    align-items: start;
}

.split.wide-right {
    grid-template-columns: minmax(0, 1fr) 420px;
}

/* ============================================================
   KPIs
   ============================================================ */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
    gap: 1rem;
    margin-bottom: 1.2rem;
}

.stat-card {
    position: relative;
    overflow: hidden;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.05rem 1.15rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.stat-card::before {
    content: '';
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: linear-gradient(180deg, var(--accent-primary), var(--accent-secondary));
}

.stat-card.ok::before {
    background: linear-gradient(180deg, var(--accent-success), #047857);
}

.stat-card.warn::before {
    background: linear-gradient(180deg, var(--accent-warning), #b45309);
}

.stat-card.bad::before {
    background: linear-gradient(180deg, var(--accent-danger), #b91c1c);
}

.stat-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.stat-label {
    font-size: .76rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: .35rem;
}

.stat-value {
    font-size: 1.65rem;
    font-weight: 800;
    line-height: 1.2;
    margin-top: .3rem;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.stat-hint {
    font-size: .78rem;
    color: var(--text-secondary);
    margin-top: .2rem;
}

.stat-hint b {
    color: var(--accent-primary);
}

/* ============================================================
   Botones
   ============================================================ */

.btn {
    padding: .62rem 1.05rem;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-family: inherit;
    font-size: .88rem;
    font-weight: 600;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    text-decoration: none;
    box-shadow: var(--shadow-sm);
    white-space: nowrap;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled,
.btn.busy {
    opacity: .55;
    cursor: progress;
    transform: none;
    box-shadow: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: #fff;
}

.btn-primary:hover {
    filter: brightness(1.07);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-success {
    background: linear-gradient(135deg, var(--accent-success), #059669);
    color: #fff;
}

.btn-danger {
    background: linear-gradient(135deg, var(--accent-danger), #dc2626);
    color: #fff;
}

.btn-warning {
    background: linear-gradient(135deg, var(--accent-warning), #d97706);
    color: #fff;
}

.btn-ghost {
    background: transparent;
    border-color: var(--border-color);
    color: var(--text-secondary);
    box-shadow: none;
}

.btn-ghost:hover {
    background: var(--bg-tertiary);
    color: var(--accent-primary);
}

.btn-lg {
    padding: .8rem 1.4rem;
    font-size: .96rem;
}

.btn-sm {
    padding: .38rem .7rem;
    font-size: .8rem;
}

.btn-icon {
    padding: .38rem .5rem;
    font-size: .92rem;
}

.btn-block {
    width: 100%;
}

.actions {
    display: flex;
    gap: .45rem;
    flex-wrap: wrap;
    align-items: center;
}

.actions.end {
    justify-content: flex-end;
}

/* ============================================================
   Formularios
   ============================================================ */

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem 1.1rem;
}

.form-grid.two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field {
    display: flex;
    flex-direction: column;
    gap: .32rem;
    min-width: 0;
}

.field.span-all {
    grid-column: 1 / -1;
}

.field label {
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: .3rem;
}

.field label .opt {
    font-weight: 500;
    color: var(--text-muted);
    font-size: .74rem;
}

.field .hint {
    font-size: .76rem;
    color: var(--text-muted);
}

.field .error {
    font-size: .78rem;
    color: var(--accent-danger);
    font-weight: 600;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="search"],
input[type="url"],
input[type="color"],
select,
textarea {
    width: 100%;
    padding: .6rem .8rem;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: .9rem;
    font-family: inherit;
    transition: var(--transition);
    background: var(--bg-secondary);
    color: var(--text-primary);
    color-scheme: light;
}

[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
    background: var(--bg-tertiary);
    color-scheme: dark;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
}

input.invalid,
select.invalid,
textarea.invalid {
    border-color: var(--accent-danger);
}

textarea {
    min-height: 84px;
    resize: vertical;
}

input[type="color"] {
    padding: .18rem;
    height: 38px;
    cursor: pointer;
}

input.num,
td.num,
.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.inline-toggle {
    display: flex;
    align-items: center;
    gap: .55rem;
    font-size: .85rem;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}

.switch {
    position: relative;
    width: 40px;
    height: 22px;
    border-radius: 999px;
    background: var(--border-strong);
    transition: var(--transition);
    flex-shrink: 0;
}

.switch::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

input:checked + .switch,
.switch.on {
    background: var(--accent-success);
}

input:checked + .switch::after,
.switch.on::after {
    left: 21px;
}

/* ============================================================
   Tablas
   ============================================================ */

.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: .88rem;
}

table thead {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: #fff;
}

table th {
    padding: .72rem .85rem;
    text-align: left;
    font-weight: 600;
    font-size: .74rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    white-space: nowrap;
}

table th.num,
table td.num {
    text-align: right;
}

table td {
    padding: .72rem .85rem;
    border-top: 1px solid var(--border-color);
    vertical-align: middle;
}

table tbody tr {
    transition: background .15s ease;
}

table tbody tr:hover {
    background: var(--bg-hover);
}

table tbody tr.clickable {
    cursor: pointer;
}

table tbody tr.mark {
    background: rgba(37, 99, 235, .06);
}

table .strong {
    font-weight: 600;
}

table .sub {
    display: block;
    font-size: .78rem;
    color: var(--text-muted);
    font-weight: 400;
}

table tfoot td {
    border-top: 2px solid var(--border-strong);
    font-weight: 700;
    background: var(--bg-tertiary);
}

.cell-actions {
    display: flex;
    gap: .3rem;
    justify-content: flex-end;
    flex-wrap: wrap;
}

/* ============================================================
   Estados / badges (texto + color, nunca solo color)
   ============================================================ */

.badge {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .2rem .6rem;
    border-radius: 999px;
    font-size: .74rem;
    font-weight: 700;
    letter-spacing: .01em;
    border: 1px solid transparent;
    white-space: nowrap;
}

.badge::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}

.badge.b-borrador {
    background: #eef2f7;
    color: #475569;
    border-color: #dbe3ec;
}

.badge.b-enviada {
    background: rgba(14, 165, 233, .12);
    color: #0369a1;
    border-color: rgba(14, 165, 233, .3);
}

.badge.b-negociacion {
    background: rgba(124, 58, 237, .12);
    color: #6d28d9;
    border-color: rgba(124, 58, 237, .3);
}

.badge.b-aceptada {
    background: rgba(16, 185, 129, .13);
    color: #047857;
    border-color: rgba(16, 185, 129, .32);
}

.badge.b-rechazada {
    background: rgba(239, 68, 68, .12);
    color: #b91c1c;
    border-color: rgba(239, 68, 68, .3);
}

.badge.b-vencida {
    background: rgba(245, 158, 11, .14);
    color: #92400e;
    border-color: rgba(245, 158, 11, .34);
}

.badge.b-cancelada {
    background: rgba(100, 116, 139, .14);
    color: #334155;
    border-color: rgba(100, 116, 139, .3);
}

.badge.b-sustituida {
    background: rgba(148, 163, 184, .16);
    color: #475569;
    border-color: rgba(148, 163, 184, .34);
}

.badge.b-pendiente {
    background: rgba(245, 158, 11, .14);
    color: #92400e;
    border-color: rgba(245, 158, 11, .34);
}

.badge.b-completado {
    background: rgba(16, 185, 129, .13);
    color: #047857;
    border-color: rgba(16, 185, 129, .32);
}

.badge.b-producto {
    background: rgba(37, 99, 235, .1);
    color: #1d4ed8;
    border-color: rgba(37, 99, 235, .26);
}

.badge.b-servicio {
    background: rgba(124, 58, 237, .1);
    color: #6d28d9;
    border-color: rgba(124, 58, 237, .26);
}

.badge.b-inactivo {
    background: #eef2f7;
    color: #64748b;
    border-color: #dbe3ec;
}

[data-theme="dark"] .badge {
    border-color: var(--border-strong);
}

.tag {
    display: inline-block;
    padding: .12rem .5rem;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    font-size: .74rem;
    color: var(--text-secondary);
}

.folio {
    font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
    font-size: .82rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.rev-chip {
    font-size: .7rem;
    font-weight: 700;
    padding: .08rem .4rem;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

/* ============================================================
   Filtros y búsqueda
   ============================================================ */

.filters {
    display: flex;
    gap: .6rem;
    flex-wrap: wrap;
    align-items: flex-end;
    margin-bottom: 1rem;
}

.filters .field {
    flex: 0 0 auto;
    min-width: 160px;
}

.filters .field.search {
    flex: 1 1 260px;
    min-width: 220px;
}

.chip-row {
    display: flex;
    gap: .4rem;
    flex-wrap: wrap;
}

.chip {
    padding: .3rem .7rem;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: .8rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.chip:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.chip.on {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: #fff;
}

/* ============================================================
   Estados vacíos
   ============================================================ */

.empty {
    text-align: center;
    padding: 2.4rem 1.2rem;
    color: var(--text-secondary);
}

.empty .empty-ico {
    font-size: 2.4rem;
    margin-bottom: .6rem;
    opacity: .85;
}

.empty h3 {
    font-size: 1.05rem;
    margin-bottom: .4rem;
    color: var(--text-primary);
}

.empty p {
    font-size: .88rem;
    max-width: 520px;
    margin: 0 auto .9rem;
}

.empty ol {
    text-align: left;
    max-width: 430px;
    margin: 0 auto 1rem;
    padding-left: 1.2rem;
    font-size: .85rem;
    color: var(--text-secondary);
}

.empty ol li {
    margin-bottom: .3rem;
}

.steps {
    display: grid;
    gap: .7rem;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    margin-bottom: 1.2rem;
}

.step {
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-lg);
    padding: .9rem 1rem;
    background: var(--bg-secondary);
    display: flex;
    gap: .7rem;
    align-items: flex-start;
}

.step .n {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: .8rem;
    flex-shrink: 0;
}

.step.done {
    border-style: solid;
    border-color: rgba(16, 185, 129, .4);
}

.step.done .n {
    background: var(--accent-success);
    color: #fff;
}

.step b {
    display: block;
    font-size: .88rem;
}

.step span {
    font-size: .8rem;
    color: var(--text-secondary);
}

/* ============================================================
   Línea de tiempo
   ============================================================ */

.timeline {
    list-style: none;
    position: relative;
    padding-left: 1.5rem;
}

.timeline::before {
    content: '';
    position: absolute;
    left: .42rem;
    top: .4rem;
    bottom: .4rem;
    width: 2px;
    background: var(--border-color);
}

.timeline li {
    position: relative;
    padding-bottom: 1rem;
}

.timeline li::before {
    content: '';
    position: absolute;
    left: -1.13rem;
    top: .35rem;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: var(--accent-primary);
    border: 2px solid var(--bg-secondary);
    box-shadow: 0 0 0 2px var(--border-color);
}

.timeline li.t-aceptada::before {
    background: var(--accent-success);
}

.timeline li.t-rechazada::before,
.timeline li.t-error::before {
    background: var(--accent-danger);
}

.timeline li.t-vencida::before {
    background: var(--accent-warning);
}

.timeline li.t-nota::before {
    background: var(--text-muted);
}

.timeline .tl-title {
    font-weight: 600;
    font-size: .88rem;
}

.timeline .tl-meta {
    font-size: .76rem;
    color: var(--text-muted);
}

.timeline .tl-detail {
    font-size: .84rem;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: .5rem .7rem;
    margin-top: .35rem;
    border: 1px solid var(--border-color);
}

/* ============================================================
   Autocompletado
   ============================================================ */

.ac-wrap {
    position: relative;
}

.ac-list {
    position: absolute;
    z-index: 50;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    max-height: 300px;
    overflow-y: auto;
    display: none;
}

.ac-list.open {
    display: block;
}

.ac-item {
    padding: .55rem .75rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    font-size: .86rem;
    display: flex;
    gap: .5rem;
    align-items: center;
}

.ac-item:last-child {
    border-bottom: none;
}

.ac-item:hover,
.ac-item.sel {
    background: var(--bg-hover);
}

.ac-item .ac-main {
    flex: 1;
    min-width: 0;
}

.ac-item .ac-main b {
    display: block;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ac-item .ac-main span {
    font-size: .76rem;
    color: var(--text-muted);
}

.ac-item .ac-right {
    font-weight: 700;
    font-size: .82rem;
    color: var(--accent-primary);
    white-space: nowrap;
}

.ac-new {
    color: var(--accent-primary);
    font-weight: 700;
    font-size: .8rem;
}

/* ============================================================
   Editor de cotizaciones
   ============================================================ */

.items-head,
.item-row {
    display: grid;
    grid-template-columns: 26px minmax(150px, 1.6fr) 78px 84px 108px 92px 96px 104px 30px;
    gap: .4rem;
    align-items: center;
}

.items-head {
    padding: 0 .3rem .4rem;
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    z-index: 2;
}

.item-row {
    padding: .45rem .3rem;
    border-bottom: 1px solid var(--border-color);
    animation: fadeIn .2s ease-in;
}

.item-row:hover {
    background: var(--bg-hover);
}

.item-row input,
.item-row select {
    padding: .4rem .5rem;
    font-size: .85rem;
}

.item-row .grip {
    cursor: grab;
    color: var(--text-muted);
    text-align: center;
    font-size: .9rem;
    user-select: none;
}

.item-row.dragging {
    opacity: .5;
}

.item-row.drop-target {
    box-shadow: inset 0 2px 0 var(--accent-primary);
}

.item-name {
    min-width: 0;
}

.item-desc {
    grid-column: 2 / -1;
    padding-left: .2rem;
}

.item-desc textarea {
    min-height: 34px;
    font-size: .82rem;
    padding: .35rem .5rem;
}

.item-line-total {
    font-weight: 700;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.item-sub {
    grid-column: 2 / -1;
    display: flex;
    gap: .8rem;
    font-size: .76rem;
    color: var(--text-muted);
    padding-left: .3rem;
}

.item-sub .warn {
    color: var(--accent-warning);
    font-weight: 600;
}

.totals {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1rem;
    font-size: .88rem;
}

.totals .row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: .22rem 0;
    font-variant-numeric: tabular-nums;
}

.totals .row.muted {
    color: var(--text-secondary);
    font-size: .82rem;
}

.totals .row.grand {
    border-top: 2px solid var(--border-strong);
    margin-top: .5rem;
    padding-top: .6rem;
    font-size: 1.12rem;
    font-weight: 800;
}

.totals .row input[type="number"] {
    width: 110px;
    text-align: right;
    padding: .3rem .45rem;
}

.totals .tax-list {
    font-size: .78rem;
    color: var(--text-secondary);
}

.editor-side {
    position: sticky;
    top: calc(var(--header-height) + 1rem);
}

.autosave {
    font-size: .76rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: .35rem;
}

.autosave.saved {
    color: var(--accent-success);
}

.autosave.pending::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent-warning);
}

/* ============================================================
   Documento (previsualización y vista pública)
   ============================================================ */

.doc-frame {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.doc {
    padding: 2rem 2.2rem;
    color: #101828;
    background: #fff;
}

[data-theme="dark"] .doc {
    background: #f7f9fc;
}

.doc-top {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    align-items: flex-start;
    border-bottom: 3px solid var(--doc-accent, #2563eb);
    padding-bottom: 1.1rem;
    margin-bottom: 1.2rem;
}

.doc-logo img {
    max-height: 62px;
    max-width: 210px;
    display: block;
}

.doc-logo .fallback {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--doc-accent, #2563eb);
}

.doc-biz {
    flex: 1;
    min-width: 220px;
}

.doc-biz h2 {
    font-size: 1.25rem;
    font-weight: 800;
    color: #0f172a;
}

.doc-biz p {
    font-size: .8rem;
    color: #4b5563;
    line-height: 1.45;
}

.doc-meta {
    text-align: right;
    min-width: 190px;
}

.doc-meta .kind {
    font-size: .72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: var(--doc-accent, #2563eb);
}

.doc-meta .folio {
    font-size: 1.15rem;
    font-weight: 800;
    color: #0f172a;
    font-family: ui-monospace, Menlo, Consolas, monospace;
}

.doc-meta dl {
    font-size: .78rem;
    color: #4b5563;
    display: grid;
    grid-template-columns: auto auto;
    gap: .1rem .6rem;
    justify-content: end;
    margin-top: .4rem;
}

.doc-meta dt {
    text-align: right;
}

.doc-meta dd {
    font-weight: 700;
    color: #0f172a;
}

.doc-parties {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.2rem;
    margin-bottom: 1.2rem;
}

.doc-party h4,
.doc-block h4 {
    font-size: .7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #94a3b8;
    margin-bottom: .3rem;
}

.doc-party p {
    font-size: .86rem;
    color: #1f2937;
}

.doc-party p.name {
    font-weight: 700;
    font-size: .98rem;
}

.doc-party p.muted {
    color: #6b7280;
    font-size: .82rem;
}

.doc table {
    background: transparent;
    box-shadow: none;
    border-radius: 0;
    font-size: .84rem;
}

.doc table thead {
    background: var(--doc-accent, #2563eb);
}

.doc table th {
    color: #fff;
}

.doc table td,
.doc table th {
    padding: .5rem .6rem;
    border: 1px solid #e5e7eb;
}

.doc table tbody tr:nth-child(even) {
    background: #f8fafc;
}

.doc .item-desc {
    display: block;
    font-size: .78rem;
    color: #6b7280;
    font-weight: 400;
    margin-top: .15rem;
    white-space: pre-wrap;
}

.doc-foot-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(260px, .8fr);
    gap: 1.4rem;
    margin-top: 1.2rem;
    align-items: start;
}

.doc-notes {
    font-size: .8rem;
    color: #374151;
}

.doc-notes section {
    margin-bottom: .8rem;
}

.doc-notes b {
    display: block;
    color: #0f172a;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.doc-notes p {
    white-space: pre-wrap;
}

.doc-totals {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: .9rem 1rem;
    font-size: .86rem;
}

.doc-totals .row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: .18rem 0;
    font-variant-numeric: tabular-nums;
}

.doc-totals .row.grand {
    border-top: 2px solid #cbd5e1;
    margin-top: .4rem;
    padding-top: .5rem;
    font-weight: 800;
    font-size: 1.05rem;
    color: #0f172a;
}

.doc-totals .row.minor {
    color: #6b7280;
    font-size: .8rem;
}

.doc-sign {
    margin-top: 2.2rem;
    display: flex;
    justify-content: space-between;
    gap: 2rem;
    flex-wrap: wrap;
}

.doc-sign .line {
    min-width: 240px;
    border-top: 1.5px solid #9ca3af;
    padding-top: .35rem;
    font-size: .82rem;
}

.doc-sign .line b {
    display: block;
}

.doc-sign .line span {
    color: #6b7280;
}

.doc-footer {
    margin-top: 1.6rem;
    padding-top: .7rem;
    border-top: 1px solid #e5e7eb;
    font-size: .74rem;
    color: #94a3b8;
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

/* ============================================================
   Compartir / respuesta pública
   ============================================================ */

.public-wrap {
    max-width: 900px;
    margin: 0 auto;
    padding: 1.2rem;
}

.public-bar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: .8rem 1rem;
    margin-bottom: 1rem;
    display: flex;
    gap: .8rem;
    align-items: center;
    flex-wrap: wrap;
}

.public-bar .biz {
    flex: 1;
    min-width: 160px;
}

.public-bar .biz b {
    display: block;
    font-size: .95rem;
}

.public-bar .biz span {
    font-size: .78rem;
    color: var(--text-muted);
}

.answer-box {
    border-radius: var(--radius-lg);
    padding: 1.1rem 1.2rem;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    box-shadow: var(--shadow-md);
    margin-top: 1rem;
}

.answer-box.aceptada {
    border-color: rgba(16, 185, 129, .45);
    background: rgba(16, 185, 129, .07);
}

.answer-box.rechazada {
    border-color: rgba(239, 68, 68, .4);
    background: rgba(239, 68, 68, .06);
}

.answer-box.cambios {
    border-color: rgba(245, 158, 11, .45);
    background: rgba(245, 158, 11, .07);
}

.notice {
    display: flex;
    gap: .7rem;
    align-items: flex-start;
    border-radius: var(--radius-md);
    padding: .75rem .9rem;
    font-size: .84rem;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.notice b {
    color: var(--text-primary);
}

.notice.info {
    border-color: rgba(14, 165, 233, .35);
    background: rgba(14, 165, 233, .08);
}

.notice.warn {
    border-color: rgba(245, 158, 11, .4);
    background: rgba(245, 158, 11, .09);
}

.notice.error {
    border-color: rgba(239, 68, 68, .4);
    background: rgba(239, 68, 68, .07);
}

.notice.ok {
    border-color: rgba(16, 185, 129, .4);
    background: rgba(16, 185, 129, .07);
}

.notice .ico {
    font-size: 1.05rem;
    line-height: 1.2;
}

/* ============================================================
   Modales, toasts, menús
   ============================================================ */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .45);
    backdrop-filter: blur(3px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 100;
}

.modal-backdrop.open {
    display: flex;
    animation: fadeIn .18s ease-in;
}

.modal {
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: min(660px, 100%);
    max-height: calc(100vh - 2rem);
    display: flex;
    flex-direction: column;
    animation: slideIn .2s ease-out;
    border: 1px solid var(--border-color);
}

.modal.wide {
    width: min(1000px, 100%);
}

.modal-head {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: 1rem 1.2rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-head h3 {
    font-size: 1.02rem;
    font-weight: 700;
    flex: 1;
}

.modal-body {
    padding: 1.2rem;
    overflow-y: auto;
}

.modal-foot {
    padding: .9rem 1.2rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: .5rem;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.toast-host {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    z-index: 200;
    max-width: min(420px, calc(100vw - 2rem));
}

.toast {
    background: var(--bg-secondary);
    border-left: 4px solid var(--accent-primary);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xl);
    padding: .7rem .9rem;
    font-size: .87rem;
    display: flex;
    gap: .6rem;
    align-items: flex-start;
    animation: slideIn .2s ease-out;
    border: 1px solid var(--border-color);
}

.toast.ok {
    border-left-color: var(--accent-success);
}

.toast.error {
    border-left-color: var(--accent-danger);
}

.toast.warn {
    border-left-color: var(--accent-warning);
}

.toast b {
    display: block;
    font-size: .88rem;
}

.toast p {
    color: var(--text-secondary);
    font-size: .82rem;
}

.toast .close {
    margin-left: auto;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1;
}

.menu {
    position: absolute;
    z-index: 90;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 210px;
    padding: .3rem;
    display: none;
}

.menu.open {
    display: block;
    animation: fadeIn .14s ease-in;
}

.menu button,
.menu a {
    display: flex;
    width: 100%;
    gap: .5rem;
    align-items: center;
    padding: .5rem .6rem;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font: inherit;
    font-size: .86rem;
    text-align: left;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-decoration: none;
}

.menu button:hover,
.menu a:hover {
    background: var(--bg-hover);
    color: var(--accent-primary);
}

.menu .sep {
    height: 1px;
    background: var(--border-color);
    margin: .3rem 0;
}

.menu .danger {
    color: var(--accent-danger);
}

/* ============================================================
   Utilidades
   ============================================================ */

.muted {
    color: var(--text-muted);
}

.soft {
    color: var(--text-secondary);
}

.strong {
    font-weight: 700;
}

.tiny {
    font-size: .76rem;
}

.right {
    text-align: right;
}

.center {
    text-align: center;
}

.nowrap {
    white-space: nowrap;
}

.mono {
    font-family: ui-monospace, Menlo, Consolas, monospace;
}

.row-flex {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
}

.stack {
    display: flex;
    flex-direction: column;
    gap: .8rem;
}

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.spacer { flex: 1; }

.bar {
    height: 7px;
    border-radius: 999px;
    background: var(--bg-tertiary);
    overflow: hidden;
}

.bar > i {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    transition: width .4s ease;
}

.bar.ok > i { background: linear-gradient(90deg, var(--accent-success), #047857); }
.bar.warn > i { background: linear-gradient(90deg, var(--accent-warning), #b45309); }
.bar.bad > i { background: linear-gradient(90deg, var(--accent-danger), #b91c1c); }

.mini-table {
    width: 100%;
    font-size: .84rem;
    border-collapse: collapse;
    background: transparent;
    box-shadow: none;
}

.mini-table td {
    padding: .35rem 0;
    border-top: 1px solid var(--border-color);
}

.mini-table td:last-child {
    text-align: right;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.skeleton {
    background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--border-color) 37%, var(--bg-tertiary) 63%);
    background-size: 400% 100%;
    animation: shimmer 1.3s ease infinite;
    border-radius: var(--radius-sm);
    height: 14px;
}

.spin {
    width: 15px;
    height: 15px;
    border: 2px solid rgba(255, 255, 255, .45);
    border-top-color: #fff;
    border-radius: 50%;
    animation: rotate .7s linear infinite;
    display: inline-block;
}

.spin.dark {
    border-color: var(--border-strong);
    border-top-color: var(--accent-primary);
}

@keyframes rotate { to { transform: rotate(360deg); } }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes slideIn { from { opacity: 0; transform: translateY(14px) scale(.99); } to { opacity: 1; transform: none; } }

/* ============================================================
   Login e instalación
   ============================================================ */

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.2rem;
    background:
        radial-gradient(1100px 500px at 12% -10%, rgba(37, 99, 235, .16), transparent 60%),
        radial-gradient(800px 400px at 100% 0%, rgba(124, 58, 237, .13), transparent 55%),
        var(--bg-primary);
}

.auth-card {
    width: min(1020px, 100%);
    display: grid;
    grid-template-columns: 1.05fr .95fr;
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.auth-card.single {
    grid-template-columns: 1fr;
    width: min(560px, 100%);
}

.auth-side {
    padding: 2.2rem;
    background: linear-gradient(150deg, var(--accent-primary), var(--accent-secondary));
    color: #fff;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.auth-side h1 {
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1.25;
}

.auth-side p {
    font-size: .92rem;
    opacity: .93;
}

.auth-side ul {
    list-style: none;
    display: grid;
    gap: .6rem;
    font-size: .88rem;
    margin-top: .4rem;
}

.auth-side li {
    display: flex;
    gap: .55rem;
    align-items: flex-start;
}

.auth-form {
    padding: 2.2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    justify-content: center;
}

.auth-form h2 {
    font-size: 1.25rem;
    font-weight: 800;
}

.auth-form .lead {
    font-size: .88rem;
    color: var(--text-secondary);
    margin-top: -.5rem;
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 1180px) {
    .split,
    .split.wide-right {
        grid-template-columns: minmax(0, 1fr);
    }

    .editor-side {
        position: static;
    }
}

@media (max-width: 860px) {
    .items-head {
        display: none;
    }

    .item-row {
        grid-template-columns: 24px 1fr 1fr;
        gap: .5rem;
        padding: .8rem .4rem;
        border-bottom: 2px solid var(--border-color);
    }

    .item-row .grip {
        grid-row: 1 / 3;
    }

    .item-row .item-name {
        grid-column: 2 / -1;
    }

    .item-row .item-desc,
    .item-row .item-sub {
        grid-column: 1 / -1;
    }

    .doc-foot-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    :root {
        --sidebar-width: 272px;
    }

    body {
        font-size: 14.5px;
    }

    .navbar {
        transform: translateX(-100%);
        box-shadow: var(--shadow-xl);
    }

    .navbar.mobile-open {
        transform: none;
    }

    .navbar.collapsed {
        width: var(--sidebar-width);
    }

    .navbar.collapsed .brand-text,
    .navbar.collapsed .nav-label,
    .navbar.collapsed .nav-section-title,
    .navbar.collapsed .nav-user-text {
        display: revert;
    }

    .container,
    .navbar.collapsed ~ .container {
        margin-left: 0;
        width: 100%;
    }

    .work {
        padding: .9rem;
    }

    .topbar {
        padding: 0 .8rem;
    }

    .scrim {
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, .4);
        z-index: 55;
    }

    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: .7rem;
    }

    .stat-value {
        font-size: 1.35rem;
    }

    .card {
        padding: 1rem;
    }

    .auth-card {
        grid-template-columns: 1fr;
    }

    .auth-side {
        padding: 1.4rem;
    }

    .auth-form {
        padding: 1.4rem;
    }

    .doc {
        padding: 1.1rem;
    }

    .form-grid.two {
        grid-template-columns: 1fr;
    }

    /* Las tablas se vuelven fichas apiladas. */
    table.responsive thead {
        display: none;
    }

    table.responsive,
    table.responsive tbody,
    table.responsive tr,
    table.responsive td {
        display: block;
        width: 100%;
    }

    table.responsive tr {
        border: 1px solid var(--border-color);
        border-radius: var(--radius-md);
        padding: .5rem .7rem;
        margin-bottom: .6rem;
        background: var(--bg-secondary);
    }

    table.responsive td {
        border-top: none;
        padding: .28rem 0;
        display: flex;
        justify-content: space-between;
        gap: .8rem;
        align-items: center;
    }

    table.responsive td::before {
        content: attr(data-label);
        font-size: .74rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: .04em;
        color: var(--text-muted);
        flex: 0 0 auto;
    }

    table.responsive td.col-span {
        display: block;
    }

    table.responsive td.col-span::before {
        display: block;
        margin-bottom: .2rem;
    }

    .cell-actions {
        justify-content: flex-start;
    }
}

@media print {
    .navbar,
    .topbar,
    .no-print,
    .toast-host {
        display: none !important;
    }

    .container,
    .navbar.collapsed ~ .container {
        margin: 0;
        width: 100%;
    }

    .work {
        padding: 0;
    }

    .doc-frame,
    .card {
        box-shadow: none;
        border: none;
    }
}

/* ============================================================
   Prospectos: pestañas, tablero, selección por lote y CRM
   ============================================================ */

.segment {
    display: inline-flex;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-secondary);
}

.segment button {
    padding: .4rem .85rem;
    border: 0;
    background: transparent;
    color: var(--text-secondary);
    font-size: .82rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.segment button + button {
    border-left: 1px solid var(--border-color);
}

.segment button.on {
    background: var(--accent-primary);
    color: #fff;
}

.board {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(225px, 1fr);
    gap: .7rem;
    overflow-x: auto;
    padding-bottom: .5rem;
    align-items: start;
}

.board-col {
    display: flex;
    flex-direction: column;
    min-height: 130px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

.board-col header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    padding: .6rem .7rem;
    font-size: .8rem;
}

.board-col header span {
    font-size: .72rem;
    font-weight: 700;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    padding: .05rem .45rem;
}

.board-cards {
    display: flex;
    flex-direction: column;
    gap: .45rem;
    padding: 0 .5rem .55rem;
}

.board-card {
    display: flex;
    flex-direction: column;
    gap: .15rem;
    text-align: left;
    padding: .55rem .6rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
}

.board-card:hover {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-sm);
}

.board-card b {
    font-size: .84rem;
}

.board-card > span:not(.badge) {
    font-size: .75rem;
    color: var(--text-muted);
}

.batch-bar {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
    margin-bottom: .7rem;
    padding: .55rem .7rem;
    border: 1px solid var(--accent-primary);
    border-radius: var(--radius-md);
    background: rgba(37, 99, 235, .07);
}

.batch-bar[hidden] {
    display: none;
}

table th.check,
table td.check {
    width: 34px;
    text-align: center;
    padding-left: .6rem;
    padding-right: .2rem;
}

.compact {
    max-width: 240px;
    padding: .34rem .5rem;
    font-size: .8rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* Estados del prospecto */
.badge.b-nuevo { background: rgba(37, 99, 235, .1); color: #1d4ed8; border-color: rgba(37, 99, 235, .26); }
.badge.b-por_contactar { background: rgba(245, 158, 11, .14); color: #92400e; border-color: rgba(245, 158, 11, .34); }
.badge.b-contacto_intentado { background: rgba(14, 165, 233, .12); color: #0369a1; border-color: rgba(14, 165, 233, .3); }
.badge.b-conversacion { background: rgba(124, 58, 237, .12); color: #6d28d9; border-color: rgba(124, 58, 237, .3); }
.badge.b-calificado { background: rgba(16, 185, 129, .13); color: #047857; border-color: rgba(16, 185, 129, .32); }
.badge.b-retomar { background: rgba(249, 115, 22, .13); color: #c2410c; border-color: rgba(249, 115, 22, .32); }
.badge.b-no_interesado,
.badge.b-no_encaja { background: rgba(100, 116, 139, .14); color: #334155; border-color: rgba(100, 116, 139, .3); }
.badge.b-no_contactar { background: rgba(239, 68, 68, .12); color: #b91c1c; border-color: rgba(239, 68, 68, .3); }

/* Etapas de oportunidad */
.badge.b-diagnostico { background: rgba(100, 116, 139, .14); color: #334155; border-color: rgba(100, 116, 139, .3); }
.badge.b-demostracion { background: rgba(14, 165, 233, .12); color: #0369a1; border-color: rgba(14, 165, 233, .3); }
.badge.b-propuesta { background: rgba(37, 99, 235, .1); color: #1d4ed8; border-color: rgba(37, 99, 235, .26); }
.badge.b-cotizacion { background: rgba(124, 58, 237, .12); color: #6d28d9; border-color: rgba(124, 58, 237, .3); }
.badge.b-ganada { background: rgba(16, 185, 129, .13); color: #047857; border-color: rgba(16, 185, 129, .32); }
.badge.b-perdida { background: rgba(239, 68, 68, .12); color: #b91c1c; border-color: rgba(239, 68, 68, .3); }

/* Ventas y pagos */
.badge.b-confirmada { background: rgba(16, 185, 129, .13); color: #047857; border-color: rgba(16, 185, 129, .32); }
.badge.b-pagada { background: rgba(16, 185, 129, .13); color: #047857; border-color: rgba(16, 185, 129, .32); }
.badge.b-parcial { background: rgba(245, 158, 11, .14); color: #92400e; border-color: rgba(245, 158, 11, .34); }
.badge.b-anulada { background: rgba(100, 116, 139, .14); color: #334155; border-color: rgba(100, 116, 139, .3); }

@media (max-width: 720px) {
    .batch-bar .compact {
        max-width: 100%;
        flex: 1 1 100%;
    }
}

/* Recorte de mapa del prospecto */
.biz { display: flex; gap: .6rem; align-items: flex-start; }
.map-thumb {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--line, #e2e8f0);
    background: #f1f5f9;
    flex: 0 0 auto;
}
.map-card {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    align-items: flex-start;
    margin-bottom: .75rem;
}
.map-card img {
    display: block;
    width: 100%;
    max-width: 320px;
    max-height: 220px;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid var(--line, #e2e8f0);
    background: #f1f5f9;
}
.link-maps { display: inline-block; margin-top: .2rem; }
