:root {
    --bg-main: #f8fafc;
    /* Fondo súper limpio y amigable */
    --panel-bg: rgba(255, 255, 255, 0.95);
    --panel-border: rgba(27, 117, 188, 0.1);
    /* Toque azul tenue en bordes */
    --brand-blue: #1B75BC;
    /* Azul primario del Logo Sigma (el cuerpo de la letra) */
    --brand-orange: #F58220;
    /* Naranja cálido de la carita feliz */
    --accent-glow: rgba(245, 130, 32, 0.3);
    /* Resplandor naranja */
    --text-primary: #334155;
    --text-muted: #64748b;
    --premium: #F58220;
    /* El Naranja será el color de las acciones Premium y de mejora */
    --user-msg-bg: #eff6ff;
    /* Azul súper claro para los mensajes del usuario */
    --bot-msg-bg: #ffffff;
    /* Blanco para el bot */
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Outfit', -apple-system, sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    background-image:
        radial-gradient(circle at 10% 20%, rgba(27, 117, 188, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(245, 130, 32, 0.05) 0%, transparent 40%);
}

.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--panel-border);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
}

.app-layout {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 320px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--panel-border);
    padding: 1.5rem;
    z-index: 10;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 2rem;
    color: #0f172a;
}

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

.accent {
    color: var(--brand-orange);
}

.session-info {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px dashed var(--panel-border);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
}

.pulse {
    width: 10px;
    height: 10px;
    background-color: var(--brand-orange);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--accent-glow);
    animation: pulsate 2s infinite;
}

@keyframes pulsate {
    0% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.6;
        transform: scale(1.1);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* History area */
.history-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px dashed var(--panel-border);
}

.history-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 1rem;
    max-height: 150px;
    overflow-y: auto;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.8rem;
    background: white;
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    font-size: 0.85rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
}

.history-item:hover {
    border-color: var(--brand-blue);
    background: var(--user-msg-bg);
}

.history-item i {
    width: 14px;
    height: 14px;
    color: var(--brand-orange);
}

.phase-badge {
    margin-left: auto;
    font-size: 0.7rem;
    padding: 2px 6px;
    background: #f1f5f9;
    color: var(--text-muted);
    border-radius: 10px;
}

.btn-new-project {
    width: 100%;
    background: transparent;
    border: 1px dashed var(--brand-blue);
    color: var(--brand-blue);
    padding: 0.5rem;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-new-project:hover {
    background: rgba(27, 117, 188, 0.05);
}

.mt-4 {
    margin-top: 1.5rem;
}

/* DMAIC Tracker */
.dmaic-tracker {
    flex: 1;
}

.tracker-title {
    font-size: 0.85rem;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

#dmaic-steps {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.dmaic-step {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.8rem;
    border-radius: 12px;
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.step-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.03);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.step-content h5 {
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 0.2rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.step-content p {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.dmaic-step.active {
    background: white;
    border-color: rgba(27, 117, 188, 0.2);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
}

.dmaic-step.active .step-icon {
    background: var(--brand-blue);
    color: white;
    box-shadow: 0 4px 10px rgba(27, 117, 188, 0.3);
}

.dmaic-step.locked {
    opacity: 0.5;
}

.lock-icon {
    width: 14px;
    height: 14px;
    color: var(--text-muted);
}

/* Horizontal DMAIC Tracker Override */
.dmaic-tracker.horizontal {
    background: white;
    padding: 0.8rem 2.5rem;
    border-bottom: 1px solid var(--panel-border);
    z-index: 4;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.02);
    flex: none;
    /* Do not grow */
}

.dmaic-tracker.horizontal #dmaic-steps {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.dmaic-tracker.horizontal .dmaic-step {
    flex: 1;
    justify-content: center;
    padding: 0.5rem;
    gap: 0.6rem;
}

.dmaic-tracker.horizontal .step-icon {
    width: 32px;
    height: 32px;
}

.dmaic-tracker.horizontal .step-icon i {
    width: 16px;
    height: 16px;
}

.dmaic-tracker.horizontal .step-content h5 {
    font-size: 0.95rem;
    margin-bottom: 0px;
}

.dmaic-tracker.horizontal .step-content p {
    font-size: 0.75rem;
    margin-top: 0px;
}


.sidebar-footer {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.subscription-status {
    font-size: 0.85rem;
    font-weight: 500;
    text-align: center;
    padding: 0.6rem;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.03);
}

.subscription-status.premium {
    background: rgba(245, 158, 11, 0.1);
    color: var(--premium);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.btn-upgrade {
    background: white;
    color: var(--premium);
    border: 2px solid var(--premium);
    padding: 0.8rem;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.btn-upgrade:hover {
    background: var(--premium);
    color: white;
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.3);
}

/* Workspace */
.workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background: linear-gradient(180deg, transparent 0%, rgba(16, 185, 129, 0.02) 100%);
}

.workspace-header {
    padding: 1.5rem 2.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--panel-border);
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    z-index: 5;
}

.workspace-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #0f172a;
}

.subtitle {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

.btn-tool {
    background: white;
    border: 1px solid var(--panel-border);
    color: var(--text-primary);
    padding: 0.7rem 1.2rem;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
}

.btn-tool:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    transform: translateY(-1px);
}

.upload-panel {
    position: absolute;
    top: 85px;
    right: 2.5rem;
    padding: 2rem;
    border-radius: 20px;
    width: 450px;
    z-index: 20;
    box-shadow: 0 12px 40px rgba(27, 117, 188, 0.15);
    background: white;
    border: 1px solid rgba(27, 117, 188, 0.1);
}

.upload-panel h3 {
    margin-bottom: 0.8rem;
    color: var(--brand-blue);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
}

.upload-panel p {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 1.8rem;
    line-height: 1.5;
}

.upload-controls {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.file-input,
.text-input {
    width: 100%;
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    padding: 1rem;
    border-radius: 12px;
    color: var(--text-primary);
    font-family: inherit;
    outline: none;
    transition: all 0.2s;
    font-size: 0.95rem;
}

.text-input:focus {
    border-color: var(--brand-blue);
    background: white;
    box-shadow: 0 4px 12px rgba(27, 117, 188, 0.08);
}

.file-input {
    padding: 0.8rem;
    cursor: pointer;
}

.btn-primary {
    background: var(--brand-orange);
    color: white;
    border: none;
    padding: 0.9rem;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    transition: 0.2s;
    box-shadow: 0 4px 15px var(--accent-glow);
}

.btn-primary:hover {
    background: #E67311;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--accent-glow);
}

/* Restored History Item Styles from previous chunk replacement */
.history-item:hover {
    background: #e2e8f0;
}

.history-item.active-history {
    border-left: 3px solid var(--brand-orange);
    background: #f8fafc;
}

.phase-badge {
    background: var(--brand-blue);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.70rem;
    font-weight: 600;
}

.btn-delete-proj {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 2px;
    display: flex;
    align-items: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.btn-delete-proj:hover {
    color: #ef4444;
    background: #fee2e2;
}


/* Poka-Yoke Panel overhauls */
.poka-yoke-panel {
    position: absolute;
    top: 85px;
    right: 2.5rem;
    width: 480px;
    padding: 2rem;
    border-radius: 20px;
    background: white;
    z-index: 20;
    box-shadow: 0 12px 40px rgba(245, 130, 32, 0.15);
    border: 1px solid rgba(245, 130, 32, 0.2);
    max-height: 75vh;
    overflow-y: auto;
}

.poka-yoke-panel::-webkit-scrollbar {
    width: 6px;
}

.poka-yoke-panel::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

.poka-yoke-panel h3 {
    color: var(--brand-orange);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.8rem;
    font-size: 1.25rem;
}

.poka-yoke-panel>p {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

/* OCR Controls Premium Styling */
.ocr-controls {
    background: #eff6ff;
    border: 1px dashed var(--brand-blue);
    padding: 1.2rem;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.8rem;
    margin-bottom: 2rem;
    transition: all 0.2s;
}

.ocr-controls:hover {
    background: #e0f2fe;
}

.btn-secondary {
    background: white;
    color: var(--brand-blue);
    border: 2px solid var(--brand-blue);
    padding: 0.8rem 1.2rem;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s;
    font-size: 0.95rem;
}

.btn-secondary:hover {
    background: var(--brand-blue);
    color: white;
    box-shadow: 0 4px 12px rgba(27, 117, 188, 0.2);
}

.dynamic-form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.2rem;
    margin-bottom: 1.5rem;
    padding: 1.2rem;
    background: #f8fafc;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: capitalize;
}

/* Collected Data Table Styling */
.collected-data h4 {
    color: var(--brand-blue);
    margin-bottom: 1rem;
    font-size: 1.1rem;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 0.5rem;
}

.table-container {
    max-height: 200px;
    overflow-y: auto;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    margin-bottom: 1.5rem;
}

#data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    background: white;
}

#data-table th {
    background: #f1f5f9;
    padding: 0.8rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    position: sticky;
    top: 0;
}

#data-table td {
    padding: 0.8rem;
    border-bottom: 1px solid #f1f5f9;
    color: var(--text-muted);
}

#data-table tr:hover td {
    background: #f8fafc;
}

/* Feed Area Layout */
.feed-area {
    flex: 1;
    overflow-y: auto;
    padding: 2.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    scroll-behavior: smooth;
}

/* Scrollbar customization */
.feed-area::-webkit-scrollbar {
    width: 8px;
}

.feed-area::-webkit-scrollbar-track {
    background: transparent;
}

.feed-area::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

.feed-area::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}

.feed-entry {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    max-width: 85%;
}

.feed-entry.user {
    align-self: flex-end;
    align-items: flex-end;
}

.entry-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.85rem;
    margin-bottom: 0.2rem;
}

.expert-avatar {
    width: 26px;
    height: 26px;
    color: var(--brand-orange);
    background: rgba(245, 130, 32, 0.1);
    padding: 4px;
    border-radius: 50%;
}

.feed-entry.user .expert-avatar {
    color: var(--brand-blue);
    background: rgba(27, 117, 188, 0.1);
}

.feed-entry.expert .entry-header strong {
    color: var(--brand-orange);
    font-weight: 600;
}

.timestamp {
    color: #94a3b8;
    font-size: 0.8rem;
}

.entry-body {
    padding: 1.2rem 1.5rem;
    border-radius: 0 16px 16px 16px;
    line-height: 1.6;
    font-size: 1.05rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.02);
}

.feed-entry.expert .entry-body {
    background: var(--bot-msg-bg);
    border: 1px solid var(--panel-border);
    color: var(--text-primary);
}

.feed-entry.user .entry-body {
    background: var(--user-msg-bg);
    border: 1px solid rgba(59, 130, 246, 0.1);
    border-radius: 16px 0 16px 16px;
    color: #0f172a;
}

.entry-body p {
    margin-bottom: 1rem;
}

.entry-body p:last-child {
    margin-bottom: 0;
}

.entry-body strong {
    color: #0f172a;
    font-weight: 600;
}

.entry-body em {
    color: var(--brand-orange);
    font-style: normal;
    font-weight: 500;
}

/* Console Input */
.input-console {
    padding: 1.5rem 2.5rem;
    background: white;
    border-top: 1px solid var(--panel-border);
    z-index: 5;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.02);
}

.console-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    padding: 0.6rem 1.5rem;
    border-top: 1px solid rgba(0,0,0,0.06);
    background: var(--bg-main);
}

/* PREM badge */
.prem-badge {
    font-size: 0.55rem;
    font-weight: 700;
    background: var(--brand-orange);
    color: white;
    padding: 2px 5px;
    border-radius: 4px;
    letter-spacing: 0.5px;
    vertical-align: middle;
    line-height: 1;
}

/* V2: Billetera de Ahorros */
.billetera-widget {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    margin: 12px 1rem 16px;
    background: linear-gradient(135deg, #e8f5e9, #f1f8e9);
    border-radius: 10px;
    border: 1px solid #c8e6c9;
}
.billetera-icon { font-size: 1.3rem; }
.billetera-text { display: flex; flex-direction: column; }
.billetera-label { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.5px; color: #666; font-weight: 600; }
.billetera-amount { font-size: 0.95rem; font-weight: 700; color: #2e7d32; }

/* Floating Action Button for Data Capture */
.fab-capture {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--brand-orange);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    z-index: 50;
    transition: transform 0.2s, box-shadow 0.2s;
}
.fab-capture:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0,0,0,0.35);
}

/* V3: Simulator FAB */
.fab-simulator {
    position: fixed;
    bottom: 145px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #2e7d32;
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    z-index: 50;
    font-size: 1.4rem;
    transition: transform 0.2s, box-shadow 0.2s;
}
.fab-simulator:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0,0,0,0.35);
}

/* V3: Simulator sliders */
.simulator-sliders { display: flex; flex-direction: column; gap: 18px; margin-bottom: 20px; }
.sim-slider-group { display: flex; flex-direction: column; gap: 4px; }
.sim-slider-header { display: flex; justify-content: space-between; align-items: center; }
.sim-slider-label { font-weight: 600; font-size: 0.85rem; color: var(--text-primary); }
.sim-slider-value { font-weight: 700; font-size: 0.9rem; color: #2e7d32; background: #e8f5e9; padding: 2px 8px; border-radius: 4px; }
.sim-slider-range { display: flex; justify-content: space-between; font-size: 0.7rem; color: var(--text-muted); margin-top: 2px; }
.sim-slider-group input[type=range] {
    width: 100%;
    height: 6px;
    appearance: none;
    background: linear-gradient(to right, #c8e6c9, #2e7d32);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}
.sim-slider-group input[type=range]::-webkit-slider-thumb {
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #2e7d32;
    border: 3px solid white;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    cursor: pointer;
}

/* Simulator result card */
.simulator-result {
    background: linear-gradient(135deg, #e8f5e9, #f1f8e9);
    border: 1px solid #c8e6c9;
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.sim-predicted, .sim-improvement, .sim-savings { display: flex; justify-content: space-between; align-items: center; }
.sim-label { font-size: 0.8rem; color: #555; font-weight: 500; }
.sim-value { font-size: 1.4rem; font-weight: 800; color: #2e7d32; }
.sim-delta { font-size: 1.1rem; font-weight: 700; }
.sim-delta.positive { color: #2e7d32; }
.sim-delta.negative { color: #c62828; }
.sim-savings-val { font-size: 1.1rem; font-weight: 700; color: #1565c0; }
.fab-capture svg { width: 24px; height: 24px; }
.fab-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--brand-blue);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
}

.console-wrapper:focus-within {
    border-color: var(--brand-blue);
    background: white;
    box-shadow: 0 0 0 4px rgba(27, 117, 188, 0.1);
}

.console-wrapper textarea {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    padding: 0.8rem;
    font-size: 1.05rem;
    resize: none;
    outline: none;
    font-family: inherit;
    line-height: 1.5;
}

.console-wrapper textarea::placeholder {
    color: #94a3b8;
}

.btn-send-console {
    background: #f1f5f9;
    color: var(--brand-blue);
    border: none;
    width: 50px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-send-console:hover {
    background: var(--brand-blue);
    color: white;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1100;
    padding: 1rem;
}

.hidden {
    display: none !important;
}

.premium-modal {
    width: 100%;
    max-width: 500px;
    padding: 2.5rem;
    border-radius: 20px;
    position: relative;
    border: none;
    background: white;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
    max-height: 85vh;
    overflow-y: auto;
}

.close-modal {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: #f1f5f9;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}

.close-modal:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.modal-badge {
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 1.2rem;
}

.premium-modal h2 {
    font-size: 2rem;
    margin-bottom: 0.8rem;
    color: #0f172a;
}

.premium-modal p {
    color: var(--text-muted);
    font-size: 1.05rem;
    line-height: 1.5;
}

.price-highlight {
    color: var(--brand-orange);
    font-weight: 700;
    font-size: 1.2rem;
}

.features-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin: 2rem 0;
}

.feat {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    background: #f8fafc;
    padding: 1.2rem;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    font-weight: 500;
    color: #334155;
}

.feat i {
    color: var(--premium);
}

.full-width {
    width: 100%;
}

.mt-4 {
    margin-top: 1.5rem;
}

/* --- User Profile Badge --- */
.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-profile-badge {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    background: none;
    padding: 4px 0;
    margin-bottom: 4px;
    border-radius: 0;
    border: none;
    box-shadow: none;
    outline: none;
    color: var(--brand-blue);
    font-weight: 500;
    cursor: pointer;
    transition: color 0.2s;
}

.user-profile-badge:hover > .tracker-title {
    color: #145d8a;
}

.user-dropdown {
    opacity: 1 !important;
}

.user-profile-badge.hidden {
    display: none !important;
}

.user-dropdown {
    position: absolute;
    top: 100%;
    left: 1rem;
    right: 1rem;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    z-index: 100;
    display: flex;
    flex-direction: column;
    padding: 5px 0;
}

.user-dropdown.hidden {
    display: none;
}

.dropdown-item {
    background: none;
    border: none;
    padding: 10px 15px;
    text-align: left;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.dropdown-item:hover {
    background: #f8fafc;
    color: var(--brand-blue);
}

.hidden-desktop {
    display: none !important;
}

/* --- Mobile Responsiveness --- */
.mobile-menu-btn {
    display: none;
}

.mobile-overlay-shadow {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.mobile-overlay-shadow.active {
    display: block;
}

@media (max-width: 768px) {
    /* Prevent iOS Safari auto-zoom on input focus */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    textarea,
    select {
        font-size: 16px !important;
    }

    .app-layout {
        flex-direction: column;
    }

    .sidebar {
        position: fixed;
        left: -320px;
        top: 12px;
        height: calc(100vh - 24px);
        width: 300px;
        background: var(--bg-main);
        transition: left 0.3s ease;
        z-index: 1000;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.12);
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 3rem;
        border-radius: 0 16px 16px 0;
    }

    .sidebar.mobile-active {
        left: 0;
    }

    .sidebar-user-area {
        padding: 0 1.5rem;
        margin-bottom: 1rem;
    }

    .mobile-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        color: var(--text-primary);
        cursor: pointer;
        padding: 12px;
        margin-right: 8px;
        margin-left: -8px;
        min-width: 44px;
        min-height: 44px;
    }

    .workspace-header {
        justify-content: flex-start;
        align-items: center;
    }

    .header-titles h1 {
        font-size: 1.2rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .header-titles p {
        font-size: 0.8rem;
    }

    .console-wrapper {
        flex-direction: row;
        align-items: flex-end;
        border-radius: 24px;
        padding: 6px 6px 6px 14px;
        gap: 6px;
        background: white;
        border: 1px solid #e2e8f0;
        margin: 0 10px calc(12px + env(safe-area-inset-bottom)) 10px;
    }

    .console-wrapper textarea {
        min-height: 36px;
        max-height: 120px;
        font-size: 0.95rem;
        padding: 6px 0;
        overflow-y: auto;
        border: none;
        background: transparent;
        resize: none;
        flex: 1;
        line-height: 1.4;
        color: var(--text-primary);
    }

    .btn-send-console {
        width: 36px;
        height: 36px;
        min-width: 36px;
        aspect-ratio: 1;
        border-radius: 50%;
        margin-top: 0;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }

    .stat-cards {
        overflow-x: auto;
        padding-bottom: 10px;
        gap: 15px;
    }

    /* Core Viewport Clamping */
    .workspace {
        width: 100vw;
        max-width: 100vw;
        overflow-x: hidden;
    }

    .feed-area {
        max-width: 100vw;
        padding: 1rem;
        overflow-x: hidden;
    }

    .feed-entry {
        max-width: 100%;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    /* Header & Panel Resize */
    .hidden-desktop {
        display: flex !important;
    }

    .desktop-title,
    .desktop-subtitle,
    .hide-mobile {
        display: none !important;
    }

    .workspace-header {
        padding: max(1rem, env(safe-area-inset-top)) 1rem 1rem 1rem;
        gap: 0.5rem;
    }

    .header-actions {
        gap: 0.5rem;
    }

    .btn-tool {
        padding: 0.6rem;
    }

    .user-profile-badge {
        padding: 5px 10px;
    }

    .upload-panel {
        width: 90vw;
        right: 5vw;
        top: 70px;
        padding: 1.5rem;
    }

    .dmaic-tracker.horizontal {
        padding: 0.5rem 1rem;
        overflow-x: auto;
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
        /* Smooth iOS scrolling */
        scrollbar-width: none;
        /* Firefox */
        -ms-overflow-style: none;
        /* IE/Edge */
    }

    .dmaic-tracker.horizontal::-webkit-scrollbar {
        display: none;
        /* Chrome, Safari, Opera */
    }

    .dmaic-tracker.horizontal #dmaic-steps {
        gap: 1.5rem;
        width: max-content;
        /* Force container to fit all steps without breaking lines */
        justify-content: flex-start;
    }

    .dmaic-tracker.horizontal .dmaic-step {
        flex: 0 0 auto;
        /* Prevent shrinking */
        padding: 0.5rem 0.2rem;
    }
}

/* ===== Onboarding Tutorial ===== */
.onboarding-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.65);
    z-index: 9999;
    transition: opacity 0.3s ease;
}

.onboarding-spotlight {
    position: fixed;
    border-radius: 16px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.6), 0 0 20px rgba(27, 117, 188, 0.4);
    z-index: 10000;
    transition: all 0.4s ease;
    pointer-events: none;
}

.onboarding-tooltip {
    position: fixed;
    width: 340px;
    background: white;
    border-radius: 16px;
    padding: 24px;
    z-index: 10001;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transition: all 0.4s ease;
    border-top: 4px solid var(--brand-blue);
}

.onboarding-step-count {
    font-size: 0.75rem;
    color: var(--brand-blue);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.onboarding-tooltip h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 8px;
}

.onboarding-tooltip p {
    font-size: 0.9rem;
    color: #64748b;
    line-height: 1.5;
    margin-bottom: 20px;
}

.onboarding-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.onboarding-btn-skip {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 0.85rem;
    padding: 8px 12px;
}

.onboarding-btn-skip:hover { color: #64748b; }

.onboarding-btn-next {
    background: var(--brand-blue);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.9rem;
    transition: transform 0.2s;
}

.onboarding-btn-next:hover { transform: scale(1.05); }

.btn-repeat-tour {
    background: none;
    border: 1px solid var(--panel-border);
    color: var(--text-muted);
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.75rem;
    margin-top: 8px;
    width: 100%;
    transition: all 0.2s;
}
.btn-repeat-tour:hover { border-color: var(--brand-blue); color: var(--brand-blue); }

@media (max-width: 768px) {
    .onboarding-tooltip {
        width: calc(100vw - 32px);
        left: 16px !important;
        max-width: 360px;
    }
}