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

:root {
    --apple-blue: #10b981;
    --apple-blue-dark: #059669;
    --accent-rgb: 16, 185, 129;
    --gradient-text-end: #065f46;
    --accent-secondary: #34d399;
    --bg-start: #f3f4f6;
    --bg-end: #f3f4f6;
    --card-bg: #ffffff;
    --card-border: #e5e7eb;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --input-bg: #f9fafb;
    --input-border: #d1d5db;
    --input-focus: rgba(16, 185, 129, 0.4);
    --danger: #ef4444;
    --success: #10b981;
    --radius: 8px;
    --radius-lg: 12px;
    --sidebar-bg: #111827;
    --topbar-bg: #ffffff;
    --dropdown-bg: #ffffff;
    --select-option-bg: #ffffff;
    --sidebar-text: #9ca3af;
    --sidebar-text-active: #ffffff;
    --sidebar-hover-bg: rgba(255, 255, 255, 0.06);
    --sidebar-active-bg: rgba(16, 185, 129, 0.15);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.03);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Inter', system-ui, sans-serif;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-start);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    padding: 20px;
}

/* Auth pages card */
.card {
    width: 100%;
    max-width: 420px;
    padding: 40px 36px;
    border-radius: var(--radius-lg);
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    box-shadow: var(--shadow-lg);
    position: relative;
    z-index: 1;
}

.card h1 {
    font-size: 28px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 6px;
    letter-spacing: -0.5px;
    color: var(--text-primary);
    background: none;
    -webkit-background-clip: unset;
    -webkit-text-fill-color: unset;
    background-clip: unset;
}

.card .subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 15px;
    margin-bottom: 32px;
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input {
    width: 100%;
    padding: 12px 14px;
    font-size: 15px;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--radius);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input::placeholder {
    color: #9ca3af;
}

.form-group input:focus {
    border-color: var(--apple-blue);
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.15);
    background: #fff;
}

.btn {
    display: block;
    width: 100%;
    padding: 12px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
    text-align: center;
    text-decoration: none;
}

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

.btn-primary {
    background: var(--apple-blue);
    color: #fff;
    box-shadow: 0 2px 8px rgba(var(--accent-rgb), 0.25);
}

.btn-primary:hover {
    background: var(--apple-blue-dark);
    box-shadow: 0 4px 12px rgba(var(--accent-rgb), 0.3);
}

.btn-secondary {
    background: #f3f4f6;
    color: var(--text-primary);
    border: 1px solid var(--card-border);
}

.btn-secondary:hover {
    background: #e5e7eb;
}

.btn.btn-outline {
    background: transparent;
    color: var(--apple-blue);
    border: 1px solid var(--apple-blue) !important;
}

.btn.btn-outline:hover {
    background: var(--apple-blue);
    color: #fff;
    border-color: var(--apple-blue) !important;
}

.btn-danger {
    background: #fef2f2;
    color: var(--danger);
    border: 1px solid #fecaca;
}

.btn-danger:hover {
    background: #fee2e2;
}

.btn-success {
    background: #ecfdf5;
    color: var(--success);
    border: 1px solid #a7f3d0;
}

.btn-success:hover {
    background: #d1fae5;
}

.btn:disabled,
.btn.btn-export-loading {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
    pointer-events: none;
}

.btn-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-right: 6px;
    vertical-align: middle;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: btn-spin 0.6s linear infinite;
}

@keyframes btn-spin {
    to { transform: rotate(360deg); }
}

.link-row {
    text-align: center;
    margin-top: 20px;
    font-size: 14px;
    color: var(--text-secondary);
}

.link-row a {
    color: var(--apple-blue);
    text-decoration: none;
    font-weight: 500;
    transition: opacity 0.2s;
}

.link-row a:hover {
    opacity: 0.8;
    text-decoration: underline;
}

.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    margin-bottom: 20px;
    line-height: 1.4;
}

.alert-error {
    background: #fef2f2;
    color: var(--danger);
    border: 1px solid #fecaca;
}

.alert-success {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.checkbox-group {
    margin-bottom: 4px;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--apple-blue);
    cursor: pointer;
}

/* Cookie policy */
.cookie-policy h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 20px 0 8px;
}

.cookie-policy h3:first-child {
    margin-top: 10px;
}

.cookie-policy p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.cookie-policy strong {
    color: var(--apple-blue);
}

.cookie-item {
    margin-bottom: 24px;
}

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

.forgot-link {
    text-align: right;
    margin-top: -10px;
    margin-bottom: 18px;
}

.forgot-link a {
    color: var(--text-secondary);
    font-size: 13px;
    text-decoration: none;
    transition: color 0.2s;
}

.forgot-link a:hover {
    color: var(--apple-blue);
}

/* ========================================
   Dashboard
   ======================================== */
.dashboard-card {
    max-width: 500px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s;
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
}

.stat-card .top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stat-card .top .stat-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-top: 0;
}

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon-blue {
    background: rgba(var(--accent-rgb), 0.1);
    color: var(--apple-blue);
}

.stat-icon-green {
    background: #ecfdf5;
    color: #10b981;
}

.stat-icon-purple {
    background: #f5f3ff;
    color: #8b5cf6;
}

.stat-icon-cyan {
    background: #ecfeff;
    color: #06b6d4;
}

.stat-icon-red {
    background: #fef2f2;
    color: var(--danger);
}

.stat-number-red {
    color: var(--danger);
}

.stat-card-wide {
    grid-column: span 2;
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-number {
    font-size: 28px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.5px;
    color: var(--text-primary);
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Progress bar in stat cards */
.progress-bar {
    width: 100%;
    height: 6px;
    background: #f3f4f6;
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar .fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.6s ease;
}

.progress-bar .fill-green {
    background: #10b981;
}

.progress-bar .fill-blue {
    background: var(--apple-blue);
}

.progress-bar .fill-purple {
    background: #8b5cf6;
}

.progress-bar .fill-cyan {
    background: #06b6d4;
}

.progress-bar .fill-red {
    background: var(--danger);
}

.progress-bar .fill-orange {
    background: #f97316;
}

.progress-bar .fill-indigo {
    background: #6366f1;
}

.progress-bar .fill-amber {
    background: #f59e0b;
}

.progress-bar .fill-teal {
    background: #14b8a6;
}

.progress-bar .fill-pink {
    background: #ec4899;
}

.stat-icon-orange {
    background: #fff7ed;
    color: #f97316;
}

.stat-icon-indigo {
    background: #eef2ff;
    color: #6366f1;
}

.stat-icon-amber {
    background: #fffbeb;
    color: #f59e0b;
}

.stat-icon-teal {
    background: #f0fdfa;
    color: #14b8a6;
}

.stat-icon-pink {
    background: #fdf2f8;
    color: #ec4899;
}

.dashboard-section {
    margin-top: 32px;
}

.dashboard-section-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dashboard-section-title svg {
    color: var(--text-secondary);
}

.progress-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.chart-card {
    display: flex;
    flex-direction: column;
}

.chart-container {
    position: relative;
    height: 260px;
    margin: 20px 0;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    padding-top: 8px;
    border-top: 1px solid var(--card-border);
}

.chart-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.chart-legend-color {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.chart-legend-label {
    color: var(--text-secondary);
}

.chart-legend-value {
    font-weight: 600;
    color: var(--text-primary);
}

@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

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

    .stat-card-wide {
        grid-column: span 1;
    }

    .charts-grid {
        grid-template-columns: 1fr;
    }
}

.user-info {
    text-align: center;
    margin-bottom: 28px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--card-border);
}

.user-info .avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--apple-blue), var(--accent-secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 700;
    color: #fff;
    margin: 0 auto 14px;
    box-shadow: 0 4px 12px rgba(var(--accent-rgb), 0.25);
}

.user-info h2 {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 4px;
}

.user-info p {
    color: var(--text-secondary);
    font-size: 14px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid var(--card-border);
    font-size: 14px;
}

.info-row .label {
    color: var(--text-secondary);
}

.info-row .value {
    font-weight: 500;
}

.actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 28px;
}

/* Clients */
.clients-card {
    max-width: 720px;
}

.search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    align-items: flex-end;
}

.btn-inline {
    width: auto;
    padding: 12px 24px;
    flex-shrink: 0;
}

.btn-sm {
    display: inline-block;
    width: auto;
    padding: 6px 14px;
    font-size: 13px;
    border-radius: 6px;
}

.table-wrap {
    overflow-x: auto;
    margin-bottom: 8px;
}

.clients-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.clients-table th {
    text-align: left;
    padding: 10px 12px;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--card-border);
    background: #f9fafb;
}

.clients-table td {
    padding: 12px;
    border-bottom: 1px solid #f3f4f6;
    color: var(--text-primary);
}

.clients-table tbody tr:hover {
    background: #f9fafb;
}

.actions-cell {
    white-space: nowrap;
    display: flex;
    gap: 6px;
    align-items: center;
}

.monto-cell {
    white-space: nowrap;
}

.monto-deuda {
    color: var(--danger);
    font-weight: 600;
}

.monto-ok {
    color: var(--success);
    font-weight: 600;
}

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

.empty-state {
    text-align: center;
    color: var(--text-secondary);
    padding: 32px 0;
    font-size: 15px;
}

/* Responsive - Auth pages */
@media (max-width: 480px) {
    .card {
        padding: 28px 20px;
    }

    .clients-card {
        max-width: 100%;
    }

    .search-bar {
        flex-direction: column;
    }

    .btn-inline {
        width: 100%;
    }
}

/* ========================================
   App Layout (authenticated pages)
   ======================================== */

body.app-layout {
    display: block;
    padding: 0;
    min-height: 100vh;
    align-items: stretch;
    justify-content: stretch;
    background: var(--bg-start);
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 260px;
    height: 100vh;
    background: var(--sidebar-bg);
    border-right: none;
    display: flex;
    flex-direction: column;
    z-index: 100;
    overflow-y: auto;
}

.sidebar-header {
    padding: 24px 20px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-brand {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.3px;
    color: #ffffff;
    background: none;
    -webkit-background-clip: unset;
    -webkit-text-fill-color: unset;
    background-clip: unset;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Nav groups */
.nav-group {
    margin-bottom: 8px;
}

.nav-group-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: rgba(255, 255, 255, 0.35);
    padding: 12px 12px 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
    transition: color 0.2s;
}

.nav-group-title:hover {
    color: rgba(255, 255, 255, 0.55);
}

.nav-group-title .nav-group-chevron {
    width: 14px;
    height: 14px;
    transition: transform 0.25s ease;
    flex-shrink: 0;
}

.nav-group.collapsed .nav-group-title .nav-group-chevron {
    transform: rotate(-90deg);
}

.nav-group-links {
    overflow: hidden;
    transition: max-height 0.25s ease;
}

.nav-group.collapsed .nav-group-links {
    max-height: 0 !important;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s, color 0.2s;
    border-right: 3px solid transparent;
}

.sidebar-link:hover {
    background: var(--sidebar-hover-bg);
    color: #e5e7eb;
}

.sidebar-link.active {
    background: var(--sidebar-active-bg);
    color: var(--apple-blue);
    border-right-color: var(--apple-blue);
}

.sidebar-link svg {
    flex-shrink: 0;
}

/* Chat badges (sidebar + topbar) */
.chat-badges,
.topbar-chat-badges {
    display: flex;
    gap: 5px;
    margin-left: auto;
    align-items: center;
}

.chat-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    color: #fff;
}

.chat-badge-new {
    background: #ef4444;
    animation: badge-pulse 2s ease-in-out infinite;
}

.chat-badge-open {
    background: #f59e0b;
}

.chat-badge-pending {
    background: #3b82f6;
}

@keyframes badge-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Topbar chat indicator */
.topbar-chat-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: background 0.2s, color 0.2s;
    position: relative;
    margin-right: 8px;
}

.topbar-chat-indicator:hover {
    background: var(--sidebar-hover-bg);
    color: var(--text-primary);
}

.topbar-chat-indicator svg {
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin-bottom: 8px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
}

.sidebar-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--apple-blue), var(--accent-secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-user-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.sidebar-username {
    font-size: 13px;
    font-weight: 600;
    color: #f3f4f6;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-email {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.45);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-role {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--apple-blue);
}

.sidebar-logout {
    color: var(--sidebar-text);
    font-size: 13px;
}

.sidebar-logout:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

/* Main wrapper */
.main-wrapper {
    margin-left: 260px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Top bar */
.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 32px;
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--card-border);
    box-shadow: var(--shadow-sm);
}

.topbar-title {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.3px;
    color: var(--text-primary);
    background: none;
    -webkit-background-clip: unset;
    -webkit-text-fill-color: unset;
    background-clip: unset;
}

.maintenance-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    background: #fffbeb;
    border-bottom: 1px solid #fde68a;
    color: #92400e;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.maintenance-countdown-bar {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    background: #fffbeb;
    border-bottom: 1px solid #fde68a;
    color: #92400e;
    font-size: 13px;
    font-weight: 600;
    transition: background 0.3s, border-color 0.3s;
}

.maintenance-countdown-bar.active {
    display: flex;
}

.maintenance-countdown-bar strong {
    font-variant-numeric: tabular-nums;
    font-size: 15px;
    letter-spacing: 0.04em;
}

.maintenance-countdown-bar.urgent {
    background: #fef2f2;
    border-bottom-color: #fecaca;
    color: var(--danger);
}

.maintenance-countdown-bar.urgent strong {
    animation: countdown-blink 1s step-end infinite;
}

@keyframes countdown-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.maintenance-countdown-btn {
    margin-left: 12px;
    padding: 4px 14px;
    border-radius: 6px;
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid #fde68a;
    color: inherit;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.2s;
    white-space: nowrap;
}

.maintenance-countdown-btn:hover {
    background: rgba(245, 158, 11, 0.25);
}

.maintenance-countdown-bar.urgent .maintenance-countdown-btn {
    background: #fef2f2;
    border-color: #fecaca;
}

.maintenance-countdown-bar.urgent .maintenance-countdown-btn:hover {
    background: #fee2e2;
}

/* Maintenance modal */
.maintenance-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 10000;
    align-items: center;
    justify-content: center;
}

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

.maintenance-modal {
    background: #ffffff;
    border: 2px solid #fde68a;
    border-radius: 20px;
    padding: 40px 36px;
    max-width: 440px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(245, 158, 11, 0.1);
    animation: maintenance-modal-in 0.4s ease-out;
}

@keyframes maintenance-modal-in {
    from {
        opacity: 0;
        transform: scale(0.85) translateY(30px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.maintenance-modal-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, #fffbeb, #fef3c7);
    color: #f59e0b;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.2);
}

.maintenance-modal-title {
    font-size: 22px;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0 0 12px 0;
}

.maintenance-modal-text {
    font-size: 14px;
    color: #555555;
    line-height: 1.6;
    margin: 0 0 20px 0;
}

.maintenance-modal-time {
    font-size: 15px;
    color: #92400e;
    font-weight: 600;
    margin: 0 0 28px 0;
    background: #fffbeb;
    padding: 10px 20px;
    border-radius: 10px;
    display: inline-block;
    border: 1px solid #fde68a;
}

.maintenance-modal-time strong {
    font-variant-numeric: tabular-nums;
    font-size: 20px;
    letter-spacing: 0.04em;
}

.maintenance-modal-btn {
    display: inline-block;
    padding: 12px 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    border: none;
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 3px 10px rgba(245, 158, 11, 0.3);
}

.maintenance-modal-btn:hover {
    background: linear-gradient(135deg, #d97706, #b45309);
    transform: translateY(-1px);
    box-shadow: 0 5px 15px rgba(245, 158, 11, 0.4);
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 8px;
    transition: background 0.2s;
}

.topbar-user:hover {
    background: #f3f4f6;
}

.topbar-chevron {
    color: var(--text-secondary);
    transition: transform 0.2s;
}

.topbar-user:hover .topbar-chevron {
    transform: rotate(180deg);
}

/* Topbar dropdown */
.topbar-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 200px;
    background: var(--dropdown-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 0.2s, visibility 0.2s, transform 0.2s;
    z-index: 200;
}

.topbar-user:hover .topbar-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.topbar-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 6px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}

.topbar-dropdown-item:hover {
    background: #f3f4f6;
    color: var(--text-primary);
}

.topbar-dropdown-logout:hover {
    background: #fef2f2;
    color: var(--danger);
}

.topbar-dropdown-divider {
    height: 1px;
    background: var(--card-border);
    margin: 4px 8px;
}

.topbar-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--apple-blue), var(--accent-secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: #fff;
}

.topbar-username {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.hamburger {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: background 0.2s;
}

.hamburger:hover {
    background: #f3f4f6;
}

/* Content area */
.content {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
}

/* Content card */
.content-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 32px;
    position: relative;
}

.content-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 16px;
}

.content-card-title {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.3px;
    color: var(--text-primary);
    background: none;
    -webkit-background-clip: unset;
    -webkit-text-fill-color: unset;
    background-clip: unset;
    margin-bottom: 4px;
}

.content-card-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
}

/* App footer */
.app-footer {
    padding: 20px 32px;
    border-top: 1px solid var(--card-border);
    text-align: center;
    color: var(--text-secondary);
    font-size: 13px;
}

/* Sidebar overlay (mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 90;
}

.sidebar-overlay.open {
    display: block;
}

/* App layout responsive overrides */
body.app-layout .content-card .user-info {
    text-align: center;
    margin-bottom: 28px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--card-border);
}

body.app-layout .content-card .info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid var(--card-border);
    font-size: 14px;
}

/* Form grid layout */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 20px;
}

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

.form-section-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--apple-blue);
    margin: 28px 0 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--apple-blue);
    letter-spacing: -0.2px;
}

.form-section-title:first-of-type {
    margin-top: 20px;
}

/* Select */
.form-select {
    width: 100%;
    padding: 12px 14px;
    font-size: 15px;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--radius);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%236b7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 40px;
}

.form-select:focus {
    border-color: var(--apple-blue);
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.15);
    background-color: #fff;
}

.form-select option {
    background: var(--select-option-bg);
    color: var(--text-primary);
}

/* Textarea */
.form-textarea {
    width: 100%;
    padding: 12px 14px;
    font-size: 15px;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--radius);
    outline: none;
    resize: vertical;
    min-height: 100px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-textarea:focus {
    border-color: var(--apple-blue);
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.15);
    background: #fff;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.badge-activo {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.badge-inactivo {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.badge-prospecto {
    background: rgba(var(--accent-rgb), 0.08);
    color: var(--apple-blue);
    border: 1px solid rgba(var(--accent-rgb), 0.2);
}

.badge-eliminado {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.badge-activo-reg {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.badge-oferta-activa {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.badge-oferta-inactiva {
    background: #f3f4f6;
    color: #6b7280;
    border: 1px solid #d1d5db;
}

/* Tareas badges */
.badge-prioridad-baja {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.badge-prioridad-media {
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

.badge-prioridad-alta {
    background: #fff7ed;
    color: #9a3412;
    border: 1px solid #fed7aa;
}

.badge-prioridad-urgente {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
    font-weight: 600;
}

.badge-tarea-pendiente {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
}

.badge-tarea-progreso {
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

.badge-tarea-completada {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.badge-tarea-cancelada {
    background: #f3f4f6;
    color: #6b7280;
    border: 1px solid #d1d5db;
}

.precio-original {
    text-decoration: line-through;
    color: var(--text-secondary);
    font-size: 0.9em;
    margin-right: 6px;
}

.precio-oferta {
    color: #059669;
    font-weight: 600;
}

/* Ofertas style selector in settings */
.ofertas-style-selector {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}
.ofertas-style-option {
    flex: 1;
    min-width: 200px;
    cursor: pointer;
    border: 2px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 16px;
    text-align: center;
    transition: all 0.25s ease;
    background: var(--card-bg);
    position: relative;
}
.ofertas-style-option:hover {
    border-color: var(--apple-blue);
    box-shadow: 0 4px 16px rgba(var(--accent-rgb), 0.25);
    transform: translateY(-4px);
    background: rgba(var(--accent-rgb), 0.02);
}
.ofertas-style-option:hover .ofertas-style-label {
    color: var(--apple-blue);
    text-decoration: underline;
}
.ofertas-style-active {
    border-color: var(--apple-blue);
    box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.3), 0 4px 12px rgba(var(--accent-rgb), 0.15);
    background: rgba(var(--accent-rgb), 0.05);
}
.ofertas-style-active .ofertas-style-label {
    color: var(--apple-blue);
}
.ofertas-style-label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    margin-top: 12px;
    color: var(--text-primary);
}
.ofertas-style-desc {
    display: block;
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* Mini preview sketches */
.ofertas-style-preview {
    background: var(--input-bg);
    border-radius: 8px;
    padding: 12px;
    min-height: 90px;
    display: flex;
    gap: 6px;
    align-items: flex-start;
}
.ofertas-preview-vertical {
    flex-direction: row;
    justify-content: center;
}
.ofertas-preview-vertical .osp-card {
    flex: 1;
    background: var(--card-bg);
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.ofertas-preview-vertical .osp-img {
    height: 28px;
    background: linear-gradient(135deg, #ddd, #ccc);
}
.ofertas-preview-vertical .osp-lines {
    padding: 4px 5px;
}
.ofertas-preview-vertical .osp-lines div {
    height: 3px;
    background: #ddd;
    border-radius: 2px;
    margin-bottom: 3px;
}
.ofertas-preview-vertical .osp-lines div:nth-child(2) {
    width: 70%;
}
.ofertas-preview-vertical .osp-price {
    width: 40%;
    background: #b08d5e !important;
    height: 4px !important;
}

.ofertas-preview-horizontal {
    flex-direction: column;
    gap: 6px;
}
.ofertas-preview-horizontal .osp-hcard {
    display: flex;
    gap: 6px;
    background: var(--card-bg);
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.ofertas-preview-horizontal .osp-himg {
    width: 40px;
    min-height: 32px;
    background: linear-gradient(135deg, #ddd, #ccc);
    flex-shrink: 0;
}
.ofertas-preview-horizontal .osp-hlines {
    padding: 5px 6px;
    flex: 1;
}
.ofertas-preview-horizontal .osp-hlines div {
    height: 3px;
    background: #ddd;
    border-radius: 2px;
    margin-bottom: 3px;
}
.ofertas-preview-horizontal .osp-hlines div:nth-child(2) {
    width: 60%;
}
.ofertas-preview-horizontal .osp-price {
    width: 35%;
    background: #b08d5e !important;
    height: 4px !important;
}

.ofertas-preview-minimalista {
    flex-direction: column;
    gap: 4px;
}
.ofertas-preview-minimalista .osp-mcard {
    display: flex;
    gap: 0;
    background: var(--card-bg);
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    align-items: stretch;
}
.ofertas-preview-minimalista .osp-maccent {
    width: 3px;
    background: linear-gradient(180deg, #c9a87c, #b08d5e);
    flex-shrink: 0;
}
.ofertas-preview-minimalista .osp-mimg {
    width: 28px;
    min-height: 18px;
    background: linear-gradient(135deg, #ddd, #ccc);
    flex-shrink: 0;
}
.ofertas-preview-minimalista .osp-mlines {
    padding: 3px 5px;
    flex: 1;
}
.ofertas-preview-minimalista .osp-mlines div {
    height: 2px;
    background: #ddd;
    border-radius: 2px;
    margin-bottom: 2px;
}
.ofertas-preview-minimalista .osp-price {
    width: 30%;
    background: #b08d5e !important;
    height: 3px !important;
}

.ofertas-live-preview {
    margin-top: 8px;
}

/* ========================================
   Date picker variants
   ======================================== */

/* Fecha 1: Native date input */
.date-native input[type="date"] {
    width: 100%;
    padding: 12px 14px;
    font-size: 15px;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--radius);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.date-native input[type="date"]:focus {
    border-color: var(--apple-blue);
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.15);
    background: #fff;
}

.date-native input[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
}

/* Fecha 2: Three selects (day/month/year) */
.date-selects {
    display: flex;
    gap: 8px;
}

.date-select-part {
    flex: 1;
    padding: 10px 8px !important;
    font-size: 14px !important;
    min-width: 0;
    background-position: right 6px center !important;
    padding-right: 26px !important;
}

/* Fecha 3: Masked input with calendar icon */
.date-masked-wrap {
    position: relative;
}

.date-masked-input {
    width: 100%;
    padding: 12px 44px 12px 14px !important;
    font-size: 15px;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--radius);
    outline: none;
    letter-spacing: 1px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.date-masked-input:focus {
    border-color: var(--apple-blue);
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.15);
    background: #fff;
}

.date-masked-icon {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none;
    display: flex;
}

/* Fecha 4: Date with preview card */
.date-split-wrap {
    display: flex;
    gap: 12px;
    align-items: center;
}

.date-split-input {
    flex: 1;
    padding: 12px 14px;
    font-size: 15px;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--radius);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.date-split-input:focus {
    border-color: var(--apple-blue);
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.15);
    background: #fff;
}

.date-split-input::-webkit-calendar-picker-indicator {
    cursor: pointer;
}

.date-split-preview {
    min-width: 80px;
    padding: 8px 14px;
    background: rgba(var(--accent-rgb), 0.06);
    border: 1px solid rgba(var(--accent-rgb), 0.15);
    border-radius: var(--radius);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.date-split-day {
    font-size: 22px;
    font-weight: 700;
    color: var(--apple-blue);
    line-height: 1;
}

.date-split-monthyear {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.date-split-placeholder {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Fecha 5: Datetime-local with badge */
.date-datetime-wrap {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.date-datetime-input {
    width: 100%;
    padding: 12px 14px;
    font-size: 15px;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--radius);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.date-datetime-input:focus {
    border-color: var(--apple-blue);
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.15);
    background: #fff;
}

.date-datetime-input::-webkit-calendar-picker-indicator {
    cursor: pointer;
}

.date-datetime-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #f5f3ff;
    border: 1px solid #ddd6fe;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    color: #7c3aed;
    align-self: flex-start;
}

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

    .date-selects {
        flex-direction: column;
    }

    .date-split-wrap {
        flex-direction: column;
    }
}

/* Mobile - App layout */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-wrapper {
        margin-left: 0;
        overflow-x: hidden;
    }

    .hamburger {
        display: block;
    }

    .topbar {
        padding: 12px 16px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .topbar-title {
        font-size: 16px;
        flex: 1 0 calc(100% - 48px);
        order: 1;
    }

    .topbar-chat-indicator {
        order: 5;
    }

    .topbar-user {
        order: 6;
        margin-left: auto;
    }

    .topbar-username {
        display: none;
    }

    .topbar-chevron {
        display: none;
    }

    .empresa-selector {
        order: 10;
        width: 100%;
        margin-left: 0;
    }

    .empresa-search-box input {
        width: 100%;
    }

    .empresa-selector-select {
        flex: 1;
        min-width: 0;
    }

    .content {
        padding: 20px 16px;
    }

    .content-card {
        padding: 20px;
    }

    .content-card-header {
        flex-wrap: wrap;
    }

    .content-card-header > div:last-child {
        flex-wrap: wrap !important;
    }

    .content-card-header .btn-inline {
        width: 100%;
        order: 10;
    }

    .app-footer {
        padding: 16px;
    }
}

/* ============================================
   PAGINATION
   ============================================ */
.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}
.pagination-info {
    font-size: 13px;
    color: var(--text-secondary);
}
.pagination-pp {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}
.pp-select {
    appearance: none;
    -webkit-appearance: none;
    padding: 6px 30px 6px 10px;
    border-radius: 6px;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='10' viewBox='0 0 20 20' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 7l6 6 6-6' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    transition: all 0.2s;
}
.pp-select:hover,
.pp-select:focus {
    border-color: var(--apple-blue);
    outline: none;
}
.pp-select option {
    background: var(--select-option-bg);
    color: var(--text-primary);
}

/* ============================================
   ESTILO 1: Clasico con numeros
   ============================================ */
.pag-1 {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--card-border);
}
.pag-btn {
    min-width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s;
    padding: 0 6px;
}
.pag-btn:hover {
    background: rgba(var(--accent-rgb), 0.08);
    color: var(--text-primary);
    border-color: var(--apple-blue);
}
.pag-active {
    background: var(--apple-blue);
    color: #fff;
    border-color: var(--apple-blue);
    font-weight: 600;
}
.pag-dots {
    color: var(--text-secondary);
    padding: 0 4px;
    font-size: 14px;
}

/* ============================================
   Sort arrows
   ============================================ */
.sort-arrow {
    font-size: 10px;
    opacity: 0.7;
    margin-left: 2px;
}

/* ============================================
   Form hint
   ============================================ */
.form-hint {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 6px;
    line-height: 1.4;
}

/* ============================================
   Logo upload
   ============================================ */
.logo-upload-wrap {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
}

.logo-preview {
    width: 160px;
    height: 160px;
    border-radius: var(--radius);
    border: 1px solid var(--card-border);
    background: var(--input-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.logo-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.logo-placeholder {
    width: 160px;
    height: 160px;
    border-radius: var(--radius);
    border: 2px dashed var(--input-border);
    background: var(--input-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 13px;
}

.logo-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ============================================
   Detail tabs (view/edit pages)
   ============================================ */
.detail-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--card-border);
    margin-bottom: 24px;
    margin-top: 8px;
}

.detail-tab {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    color: var(--text-secondary);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
}

.detail-tab:hover {
    color: var(--text-primary);
}

.detail-tab.active {
    color: var(--apple-blue);
    border-bottom-color: var(--apple-blue);
    font-weight: 600;
}

.detail-tab-content {
    display: none;
}

/* ============================================
   Change history table
   ============================================ */
.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.history-table th {
    text-align: left;
    padding: 10px 12px;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--card-border);
    background: #f9fafb;
}

.history-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #f3f4f6;
    color: var(--text-primary);
    vertical-align: top;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-table tbody tr:hover {
    background: #f9fafb;
}

.history-old-value {
    color: var(--danger);
}

.history-new-value {
    color: var(--success);
}

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

.badge-action-create {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.badge-action-edit {
    background: rgba(var(--accent-rgb), 0.08);
    color: var(--apple-blue);
    border: 1px solid rgba(var(--accent-rgb), 0.2);
}

.badge-action-delete {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.badge-action-restore {
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

@media (max-width: 768px) {
    .detail-tabs {
        overflow-x: auto;
    }

    .detail-tab {
        white-space: nowrap;
        padding: 8px 14px;
        font-size: 13px;
    }

    .history-table td {
        max-width: 120px;
    }
}

/* ============================================
   Before & After module
   ============================================ */
.ba-image-upload {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 24px;
    border: 2px dashed var(--input-border);
    border-radius: var(--radius);
    background: var(--input-bg);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    position: relative;
}

.ba-image-upload:hover,
.ba-image-upload.dragover {
    border-color: var(--apple-blue);
    background: rgba(var(--accent-rgb), 0.04);
}

.ba-image-upload input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.ba-image-preview {
    width: 100%;
    aspect-ratio: 4 / 3;
    border-radius: var(--radius);
    border: 1px solid var(--card-border);
    background: var(--input-bg);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ba-image-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ba-image-preview-full {
    aspect-ratio: auto;
    max-height: 400px;
}

.ba-image-preview-full img {
    object-fit: contain;
}

.ba-comparison {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.ba-comparison-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ba-comparison-label {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

.ba-thumb-pair {
    display: flex;
    gap: 4px;
    align-items: center;
}

.ba-thumb {
    width: 48px;
    height: 36px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid var(--card-border);
}

@media (max-width: 600px) {
    .ba-comparison {
        grid-template-columns: 1fr;
    }
}

/* === Galeria Style Selector === */
.galeria-style-selector {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}
.galeria-style-option {
    flex: 1;
    min-width: 160px;
    cursor: pointer;
    border: 2px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 16px;
    text-align: center;
    transition: all 0.25s ease;
    background: var(--card-bg);
    position: relative;
}
.galeria-style-option:hover {
    border-color: var(--apple-blue);
    box-shadow: 0 4px 16px rgba(var(--accent-rgb), 0.25);
    transform: translateY(-4px);
    background: rgba(var(--accent-rgb), 0.02);
}
.galeria-style-option:hover .galeria-style-label {
    color: var(--apple-blue);
    text-decoration: underline;
}
.galeria-style-active {
    border-color: var(--apple-blue);
    box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.3), 0 4px 12px rgba(var(--accent-rgb), 0.15);
    background: rgba(var(--accent-rgb), 0.05);
}
.galeria-style-active .galeria-style-label {
    color: var(--apple-blue);
}
.galeria-style-label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    margin-top: 12px;
    color: var(--text-primary);
}
.galeria-style-desc {
    display: block;
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-top: 2px;
}
.galeria-style-preview {
    background: var(--input-bg);
    border-radius: 8px;
    padding: 12px;
    min-height: 80px;
    display: flex;
    gap: 5px;
    align-items: flex-start;
}

/* Grid preview */
.gsp-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    width: 100%;
}
.gsp-grid .gsp-item {
    aspect-ratio: 1;
    background: linear-gradient(135deg, #ddd, #ccc);
    border-radius: 3px;
}

/* Carousel preview */
.gsp-carousel {
    justify-content: center;
    align-items: center;
    width: 100%;
}
.gsp-carousel .gsp-arrow {
    font-size: 1.2rem;
    color: var(--text-secondary);
    flex-shrink: 0;
}
.gsp-carousel .gsp-slide {
    flex: 1;
    height: 56px;
    background: linear-gradient(135deg, #ddd, #ccc);
    border-radius: 4px;
    margin: 0 6px;
}

/* Minimal preview */
.gsp-minimal {
    flex-direction: column;
    gap: 5px;
    width: 100%;
}
.gsp-mrow {
    display: flex;
    gap: 6px;
    background: var(--card-bg);
    border-radius: 4px;
    padding: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.gsp-mimg {
    width: 32px;
    height: 24px;
    background: linear-gradient(135deg, #ddd, #ccc);
    border-radius: 3px;
    flex-shrink: 0;
}
.gsp-mlines {
    flex: 1;
    padding-top: 3px;
}
.gsp-mlines div {
    height: 3px;
    background: #ddd;
    border-radius: 2px;
    margin-bottom: 3px;
}
.gsp-mlines div:nth-child(2) {
    width: 65%;
}

/* Lightbox preview */
.gsp-lightbox {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 3px;
    width: 100%;
}
.gsp-litem {
    aspect-ratio: 1;
    background: linear-gradient(135deg, #ddd, #ccc);
    border-radius: 2px;
}

/* Mosaic preview */
.gsp-mosaic {
    display: flex;
    gap: 4px;
    width: 100%;
}
.gsp-mcol {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.gsp-mi {
    background: linear-gradient(135deg, #ddd, #ccc);
    border-radius: 3px;
    height: 24px;
}
.gsp-mi-tall { height: 40px; }
.gsp-mi-med { height: 32px; }

/* Readonly banner for empresa selector */
.readonly-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--blue-50, #eff6ff);
    border-bottom: 1px solid var(--blue-200, #bfdbfe);
    color: var(--blue-800, #1e40af);
    font-size: 13px;
    font-weight: 600;
}
.readonly-banner-btn {
    margin-left: 12px;
    padding: 4px 12px;
    border: 1px solid var(--apple-blue);
    border-radius: 6px;
    background: transparent;
    color: var(--apple-blue);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}
.readonly-banner-btn:hover {
    background: var(--apple-blue);
    color: #fff;
}

/* Empresa selector in topbar */
.empresa-selector {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: 16px;
    margin-right: auto;
}
.empresa-search-box {
    position: relative;
}
.empresa-search-box input {
    padding: 5px 28px 5px 10px;
    border: 1px solid var(--card-border);
    border-radius: 6px;
    background: var(--input-bg);
    color: var(--text-primary);
    font-size: 12px;
    width: 150px;
    height: 28px;
    box-sizing: border-box;
}
.empresa-search-box input::placeholder {
    color: var(--text-secondary);
    font-size: 12px;
}
.empresa-search-icon {
    position: absolute;
    right: 7px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none;
    line-height: 0;
}
.empresa-selector-select {
    border: 1px solid var(--card-border);
    border-radius: 6px;
    background: var(--input-bg);
    color: var(--text-primary);
    font-size: 12px;
    cursor: pointer;
    width: 220px;
    height: 48px;
    overflow-y: auto;
    padding: 2px;
}
.empresa-selector-select option {
    padding: 3px 8px;
    border-radius: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.empresa-selector-select option:checked {
    background: var(--apple-blue);
    color: #fff;
}
.empresa-go-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 1px solid var(--card-border);
    border-radius: 6px;
    background: var(--input-bg);
    color: var(--text-secondary);
    cursor: pointer;
    flex-shrink: 0;
}
.empresa-go-btn:hover {
    background: var(--apple-blue);
    color: #fff;
    border-color: var(--apple-blue);
}

/* ========== Chat Module ========== */
.chat-container {
    display: flex;
    height: calc(100vh - 200px);
    min-height: 400px;
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--card-bg);
}
.chat-sidebar {
    width: 320px;
    min-width: 280px;
    border-right: 1px solid var(--card-border);
    display: flex;
    flex-direction: column;
    background: var(--card-bg);
}
.chat-sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--card-border);
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.chat-sidebar-header h3 {
    font-size: 15px;
    font-weight: 600;
}
.chat-sidebar-search {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--input-border);
    border-radius: var(--radius);
    background: var(--input-bg);
    color: var(--text-primary);
    font-size: 13px;
}
.chat-sidebar-filters {
    display: flex;
    gap: 6px;
}
.chat-sidebar-filters .btn {
    font-size: 12px;
    padding: 4px 10px;
}
.chat-sidebar-filters .btn.active {
    background: var(--apple-blue);
    color: #fff;
    border-color: var(--apple-blue);
}
.chat-conv-list {
    flex: 1;
    overflow-y: auto;
}
.chat-conv-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--card-border);
    transition: background 0.15s;
}
.chat-conv-item:hover {
    background: var(--sidebar-hover-bg);
}
.chat-conv-item.active {
    background: rgba(var(--accent-rgb), 0.08);
    border-left: 3px solid var(--apple-blue);
}
.chat-conv-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--apple-blue);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 15px;
    flex-shrink: 0;
}
.chat-conv-info {
    flex: 1;
    min-width: 0;
}
.chat-conv-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-conv-preview {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}
.chat-conv-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}
.chat-conv-time {
    font-size: 11px;
    color: var(--text-secondary);
}
.chat-conv-badge {
    background: var(--apple-blue);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
}
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}
.chat-main-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--card-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.chat-main-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}
.chat-main-header-info h3 {
    font-size: 15px;
    font-weight: 600;
}
.chat-main-header-info span {
    font-size: 12px;
    color: var(--text-secondary);
}
.chat-main-actions {
    display: flex;
    gap: 6px;
}
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.chat-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
    font-size: 14px;
    gap: 8px;
}
.chat-empty svg {
    opacity: 0.4;
}

/* Support online status indicator */
.chat-support-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    margin: 4px 0;
}

.support-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.support-status-dot.online {
    background: #22c55e;
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.6);
    animation: dot-pulse 2s ease-in-out infinite;
}

.support-status-dot.offline {
    background: #6b7280;
}

@keyframes dot-pulse {
    0%, 100% { box-shadow: 0 0 6px rgba(34, 197, 94, 0.6); }
    50% { box-shadow: 0 0 12px rgba(34, 197, 94, 0.9); }
}

.chat-empty button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chat-date-sep {
    text-align: center;
    font-size: 11px;
    color: var(--text-secondary);
    padding: 8px 0;
}
.chat-date-sep span {
    background: var(--input-bg);
    padding: 4px 12px;
    border-radius: 12px;
}
.chat-bubble {
    max-width: 70%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.45;
    word-wrap: break-word;
    position: relative;
}
.chat-bubble-mine {
    align-self: flex-end;
    background: var(--apple-blue);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.chat-bubble-other {
    align-self: flex-start;
    background: var(--input-bg);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}
.chat-bubble-sender {
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 4px;
    opacity: 0.8;
}
.chat-bubble-time {
    font-size: 10px;
    opacity: 0.7;
    margin-top: 4px;
    text-align: right;
}
.chat-bubble-other .chat-bubble-time {
    color: var(--text-secondary);
}
.chat-bubble-attachment {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    padding: 8px;
    background: rgba(0,0,0,0.08);
    border-radius: 8px;
    font-size: 12px;
    text-decoration: none;
    color: inherit;
}
.chat-bubble-mine .chat-bubble-attachment {
    background: rgba(255,255,255,0.15);
}
.chat-bubble-attachment:hover {
    background: rgba(0,0,0,0.12);
}
.chat-bubble-attachment img {
    max-width: 200px;
    max-height: 150px;
    border-radius: 6px;
}
.chat-system-msg {
    align-self: center;
    background: var(--input-bg);
    color: var(--text-secondary);
    font-size: 12px;
    padding: 6px 14px;
    border-radius: 12px;
    font-style: italic;
}
.chat-input-bar {
    padding: 12px 16px;
    border-top: 1px solid var(--card-border);
    display: flex;
    align-items: flex-end;
    gap: 8px;
}
.chat-input-bar textarea {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--input-border);
    border-radius: var(--radius-lg);
    background: var(--input-bg);
    color: var(--text-primary);
    font-size: 14px;
    resize: none;
    max-height: 120px;
    min-height: 42px;
    font-family: inherit;
    line-height: 1.4;
}
.chat-input-bar textarea:focus {
    outline: none;
    border-color: var(--apple-blue);
    box-shadow: 0 0 0 3px var(--input-focus);
}
.chat-attach-btn {
    width: 42px;
    height: 42px;
    border: 1px solid var(--input-border);
    border-radius: var(--radius);
    background: var(--input-bg);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}
.chat-attach-btn:hover {
    border-color: var(--apple-blue);
    color: var(--apple-blue);
}
.chat-send-btn {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: var(--radius);
    background: var(--apple-blue);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}
.chat-send-btn:hover {
    background: var(--apple-blue-dark);
}
.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Chat single pane (empresas) */
.chat-single .chat-sidebar {
    display: none;
}
.chat-single .chat-main {
    width: 100%;
}

/* ========== Tickets Module ========== */
.priority-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
}
.priority-dot.baja { background: #6b7280; }
.priority-dot.media { background: #f59e0b; }
.priority-dot.alta { background: #f97316; }
.priority-dot.urgente { background: #ef4444; }
.badge-prioridad {
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}
.badge-prioridad.baja { background: rgba(107,114,128,0.12); color: #6b7280; }
.badge-prioridad.media { background: rgba(245,158,11,0.12); color: #d97706; }
.badge-prioridad.alta { background: rgba(249,115,22,0.12); color: #ea580c; }
.badge-prioridad.urgente { background: rgba(239,68,68,0.12); color: #dc2626; }
.badge-estado-ticket {
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}
.badge-estado-ticket.abierto { background: rgba(59,130,246,0.12); color: #2563eb; }
.badge-estado-ticket.en_progreso { background: rgba(245,158,11,0.12); color: #d97706; }
.badge-estado-ticket.esperando_respuesta { background: rgba(168,85,247,0.12); color: #7c3aed; }
.badge-estado-ticket.resuelto { background: rgba(16,185,129,0.12); color: #059669; }
.badge-estado-ticket.cerrado { background: rgba(107,114,128,0.12); color: #6b7280; }

.ticket-detail-grid {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 20px;
    margin-top: 16px;
}
.ticket-detail-main {
    min-width: 0;
}
.ticket-detail-sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.ticket-detail-sidebar .info-card {
    background: var(--input-bg);
    border-radius: var(--radius);
    padding: 16px;
}
.ticket-detail-sidebar .info-card h4 {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.ticket-detail-sidebar .info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-size: 13px;
}
.ticket-detail-sidebar .info-row label {
    color: var(--text-secondary);
}
.ticket-description {
    background: var(--input-bg);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 20px;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
}
.ticket-replies {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}
.ticket-reply {
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 14px 16px;
    background: var(--card-bg);
}
.ticket-reply.internal {
    background: rgba(245,158,11,0.06);
    border-color: rgba(245,158,11,0.25);
}
.ticket-reply-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.ticket-reply-author {
    font-weight: 600;
    font-size: 13px;
}
.ticket-reply-date {
    font-size: 12px;
    color: var(--text-secondary);
}
.ticket-reply-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 8px;
    background: rgba(245,158,11,0.15);
    color: #d97706;
    font-weight: 500;
}
.ticket-reply-body {
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
}
.ticket-reply-form {
    margin-top: 20px;
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 16px;
}
.ticket-reply-form h4 {
    font-size: 14px;
    margin-bottom: 12px;
}
.ticket-reply-attachment {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding: 4px 10px;
    background: var(--input-bg);
    border-radius: 6px;
    font-size: 12px;
    color: var(--apple-blue);
    text-decoration: none;
}
.ticket-reply-attachment:hover {
    background: rgba(var(--accent-rgb), 0.1);
}
.ticket-chat-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--apple-blue);
    text-decoration: none;
    font-size: 13px;
    padding: 6px 12px;
    border-radius: var(--radius);
    background: rgba(var(--accent-rgb), 0.08);
}
.ticket-chat-link:hover {
    background: rgba(var(--accent-rgb), 0.15);
}

/* ============================================================
   Quill.js Dark Theme Overrides
   ============================================================ */
.ql-toolbar.ql-snow {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--radius) var(--radius) 0 0;
}
.ql-container.ql-snow {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    font-size: 14px;
    min-height: 180px;
    color: var(--text-primary);
}
.ql-editor {
    min-height: 180px;
    color: var(--text-primary);
}
.ql-editor.ql-blank::before {
    color: var(--text-secondary);
    font-style: italic;
}
.ql-snow .ql-stroke {
    stroke: var(--text-secondary);
}
.ql-snow .ql-fill, .ql-snow .ql-stroke.ql-fill {
    fill: var(--text-secondary);
}
.ql-snow .ql-picker {
    color: var(--text-secondary);
}
.ql-snow .ql-picker-options {
    background: var(--dropdown-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--radius);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.ql-snow .ql-picker-label:hover,
.ql-snow .ql-picker-item:hover {
    color: var(--apple-blue);
}
.ql-snow .ql-picker-label:hover .ql-stroke,
.ql-snow .ql-picker-item:hover .ql-stroke {
    stroke: var(--apple-blue);
}
.ql-snow button:hover,
.ql-snow button.ql-active {
    color: var(--apple-blue);
}
.ql-snow button:hover .ql-stroke,
.ql-snow button.ql-active .ql-stroke {
    stroke: var(--apple-blue);
}
.ql-snow button:hover .ql-fill,
.ql-snow button.ql-active .ql-fill {
    fill: var(--apple-blue);
}

/* ============================================================
   FAQ Response Content (rendered HTML preview)
   ============================================================ */
.faq-respuesta-content {
    padding: 16px;
    background: var(--input-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    color: var(--text-primary);
    line-height: 1.6;
    word-wrap: break-word;
}
.faq-respuesta-content p {
    margin-bottom: 8px;
}
.faq-respuesta-content ul, .faq-respuesta-content ol {
    margin: 8px 0;
    padding-left: 24px;
}
.faq-respuesta-content li {
    margin-bottom: 4px;
}
.faq-respuesta-content a {
    color: var(--apple-blue);
}
.faq-respuesta-content strong {
    font-weight: 600;
}

/* ============================================================
   Quill Rich Text Editor — global styles
   ============================================================ */
/* Editor container */
.quill-editor-instance {
    background: var(--input-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    color: var(--text-primary);
    min-height: 120px;
}
.quill-editor-instance .ql-editor {
    min-height: 100px;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
}
.quill-editor-instance .ql-editor.ql-blank::before {
    color: var(--text-secondary);
    font-style: normal;
}
/* Toolbar */
.ql-toolbar.ql-snow {
    background: var(--card-bg);
    border-color: var(--card-border) !important;
    border-radius: var(--radius) var(--radius) 0 0;
}
.ql-toolbar.ql-snow .ql-stroke {
    stroke: var(--text-secondary);
}
.ql-toolbar.ql-snow .ql-fill {
    fill: var(--text-secondary);
}
.ql-toolbar.ql-snow .ql-picker-label {
    color: var(--text-secondary);
}
.ql-toolbar.ql-snow button:hover .ql-stroke,
.ql-toolbar.ql-snow button.ql-active .ql-stroke {
    stroke: var(--apple-blue);
}
.ql-toolbar.ql-snow button:hover .ql-fill,
.ql-toolbar.ql-snow button.ql-active .ql-fill {
    fill: var(--apple-blue);
}
.ql-toolbar.ql-snow .ql-picker-options {
    background: var(--card-bg);
    border-color: var(--card-border);
}
.quill-editor-instance.ql-container.ql-snow {
    border-color: var(--card-border) !important;
    border-radius: 0 0 var(--radius) var(--radius);
}
/* Rich text content (view mode) */
.rich-text-content {
    padding: 16px;
    background: var(--input-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    color: var(--text-primary);
    line-height: 1.6;
    word-wrap: break-word;
}
.rich-text-content p {
    margin-bottom: 8px;
}
.rich-text-content ul, .rich-text-content ol {
    margin: 8px 0;
    padding-left: 24px;
}
.rich-text-content li {
    margin-bottom: 4px;
}
.rich-text-content a {
    color: var(--apple-blue);
}
.rich-text-content strong {
    font-weight: 600;
}

/* FAQ attachments grid */
.faq-adjuntos-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 12px;
}
.faq-adjunto-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--input-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    font-size: 13px;
    color: var(--text-primary);
    text-decoration: none;
    transition: border-color 0.2s;
}
.faq-adjunto-item:hover {
    border-color: var(--apple-blue);
}
.faq-adjunto-thumb {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
}
.faq-adjunto-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(var(--accent-rgb), 0.1);
    border-radius: 4px;
    color: var(--apple-blue);
}
.faq-adjunto-info {
    display: flex;
    flex-direction: column;
}
.faq-adjunto-name {
    font-weight: 500;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.faq-adjunto-size {
    font-size: 11px;
    color: var(--text-secondary);
}

/* FAQ visibility badge */
.badge-publico {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}
.badge-privado {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

/* Inventory movement badges */
.badge-mov-entrada {
    background: #ecfdf5;
    color: #065f46;
}
.badge-mov-salida {
    background: #fef2f2;
    color: #991b1b;
}
.badge-mov-ajuste {
    background: #fffbeb;
    color: #92400e;
}
.badge-motivo-compra {
    background: rgba(59, 130, 246, 0.1);
    color: #2563eb;
}
.badge-motivo-venta {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
}
.badge-motivo-ajuste_manual {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
}
.badge-motivo-devolucion {
    background: rgba(168, 85, 247, 0.1);
    color: #7c3aed;
}
.badge-motivo-perdida {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
}
.badge-motivo-factura {
    background: rgba(107, 114, 128, 0.1);
    color: #6b7280;
}

/* ============================================================
   Chat FAQ Panel (accordion in chat empty state)
   ============================================================ */
.chat-faq-panel {
    width: 100%;
    max-width: 600px;
    margin-top: 20px;
    text-align: left;
}
.chat-faq-panel h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}
.chat-faq-cat-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 12px 0 6px;
}
.chat-faq-item {
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    margin-bottom: 6px;
    overflow: hidden;
}
.chat-faq-question {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: var(--input-bg);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    transition: background 0.15s;
}
.chat-faq-question:hover {
    background: rgba(var(--accent-rgb), 0.05);
}
.chat-faq-question svg {
    flex-shrink: 0;
    transition: transform 0.2s;
}
.chat-faq-item.open .chat-faq-question svg {
    transform: rotate(180deg);
}
.chat-faq-answer {
    display: none;
    padding: 12px 14px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-secondary);
    border-top: 1px solid var(--card-border);
}
.chat-faq-item.open .chat-faq-answer {
    display: block;
}

/* Responsive chat */
@media (max-width: 1024px) {
    .chat-container {
        flex-direction: column;
        height: calc(100vh - 230px);
    }
    .chat-sidebar {
        width: 100%;
        min-width: unset;
        max-height: 200px;
        border-right: none;
        border-bottom: 1px solid var(--card-border);
    }
    .chat-sidebar.collapsed {
        display: none;
    }
    .chat-bubble {
        max-width: 85%;
    }
    .ticket-detail-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1024px) and (max-height: 500px) {
    .topbar-title {
        flex: 1 0 auto;
    }

    .empresa-selector {
        display: none;
    }

    .content {
        padding: 8px 16px;
    }

    .app-footer {
        display: none;
    }

    .chat-container {
        height: 80vh !important;
        min-height: 400px !important;
    }

    .chat-sidebar {
        max-height: 150px;
    }
}

/* ===== Productos y Servicios badges ===== */
.badge-tipo-producto {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.badge-tipo-servicio {
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

.stock-alert {
    color: #dc2626;
    font-weight: 600;
}

/* ===== Inventario badges ===== */
.badge-mov-entrada {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.badge-mov-salida {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.badge-mov-ajuste {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
}

/* ===== Facturacion badges ===== */
.badge-factura-borrador {
    background: #f3f4f6;
    color: #6b7280;
    border: 1px solid #d1d5db;
}

.badge-factura-emitida {
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

.badge-factura-pagada {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.badge-factura-parcial {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
}

.badge-factura-vencida {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.badge-factura-anulada {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #9ca3af;
    text-decoration: line-through;
}

/* ===== Cotizacion badges ===== */
.badge-cotizacion-convertida {
    background: rgba(88, 86, 214, 0.15);
    color: #5856d6;
    border: 1px solid rgba(88, 86, 214, 0.3);
}

/* ===== Deuda badges ===== */
.badge-deuda-pendiente {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
}

.badge-deuda-parcial {
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

.badge-deuda-pagada {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.badge-deuda-vencida {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.badge-deuda-cancelada {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #9ca3af;
}

/* ===== Documentos badges ===== */
.badge-doc-contrato {
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

.badge-doc-factura {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.badge-doc-recibo {
    background: #f5f3ff;
    color: #6d28d9;
    border: 1px solid #ddd6fe;
}

.badge-doc-acuerdo {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
}

.badge-doc-otro {
    background: #f3f4f6;
    color: #6b7280;
    border: 1px solid #d1d5db;
}

/* ===== Notification bell & badge ===== */
.notif-bell {
    position: relative;
}

.notif-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ff453a;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    line-height: 1;
}

/* ===== Notification list styles ===== */
.notif-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.notif-item {
    display: flex;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 10px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    transition: background 0.15s;
}

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

.notif-item.unread {
    border-left: 3px solid var(--apple-blue);
}

.notif-icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.notif-icon-info { background: rgba(0, 122, 255, 0.12); color: #007aff; }
.notif-icon-warning { background: rgba(255, 159, 10, 0.12); color: #ff9f0a; }
.notif-icon-success { background: rgba(48, 209, 88, 0.12); color: #30d158; }
.notif-icon-error { background: rgba(255, 69, 58, 0.12); color: #ff453a; }

.notif-content {
    flex: 1;
    min-width: 0;
}

.notif-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.notif-msg {
    font-size: 13px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.notif-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.notif-time {
    font-size: 12px;
    color: var(--text-secondary);
}

/* ===== Factura items table ===== */
.factura-items-table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
}

.factura-items-table th,
.factura-items-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--card-border);
    text-align: left;
    font-size: 14px;
}

.factura-items-table th {
    background: var(--bg-secondary);
    font-weight: 600;
    font-size: 13px;
    color: var(--text-secondary);
}

.factura-items-table .item-remove {
    color: #ff453a;
    cursor: pointer;
    border: none;
    background: none;
    font-size: 18px;
    padding: 4px 8px;
}

.factura-totals {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    padding: 12px 0;
    font-size: 14px;
}

.factura-totals .total-row {
    display: flex;
    gap: 24px;
    min-width: 250px;
}

.factura-totals .total-row label {
    flex: 1;
    text-align: right;
    color: var(--text-secondary);
}

.factura-totals .total-row span {
    min-width: 100px;
    text-align: right;
    font-weight: 500;
}

.factura-totals .total-row.grand-total {
    font-size: 16px;
    font-weight: 700;
    border-top: 2px solid var(--card-border);
    padding-top: 8px;
    margin-top: 4px;
}

/* ===== Product search autocomplete ===== */
.producto-search-wrap {
    position: relative;
}

.producto-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: none;
}

.producto-search-results .search-result-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
    border-bottom: 1px solid var(--card-border);
    display: flex;
    justify-content: space-between;
}

.producto-search-results .search-result-item:hover {
    background: var(--bg-secondary);
}

.producto-search-results .search-result-item:last-child {
    border-bottom: none;
}

/* ===== Manual content styles ===== */
.manual-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--card-border);
    margin-bottom: 24px;
}

.manual-tab {
    padding: 10px 20px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.15s, border-color 0.15s;
}

.manual-tab:hover {
    color: var(--text-primary);
}

.manual-tab.active {
    color: var(--apple-blue);
    border-bottom-color: var(--apple-blue);
    font-weight: 600;
}

.manual-content {
    line-height: 1.7;
    color: var(--text-primary);
    font-size: 15px;
}

.manual-content h1 {
    font-size: 26px;
    font-weight: 700;
    margin: 0 0 16px 0;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--card-border);
    color: var(--text-primary);
}

.manual-content h2 {
    font-size: 21px;
    font-weight: 600;
    margin: 32px 0 12px 0;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--card-border);
    color: var(--text-primary);
}

.manual-content h3 {
    font-size: 17px;
    font-weight: 600;
    margin: 24px 0 8px 0;
    color: var(--text-primary);
}

.manual-content h4 {
    font-size: 15px;
    font-weight: 600;
    margin: 20px 0 6px 0;
    color: var(--text-secondary);
}

.manual-content p {
    margin: 0 0 12px 0;
}

.manual-content ul,
.manual-content ol {
    margin: 0 0 12px 0;
    padding-left: 24px;
}

.manual-content li {
    margin-bottom: 4px;
}

.manual-content li ul,
.manual-content li ol {
    margin-top: 4px;
    margin-bottom: 4px;
}

.manual-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0 20px 0;
    font-size: 13px;
}

.manual-content table th,
.manual-content table td {
    padding: 8px 12px;
    border: 1px solid var(--card-border);
    text-align: left;
    vertical-align: top;
}

.manual-content table th {
    background: var(--input-bg);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-secondary);
}

.manual-content table tr:hover td {
    background: var(--input-bg);
}

.manual-content code {
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    background: var(--input-bg);
    border: 1px solid var(--card-border);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 13px;
    color: var(--apple-blue-dark);
}

.manual-content pre {
    background: var(--input-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin: 12px 0 16px 0;
    overflow-x: auto;
    font-size: 13px;
    line-height: 1.5;
}

.manual-content pre code {
    background: none;
    border: none;
    padding: 0;
    color: var(--text-primary);
}

.manual-note,
.manual-warning,
.manual-tip {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin: 12px 0 16px 0;
    font-size: 14px;
    line-height: 1.6;
}

.manual-note {
    background: rgba(var(--accent-rgb), 0.08);
    border-left: 4px solid var(--apple-blue);
    color: var(--text-primary);
}

.manual-warning {
    background: rgba(239, 68, 68, 0.06);
    border-left: 4px solid var(--danger);
    color: var(--text-primary);
}

.manual-tip {
    background: rgba(59, 130, 246, 0.06);
    border-left: 4px solid #3b82f6;
    color: var(--text-primary);
}

.manual-note strong,
.manual-warning strong,
.manual-tip strong {
    display: block;
    margin-bottom: 4px;
}

.manual-content .section-number {
    display: inline-block;
    background: var(--apple-blue);
    color: #fff;
    width: 28px;
    height: 28px;
    line-height: 28px;
    text-align: center;
    border-radius: 50%;
    font-size: 14px;
    font-weight: 600;
    margin-right: 8px;
    vertical-align: middle;
}

.manual-content .step-list {
    counter-reset: step-counter;
    list-style: none;
    padding-left: 0;
}

.manual-content .step-list li {
    counter-increment: step-counter;
    padding-left: 36px;
    position: relative;
    margin-bottom: 8px;
}

.manual-content .step-list li::before {
    content: counter(step-counter);
    position: absolute;
    left: 0;
    top: 1px;
    background: var(--apple-blue);
    color: #fff;
    width: 24px;
    height: 24px;
    line-height: 24px;
    text-align: center;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 600;
}

/* ===== CAPTCHA ===== */
.captcha-container {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.captcha-image {
    border-radius: 6px;
    border: 1px solid var(--border);
    height: 48px;
    display: block;
}

.captcha-refresh {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    width: 40px;
    height: 40px;
    cursor: pointer;
    font-size: 18px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    flex-shrink: 0;
}

.captcha-refresh:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Honeypot - multiple hiding techniques */
.hp-field {
    position: absolute;
    left: -9999px;
    top: -9999px;
    opacity: 0;
    height: 0;
    overflow: hidden;
}
