:root {
    --bg-color: #f9fafb;
    --card-bg: #ffffff;
    --primary: #2563eb;
    --primary-glow: rgba(37, 99, 235, 0.15);
    --secondary: #7c3aed;
    --text-main: #111827;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --danger: #ef4444;
    --warning: #f59e0b;
    --success: #10b981;
    --glass-bg: #ffffff;
    --glass-border: #e5e7eb;
    --surface: #f9fafb;
    --text: #111827;
}

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

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

h1,
h2,
h3 {
    font-family: 'Outfit', sans-serif;
}

.app-container {
    max-width: 1700px;
    margin: 0 auto;
    padding: 2rem;
}

header {
    margin-bottom: 0;
}

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

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.06), 0 1px 2px -1px rgba(0, 0, 0, 0.04);
    transition: box-shadow 0.2s;
}

.card:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
}

.chart-container {
    height: 300px;
}

.process-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    table-layout: auto;
}

.process-table th:nth-child(1) {
    width: 220px;
}

.process-table th:nth-child(3) {
    width: 280px;
}

.process-table th:nth-child(4) {
    width: 150px;
}

.process-table th {
    text-align: left;
    padding: 1rem;
    color: var(--text-muted);
    font-weight: 500;
    border-bottom: 1px solid var(--border);
}

.process-table td {
    padding: 1rem 0.5rem;
    border-bottom: 1px solid var(--border);
}

.no-wrap {
    white-space: nowrap !important;
}

.process-table tr:hover {
    background: #eff6ff;
    cursor: pointer;
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-pago {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-liberado {
    background: rgba(56, 189, 248, 0.2);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.3);
}

.badge-aguardando {
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-parcial {
    background: rgba(20, 184, 166, 0.2);
    color: #14b8a6;
    border: 1px solid rgba(20, 184, 166, 0.3);
}

.badge-resgate {
    background: rgba(249, 115, 22, 0.2);
    color: #f97316;
    border: 1px solid rgba(249, 115, 22, 0.3);
}

.issue-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--danger);
    margin-right: 0.5rem;
    box-shadow: 0 0 8px var(--danger);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: #ffffff;
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    border-radius: 1.5rem;
    border: 1px solid var(--glass-border);
    padding: 2rem;
    overflow-y: auto;
    position: relative;
}

.close-btn {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.5rem;
}

.modal-section {
    margin-bottom: 2rem;
}

.modal-section h3 {
    margin-bottom: 1rem;
    color: var(--primary);
}

.nested-list {
    background: #f9fafb;
    border-radius: 0.75rem;
    padding: 1rem;
    margin-bottom: 1rem;
}

.audit-issue {
    background: rgba(239, 68, 68, 0.1);
    border-left: 4px solid var(--danger);
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 0 0.5rem 0.5rem 0;
}

/* ── Chat drawer ──────────────────────────────────────────────────────────── */

.processes-chat-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    align-items: start;
}

/* FAB button */
.chat-fab {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: #2563eb;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(37, 99, 235, 0.35);
    transition: transform 0.2s, box-shadow 0.2s;
    z-index: 900;
}

.chat-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 28px rgba(37, 99, 235, 0.5);
}

/* Overlay backdrop */
.chat-drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Drawer panel */
.chat-panel {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: 400px;
    max-width: 95vw;
    background: #ffffff;
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 1010;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-panel.chat-panel-open {
    transform: translateX(0);
}

.chat-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

.chat-msg {
    max-width: 90%;
    padding: 0.6rem 0.85rem;
    border-radius: 0.75rem;
    font-size: 0.85rem;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.chat-msg-user {
    align-self: flex-end;
    background: #dbeafe;
    border: 1px solid #bfdbfe;
    color: #1e40af;
}

.chat-msg-bot {
    align-self: flex-start;
    background: #f9fafb;
    border: 1px solid var(--border);
    color: var(--text-main);
}

.chat-msg-status {
    align-self: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
    padding: 0.25rem 0;
}

.chat-msg-sql {
    align-self: flex-start;
    background: rgba(129, 140, 248, 0.1);
    border: 1px solid rgba(129, 140, 248, 0.2);
    font-family: 'Courier New', monospace;
    font-size: 0.72rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    max-width: 95%;
    overflow-x: auto;
    white-space: pre-wrap;
    color: var(--secondary);
}

.chat-input-area {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.chat-input-area input {
    flex: 1;
    background: #f9fafb;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    color: var(--text-main);
    font-size: 0.85rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input-area input:focus {
    border-color: var(--primary);
}

.chat-input-area input::placeholder {
    color: var(--text-muted);
}

.chat-input-area button {
    background: var(--primary);
    border: none;
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    transition: opacity 0.2s;
}

.chat-input-area button:hover:not(:disabled) {
    opacity: 0.85;
}

.chat-input-area button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.chat-msg-thinking {
    align-self: flex-start;
    display: flex;
    gap: 4px;
    padding: 0.6rem 0.85rem;
}

.chat-msg-thinking span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: thinking-bounce 1.2s infinite ease-in-out;
}

.chat-msg-thinking span:nth-child(2) { animation-delay: 0.2s; }
.chat-msg-thinking span:nth-child(3) { animation-delay: 0.4s; }

@keyframes thinking-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40%            { transform: scale(1);   opacity: 1;   }
}