/* =====================================================
   COTIZADOR PUERTAS CORTAFUEGO - ESTILOS MOBILE-FIRST
   Tendencias UX/UI 2024-2025
   ===================================================== */

/* ===== VARIABLES ===== */
:root {
    --bg: #f5f5f7;
    --card: #ffffff;
    --primary: #1d1d1f;
    --secondary: #86868b;
    --accent: #0071e3;
    --accent-hover: #0077ed;
    --accent-light: rgba(0,113,227,0.1);
    --header-navy: #2c3a4f;       /* navy corporativo unificado con PDF y email */
    --header-navy-dark: #1e2a3a;  /* navy más oscuro para gradients */
    --brand-red: #FD3104;          /* rojo TDA (logo y acentos) */
    --success: #34c759;
    --success-bg: #d1f2d9;
    --error: #ff3b30;
    --error-bg: #ffedec;
    --warning: #ff9500;
    --warning-bg: #fff4e5;
    --border: #d2d2d7;
    --border-light: #e8e8ed;
    --radius: 12px;
    --radius-lg: 18px;
    --radius-xl: 24px;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 24px rgba(0,0,0,0.12);
    --shadow-xl: 0 8px 32px rgba(0,0,0,0.16);

    /* Touch-friendly sizes — SAP Fiori Cozy Mode */
    --touch-target: 2.75rem;   /* 44px — Fiori cozy baseline */
    --input-height: 2.75rem;   /* 44px — all inputs uniform cozy */
    --input-height-sm: 2.75rem; /* 44px — NO compact on mobile, always cozy */

    /* Fiori spacing tokens */
    --space-xs: 0.5rem;    /* 8px */
    --space-s: 0.75rem;    /* 12px */
    --space-m: 1rem;       /* 16px */
    --space-l: 1.5rem;     /* 24px */
    --space-xl: 2rem;      /* 32px */

    /* Safe areas for notched devices */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);

    /* Bottom bar height */
    --bottom-bar-height: 72px;
}

/* ===== RESET ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--primary);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    width: 100%;
    line-height: 1.5;
    padding-bottom: calc(var(--bottom-bar-height) + var(--safe-bottom) + 16px);
    overflow-x: hidden;
}

/* Smooth scrolling */
@media (prefers-reduced-motion: no-preference) {
    html { scroll-behavior: smooth; }
}

/* ===== TYPOGRAPHY SCALE ===== */
.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.text-base { font-size: 1rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }

/* ===== HEADER - MOBILE FIRST ===== */
.header {
    background: var(--header-navy);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--border-light);
    padding: 0 1rem;
    padding-top: var(--safe-top);
    height: calc(56px + var(--safe-top));
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    color: #ffffff;
    overflow: hidden;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    flex-shrink: 0;
}

.logo-img {
    height: 36px;
    width: auto;
    flex-shrink: 0;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.15);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 0.6rem;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.logo-img {
    height: 32px;
    width: auto;
    object-fit: contain;
}

.logo-text {
    display: none;
}

.header-center {
    display: none;
}

.save-status {
    font-size: 0.7rem;
    color: #34c759;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.save-status.saving {
    color: #ff9500;
}

/* Asesor badge */
.asesor-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255,255,255,0.15);
    padding: 0.4rem 0.75rem;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-right: 1rem;
}

.asesor-badge:hover {
    background: rgba(255,255,255,0.25);
}

.asesor-badge:hover .asesor-icon {
    color: white;
}

.asesor-icon {
    font-size: 1rem;
    color: rgba(255,255,255,0.8);
}

.asesor-name {
    font-size: 0.75rem;
    font-weight: 600;
    color: rgba(255,255,255,0.8);
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.asesor-badge:hover .asesor-name {
    color: white;
}

.asesor-badge.active {
    background: rgba(52,199,89,0.25);
    border: 1px solid rgba(52,199,89,0.5);
}

.asesor-badge.active .asesor-name {
    color: #34c759;
}

/* Header stats - hidden on mobile, shown in bottom bar */
.header-stats {
    display: none;
}

/* Mobile menu button */
.header-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--touch-target);
    height: var(--touch-target);
    background: none;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--primary);
    font-size: 1.25rem;
}

.header-menu-btn:active {
    background: var(--accent-light);
}

/* ===== MAIN LAYOUT - MOBILE FIRST ===== */
.main {
    padding: 1rem;
    padding-left: calc(1rem + var(--safe-left));
    padding-right: calc(1rem + var(--safe-right));
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 100%;
    overflow-x: hidden;
}

.content-area {
    width: 100%;
}

/* ===== SECTIONS - MOBILE FIRST ===== */
.client-section,
.margin-section,
.doors-section {
    background: var(--card);
    border-radius: var(--radius-lg);
    padding: var(--space-l);
    margin-bottom: var(--space-m);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.section-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--space-l);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Collapsible sections on mobile */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
}

.section-toggle {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--bg);
    transition: transform 0.3s ease;
}

.section-toggle::after {
    content: '';
    border: solid var(--secondary);
    border-width: 0 2px 2px 0;
    padding: 3px;
    transform: rotate(45deg);
    margin-top: -2px;
}

.section-collapsed .section-toggle {
    transform: rotate(-90deg);
}

.section-collapsed .section-content {
    display: none;
}

/* ===== CLIENT GRID - MOBILE FIRST ===== */
.client-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

.field {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.field label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--secondary);
}

.field input,
.field select {
    height: var(--input-height);
    padding: 0 var(--space-m);
    font-size: 1rem;
    font-family: inherit;
    border: 1.5px solid var(--border);
    border-radius: 0.5rem;
    background: var(--bg);
    color: var(--primary);
    transition: all 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

.field select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2386868b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
}

.field input:focus,
.field select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-light);
    background: var(--card);
}

.field input::placeholder {
    color: var(--secondary);
    opacity: 0.7;
}

.field .required {
    color: var(--error);
    font-weight: 600;
}

.field-wide {
    grid-column: 1 / -1;
}

/* ===== MARGIN SECTION - MOBILE ===== */
.margin-section {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.margin-section .section-title {
    color: rgba(255,255,255,0.85);
}

.margin-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.margin-input-group {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-s);
    padding: var(--space-s);
    background: rgba(255,255,255,0.15);
    border-radius: 0.5rem;
}

.margin-input-group label {
    font-size: 1rem;
    font-weight: 500;
}

.margin-input {
    width: 90px;
    height: var(--input-height);
    padding: var(--space-xs);
    font-size: 1.375rem;
    font-weight: 600;
    font-family: 'SF Mono', ui-monospace, monospace;
    text-align: center;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 0.5rem;
    background: rgba(255,255,255,0.15);
    color: white;
}

.margin-input:focus {
    outline: none;
    border-color: white;
    background: rgba(255,255,255,0.25);
}

.margin-result {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-m);
    background: rgba(255,255,255,0.15);
    border-radius: 0.5rem;
}

.margin-result-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    opacity: 0.85;
    letter-spacing: 0.5px;
}

.margin-result-value {
    font-size: 1.1rem;
    font-weight: 700;
    font-feature-settings: 'tnum';
    margin-top: 0.25rem;
}

.margin-hint {
    grid-column: 1 / -1;
    font-size: 0.75rem;
    opacity: 0.7;
    text-align: center;
    margin-top: var(--space-xs);
    line-height: 1.4;
}

/* ===== DOORS SECTION - MOBILE ===== */
.doors-section {
    padding: var(--space-l);
}

.doors-header {
    display: flex;
    flex-direction: column;
    gap: var(--space-s);
    margin-bottom: var(--space-l);
    padding-bottom: var(--space-m);
    border-bottom: 1px solid var(--border-light);
}

.doors-header h2 {
    font-size: 1.0625rem;
    font-weight: 600;
}

.doors-header-actions {
    display: flex;
    gap: var(--space-s);
}

.doors-header-actions .btn {
    flex: 1;
    justify-content: center;
}

/* ===== BUTTONS - TOUCH FRIENDLY ===== */
.btn {
    min-height: var(--touch-target);
    padding: var(--space-s) var(--space-l);
    font-size: 0.9375rem;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    -webkit-user-select: none;
    user-select: none;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: var(--bg);
    color: var(--primary);
    border: 1.5px solid var(--border);
}

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

.btn-ghost {
    background: transparent;
    color: var(--accent);
    min-height: 36px;
    padding: 0.5rem 0.75rem;
}

.btn-ghost:hover {
    background: var(--accent-light);
}

.btn-danger {
    background: transparent;
    color: var(--error);
    min-height: 36px;
    padding: 0.5rem 0.75rem;
}

.btn-danger:hover {
    background: var(--error-bg);
}

.btn-icon {
    width: var(--touch-target);
    height: var(--touch-target);
    min-height: auto;
    padding: 0;
    border-radius: 50%;
}

/* ===== DOOR ROW - CLEAN CARD ===== */
.door-row {
    background: var(--card);
    border-radius: var(--radius-lg);
    padding: var(--space-l);
    margin-bottom: var(--space-m);
    border: 1.5px solid var(--border-light);
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.door-row.valid {
    border-color: var(--success);
    border-left: 4px solid var(--success);
}

.door-row.invalid {
    border-color: var(--error);
    border-left: 4px solid var(--error);
}

/* Swipe delete indicator */
.door-row::before {
    content: '🗑️ Eliminar';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 100px;
    background: var(--error);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.door-row.swiping::before {
    transform: translateX(0);
}

.door-row-inner {
    background: inherit;
    position: relative;
    z-index: 1;
    transition: transform 0.3s ease;
}

.door-row.swiping .door-row-inner {
    transform: translateX(-100px);
}

.door-row-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-m);
}

.door-row-number {
    font-weight: 600;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    flex-wrap: wrap;
}

.door-row-status {
    font-size: 0.6875rem;
    padding: 0.15rem 0.5rem;
    border-radius: 2rem;
    font-weight: 600;
}

.door-row-status.valid {
    background: var(--success);
    color: white;
}

.door-row-status.invalid {
    background: var(--error);
    color: white;
}

.door-row-actions {
    display: flex;
    gap: 0.25rem;
    flex-shrink: 0;
}

/* ===== DOOR GROUPS — Fiori form groups ===== */
.door-group {
    display: grid;
    gap: var(--space-m);
    padding-bottom: var(--space-m);
}

/* Grupo 1: Configuracion (Linea, Modalidad, Material, Marco) */
.door-group-config {
    grid-template-columns: repeat(2, 1fr);
    border-bottom: 1px solid var(--border-light);
}

/* Grupo 2: Dimensiones + Cantidad + Precio */
.door-group-dims {
    grid-template-columns: 1fr auto 1fr;
    align-items: end;
}

/* Grupo 2b: Cantidad + Precio en fila */
.door-group-qty {
    display: flex;
    align-items: end;
    gap: var(--space-m);
}

.door-dims-sep {
    color: var(--secondary);
    font-size: 1.5rem;
    font-weight: 600;
    padding-top: 1.5rem;
    text-align: center;
}

.door-field {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.door-field label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.door-field select,
.door-field input {
    height: var(--input-height);
    padding: 0 var(--space-s);
    font-size: 0.9375rem;
    font-family: inherit;
    border: 1.5px solid var(--border);
    border-radius: 0.5rem;
    background: var(--card);
    color: var(--primary);
    -webkit-appearance: none;
    appearance: none;
}

.door-field select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2386868b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2rem;
}

.door-field select:focus,
.door-field input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.door-field input.error {
    border-color: var(--error);
    background: var(--error-bg);
}

.door-field input.valid {
    border-color: var(--success);
}

/* Inputs de dimensiones — grandes y claros */
.door-field-ancho,
.door-field-alto {
    flex: 1;
    min-width: 0;
}

.door-field-ancho input,
.door-field-alto input {
    width: 100%;
    height: 3rem;
    font-size: 1.125rem;
    font-weight: 600;
    font-family: 'SF Mono', ui-monospace, monospace;
    text-align: center;
    border-width: 2px;
}

.door-field-ancho input::placeholder,
.door-field-alto input::placeholder {
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--secondary);
    opacity: 0.6;
}

/* Input de cantidad */
.door-field-qty {
    width: 5rem;
    flex-shrink: 0;
}

.door-field-qty input {
    width: 100%;
    height: 3rem;
    font-size: 1.125rem;
    font-weight: 600;
    font-family: 'SF Mono', ui-monospace, monospace;
    text-align: center;
    border-width: 2px;
}

.dim-bracket-info {
    font-size: 0.8125rem;
    color: var(--accent);
    margin-bottom: var(--space-s);
    font-weight: 500;
}

.door-linea-badge {
    font-size: 0.6875rem;
    font-weight: 700;
    color: #fff;
    padding: 0.15rem 0.5rem;
    border-radius: 0.25rem;
    letter-spacing: 0.3px;
    line-height: 1.3;
}

.door-linea-name {
    font-size: 0.75rem;
    color: var(--secondary);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 140px;
}

/* Precio inline en grupo de dimensiones */
.door-price-inline {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: flex-end;
    padding-bottom: 0.25rem;
}

.door-price-label {
    font-size: 0.6875rem;
    color: var(--secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.door-price-value {
    font-size: 1.125rem;
    font-weight: 700;
    font-feature-settings: 'tnum';
    color: var(--primary);
    line-height: 1.3;
}

.door-price-value.invalid {
    color: var(--error);
    font-size: 0.8125rem;
    font-weight: 600;
}

/* ===== HARDWARE UPGRADES ROW ===== */
.door-row-extras {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    align-items: center;
    padding-top: var(--space-m);
    border-top: 1px solid var(--border-light);
}

.extras-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-right: var(--space-xs);
}

.acc-toggle {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: 0.8125rem;
    color: var(--secondary);
    cursor: pointer;
    padding: var(--space-xs) var(--space-s);
    border-radius: 2rem;
    background: var(--bg);
    border: 1.5px solid transparent;
    transition: all 0.2s;
    -webkit-user-select: none;
    user-select: none;
    min-height: 2.25rem;
}

.acc-toggle:active {
    transform: scale(0.97);
}

.acc-toggle.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.acc-toggle input {
    display: none;
}

.note-field {
    flex: 1 1 100%;
    margin-top: var(--space-xs);
}

.note-field input {
    width: 100%;
    height: 2.25rem;
    padding: 0 var(--space-s);
    font-size: 0.8125rem;
    border: 1px solid var(--border-light);
    border-radius: 0.5rem;
    background: var(--bg);
    color: var(--primary);
}

.note-field input::placeholder {
    color: var(--secondary);
    opacity: 0.6;
}

/* ===== DOOR ERROR MESSAGE ===== */
.door-row-error {
    margin-top: var(--space-s);
    padding: var(--space-xs) var(--space-s);
    background: var(--error-bg);
    border-radius: 0.5rem;
    font-size: 0.8125rem;
    color: var(--error);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
}

.door-row-suggestion {
    color: var(--accent);
    font-weight: 600;
}

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--secondary);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.empty-state p {
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.empty-state .btn {
    min-width: 200px;
}

/* ===== SUMMARY PANEL - HIDDEN ON MOBILE (shown in bottom bar) ===== */
.summary-panel {
    display: none;
}

/* ===== BOTTOM NAVIGATION BAR - MOBILE ===== */
.bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(245,245,247,0.95);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-top: 1px solid var(--border-light);
    padding: 0.75rem 1rem;
    padding-bottom: calc(0.75rem + var(--safe-bottom));
    padding-left: calc(1rem + var(--safe-left));
    padding-right: calc(1rem + var(--safe-right));
    z-index: 200;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
}

.bottom-bar-stats {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    flex: 1;
    min-width: 0;
    overflow: hidden;   /* en pantallas angostas recorta en su borde, no se encima con los botones */
}

.bottom-bar-main {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.bottom-bar-total {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent);
    font-feature-settings: 'tnum';
}

.bottom-bar-label {
    font-size: 0.7rem;
    color: var(--secondary);
}

.bottom-bar-sub {
    font-size: 0.7rem;
    color: var(--secondary);
    display: flex;
    gap: 0.75rem;
}

.bottom-bar-sub span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.bottom-bar-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.bottom-bar-btn {
    height: 42px;
    min-width: 42px;
    padding: 0 13px;
    border-radius: 21px;          /* píldora: ancho automático según el texto */
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;          /* el texto no se parte ni se desborda */
    flex: 0 0 auto;
    cursor: pointer;
    transition: all 0.2s;
}

.bottom-bar-btn:active {
    transform: scale(0.92);
}

.bottom-bar-btn.primary {
    background: var(--accent);
    color: white;
    box-shadow: 0 4px 12px rgba(0,113,227,0.3);
}

.bottom-bar-btn.excel {
    background: #217346;
    color: white;
}

.bottom-bar-btn.summary {
    background: #64748b;          /* slate fijo: legible en light y dark (var(--primary) se volvía blanco en dark) */
    color: white;
}

.bottom-bar-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Pantallas muy angostas (iPhone SE/mini): comprime para que el total no se recorte */
@media (max-width: 374px) {
    .bottom-bar { gap: 0.4rem; }
    .bottom-bar-total { font-size: 0.95rem; }
    .bottom-bar-btn { padding: 0 11px; font-size: 0.74rem; height: 40px; }
}

.bottom-bar-btn.loading {
    position: relative;
    color: transparent;
}

.bottom-bar-btn.loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid white;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ===== SUMMARY SHEET (Slide-up modal) ===== */
.summary-sheet-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 300;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.summary-sheet-overlay.active {
    opacity: 1;
    visibility: visible;
}

.summary-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--card);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    max-height: 85vh;
    overflow-y: auto;
    z-index: 301;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    padding-bottom: var(--safe-bottom);
}

.summary-sheet-overlay.active .summary-sheet {
    transform: translateY(0);
}

.summary-sheet-handle {
    width: 36px;
    height: 5px;
    background: var(--border);
    border-radius: 3px;
    margin: 0.75rem auto;
}

.summary-sheet-header {
    padding: 0 1.25rem 1rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.summary-sheet-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.summary-sheet-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--bg);
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.summary-sheet-body {
    padding: 1.25rem;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border-light);
}

.summary-row:last-child {
    border-bottom: none;
}

.summary-label {
    color: var(--secondary);
}

.summary-value {
    font-weight: 500;
    font-feature-settings: 'tnum';
}

.summary-divider {
    height: 1px;
    background: var(--border);
    margin: 0.75rem 0;
}

.summary-totals {
    background: var(--bg);
    margin: 1rem -1.25rem -1.25rem;
    padding: 1.25rem;
    padding-bottom: calc(1.25rem + var(--safe-bottom));
}

.summary-total-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.summary-total-label {
    color: var(--secondary);
}

.summary-total-value {
    font-weight: 600;
    font-feature-settings: 'tnum';
}

.summary-grand {
    padding-top: 0.75rem;
    margin-top: 0.75rem;
    border-top: 2px solid var(--primary);
}

.summary-grand .summary-total-label {
    font-weight: 600;
    color: var(--primary);
}

.summary-grand .summary-total-value {
    font-size: 1.35rem;
    color: var(--accent);
}

.summary-sale {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px dashed var(--border);
}

.summary-sale .summary-total-label {
    color: #764ba2;
    font-weight: 600;
}

.summary-sale .summary-total-value {
    color: #764ba2;
    font-size: 1.25rem;
}

/* Discount styling */
.discount-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0.6rem;
    background: linear-gradient(135deg, #34c759 0%, #30d158 100%);
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 20px;
    margin-left: 0.5rem;
}

.discount-row {
    background: linear-gradient(135deg, rgba(52,199,89,0.1) 0%, rgba(48,209,88,0.1) 100%);
    border-radius: var(--radius);
    padding: 0.75rem;
    margin-bottom: 0.75rem;
}

.discount-row .summary-total-label {
    color: #34c759;
    font-weight: 600;
}

.discount-row .summary-total-value {
    color: #34c759;
}

.discount-info {
    font-size: 0.7rem;
    color: var(--secondary);
    margin-top: 0.35rem;
}

.discount-next {
    font-size: 0.7rem;
    color: var(--accent);
    margin-top: 0.35rem;
    font-style: italic;
}

/* ===== CONDITIONS CARD ===== */
.conditions-card {
    background: var(--card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
}

.conditions-card h4 {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.75rem;
}

.conditions-list {
    list-style: none;
    font-size: 0.8rem;
    color: var(--secondary);
}

.conditions-list li {
    padding: 0.25rem 0;
    padding-left: 1rem;
    position: relative;
}

.conditions-list li::before {
    content: '•';
    position: absolute;
    left: 0;
    color: var(--accent);
}

/* ===== RECENT QUOTES ===== */
.recent-quotes-card {
    background: var(--card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
}

.recent-quotes-card h4 {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.recent-quotes-card .clear-btn {
    font-size: 0.75rem;
    color: var(--error);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.35rem 0.6rem;
    border-radius: var(--radius);
    min-height: 32px;
}

.recent-quotes-card .clear-btn:active {
    background: var(--error-bg);
}

.recent-quote-item {
    padding: 0.85rem;
    border-radius: var(--radius);
    margin-bottom: 0.6rem;
    background: var(--bg);
    cursor: pointer;
    transition: all 0.2s;
    border: 1.5px solid transparent;
}

.recent-quote-item:active {
    transform: scale(0.98);
}

.recent-quote-item:last-child {
    margin-bottom: 0;
}

.recent-quote-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.35rem;
}

.recent-quote-client {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.recent-quote-date {
    font-size: 0.7rem;
    color: var(--secondary);
}

.recent-quote-details {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--secondary);
}

.recent-quote-total {
    font-weight: 600;
    color: var(--accent);
}

.recent-quotes-empty {
    text-align: center;
    padding: 1.5rem;
    color: var(--secondary);
    font-size: 0.85rem;
}

.recent-quotes-empty span {
    font-size: 2rem;
    display: block;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

/* ===== MODAL WIZARD - MOBILE OPTIMIZED ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    z-index: 400;
    display: none;
    align-items: flex-end;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--card);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    padding-bottom: var(--safe-bottom);
}

.modal-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: var(--card);
    z-index: 1;
}

.modal-header h3 {
    font-size: 1.15rem;
    font-weight: 600;
}

.modal-close {
    width: var(--touch-target);
    height: var(--touch-target);
    background: var(--bg);
    border: none;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--secondary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:active {
    background: var(--border-light);
}

.modal-body {
    padding: 1.25rem;
}

.wizard-step {
    display: none;
}

.wizard-step.active {
    display: block;
}

.wizard-step h4 {
    font-size: 1.0625rem;
    font-weight: 600;
    margin-bottom: var(--space-xs);
    color: var(--primary);
}

.wizard-hint {
    font-size: 0.875rem;
    color: var(--secondary);
    margin-bottom: var(--space-l);
    line-height: 1.5;
}

.wizard-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-s);
}

.wizard-options-compact {
    margin-bottom: var(--space-l);
}

.wizard-option {
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    min-height: 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Tarjeta estilo Fiori — alineada a la izquierda, mas informativa */
.wizard-option-card {
    text-align: left;
    align-items: flex-start;
    padding: var(--space-l) var(--space-m);
    position: relative;
    min-height: auto;
}

.wizard-option:active {
    transform: scale(0.97);
}

.wizard-option.selected {
    border-color: var(--accent);
    background: var(--accent-light);
}

.wizard-option.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Badge de la tarjeta (Mejor precio, Mas vendida, Premium) */
.wizard-option-badge {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--secondary);
    background: var(--bg);
    padding: 0.2rem 0.6rem;
    border-radius: 1rem;
    margin-bottom: var(--space-s);
    display: inline-block;
}

.wizard-option-badge-pop {
    color: #fff;
    background: var(--accent);
}

.wizard-option-badge-premium {
    color: #fff;
    background: #af52de;
}

.wizard-option-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.wizard-option-title {
    font-weight: 700;
    font-size: 1.125rem;
    color: var(--primary);
}

.wizard-option-subtitle {
    font-size: 0.8125rem;
    color: var(--secondary);
    margin-top: 0.15rem;
}

.wizard-option-desc {
    font-size: 0.8125rem;
    color: var(--secondary);
    margin-top: var(--space-xs);
    line-height: 1.5;
}

/* Lista de specs dentro de tarjeta */
.wizard-option-specs {
    list-style: none;
    padding: 0;
    margin: var(--space-s) 0 0;
    font-size: 0.8125rem;
    color: var(--secondary);
    line-height: 1.7;
}

.wizard-option-specs li::before {
    content: '\2713  ';
    color: var(--success);
    font-weight: 700;
}

.wizard-option-specs .wizard-spec-excluded::before {
    content: '\2717  ';
    color: var(--error);
}

.wizard-option-specs .wizard-spec-excluded {
    color: var(--error);
    opacity: 0.8;
}

/* Linea step: 3 columnas en vez de 2 */
.wizard-options-linea {
    grid-template-columns: 1fr;
    gap: var(--space-m);
}

@media (min-width: 600px) {
    .wizard-options-linea {
        grid-template-columns: repeat(3, 1fr);
    }
}

.wizard-field {
    margin-bottom: var(--space-l);
}

.wizard-field label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--secondary);
    margin-bottom: var(--space-xs);
}

.wizard-field input,
.wizard-field select {
    width: 100%;
    height: 3rem;
    padding: 0 var(--space-m);
    font-size: 1.0625rem;
    font-family: inherit;
    border: 1.5px solid var(--border);
    border-radius: 0.5rem;
    background: var(--card);
    color: var(--primary);
}

.wizard-field input:focus,
.wizard-field select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-light);
    background: var(--card);
}

.wizard-dims {
    display: flex;
    gap: var(--space-s);
    align-items: center;
}

.wizard-dims input {
    flex: 1;
    text-align: center;
    font-family: 'SF Mono', ui-monospace, monospace;
    font-weight: 600;
    font-size: 1.375rem;
    height: 3.5rem;
}

.wizard-dims-sep {
    font-size: 1.25rem;
    color: var(--secondary);
    font-weight: 500;
    flex-shrink: 0;
}

.wizard-dims span {
    color: var(--secondary);
    font-size: 1.25rem;
    font-weight: 500;
}

.wizard-limits {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 0.85rem;
    font-size: 0.8rem;
    color: var(--secondary);
    margin-top: 0.75rem;
    line-height: 1.6;
}

.modal-footer {
    padding: 1.25rem;
    border-top: 1px solid var(--border-light);
    display: flex;
    gap: 0.75rem;
    position: sticky;
    bottom: 0;
    background: var(--card);
}

.modal-footer .btn {
    flex: 1;
    min-height: 52px;
    font-size: 1rem;
}

/* ===== ANIMATIONS ===== */
@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes priceUpdate {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); color: var(--accent); }
    100% { transform: scale(1); }
}

@keyframes pricePop {
    0% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
    100% { transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

.slide-up {
    animation: slideUp 0.3s ease;
}

.price-animated {
    animation: priceUpdate 0.3s ease-out;
}

.price-pop {
    animation: pricePop 0.3s ease-out;
}

/* ===== TABLET STYLES (768px+) ===== */
@media (min-width: 768px) {
    .header {
        padding: 0 1.5rem;
        height: calc(56px + var(--safe-top));
    }

    .logo-text {
        display: flex;
        flex-direction: column;
        line-height: 1.2;
    }

    .logo-text span:first-child {
        font-size: 0.6rem;
        color: rgba(255,255,255,0.65);
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    .logo-text span:last-child {
        font-size: 0.9rem;
        font-weight: 600;
        color: #ffffff;
    }

    .header-center {
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }

    .header-menu-btn {
        display: none;
    }

    .main {
        padding: 1.5rem;
    }

    .client-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Tablet: configuracion en 3 columnas */
    .door-group-config {
        grid-template-columns: repeat(3, 1fr);
    }

    .doors-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }

    .doors-header-actions .btn {
        flex: none;
    }

    .modal {
        max-width: 520px;
        border-radius: var(--radius-xl);
        margin: 2rem;
        max-height: calc(100vh - 4rem);
    }

    .modal-overlay {
        align-items: center;
    }
}

/* ===== DESKTOP STYLES (1280px+) ===== */
@media (min-width: 1280px) {
    body {
        padding-bottom: 0;
    }

    .header {
        padding: 0 2rem;
    }

    .header-stats {
        display: flex;
        gap: 1.5rem;
        font-size: 0.8rem;
    }

    .header-stat {
        text-align: center;
    }

    .header-stat-label {
        color: rgba(255,255,255,0.55);
        font-size: 0.6rem;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    .header-stat-value {
        font-weight: 600;
        font-size: 0.9rem;
        font-feature-settings: 'tnum';
        color: #ffffff;
    }

    .header-stat-value.accent {
        color: #38bdf8;
    }

    .main {
        max-width: 1500px;
        margin: 0 auto;
        padding: 1.5rem 2rem;
        display: grid;
        grid-template-columns: 1fr 340px;
        gap: 1.5rem;
    }

    .client-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .field input,
    .field select {
        height: var(--input-height);
        font-size: 0.9375rem;
    }

    .margin-grid {
        display: flex;
        align-items: center;
        gap: 1.5rem;
        flex-wrap: wrap;
    }

    .margin-input-group {
        grid-column: auto;
        padding: 0;
        background: transparent;
    }

    .margin-result {
        flex-direction: column;
        align-items: flex-start;
    }

    /* Desktop: configuracion en una fila */
    .door-group-config {
        grid-template-columns: repeat(4, 1fr);
    }

    /* Desktop: dims y qty en una fila visual */
    .door-group-dims {
        grid-template-columns: 1fr auto 1fr;
    }

    .door-group-qty {
        margin-top: calc(-1 * var(--space-m));
    }

    .door-field select,
    .door-field input {
        height: 2.5rem;
        font-size: 0.9375rem;
    }

    .door-field-ancho input,
    .door-field-alto input,
    .door-field-qty input {
        height: 2.75rem;
        font-size: 1.125rem;
    }

    .door-price-value {
        font-size: 1.0625rem;
    }

    /* Hide bottom bar on desktop */
    .bottom-bar {
        display: none;
    }

    /* Show summary panel on desktop */
    .summary-panel {
        display: block;
        position: sticky;
        top: 72px;
        align-self: start;
    }

    .summary-card {
        background: var(--card);
        border-radius: var(--radius-lg);
        box-shadow: var(--shadow);
        overflow: hidden;
    }

    .summary-header {
        background: var(--primary);
        color: white;
        padding: 1rem 1.25rem;
    }

    .summary-header h3 {
        font-size: 0.9rem;
        font-weight: 600;
    }

    .summary-header-sub {
        font-size: 0.75rem;
        opacity: 0.7;
        margin-top: 0.15rem;
    }

    .summary-body {
        padding: 1rem 1.25rem;
    }

    .summary-row {
        font-size: 0.8rem;
        padding: 0.4rem 0;
    }

    .summary-totals {
        margin: 1rem -1.25rem -1rem;
        padding: 1rem 1.25rem;
    }

    .summary-total-row {
        font-size: 0.85rem;
    }

    .summary-grand .summary-total-value {
        font-size: 1.2rem;
    }

    .summary-sale .summary-total-value {
        font-size: 1.1rem;
    }

    .summary-actions {
        padding: 1rem 1.25rem;
        border-top: 1px solid var(--border-light);
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    .btn-generate,
    .btn-email,
    .btn-excel {
        width: 100%;
        padding: var(--space-m);
        font-size: 0.9375rem;
        font-weight: 600;
        border: none;
        border-radius: 0.5rem;
        cursor: pointer;
        transition: all 0.2s;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: var(--space-xs);
        min-height: var(--touch-target);
    }

    .btn-generate {
        background: var(--accent);
        color: white;
    }

    .btn-generate:hover:not(:disabled) {
        background: var(--accent-hover);
        transform: translateY(-1px);
    }

    .btn-email {
        background: var(--header-navy);
        color: white;
    }

    .btn-email:hover:not(:disabled) {
        background: #1e293b;
        transform: translateY(-1px);
    }

    .btn-excel {
        background: #217346;
        color: white;
    }

    .btn-excel:hover:not(:disabled) {
        background: #1e6b3e;
        transform: translateY(-1px);
    }

    .btn-generate:disabled,
    .btn-email:disabled,
    .btn-excel:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

    .btn-generate.loading,
    .btn-email.loading,
    .btn-excel.loading {
        position: relative;
        color: transparent;
    }

    .btn-generate.loading::after,
    .btn-excel.loading::after {
        content: '';
        position: absolute;
        width: 18px;
        height: 18px;
        border: 2px solid white;
        border-top-color: transparent;
        border-radius: 50%;
        animation: spin 0.8s linear infinite;
    }

    .conditions-card,
    .recent-quotes-card {
        margin-top: 0.75rem;
    }

    .note-field {
        min-width: 200px;
        margin-top: 0;
    }

    .acc-toggle {
        min-height: 32px;
        padding: 0.35rem 0.5rem;
        font-size: 0.75rem;
    }
}

/* ===== LARGE DESKTOP (1400px+) ===== */
@media (min-width: 1400px) {
    .main {
        grid-template-columns: 1fr 380px;
    }

    .client-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

/* ===== DARK MODE SUPPORT ===== */
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #1c1c1e;
        --card: #2c2c2e;
        --primary: #ffffff;
        --secondary: #98989d;
        --border: #3a3a3c;
        --border-light: #38383a;
        --success-bg: rgba(52,199,89,0.2);
        --error-bg: rgba(255,59,48,0.2);
        --warning-bg: rgba(255,149,0,0.2);
        --accent-light: rgba(0,113,227,0.2);
    }

    /* El header mantiene su color oscuro propio */
    .header {
        background: #1e293b;
    }

    .bottom-bar,
    .summary-sheet {
        background: rgba(44,44,46,0.95);
    }

    /* Login card forzar legibilidad */
    .login-overlay {
        background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    }

    /* Wizard modal */
    .modal {
        background: var(--card);
    }
}

/* ===== PRINT STYLES ===== */
@media print {
    .header,
    .bottom-bar,
    .summary-panel,
    .doors-header-actions,
    .door-row-actions,
    .modal-overlay {
        display: none !important;
    }

    body {
        padding: 0;
        background: white;
    }

    .main {
        display: block;
        padding: 1rem;
    }

    .door-row {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}

/* ===== ACCESSIBILITY ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus visible for keyboard navigation */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Hide focus for mouse users */
:focus:not(:focus-visible) {
    outline: none;
}

/* ===== LOGIN SCREEN ===== */
.login-overlay {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.login-overlay.hidden {
    display: none;
}

.login-card {
    background: var(--card);
    border-radius: var(--radius-xl);
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    text-align: center;
}

.login-logo {
    margin-bottom: var(--space-l);
}

.login-brand {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.5px;
}

.login-brand-sub {
    font-size: 0.875rem;
    color: var(--secondary);
    margin-top: 4px;
}

.login-logo img {
    height: 70px;
    width: auto;
    margin-bottom: 0.5rem;
}

.login-title {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: var(--space-xs);
}

.login-subtitle {
    font-size: 0.9375rem;
    color: var(--secondary);
    margin-bottom: var(--space-xl);
}

.login-input {
    width: 100%;
    height: 3.25rem;
    padding: 0 var(--space-l);
    font-size: 1.0625rem;
    border: 2px solid var(--border);
    border-radius: 0.5rem;
    margin-bottom: var(--space-m);
    transition: all 0.2s;
    background: var(--bg);
    color: var(--primary);
}

.login-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-light);
    background: var(--card);
}

.login-btn {
    width: 100%;
    height: 3.25rem;
    background: var(--header-navy);
    color: white;
    font-size: 1.0625rem;
    font-weight: 600;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.login-btn:hover {
    background: #1e293b;
    transform: translateY(-1px);
}

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

.login-error {
    color: var(--error);
    font-size: 0.875rem;
    margin-top: 1rem;
    font-weight: 500;
}

.login-footer {
    font-size: 0.75rem;
    color: var(--secondary);
    margin-top: 2rem;
}

/* ===== OVERFLOW PREVENTION ===== */
html, body {
    overflow-x: hidden !important;
    width: 100% !important;
}

.main,
.content-area,
.client-section,
.margin-section,
.doors-section,
.door-row,
.door-row-inner,
.door-group,
.door-row-extras,
.door-row-header {
    max-width: 100%;
    overflow-x: hidden;
}

.door-field select,
.door-field input,
.field input,
.field select {
    max-width: 100%;
}

/* Prevenir que select options largos desborden */
select {
    text-overflow: ellipsis;
}

/* ===== TOAST NOTIFICATIONS ===== */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius);
    color: white;
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    max-width: 380px;
    pointer-events: auto;
    animation: toastSlideIn 0.35s cubic-bezier(0.22, 1, 0.36, 1);
    backdrop-filter: blur(8px);
}

.toast-icon {
    font-size: 1.1rem;
    font-weight: 700;
    flex-shrink: 0;
    width: 1.5rem;
    height: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
}

.toast-success {
    background: rgba(33, 115, 70, 0.95);
}

.toast-error {
    background: rgba(220, 53, 69, 0.95);
}

.toast-info {
    background: rgba(0, 113, 227, 0.95);
}

.toast-exit {
    animation: toastSlideOut 0.3s ease-in forwards;
}

@keyframes toastSlideIn {
    from {
        transform: translateX(calc(100% + 1rem));
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes toastSlideOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-0.75rem);
    }
}

@media (max-width: 600px) {
    .toast-container {
        top: auto;
        bottom: 5rem;
        right: 0.75rem;
        left: 0.75rem;
    }

    .toast {
        max-width: 100%;
    }
}

/* =====================================================
   WIZARD IGT — Categorías grid + Productos grid
   ===================================================== */

.wizard-options-categorias {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
}

.wizard-options-categorias .wizard-option {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 1rem;
    gap: 0.25rem;
    cursor: pointer;
}

.wizard-options-categorias .wizard-option strong {
    display: inline-block;
    background: var(--accent, #0071e3);
    color: #fff;
    padding: 0.2rem 0.55rem;
    border-radius: 0.4rem;
    font-size: 0.8rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.wizard-options-categorias .wizard-option span {
    font-weight: 600;
    color: var(--text, #1d1d1f);
    font-size: 0.95rem;
    line-height: 1.25;
}

.wizard-options-categorias .wizard-option small {
    color: var(--text-secondary, #6e6e73);
    font-size: 0.78rem;
}

.wizard-productos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
    max-height: 60vh;
    overflow-y: auto;
    padding-right: 0.25rem;
}

.wizard-product-card {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem;
    border: 2px solid var(--border, #d2d2d7);
    border-radius: 0.75rem;
    background: var(--surface, #fff);
    cursor: pointer;
    transition: border-color 0.15s ease, transform 0.1s ease;
    align-items: stretch;
}

.wizard-product-card:hover {
    border-color: var(--accent, #0071e3);
}

.wizard-product-card:active {
    transform: scale(0.98);
}

.wizard-product-card.selected {
    border-color: var(--accent, #0071e3);
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.15);
}

.wizard-product-img {
    width: 64px;
    height: 64px;
    flex-shrink: 0;
    background: #f5f5f7;
    border-radius: 0.5rem;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wizard-product-img img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.wizard-product-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    flex: 1;
    min-width: 0;
}

.wizard-product-code {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--text-secondary, #6e6e73);
}

.wizard-product-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text, #1d1d1f);
    line-height: 1.25;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.wizard-product-dims {
    font-size: 0.78rem;
    color: var(--text-secondary, #6e6e73);
}

.wizard-product-price {
    margin-top: auto;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--accent, #0071e3);
}

.wizard-summary {
    padding: 0.85rem 1rem;
    background: #f5f5f7;
    border-radius: 0.6rem;
    margin-bottom: 1rem;
}

.wizard-summary strong {
    font-size: 0.95rem;
    color: var(--text, #1d1d1f);
}

.wizard-summary-precio {
    margin-top: 0.4rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent, #0071e3);
}

/* Línea de producto: meta info y precio unitario */
.item-meta {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.5rem 0;
    margin: 0.5rem 0;
    border-top: 1px dashed var(--border, #d2d2d7);
    border-bottom: 1px dashed var(--border, #d2d2d7);
    font-size: 0.85rem;
}

.item-meta-row {
    color: var(--text-secondary, #6e6e73);
}

.item-meta-row strong {
    color: var(--text, #1d1d1f);
    margin-right: 0.35rem;
}

.item-precio-unit {
    font-weight: 600;
    color: var(--accent, #0071e3);
}

@media (max-width: 600px) {
    .wizard-options-categorias {
        grid-template-columns: repeat(2, 1fr);
    }
    .wizard-productos-grid {
        grid-template-columns: 1fr;
        max-height: 55vh;
    }
}

/* =====================================================
   PRECIOS EDITABLES POR LÍNEA (costo + venta)
   ===================================================== */

.door-group-prices {
    display: grid;
    grid-template-columns: 90px 1fr 1fr;
    grid-template-rows: auto auto;
    gap: 0.5rem 0.75rem;
    margin-top: 0.6rem;
    align-items: end;
}

.door-group-prices .door-field input {
    width: 100%;
    padding: 0.5rem 0.65rem;
    font-size: 0.95rem;
    font-weight: 600;
}

.door-group-prices .door-field label {
    font-size: 0.75rem;
    color: var(--text-secondary, #6e6e73);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.door-group-prices .door-price-inline {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    padding: 0.5rem 0;
    margin-top: 0.25rem;
    border-top: 1px dashed var(--border, #d2d2d7);
}

.door-group-prices .door-price-label {
    font-size: 0.72rem;
    color: var(--text-secondary, #6e6e73);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.door-group-prices .door-price-value {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text, #1d1d1f);
    font-feature-settings: 'tnum';
}

.input-costo {
    color: #b45309;
    background: rgba(245, 158, 11, 0.06);
    border-color: #fcd34d !important;
}

.input-costo:focus {
    border-color: #f59e0b !important;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.18);
}

.input-venta {
    color: #0e7490;
    background: rgba(8, 145, 178, 0.06);
    border-color: #67e8f9 !important;
    font-weight: 700 !important;
}

.input-venta:focus {
    border-color: #0891b2 !important;
    box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.18);
}

.door-ganancia {
    font-size: 0.8rem;
    margin-top: 0.25rem;
    font-weight: 600;
    color: var(--text-secondary, #6e6e73);
}

.door-ganancia.positive { color: #0f834d; }
.door-ganancia.negative { color: #c0392b; }

.item-meta-catalog {
    color: var(--text-secondary, #6e6e73);
    font-size: 0.8rem;
    font-style: italic;
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.btn-link-tiny {
    background: none;
    border: none;
    color: var(--accent, #0071e3);
    font-size: 0.75rem;
    cursor: pointer;
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    font-weight: 600;
}

.btn-link-tiny:hover {
    background: rgba(0, 113, 227, 0.1);
    text-decoration: underline;
}

@media (max-width: 600px) {
    .door-group-prices {
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem 0.6rem;
    }
    .door-group-prices .door-field-qty {
        grid-column: 1 / -1;
        max-width: 120px;
    }
    /* Margen section apilada limpia */
    .margin-grid {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    .margin-input-group {
        justify-content: space-between;
    }
    .margin-result {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
    .margin-grid > .btn,
    .margin-grid > button.btn {
        width: 100%;
        margin-top: 0.5rem;
    }
}

/* Botón "Aplicar a todas" dentro de la sección margen */
.margin-grid > .btn,
.margin-grid > button.btn {
    grid-column: 1 / -1;
    justify-self: center;
    background: rgba(255, 255, 255, 0.95);
    color: var(--accent, #0071e3);
    border: 1px solid rgba(255, 255, 255, 0.6);
    padding: 0.55rem 1.25rem;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    border-radius: 0.5rem;
    transition: transform 0.1s ease, background 0.15s ease;
}

.margin-grid > .btn:hover,
.margin-grid > button.btn:hover {
    background: white;
    transform: translateY(-1px);
}

.margin-grid > .btn:active,
.margin-grid > button.btn:active {
    transform: scale(0.98);
}
