/* =====================================================
   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);
    --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 */
    --touch-target: 44px;
    --input-height: 48px;
    --input-height-sm: 40px;

    /* 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;
    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: #2d3748;
    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;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    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: var(--success);
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.save-status.saving {
    color: var(--warning);
}

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

.asesor-badge:hover {
    background: var(--accent);
    color: white;
}

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

.asesor-icon {
    font-size: 1rem;
}

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

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

.asesor-badge.active {
    background: var(--success-bg);
    border: 1px solid var(--success);
}

.asesor-badge.active .asesor-name {
    color: var(--success);
}

/* 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%;
}

.content-area {
    width: 100%;
}

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

.section-title {
    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;
    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: 0.35rem;
}

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

.field input,
.field select {
    height: var(--input-height);
    padding: 0 1rem;
    font-size: 1rem;
    font-family: inherit;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    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: white;
}

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

/* ===== 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: 0.75rem;
    padding: 0.5rem;
    background: rgba(255,255,255,0.15);
    border-radius: var(--radius);
}

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

.margin-input {
    width: 80px;
    height: var(--input-height-sm);
    padding: 0.5rem;
    font-size: 1.25rem;
    font-weight: 600;
    font-family: 'SF Mono', ui-monospace, monospace;
    text-align: center;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: var(--radius);
    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: 0.75rem;
    background: rgba(255,255,255,0.15);
    border-radius: var(--radius);
}

.margin-result-label {
    font-size: 0.65rem;
    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;
}

/* ===== DOORS SECTION - MOBILE ===== */
.doors-section {
    padding: 1rem;
}

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

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

.doors-header-actions {
    display: flex;
    gap: 0.5rem;
}

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

/* ===== BUTTONS - TOUCH FRIENDLY ===== */
.btn {
    min-height: var(--touch-target);
    padding: 0.75rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: var(--radius);
    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 - MOBILE CARD STYLE ===== */
.door-row {
    background: var(--bg);
    border-radius: var(--radius-lg);
    padding: 1rem;
    margin-bottom: 0.75rem;
    border: 2px solid transparent;
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
}

.door-row.valid {
    border-color: var(--success);
    background: var(--success-bg);
}

.door-row.invalid {
    border-color: var(--error);
    background: var(--error-bg);
}

/* 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: 1rem;
}

.door-row-number {
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.door-row-status {
    font-size: 0.7rem;
    padding: 0.25rem 0.6rem;
    border-radius: 20px;
    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;
}

/* Door row grid - Mobile stacked */
.door-row-main {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.door-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.door-field.full-width {
    grid-column: 1 / -1;
}

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

.door-field select,
.door-field input {
    height: var(--input-height-sm);
    padding: 0 0.75rem;
    font-size: 0.9rem;
    font-family: inherit;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    background: white;
    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);
}

.door-field input[type="number"] {
    font-family: 'SF Mono', ui-monospace, monospace;
    font-weight: 500;
    text-align: center;
}

/* Dimensions group */
.dim-group {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.dim-group input {
    flex: 1;
    min-width: 0;
}

.dim-group span {
    color: var(--secondary);
    font-size: 1rem;
    font-weight: 500;
}

/* Price display */
.door-price {
    grid-column: 1 / -1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: white;
    border-radius: var(--radius);
    margin-top: 0.5rem;
}

.door-price-label {
    font-size: 0.75rem;
    color: var(--secondary);
    font-weight: 500;
}

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

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

/* ===== ACCESSORIES ROW ===== */
.door-row-extras {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px dashed var(--border);
}

.acc-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--secondary);
    cursor: pointer;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    background: white;
    border: 1.5px solid var(--border);
    transition: all 0.2s;
    -webkit-user-select: none;
    user-select: none;
    min-height: 40px;
}

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

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

.acc-toggle input {
    display: none;
}

.color-select {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    flex: 1;
    min-width: 150px;
}

.color-select select {
    flex: 1;
    height: 40px;
    padding: 0 0.75rem;
    font-size: 0.85rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    background: white;
}

.color-ral {
    width: 100px;
    height: 40px;
    padding: 0 0.75rem;
    font-size: 0.85rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
}

.note-field {
    flex: 1;
    min-width: 100%;
    margin-top: 0.5rem;
}

.note-field input {
    width: 100%;
    height: 40px;
    padding: 0 0.75rem;
    font-size: 0.85rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    background: white;
}

/* ===== DOOR ERROR MESSAGE ===== */
.door-row-error {
    grid-column: 1 / -1;
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: white;
    border-radius: var(--radius);
    font-size: 0.8rem;
    color: var(--error);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.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(255,255,255,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.75rem;
    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;
}

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

.bottom-bar-total {
    font-size: 1.25rem;
    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;
}

.bottom-bar-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    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: var(--primary);
    color: white;
}

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

.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: 1rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    color: var(--primary);
}

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

.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;
}

.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;
}

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

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

.wizard-option-desc {
    font-size: 0.75rem;
    color: var(--secondary);
    margin-top: 0.25rem;
}

.wizard-field {
    margin-bottom: 1.25rem;
}

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

.wizard-field input,
.wizard-field select {
    width: 100%;
    height: var(--input-height);
    padding: 0 1rem;
    font-size: 1rem;
    font-family: inherit;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
}

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

.wizard-dims {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

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

.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: var(--secondary);
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    .logo-text span:last-child {
        font-size: 0.9rem;
        font-weight: 600;
        color: var(--primary);
    }

    .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);
    }

    .door-row-main {
        grid-template-columns: repeat(4, 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 (1024px+) ===== */
@media (min-width: 1024px) {
    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: var(--secondary);
        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';
    }

    .header-stat-value.accent {
        color: var(--accent);
    }

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

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

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

    .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;
    }

    .door-row-main {
        grid-template-columns: 90px 110px 160px 70px 85px 60px 1fr;
        gap: 0.5rem;
    }

    .door-field.full-width {
        grid-column: auto;
    }

    .door-field select,
    .door-field input {
        height: 36px;
        font-size: 0.8rem;
    }

    .door-price {
        grid-column: auto;
        flex-direction: column;
        align-items: flex-end;
        padding: 0;
        background: transparent;
        margin-top: 0;
    }

    .door-price-label {
        font-size: 0.6rem;
    }

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

    /* 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-excel {
        width: 100%;
        padding: 0.85rem;
        font-size: 0.9rem;
        font-weight: 600;
        border: none;
        border-radius: var(--radius);
        cursor: pointer;
        transition: all 0.2s;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
    }

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

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

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

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

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

    .btn-generate.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;
    }

    .door-row-main {
        grid-template-columns: 100px 120px 180px 80px 100px 70px 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);
    }

    .door-field select,
    .door-field input,
    .acc-toggle,
    .color-select select,
    .color-ral,
    .note-field input {
        background: var(--bg);
        color: var(--primary);
    }

    .door-price,
    .door-row-error {
        background: var(--bg);
    }

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

/* ===== 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: white;
    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: 1.5rem;
}

.login-logo img {
    height: 60px;
    width: auto;
}

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

.login-subtitle {
    font-size: 0.9rem;
    color: var(--secondary);
    margin-bottom: 2rem;
}

.login-input {
    width: 100%;
    height: 52px;
    padding: 0 1.25rem;
    font-size: 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1rem;
    transition: all 0.2s;
}

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

.login-btn {
    width: 100%;
    height: 52px;
    background: #2d3748;
    color: white;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius);
    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;
}
