:root {
    --bg: #ffffff;
    --surface: #ffffff;
    --surface2: #f8fafc;
    --border: #e2e8f0;
    --accent: #ff4f00;
    --accent2: #ff7a38;
    --blue: #3b82f6;
    --green: #22c55e;
    --yellow: #f59e0b;
    --red: #ef4444;
    --text: #1e293b;
    --muted: #64748b;
    --label: #475569;
    --radius: 10px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}

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

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Skip link: visible solo al enfocar (mejor práctica para agentes con teclado) */
.skip-link {
    position: absolute;
    top: -100px;
    left: 16px;
    padding: 10px 16px;
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    text-decoration: none;
    border-radius: 8px;
    z-index: 1000;
    transition: top 0.2s;
}
.skip-link:focus {
    top: 12px;
    outline: 2px solid var(--text);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .btn:hover { transform: none; }
    .ticket-card { animation: none; }
    .toast { transition: opacity 0.2s; }
}

/* ===== Main Layout ===== */
.main {
    display: grid;
    grid-template-columns: 1fr 420px;
    gap: 0;
    min-height: 100vh;
}

.cards-row {
    display: grid;
    grid-template-columns: 6fr 6fr;
    gap: 16px;
    margin-bottom: 16px;
}
.cards-row .card { margin-bottom: 0; }
.cards-row #cardContacto { grid-column: 1; }

/* Tabs: Interés | Tickets */
.cards-row-tabs {
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.tabs-triggers {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 0;
}
.tabs-triggers button {
    flex: 1;
    min-width: 0;
    padding: 10px 8px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius) var(--radius) 0 0;
    position: relative;
    margin-bottom: -1px;
    text-align: center;
}
.tabs-triggers button:hover { color: var(--text); }
.tabs-triggers button[aria-selected="true"] {
    color: var(--accent);
    background: var(--surface);
    border-bottom: 1px solid var(--surface);
}
.tabs-triggers button[aria-selected="true"]::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 2px;
    background: var(--accent);
}
.tabs-panels {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 0 var(--radius) var(--radius) var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.tabs-panel {
    display: none;
    flex: 1;
    flex-direction: column;
    min-height: 0;
    overflow: auto;
}
.tabs-panel.active {
    display: flex;
}
.tabs-panel .card {
    border: none;
    border-radius: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.tabs-panel .card .card-header { border-radius: 0; }
.tabs-panel .card .proyecto-stack,
.tabs-panel .card .tickets-accordion,
.tabs-panel .card .tab-fields-stack { flex: 1; min-height: 0; overflow: auto; }
.tab-fields-stack { display: flex; flex-direction: column; gap: 12px; padding: 16px; }
.tab-fields-stack.tab-fields-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 16px; }
.tab-fields-stack .form-group { margin-bottom: 0; }
.field-display {
    min-height: 36px;
    padding: 8px 10px;
    border-radius: var(--radius);
    background: var(--bg-muted, #f1f3f5);
    color: var(--text);
    font-size: 14px;
    line-height: 1.4;
}
.field-display:empty { color: var(--text-muted); }
.field-display:empty::before { content: '—'; }

/* Compra Fácil: sección expandible (UX mejorada) */
.comprafacil-section {
    margin-bottom: 16px;
}
.comprafacil-trigger {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 100%;
    padding: 14px 48px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.comprafacil-trigger:hover {
    background: var(--bg-muted, #f1f3f5);
}
.comprafacil-trigger:focus { outline: none; }
.comprafacil-trigger:focus-visible {
    box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent, #2563eb);
}
.comprafacil-section.open .comprafacil-trigger {
    border-bottom-color: transparent;
    border-radius: var(--radius) var(--radius) 0 0;
    background: var(--bg-muted, #f8f9fa);
    box-shadow: 0 -1px 0 0 var(--border);
}
.comprafacil-trigger-inner {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.comprafacil-trigger-inner .comprafacil-sep {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--text-muted);
    opacity: 0.7;
}
.comprafacil-trigger-inner .comprafacil-toggle-label {
    font-weight: 500;
    font-size: 13px;
    color: var(--text-muted);
}
.comprafacil-chevron {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    transition: transform 0.25s ease, color 0.2s ease;
}
.comprafacil-trigger:hover .comprafacil-chevron,
.comprafacil-section.open .comprafacil-chevron { color: var(--text); }
.comprafacil-section.open .comprafacil-chevron {
    transform: translateY(-50%) rotate(180deg);
}
.comprafacil-content {
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height 0.35s ease-out, opacity 0.25s ease-out;
}
.comprafacil-section.open .comprafacil-content {
    max-height: 1200px;
    opacity: 1;
    transition: max-height 0.4s ease-in, opacity 0.2s ease-in;
}
.comprafacil-fields {
    padding: 16px;
    background: var(--surface);
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px 16px;
}
@media (max-width: 900px) {
    .comprafacil-fields { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 500px) {
    .comprafacil-fields { grid-template-columns: 1fr; }
    .tab-fields-stack.tab-fields-grid { grid-template-columns: 1fr; }
}

.notas-historial-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}
.notas-historial-row .card { margin-bottom: 0; }
.notas-tipificacion-col {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.notas-historial-row .notes-area { min-height: 100px; }
.notas-historial-row #historialWrap { max-height: 280px; overflow-y: auto; }

.left-panel {
    padding: 24px;
    padding-bottom: 16px;
    border-right: 1px solid var(--border);
    background: #fafbfc;
}

.right-panel {
    padding: 24px;
    padding-bottom: 16px;
    background: var(--surface);
}

.left-panel .card:last-child,
.right-panel .card:last-child {
    margin-bottom: 0;
}

/* ===== Section Cards ===== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 18px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

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

.card-edit-btn {
    padding: 6px;
    border: none;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, background 0.2s;
}

.card-edit-btn:hover {
    color: var(--accent);
    background: rgba(255, 79, 0, 0.1);
}

.card-edit-btn .icon {
    width: 16px;
    height: 16px;
}

.card-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    flex-shrink: 0;
}

.card-icon.orange {
    background: rgba(255, 79, 0, 0.15);
    color: #ea580c;
}

.card-icon.blue {
    background: rgba(59, 130, 246, 0.15);
}

.card-icon.green {
    background: rgba(34, 197, 94, 0.15);
}

.card-icon.yellow {
    background: rgba(245, 158, 11, 0.15);
}

.card-icon.purple {
    background: rgba(139, 92, 246, 0.15);
    color: #7c3aed;
}

.card-icon.teal {
    background: rgba(20, 184, 166, 0.15);
    color: #0d9488;
}

.card-icon.amber {
    background: rgba(245, 158, 11, 0.15);
    color: #d97706;
}

.card-icon.slate {
    background: rgba(100, 116, 139, 0.15);
    color: #475569;
}

.card-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

/* ===== Form ===== */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

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

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group.full {
    grid-column: 1 / -1;
}

/* Proyecto: dropdowns apilados verticalmente */
.proyecto-stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.proyecto-stack select {
    width: 100%;
}

.hora-seguimiento-wrap {
    display: flex;
    gap: 8px;
}
.hora-seguimiento-wrap select {
    flex: 1;
}

.label-with-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
}

.label-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.select-compact {
    min-height: 36px;
    padding: 8px 34px 8px 12px;
    font-size: 13px;
}

.checkbox-inline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 500;
    color: var(--muted);
    cursor: pointer;
    margin: 0;
}

.checkbox-inline input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: var(--accent);
}

.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 500;
    color: var(--label);
    text-transform: none;
    letter-spacing: 0;
    cursor: pointer;
    white-space: nowrap;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}

label {
    font-size: 11px;
    font-weight: 600;
    color: var(--label);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

input,
select {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 7px;
    color: var(--text);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    padding: 9px 12px;
    min-height: 40px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    width: 100%;
}

select {
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: 12px;
    background-position: right 10px center;
    padding-right: 34px;
}

input:focus,
select:focus {
    border-color: var(--label);
    box-shadow: 0 0 0 2px rgba(71, 85, 105, 0.15);
}

input:focus-visible,
select:focus-visible,
button:focus-visible {
    outline: 2px solid var(--label);
    outline-offset: 2px;
}

input.autofilled,
select.autofilled {
    border-color: var(--border);
    background: var(--surface2);
}

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

select option {
    background: #fff;
    color: var(--text);
}

select:disabled {
    background-color: var(--surface2);
    color: var(--muted);
    cursor: not-allowed;
    opacity: 0.85;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: 12px;
    background-position: right 10px center;
}

/* Search box */
.search-card { margin-bottom: 16px; }
.search-box-wrap {
    position: relative;
    width: 100%;
}
.search-box-wrap input {
    width: 100%;
    padding: 10px 14px 10px 40px;
    font-size: 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}
.search-box-wrap input::placeholder { color: var(--muted); }
.search-box-wrap::before {
    content: '';
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='M21 21l-4.35-4.35'/%3E%3C/svg%3E") no-repeat center;
    pointer-events: none;
}
.search-spinner-box {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
}

/* Phone search */
.phone-search-wrap {
    position: relative;
}

.phone-search-wrap input {
    padding-right: 40px;
}

.search-spinner {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    display: none;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: translateY(-50%) rotate(360deg);
    }
}

.search-spinner.active {
    display: block;
}

/* ===== Status Badge ===== */
.status-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 18px;
    font-size: 12px;
    color: var(--text);
    font-weight: 500;
}

.status-bar svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.status-bar.hidden {
    display: none;
}

.hidden { display: none !important; }

/* Modal Interés de compra */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}
.modal-overlay.hidden { display: none !important; }

/* Overlay enviando a HubSpot */
.hubspot-overlay .modal-dialog {
    max-width: 360px;
    text-align: center;
}
.hubspot-overlay .modal-dialog h2 {
    margin-bottom: 16px;
    font-size: 16px;
}
.hubspot-progress-wrap {
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 20px;
}
.hubspot-progress-bar {
    height: 100%;
    width: 0%;
    background: var(--accent);
    border-radius: 4px;
    transition: width 0.25s ease;
}
.hubspot-overlay.sending .hubspot-progress-bar {
    animation: hubspotProgress 2s ease-out forwards;
}
.hubspot-overlay.done .hubspot-progress-bar {
    width: 100%;
}
.hubspot-overlay.done .hubspot-progress-wrap { margin-bottom: 12px; }
@keyframes hubspotProgress {
    0% { width: 0%; }
    100% { width: 100%; }
}
.hubspot-overlay .hubspot-success-icon {
    display: none;
    color: var(--green);
    margin-bottom: 12px;
}
.hubspot-overlay.done .hubspot-success-icon { display: block; }

/* Panel de atajos de teclado — UX mejorada */
.keyboard-shortcuts-wrap {
    position: fixed;
    inset: 0;
    z-index: 1001;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    padding: 24px;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}
.keyboard-shortcuts-wrap.open {
    pointer-events: auto;
    opacity: 1;
    visibility: visible;
}
.keyboard-shortcuts-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    cursor: pointer;
}
.keyboard-shortcuts-panel {
    position: relative;
    max-width: 360px;
    width: 100%;
    background: var(--surface);
    border-radius: 14px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.06);
    overflow: hidden;
    font-size: 13px;
    transform: translateY(12px);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.keyboard-shortcuts-wrap.open .keyboard-shortcuts-panel {
    transform: translateY(0);
}
@media (prefers-reduced-motion: reduce) {
    .keyboard-shortcuts-wrap,
    .keyboard-shortcuts-panel { transition: none; }
    .keyboard-shortcuts-wrap.open .keyboard-shortcuts-panel { transform: none; }
}
.keyboard-shortcuts-panel-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    background: linear-gradient(135deg, var(--surface2) 0%, var(--surface) 100%);
    border-bottom: 1px solid var(--border);
}
.keyboard-shortcuts-panel-header-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}
.keyboard-shortcuts-panel-header-icon .icon { width: 20px; height: 20px; }
.keyboard-shortcuts-panel-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}
.keyboard-shortcuts-panel-header p {
    margin: 2px 0 0 0;
    font-size: 11px;
    color: var(--muted);
}
.keyboard-shortcuts-panel ul {
    list-style: none;
    margin: 0;
    padding: 12px 20px 16px;
}
.keyboard-shortcuts-panel li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 10px 12px;
    margin-bottom: 4px;
    border-radius: 8px;
    transition: background 0.15s ease;
}
.keyboard-shortcuts-panel li:hover {
    background: var(--surface2);
}
.keyboard-shortcuts-panel li:last-child { margin-bottom: 0; }
.keyboard-shortcuts-panel .shortcut-desc {
    font-size: 13px;
    color: var(--text);
}
.keyboard-shortcuts-panel .shortcut-keys {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}
.keyboard-shortcuts-panel .shortcut-keys .plus {
    font-size: 10px;
    color: var(--muted);
    margin: 0 1px;
}
.keyboard-shortcuts-panel kbd {
    padding: 4px 8px;
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    background: linear-gradient(180deg, #fff 0%, var(--surface2) 100%);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    box-shadow: 0 1px 0 var(--border);
    min-width: 24px;
    text-align: center;
}
.keyboard-shortcuts-panel-footer {
    padding: 10px 20px 14px;
    font-size: 11px;
    color: var(--muted);
    border-top: 1px solid var(--border);
}
.keyboard-shortcuts-trigger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    color: var(--muted);
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: color 0.2s, background 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.keyboard-shortcuts-trigger:hover {
    color: var(--accent);
    border-color: var(--accent2);
    background: rgba(255, 79, 0, 0.06);
}
.keyboard-shortcuts-trigger:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--accent2);
}
.keyboard-shortcuts-trigger .trigger-kbd {
    font-size: 14px;
    opacity: 0.9;
}

.modal-dialog {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    max-width: 420px;
    width: 100%;
    padding: 24px;
}
.modal-dialog h2 {
    margin: 0 0 20px 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
}
.modal-dialog .form-group { margin-bottom: 14px; }
.modal-dialog .form-group:last-of-type { margin-bottom: 20px; }
.modal-dialog .btn-row { display: flex; gap: 10px; justify-content: flex-end; }
.modal-dialog .btn { padding: 10px 18px; }

/* Script con IA */
.ai-script-card {
    background: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 100%);
    border: 1px solid rgba(139, 92, 246, 0.2);
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.06);
}
.ai-script-desc {
    font-size: 12px;
    color: var(--label);
    margin-bottom: 14px;
    line-height: 1.5;
    padding: 8px 10px;
    background: rgba(255,255,255,0.6);
    border-radius: 6px;
}
.ai-quick-prompts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}
.ai-prompt-btn {
    background: #fff;
    border: 1px solid rgba(139, 92, 246, 0.25);
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 12px;
    color: #6d28d9;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}
.ai-prompt-btn:hover {
    background: rgba(139, 92, 246, 0.12);
    border-color: rgba(139, 92, 246, 0.4);
    transform: translateY(-1px);
}
.ai-input-wrap {
    position: relative;
    margin-bottom: 12px;
}
.ai-input-wrap input {
    width: 100%;
    min-height: 42px;
    padding: 10px 44px 10px 14px;
    border-radius: 8px;
}
.ai-input-icon-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, background 0.2s;
}
.ai-input-icon-btn:hover {
    color: #6d28d9;
    background: rgba(139, 92, 246, 0.12);
}
.ai-input-icon-btn .icon {
    width: 18px;
    height: 18px;
}
.ai-response-wrap {
    background: #fff;
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 8px;
    padding: 14px;
    min-height: 90px;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.04);
}
.ai-response-placeholder {
    font-size: 12px;
    color: var(--muted);
    font-style: italic;
}
.ai-response-content {
    font-size: 13px;
    color: var(--text);
    line-height: 1.65;
    white-space: pre-wrap;
}

/* ===== Notes Area ===== */
.notes-area {
    width: 100%;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    padding: 12px;
    resize: none;
    outline: none;
    min-height: 130px;
    transition: border-color 0.2s;
    line-height: 1.6;
}

.notes-area:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* ===== Tipificación / Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 600;
    padding: 10px 18px;
    transition: all 0.18s;
    letter-spacing: 0.02em;
}

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

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(255, 79, 0, 0.35);
}

.btn-secondary {
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--label);
}

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

.btn-success {
    background: linear-gradient(135deg, #16a34a, #22c55e);
    color: #fff;
}

.btn-success:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(34, 197, 94, 0.3);
}

.btn-cta {
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    color: #fff;
    font-size: 14px;
    padding: 12px 24px;
    box-shadow: 0 2px 12px rgba(255, 79, 0, 0.25);
}
.btn-cta:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 79, 0, 0.4);
}
.btn-cta:active {
    transform: translateY(0);
}
.btn-row-cta {
    margin-top: 4px;
}
.btn-row-cta .btn {
    width: 100%;
}

.progress-hint {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.25);
    border-radius: 8px;
    font-size: 12px;
    color: #15803d;
    margin-bottom: 12px;
}
.progress-hint-icon {
    font-size: 14px;
    font-weight: 700;
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
}

.btn-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* ===== Ticket Card ===== */
/* ===== Tickets acordeón ===== */
.tickets-accordion {
    margin-top: 16px;
}

.tickets-empty {
    font-size: 12px;
    color: var(--muted);
    text-align: center;
    padding: 16px;
    background: var(--surface2);
    border-radius: var(--radius);
    border: 1px dashed var(--border);
}

.ticket-item {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 6px;
    overflow: hidden;
    background: var(--surface);
}

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

.ticket-summary {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.2s;
    gap: 8px;
}

.ticket-summary:hover {
    background: var(--surface2);
}

.ticket-check {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}

.ticket-summary-left {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
}

.ticket-summary-id {
    font-size: 11px;
    font-weight: 600;
    color: var(--label);
    flex-shrink: 0;
}

.ticket-summary-contacto {
    font-size: 12px;
    color: var(--text);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ticket-summary-gestion {
    font-size: 11px;
    color: var(--muted);
    flex-shrink: 0;
}

.ticket-summary-sep {
    font-size: 10px;
    color: var(--muted);
    flex-shrink: 0;
}

.ticket-summary-chevron {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    color: var(--muted);
    transition: transform 0.2s;
}

.ticket-item.open .ticket-summary-chevron {
    transform: rotate(180deg);
}

.ticket-details {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.ticket-item.open .ticket-details {
    max-height: 500px;
}

.ticket-details-inner {
    padding: 10px 12px 12px;
    border-top: 1px solid var(--border);
    background: var(--surface2);
}

.ticket-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.ticket-field {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.ticket-field label {
    font-size: 10px;
    color: var(--muted);
}

.ticket-field .tval {
    font-size: 13px;
    color: var(--text);
    font-weight: 500;
}

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

.ticket-notes {
    font-size: 12px;
    color: var(--muted);
    white-space: pre-wrap;
}

/* ===== Historial ===== */
.history-item {
    display: flex;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

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

.history-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    margin-top: 5px;
    flex-shrink: 0;
}

.history-dot-icon {
    width: 22px;
    height: 22px;
    margin-top: 0;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.history-empty {
    font-size: 12px;
    color: var(--muted);
    text-align: center;
    padding: 16px 0;
}

.history-content {
    flex: 1;
}

.history-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
}

.history-sub {
    font-size: 11px;
    color: var(--muted);
    margin-top: 2px;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--surface2);
    border: 1px solid var(--green);
    border-radius: 10px;
    padding: 14px 20px;
    font-size: 13px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow);
    z-index: 999;
    opacity: 0;
    transform: translateY(16px);
    transition: all 0.3s ease;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast-icon {
    font-size: 18px;
}

/* ===== Section Title ===== */
.section-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* ===== Dividers ===== */
.divider {
    height: 1px;
    background: var(--border);
    margin: 18px 0;
}

/* ===== Tipificación Select ===== */
.tip-select-wrap {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.tip-select-wrap .form-group {
    flex: 1;
}

/* Utilidades para agentes (evitar estilos inline) */
.mb-14 { margin-bottom: 14px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.ticket-field-full { grid-column: 1 / -1; }
.ticket-notes { font-size: 12px; color: var(--muted); white-space: pre-wrap; }

/* Oculto visualmente pero accesible a lectores de pantalla (mejor práctica agentes) */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ===== Script de ayuda al usuario ===== */
.script-card {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 1px solid rgba(59, 130, 246, 0.25);
}

.script-header {
    margin-bottom: 14px;
    padding: 10px 14px;
    background: var(--surface2);
    border-radius: 8px;
    border: 1px solid var(--border);
}
.script-meta-item {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 4px;
    letter-spacing: 0.02em;
}
.script-meta-item:last-child { margin-bottom: 0; }
.script-meta-item strong {
    color: var(--text);
    font-weight: 500;
    margin-left: 4px;
}

.script-list {
    list-style: none;
    padding: 0;
    margin: 0;
    counter-reset: script;
}

.script-list li {
    display: flex;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(59, 130, 246, 0.15);
    font-size: 13px;
    color: var(--text);
    line-height: 1.5;
}

.script-list li:last-child { border-bottom: none; }

.script-num {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    background: var(--blue);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
}

.script-text {
    flex: 1;
}

/* Iconos SVG (sustituyen emojis) */
.icon {
    width: 1.25em;
    height: 1.25em;
    flex-shrink: 0;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.card-icon .icon { width: 18px; height: 18px; }
.section-title .icon { width: 14px; height: 14px; margin-right: 2px; }
.btn .icon { width: 16px; height: 16px; }
.toast-icon .icon { width: 20px; height: 20px; }
.history-dot-icon .icon { width: 14px; height: 14px; }

/* ===== Responsive ===== */
@media (max-width: 900px) {
    .main {
        grid-template-columns: 1fr;
    }

    .right-panel {
        border-top: 1px solid var(--border);
    }
}

.tickets-compact {
    max-height: 280px;
    overflow-y: auto;
}

@media (max-width: 1024px) {
    .cards-row {
        grid-template-columns: 1fr;
    }
    .cards-row #cardContacto { grid-column: auto; }
    .notas-historial-row { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .cards-row { grid-template-columns: 1fr; }
}


