/* ============================================
   Botz.ai — Design System (mobile-first refined)
   v5: campos maiores no desktop, mobile com scroll + bottom nav
   ============================================ */

:root {
    --bg: #fafafa;
    --bg-sidebar: #ffffff;
    --bg-card: #ffffff;
    --bg-hover: #f4f4f5;
    --bg-input: #ffffff;
    --border: #e4e4e7;
    --border-strong: #d4d4d8;
    --text: #09090b;
    --text-muted: #71717a;
    --text-subtle: #a1a1aa;
    --accent: #22c55e;
    --accent-hover: #16a34a;
    --accent-soft: #dcfce7;
    --highlight: #f0f9ff;
    --highlight-border: #0ea5e9;
    --highlight-text: #0c4a6e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.03);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.08);
    --radius: 8px;
    --radius-sm: 6px;
    --sidebar-w: 240px;
    --bottom-nav-h: 60px;
}

[data-theme="dark"] {
    --bg: #09090b;
    --bg-sidebar: #0c0c0f;
    --bg-card: #101014;
    --bg-hover: #18181b;
    --bg-input: #18181b;
    --border: #27272a;
    --border-strong: #3f3f46;
    --text: #fafafa;
    --text-muted: #a1a1aa;
    --text-subtle: #71717a;
    --accent: #22c55e;
    --accent-hover: #16a34a;
    --accent-soft: rgba(34,197,94,0.15);
    --highlight: rgba(14,165,233,0.1);
    --highlight-border: #0ea5e9;
    --highlight-text: #7dd3fc;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
    --shadow: 0 1px 3px rgba(0,0,0,0.5);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.4);
}

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

html, body {
    height: 100vh;
      overflow-x: hidden;
    overflow-y: auto;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    transition: background 0.2s, color 0.2s;
}

/* Layout */
.app { display: flex; height: 100vh; width: 100vw; }

.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-brand {
    padding: 20px 20px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 15px;
    letter-spacing: -0.01em;
    border-bottom: 1px solid var(--border);
}

.sidebar-brand-logo {
    width: 28px;
    height: 28px;
    background: var(--text);
    color: var(--bg);
    border-radius: var(--radius-sm);
    display: grid;
    place-items: center;
    font-size: 14px;
    font-weight: 700;
}

.sidebar-nav { flex: 1; padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-subtle); padding: 12px 12px 4px; font-weight: 500; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: var(--radius-sm); color: var(--text-muted); text-decoration: none; font-size: 13.5px; font-weight: 500; transition: background 0.1s, color 0.1s; cursor: pointer; }
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: var(--text); color: var(--bg); }
.nav-item svg { width: 15px; height: 15px; stroke-width: 2; flex-shrink: 0; }

.sidebar-footer { border-top: 1px solid var(--border); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.user-card { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--radius-sm); cursor: pointer; transition: background 0.1s; }
.user-card:hover { background: var(--bg-hover); }
.user-avatar { width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg, #22c55e, #10b981); color: white; display: grid; place-items: center; font-size: 12px; font-weight: 600; flex-shrink: 0; }
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-email { font-size: 11.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* User menu dropdown */
.user-menu {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    margin-bottom: 6px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(0,0,0,0.12);
    padding: 6px;
    display: none;
    z-index: 100;
    animation: userMenuFade 0.15s ease;
}
.user-menu.open { display: block; }
@keyframes userMenuFade {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}
.user-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
    transition: background 0.1s;
    cursor: pointer;
}
.user-menu-item:hover { background: var(--bg-hover); }
.user-menu-item svg { width: 14px; height: 14px; flex-shrink: 0; color: var(--text-muted); }
.user-menu-divider { height: 1px; background: var(--border); margin: 4px 0; }
.user-menu-danger { color: var(--danger); }
.user-menu-danger svg { color: var(--danger); }
.user-menu-danger:hover { background: rgba(239,68,68,0.05); }

.theme-toggle { display: flex; align-items: center; justify-content: center; width: 100%; padding: 8px; background: transparent; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; color: var(--text-muted); font-family: inherit; font-size: 12px; gap: 6px; transition: background 0.1s, color 0.1s; }
.theme-toggle:hover { background: var(--bg-hover); color: var(--text); }
.theme-toggle svg { width: 14px; height: 14px; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .label-light { display: inline; }
[data-theme="dark"] .theme-toggle .label-dark { display: none; }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
.theme-toggle .label-light { display: none; }
.theme-toggle .label-dark { display: inline; }

/* Bottom nav (mobile only) */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-h);
    background: var(--bg-sidebar);
    border-top: 1px solid var(--border);
    z-index: 50;
    padding: 6px 8px;
    padding-bottom: max(6px, env(safe-area-inset-bottom));
}
.bottom-nav-inner {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    height: 100%;
}
.bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 10.5px;
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.15s;
    padding: 4px 2px;
    text-align: center;
    line-height: 1.2;
}
.bottom-nav a svg { width: 20px; height: 20px; }
.bottom-nav a.active { color: var(--text); }
.bottom-nav a.active svg { color: var(--accent); }

/* Mobile drawer button (opcional, escondido em favor de bottom nav) */
.mobile-menu-btn { display: none; }

/* Main */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; height: 100vh; }
.topbar { min-height: 56px; border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 24px; background: var(--bg-sidebar); flex-shrink: 0; gap: 12px; }
.topbar-title { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.topbar-sub { font-size: 13px; color: var(--text-muted); margin-left: 12px; padding-left: 12px; border-left: 1px solid var(--border); }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.status-dot { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); padding: 5px 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 100px; font-weight: 500; white-space: nowrap; }
.status-dot::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); animation: pulse 2s infinite; flex-shrink: 0; }
.status-dot.warning::before { background: var(--warning); box-shadow: 0 0 0 2px rgba(245,158,11,0.2); }
.status-dot.danger::before { background: var(--danger); box-shadow: 0 0 0 2px rgba(239,68,68,0.2); animation: none; }
.status-dot.success::before { background: var(--accent); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

.content { flex: 1; overflow: auto; padding: 24px; }
.content.fit { overflow: hidden; display: flex; flex-direction: column; }

/* Cards */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-header { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.card-title { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.card-body { padding: 18px; }

/* Forms */
.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.label { display: block; font-size: 12.5px; font-weight: 500; color: var(--text); margin-bottom: 6px; }
.hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.hint-important {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-top: 10px;
    padding: 10px 12px;
    background: var(--highlight);
    border-left: 3px solid var(--highlight-border);
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    color: var(--highlight-text);
    line-height: 1.5;
}
.hint-important svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; color: var(--highlight-border); }
.hint-important b { font-weight: 600; }

.input, .select, .textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    background: var(--bg-input);
    color: var(--text);
    transition: border-color 0.1s, box-shadow 0.1s;
}
.input::placeholder, .textarea::placeholder {
    color: var(--text-subtle);
    opacity: 1;
}
.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--text-muted);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.textarea { resize: none; font-family: 'JetBrains Mono', 'SF Mono', Consolas, monospace; font-size: 13.5px; line-height: 1.6; }
.textarea.prose { font-family: inherit; font-size: 14px; line-height: 1.55; }

/* Auto-grow textarea — sem scroll, cresce com o conteúdo */
.textarea.auto-grow {
    resize: none;
    overflow: hidden;
    min-height: 80px;
}
.select { background: var(--bg-input) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%2371717a' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E") no-repeat right 12px center; padding-right: 32px; appearance: none; }

/* Switch */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { display: none; }
.switch-track { width: 34px; height: 20px; background: var(--border-strong); border-radius: 100px; position: relative; transition: background 0.15s; flex-shrink: 0; }
.switch-track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; background: white; border-radius: 50%; transition: transform 0.15s; box-shadow: 0 1px 2px rgba(0,0,0,0.15); }
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(14px); }
.switch-label { font-size: 13px; font-weight: 500; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: var(--radius-sm); font-family: inherit; font-size: 13px; font-weight: 500; cursor: pointer; border: 1px solid transparent; transition: background 0.1s, border 0.1s, color 0.1s, transform 0.1s; text-decoration: none; line-height: 1; white-space: nowrap; }
.btn-primary { background: var(--text); color: var(--bg); }
.btn-primary:hover { opacity: 0.85; }
.btn-outline { background: var(--bg-card); color: var(--text); border-color: var(--border); }
.btn-outline:hover { background: var(--bg-hover); }
.btn-accent { background: var(--accent); color: white; }
.btn-accent:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn-danger-outline { background: var(--bg-card); color: var(--danger); border-color: var(--border); }
.btn-danger-outline:hover { background: rgba(239,68,68,0.05); border-color: rgba(239,68,68,0.3); }
.btn-danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn-danger:hover { background: #dc2626; border-color: #dc2626; }
.btn-danger-solid {
    background: var(--bg-card);
    color: var(--danger);
    border-color: rgba(239,68,68,0.3);
}
.btn-danger-solid:hover { background: rgba(239,68,68,0.1); border-color: var(--danger); }
.btn svg { width: 13px; height: 13px; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-lg { padding: 10px 18px; font-size: 14px; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-icon-only { padding: 8px; }
.btn-icon-only svg { width: 14px; height: 14px; }

/* QR Panel */
.qr-panel { display: flex; align-items: center; justify-content: center; padding: 32px; gap: 32px; flex-wrap: wrap; }
.qr-visual { background: white; border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); position: relative; transition: all 0.3s; }
.qr-visual img, .qr-visual svg { width: 240px; height: 240px; display: block; }
.qr-visual.scanning { filter: blur(2px); opacity: 0.5; }
.qr-visual.connected { background: var(--accent-soft); padding: 40px; }
.qr-visual.connected::after { content: '✓'; position: absolute; inset: 0; display: grid; place-items: center; font-size: 100px; color: var(--accent); font-weight: 700; }

.qr-info { max-width: 300px; }
.qr-info h3 { font-size: 18px; font-weight: 600; letter-spacing: -0.02em; margin-bottom: 6px; color: var(--text); }
.qr-info p { color: var(--text-muted); font-size: 13.5px; margin-bottom: 16px; }

.qr-steps { list-style: none; counter-reset: step; display: flex; flex-direction: column; gap: 8px; }
.qr-steps li { counter-increment: step; display: flex; gap: 10px; font-size: 13px; color: var(--text); align-items: flex-start; }
.qr-steps li::before { content: counter(step); background: var(--bg); border: 1px solid var(--border); color: var(--text-muted); width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 600; flex-shrink: 0; }

/* Toast */
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: var(--radius); font-size: 13px; font-weight: 500; box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 8px; opacity: 0; transform: translateY(20px); transition: all 0.3s; z-index: 2000; pointer-events: none; max-width: calc(100vw - 40px); }
.toast.show { opacity: 1; transform: translateY(0); }
.toast svg { width: 14px; height: 14px; color: var(--accent); flex-shrink: 0; }
.toast.toast-error { background: var(--danger); color: white; }
.toast.toast-error svg { color: white; }

/* Editor com dropzone overlay */
.editor-wrap { flex: 1; display: block; position: relative; min-height: 0; overflow: auto; }
.editor-wrap textarea { display: block; }
.editor-overlay { position: sticky; top: 0; left: 0; right: 0; bottom: 0; background: var(--accent-soft); border: 3px dashed var(--accent); border-radius: var(--radius-sm); display: none; align-items: center; justify-content: center; z-index: 10; pointer-events: none; opacity: 0; transition: opacity 0.15s; }
.editor-overlay.show,
.editor-overlay.processing {
    position: absolute;
    inset: 0;
}
.editor-overlay.show { display: flex; opacity: 1; }
.editor-overlay.processing { display: flex; opacity: 1; background: rgba(255,255,255,0.95); pointer-events: all; }
[data-theme="dark"] .editor-overlay.processing { background: rgba(9,9,11,0.95); }
.editor-overlay-content { text-align: center; color: var(--accent); font-weight: 600; font-size: 16px; padding: 20px; }
.editor-overlay-content svg { width: 48px; height: 48px; margin: 0 auto 8px; display: block; }
.editor-overlay-content small { display: block; font-weight: 400; font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* Utility */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12.5px; }
.text-xs { font-size: 11.5px; }
.gap-2 { gap: 8px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* Auth screens */
.auth-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; background: radial-gradient(ellipse 80% 50% at 50% -20%, var(--accent-soft), transparent), var(--bg); }
.auth-card { width: 100%; max-width: 400px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 32px; box-shadow: var(--shadow-lg); }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: 10px; font-weight: 600; font-size: 18px; letter-spacing: -0.01em; margin-bottom: 6px; }
.auth-brand-logo { width: 32px; height: 32px; background: var(--text); color: var(--bg); border-radius: 8px; display: grid; place-items: center; font-size: 16px; font-weight: 700; }
.auth-title { text-align: center; font-size: 20px; font-weight: 600; letter-spacing: -0.02em; margin-bottom: 6px; }
.auth-sub { text-align: center; color: var(--text-muted); font-size: 13.5px; margin-bottom: 24px; }
.auth-footer { text-align: center; font-size: 13px; color: var(--text-muted); margin-top: 20px; }
.auth-footer a { color: var(--text); font-weight: 500; text-decoration: none; }
.auth-footer a:hover { text-decoration: underline; }

/* Templates */
.template-btn { width: 100%; display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); font-family: inherit; font-size: 13px; font-weight: 500; cursor: pointer; text-align: left; transition: all 0.1s; margin-bottom: 6px; position: relative; }
.template-btn:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.template-btn.applied { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.template-btn.customized::before { content: ''; position: absolute; top: 6px; right: 6px; width: 6px; height: 6px; background: var(--accent); border-radius: 50%; }
.template-btn-menu { margin-left: auto; opacity: 0; background: transparent; border: none; color: var(--text-muted); cursor: pointer; padding: 6px; border-radius: 4px; transition: all 0.1s; }
.template-btn:hover .template-btn-menu, .template-btn:focus-within .template-btn-menu { opacity: 1; }
.template-btn-menu:hover { background: var(--bg-hover); color: var(--text); }
.template-btn-menu svg { width: 14px; height: 14px; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 998; display: none; align-items: center; justify-content: center; opacity: 0; transition: opacity 0.2s; padding: 16px; }
.modal-backdrop.show { display: flex; opacity: 1; }
[data-theme="dark"] .modal-backdrop { background: rgba(0,0,0,0.7); }
.modal { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; max-width: 600px; width: 100%; max-height: 90vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); transform: scale(0.95); transition: transform 0.2s; }
.modal-backdrop.show .modal { transform: scale(1); }
.modal-large { max-width: 800px; }
.modal-header { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.modal-close { background: transparent; border: none; cursor: pointer; color: var(--text-muted); padding: 6px; border-radius: 4px; transition: all 0.1s; }
.modal-close:hover { background: var(--bg-hover); color: var(--text); }
.modal-close svg { width: 18px; height: 18px; }
.modal-body { padding: 22px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; align-items: center; flex-wrap: wrap; }
.modal-footer-info { margin-right: auto; font-size: 12px; color: var(--text-muted); }

/* Upload dropzone */
.dropzone { border: 2px dashed var(--border-strong); border-radius: 12px; padding: 48px 24px; text-align: center; cursor: pointer; transition: all 0.15s; background: var(--bg); }
.dropzone:hover, .dropzone.dragover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone-icon { width: 56px; height: 56px; margin: 0 auto 12px; background: var(--bg-hover); color: var(--text-muted); border-radius: 50%; display: grid; place-items: center; }
.dropzone-icon svg { width: 28px; height: 28px; }
.dropzone-title { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.dropzone-sub { font-size: 13px; color: var(--text-muted); margin-bottom: 12px; }
.dropzone-hint { font-size: 11.5px; color: var(--text-subtle); }
.dropzone input { display: none; }

/* Upload preview */
.upload-preview { display: flex; gap: 16px; align-items: center; padding: 16px; background: var(--bg-hover); border-radius: var(--radius); margin-bottom: 12px; }
.upload-preview img { width: 80px; height: 80px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--border); flex-shrink: 0; }
.upload-preview-info { flex: 1; min-width: 0; }
.upload-preview-info b { display: block; font-size: 13.5px; margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-preview-info span { font-size: 12px; color: var(--text-muted); }
#upload-preview-list { display: none; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.upload-preview-pdf { width: 60px; height: 60px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); display: grid; place-items: center; font-size: 12px; font-weight: 600; color: var(--text-muted); flex-shrink: 0; }

/* Loader */
.loader-wrap { display: flex; flex-direction: column; align-items: center; padding: 40px 20px; gap: 16px; }
.loader { width: 40px; height: 40px; border: 3px solid var(--bg-hover); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loader-text { font-size: 14px; color: var(--text-muted); font-weight: 500; text-align: center; }
.loader-sub { font-size: 12px; color: var(--text-subtle); text-align: center; }

/* Extracted result */
.extracted-preview { background: var(--bg-hover); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; max-height: 300px; overflow-y: auto; font-family: 'JetBrains Mono', monospace; font-size: 12.5px; line-height: 1.6; white-space: pre-wrap; color: var(--text); }

/* Radio choice */
.radio-choice { display: flex; flex-direction: column; gap: 8px; margin: 16px 0; }
.radio-item { display: flex; align-items: flex-start; gap: 10px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; transition: all 0.1s; }
.radio-item:hover { background: var(--bg-hover); }
.radio-item input { margin-top: 3px; accent-color: var(--accent); }
.radio-item.selected { border-color: var(--accent); background: var(--accent-soft); }
.radio-item-content b { display: block; font-size: 13.5px; margin-bottom: 2px; }
.radio-item-content span { font-size: 12px; color: var(--text-muted); }

/* WhatsApp chat sim */
.chat-preview { background: #efeae2; border-radius: var(--radius); padding: 16px; height: 100%; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; background-image: radial-gradient(rgba(0,0,0,0.05) 1px, transparent 1px); background-size: 6px 6px; }
[data-theme="dark"] .chat-preview { background: #0a1014; background-image: radial-gradient(rgba(255,255,255,0.03) 1px, transparent 1px); }
.msg { max-width: 75%; padding: 8px 12px; border-radius: 8px; font-size: 13.5px; line-height: 1.4; box-shadow: 0 1px 1px rgba(0,0,0,0.1); animation: msgIn 0.3s; }
@keyframes msgIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.msg-them { background: white; color: #111b21; align-self: flex-start; border-top-left-radius: 2px; }
.msg-me { background: #d9fdd3; color: #111b21; align-self: flex-end; border-top-right-radius: 2px; }
[data-theme="dark"] .msg-them { background: #1f2c33; color: #e9edef; }
[data-theme="dark"] .msg-me { background: #005c4b; color: #e9edef; }
.msg-time { font-size: 10px; color: rgba(0,0,0,0.4); text-align: right; margin-top: 2px; }
[data-theme="dark"] .msg-time { color: rgba(255,255,255,0.5); }
.typing { background: white; color: var(--text-subtle); align-self: flex-start; border-radius: 8px; padding: 8px 14px; border-top-left-radius: 2px; display: flex; gap: 4px; }
[data-theme="dark"] .typing { background: #1f2c33; }
.typing span { width: 6px; height: 6px; background: #999; border-radius: 50%; animation: typing 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing { 0%, 60%, 100% { opacity: 0.3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* Modal de confirmação customizado */
.confirm-backdrop { z-index: 2100; }
.modal-confirm {
    max-width: 420px !important;
    padding: 28px 24px 20px;
    text-align: center;
    display: block;
}
.modal-confirm-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    background: var(--accent-soft);
    color: var(--accent);
    border-radius: 50%;
    display: grid;
    place-items: center;
}
.modal-confirm-icon.danger {
    background: rgba(239,68,68,0.1);
    color: var(--danger);
}
.modal-confirm-icon svg { width: 28px; height: 28px; }
.modal-confirm h3 {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 8px;
    letter-spacing: -0.01em;
    color: var(--text);
}
.modal-confirm p {
    font-size: 13.5px;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 20px;
}
.modal-confirm-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
}
.modal-confirm-actions .btn {
    flex: 1;
    justify-content: center;
    padding: 10px 16px;
    font-size: 14px;
}
.modal-confirm-opts {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
}
.modal-confirm-opt {
    display: block;
    width: 100%;
    padding: 14px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    color: var(--text);
    transition: all 0.15s;
}
.modal-confirm-opt:hover {
    background: var(--bg-hover);
    border-color: var(--border-strong);
}
.modal-confirm-opt.destaque {
    border-color: var(--accent);
    background: var(--accent-soft);
}
.modal-confirm-opt.destaque:hover {
    background: var(--accent-soft);
    border-color: var(--accent);
}
.modal-confirm-opt b {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
}
.modal-confirm-opt span {
    display: block;
    font-size: 12.5px;
    color: var(--text-muted);
    line-height: 1.4;
}

/* ================================================
   RESPONSIVE — Mobile
   ================================================ */
@media (max-width: 900px) {
    html, body {
        overflow: auto !important;
        overflow-x: hidden !important;
        height: auto;
        min-height: 100vh;
    }
    .app {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
        padding-bottom: var(--bottom-nav-h);
        width: 100%;
        overflow-x: hidden;
    }
    .sidebar { display: none; }
    .bottom-nav { display: block; }

    .main {
        height: auto;
        min-height: calc(100vh - var(--bottom-nav-h));
        overflow: visible;
        width: 100%;
    }

    .topbar {
        padding: 0 14px;
        min-height: 52px;
        position: sticky;
        top: 0;
        z-index: 40;
        gap: 8px;
    }
    .topbar > div:first-child { min-width: 0; flex: 1; overflow: hidden; }
    .topbar-title {
        font-size: 14px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        display: block;
    }
    .topbar-sub { display: none; }
    .topbar-actions { gap: 6px; flex-shrink: 0; }
    .topbar-actions .status-dot { display: none; }
    .topbar-actions .btn {
        font-size: 12px;
        padding: 7px 10px;
    }
    .btn-mobile-icon-only span { display: none; }
    .btn-mobile-icon-only { padding: 8px !important; }

    .content { padding: 14px; overflow: visible; }
    .content.fit {
        overflow: visible;
        display: block !important;
        grid-template-columns: 1fr !important;
    }
    .content.fit > div {
        margin-bottom: 14px;
        min-height: 0 !important;
        overflow: visible !important;
    }
    .content.fit > div:last-child { margin-bottom: 0; }

    /* Cards que tinham flex/altura fixa no desktop, agora fluidos */
    .card[style*="flex:1"],
    .card[style*="flex: 1"],
    .card[style*="min-height"] {
        flex: none !important;
        min-height: 0 !important;
        height: auto !important;
    }
    .card {
        display: block !important;
    }
    .card-header {
        flex-wrap: wrap;
        gap: 4px;
    }
    .card-body {
        overflow: visible !important;
        display: block !important;
    }

    /* Grid interna vira 1 coluna */
    .grid-2 { grid-template-columns: 1fr !important; gap: 10px; }
    .grid-3 { grid-template-columns: 1fr !important; gap: 10px; }
    /* Grid customizada com 3 colunas do configurar-bot */
    .card-body [style*="grid-template-columns:1fr 1fr 160px"],
    .card-body [style*="grid-template-columns: 1fr 1fr 160px"] {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }

    /* Textareas ganham altura confortável e podem crescer */
    .textarea, .textarea.prose, .textarea.auto-grow {
        min-height: 140px;
        font-size: 14px;
    }
    .textarea.auto-grow { min-height: 100px; }

    .editor-wrap {
        min-height: 320px;
        display: flex;
    }
    #base-editor {
        min-height: 320px !important;
        flex: 1;
    }

    /* Modal ocupa quase toda tela */
    .modal { max-height: 92vh; margin: 8px; }
    .modal-large { max-width: 100%; }
    .modal-header { padding: 14px 16px; }
    .modal-body { padding: 16px; }
    .modal-footer {
        padding: 12px 16px;
        flex-wrap: wrap;
        gap: 6px;
    }
    .modal-footer .btn { flex: 1; justify-content: center; }
    .modal-footer-info {
        flex-basis: 100%;
        margin-right: 0;
        text-align: center;
        font-size: 11px;
        margin-bottom: 8px;
    }
    /* Confirm modal continua centralizado */
    .modal-confirm { padding: 22px 18px 18px; }
    .modal-confirm h3 { font-size: 16px; }
    .modal-confirm p { font-size: 13px; }

    /* Dropzone compacta */
    .dropzone { padding: 32px 16px; }
    .dropzone-icon { width: 48px; height: 48px; }
    .dropzone-icon svg { width: 24px; height: 24px; }
    .dropzone-title { font-size: 14px; }
    .dropzone-sub { font-size: 12.5px; }

    /* QR panel empilha */
    .qr-panel {
        flex-direction: column;
        padding: 20px;
        gap: 20px;
        flex-wrap: nowrap;
    }
    .qr-visual { padding: 12px; }
    .qr-visual img, .qr-visual svg { width: 200px; height: 200px; }
    .qr-info { text-align: center; max-width: 100%; }
    .qr-info h3 { font-size: 17px; }
    .qr-steps li { text-align: left; }

    /* Toast acima do bottom nav */
    .toast {
        bottom: calc(var(--bottom-nav-h) + 12px);
        left: 12px;
        right: 12px;
        max-width: none;
    }

    /* Chat preview mobile */
    .chat-preview { max-height: 400px; min-height: 300px; }

    /* Auth screens mobile */
    .auth-card { padding: 24px 20px; }

    /* Hint destacado com padding menor */
    .hint-important { padding: 10px; font-size: 12px; }

    /* Grid customizada do dashboard/conversas em mobile */
    .content > div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }
}

/* Telas muito pequenas */
@media (max-width: 480px) {
    .content { padding: 12px; }
    .card-body { padding: 14px; }
    .card-header { padding: 12px 14px; }
    .modal-header h3 { font-size: 15px; }
    .bottom-nav a { font-size: 9.5px; }
    .bottom-nav a svg { width: 18px; height: 18px; }
    .topbar-actions .btn { padding: 6px 10px; font-size: 11.5px; }
    .topbar-actions .btn svg { width: 12px; height: 12px; }
    .topbar-actions { gap: 4px; }
    /* Reduz padding da topbar */
    .topbar { padding: 0 12px; }
    /* Templates apertados */
    .template-btn { padding: 10px; font-size: 12.5px; }
}

/* ================================================
   DESKTOP — Textareas grandes por padrão
   ================================================ */
@media (min-width: 901px) {
    #base-editor { min-height: 400px; }
    .textarea.auto-grow { min-height: 100px; }
}
