:root {
    /* Brand Colors */
    --primary: #fbbf24;
    --primary-rgb: 251, 191, 36;
    --primary-hover: #fcd34d;
    --primary-light: rgba(251, 191, 36, 0.1);

    /* Semantic Colors */
    --success: #10b981;
    --warning: #f97316;
    --danger: #ef4444;

    /* Base Colors - Linear Aesthetic */
    --bg-main: #0c0d0f;
    --bg-card: #141518;
    --bg-input: #1b1c20;
    --bg-sidebar: #08090a;
    --border: rgba(255, 255, 255, 0.085);
    --border-bright: rgba(255, 255, 255, 0.16);

    /* Text Colors */
    --text-primary: #f7f7f5;
    --text-secondary: #a9adb5;
    --text-muted: #717680;

    /* Shadows & Effects */
    --shadow-main: 0 1px 0 rgba(255, 255, 255, 0.03);
    --glass: rgba(255, 255, 255, 0.025);
    --transition: all 0.18s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
}

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

h1,
h2,
h3,
h4,
.logo-text,
.nav-section-title {
    font-family: 'Outfit', sans-serif;
    letter-spacing: -0.02em;
}

/* --- Layout Structure --- */

.admin-body {
    display: flex;
}

.sidebar {
    width: 260px;
    height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: var(--transition);
}

.main-wrapper {
    flex: 1;
    margin-left: 260px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    height: 70px;
    background: rgba(9, 9, 10, 0.92);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: fixed;
    top: 0;
    right: 0;
    left: 260px;
    z-index: 900;
}

.main-content {
    padding: calc(70px + 2.5rem) 2.5rem 2.5rem;
    flex: 1;
}

/* --- Sidebar Components --- */

.sidebar-header {
    padding: 2rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.logo-icon {
    width: 32px;
    height: 32px;
    background: var(--primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000;
    font-size: 1.2rem;
    overflow: hidden;
}

.logo-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.team-access-box {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: color-mix(in srgb, var(--surface) 96%, var(--primary) 4%);
    padding: 14px;
}

.team-access-copy {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 12px;
}

.team-access-copy strong {
    color: var(--text-primary);
    font-size: 0.94rem;
}

.team-access-copy span {
    color: var(--text-secondary);
    font-size: 0.82rem;
    line-height: 1.35;
}

.team-access-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 8px;
}

.team-access-item {
    display: grid;
    grid-template-columns: auto 30px minmax(0, 1fr) auto;
    align-items: center;
    gap: 9px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    padding: 9px 10px;
    cursor: pointer;
    transition: border-color .16s ease, background .16s ease, transform .16s ease;
}

.team-access-item:hover {
    border-color: color-mix(in srgb, var(--primary) 55%, var(--border));
    background: color-mix(in srgb, var(--surface) 92%, var(--primary) 8%);
}

.team-access-item:has(input:checked) {
    border-color: color-mix(in srgb, var(--primary) 70%, var(--border));
    background: color-mix(in srgb, var(--primary) 13%, var(--surface));
}

.team-access-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--primary);
    color: #111827;
    font-weight: 800;
    font-size: 0.82rem;
}

.team-access-name {
    min-width: 0;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.team-access-role {
    color: var(--text-muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: 2px;
}

.sidebar-nav {
    flex: 1;
    padding: 0 1rem;
    overflow-y: auto;
}

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

.nav-section-title {
    display: block;
    padding-left: 1rem;
    margin-bottom: 0.75rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.1em;
}

.nav-links {
    list-style: none;
}

.nav-links li {
    margin-bottom: 4px;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
}

.nav-links a i {
    font-size: 1rem;
    width: 20px;
    text-align: center;
    opacity: 0.7;
}

.nav-links a:hover {
    background: rgba(255, 255, 255, 0.035);
    color: #fff;
}

.nav-links a.active {
    background: rgba(var(--primary-rgb), 0.08);
    color: var(--primary);
}

.nav-links a.active i {
    opacity: 1;
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border);
}

.logout-link {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    transition: var(--transition);
}

.logout-link:hover {
    color: var(--danger);
}

/* --- Topbar Components --- */

.topbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
}

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

.breadcrumb-item.active {
    color: var(--text-primary);
    font-weight: 600;
}

.breadcrumb .separator {
    font-size: 0.7rem;
    color: var(--text-muted);
    opacity: 0.5;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.quick-search {
    position: relative;
    width: 240px;
    display: flex;
    align-items: center;
}

.quick-search i {
    position: absolute;
    left: 12px;
    color: var(--text-muted);
    font-size: 0.9rem;
    pointer-events: none;
}

.quick-search input {
    width: 100%;
    height: 38px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0 12px 0 36px;
    color: #fff;
    font-size: 0.85rem;
    transition: var(--transition);
}

.quick-search input:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.12);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-left: 1.5rem;
    border-left: 1px solid var(--border);
    height: 36px;
}

.user-details {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: #fff;
}

.user-role {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.user-profile-link {
    color: inherit;
    text-decoration: none;
    border-radius: 14px;
    padding-right: 6px;
    transition: background 0.18s ease;
}

.user-profile-link:hover,
.user-profile-link:focus-visible {
    color: inherit;
    text-decoration: none;
    background: rgba(255, 255, 255, 0.035);
}

.user-profile-link *,
.user-profile-link:hover * {
    text-decoration: none;
}

.user-avatar-circle {
    width: 36px;
    height: 36px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000;
    font-weight: 800;
    font-size: 0.9rem;
}

/* --- Content Components --- */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-main);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
}

/* --- Stats Grid --- */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: var(--transition);
}

.stat-card:hover {
    border-color: var(--border-bright);
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-icon {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-size: 1.1rem;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    color: #fff;
}

.stat-trend {
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 4px;
}

.trend-up {
    color: var(--success);
}

.trend-down {
    color: var(--danger);
}

/* --- Header & Action Bars --- */

.header-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
    gap: 2rem;
    padding-top: 10px;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 800;
    color: #fff;
    margin-bottom: 8px;
}

.page-header .subtitle {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.header-actions .actions {
    display: flex;
    gap: 12px;
}

.page-intro {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.page-intro h1,
.page-intro h2 {
    font-size: 1.75rem;
    font-weight: 800;
    color: #fff;
    margin-bottom: 0.5rem;
}

.page-intro p {
    max-width: 720px;
}

.hero-card {
    background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.14), transparent);
    border-color: rgba(var(--primary-rgb), 0.2);
}

.hero-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
}

.hero-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.split-grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
    gap: 2rem;
    align-items: start;
}

.metric-stack {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.status-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    font-weight: 700;
}

.status-pill.success {
    color: var(--success);
}

.status-pill.warning {
    color: var(--warning);
}

.status-pill.danger {
    color: var(--danger);
}

.info-panel {
    padding: 1rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
}

.card-header-wrap {
    flex-wrap: wrap;
    gap: 1rem;
}

.toolbar-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

.toolbar-select {
    width: auto;
    min-width: 160px;
    padding: 8px 12px;
    font-size: 0.8rem;
}

.search-card {
    padding: 0.75rem 1.25rem;
}

.search-inline {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.search-inline input {
    background: transparent;
    border: none;
    padding: 0;
    height: auto;
}

.search-inline input:focus {
    box-shadow: none;
    border: none;
}

.empty-state {
    grid-column: 1 / -1;
    padding: 4rem 2rem;
    text-align: center;
    border: 2px dashed var(--border);
    border-radius: 20px;
}

.empty-state-icon {
    font-size: 3rem;
    color: var(--text-muted);
    opacity: 0.2;
    margin-bottom: 1rem;
}

.table-avatar-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.table-avatar {
    width: 32px;
    height: 32px;
    font-size: 0.8rem;
}

.table-title {
    font-weight: 700;
    color: var(--text-primary);
}

.table-subtitle {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.table-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.05);
}

.table-chip--primary {
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary);
}

.table-truncate {
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.surface-muted {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.w-full {
    width: 100%;
}

/* --- Utility classes --- */

.m-0 { margin: 0; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 0.75rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mt-5 { margin-top: 2rem; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 0.75rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mb-5 { margin-bottom: 2rem; }
.pt-3 { padding-top: 1rem; }
.p-3 { padding: 1rem; }
.p-4 { padding: 1.5rem; }

.d-none { display: none; }
.d-block { display: block; }
.d-inline { display: inline; }
.d-flex { display: flex; }
.d-grid { display: grid; }
.flex-1 { flex: 1; }
.flex-column { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.justify-center { justify-content: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 0.75rem; }
.gap-3 { gap: 1rem; }
.gap-4 { gap: 1.5rem; }

.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.85rem; }
.text-base { font-size: 0.95rem; }
.text-lg { font-size: 1.1rem; }
.text-xl { font-size: 1.5rem; }
.text-white { color: #fff; }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.font-mono { font-family: monospace; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.font-extrabold { font-weight: 800; }
.uppercase { text-transform: uppercase; }
.tracking-wide { letter-spacing: 0.08em; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.leading-normal { line-height: 1.5; }
.leading-relaxed { line-height: 1.6; }
.no-decoration { text-decoration: none; }
.cursor-pointer { cursor: pointer; }

.min-h-control { min-height: 44px; }
.min-w-copy { min-width: min(100%, 260px); }
.quick-search-sm { width: 220px; }
.quick-search-md { width: 250px; }
.empty-cell { text-align: center; padding: 4rem; }
.empty-cell-sm { text-align: center; padding: 3rem; }
.inline-form { display: inline; }

.icon-muted { opacity: 0.4; margin-right: 4px; }
.contact-icon { width: 16px; }
.contact-icon.email { color: var(--primary); }
.contact-icon.whatsapp { color: var(--success); }
.date-stack { font-size: 0.85rem; }
.date-stack .time { font-size: 0.75rem; }
.modal-spaced { margin-bottom: 1.5rem; }
.copy-intro { margin-bottom: 1.5rem; }
.small-muted-copy { font-size: 0.85rem; }
.settings-hint { display: block; margin-top: 8px; color: var(--text-muted); }

.surface-box {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
}

.surface-box-dark {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.2);
}

.surface-box-primary {
    border: 1px solid rgba(var(--primary-rgb), 0.22);
    border-radius: 12px;
    background: rgba(var(--primary-rgb), 0.05);
}

.surface-box-success {
    border: 1px solid rgba(37, 211, 102, 0.15);
    border-radius: 12px;
    background: rgba(37, 211, 102, 0.03);
}

.section-card {
    padding: 20px;
    border-radius: 12px;
}

.notice-row {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 10px;
    border-radius: 6px;
    border: 1px dashed var(--primary);
    background: rgba(var(--primary-rgb), 0.1);
}

.notice-row > i {
    color: var(--primary);
    margin-top: 3px;
}

.form-note {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}

.checkbox-lg {
    width: 24px;
    height: 24px;
}

.checkbox-md {
    width: 18px;
    height: 18px;
}

.advanced-box {
    margin-top: 24px;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.02);
}

.advanced-box summary {
    cursor: pointer;
    color: #fff;
    font-weight: 600;
}

.avatar-preview-img,
.cover-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.rounded-full {
    border-radius: 50%;
}

.emoji-preview-input {
    margin-top: 10px;
    width: 80px;
    text-align: center;
    font-size: 1.5rem;
}

.mono-textarea {
    font-family: monospace;
    font-size: 0.9rem;
}

.channel-card {
    margin-top: 24px;
    padding: 18px;
    border: 1px solid rgba(37, 211, 102, 0.15);
    border-radius: 12px;
    background: rgba(37, 211, 102, 0.03);
}

.channel-title {
    margin-bottom: 12px;
    color: #25D366;
}

.status-check-title {
    display: block;
    color: #fff;
    font-size: 0.88rem;
}

.status-check-subtitle {
    display: block;
    color: var(--text-muted);
    font-size: 0.76rem;
    margin-top: 2px;
}

.copy-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.copy-box-note {
    display: block;
    margin-top: 10px;
}

.settings-section-copy {
    margin-bottom: 25px;
    color: var(--text-muted);
}

.settings-section-title-inline {
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-subtitle {
    font-size: 0.85rem;
    margin-bottom: 20px;
}

.wizard-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    align-items: flex-start;
}

.wizard-title {
    margin: 0 0 0.35rem;
    color: #fff;
}

.wizard-copy {
    margin: 0;
    color: var(--text-muted);
    max-width: 820px;
}

.wizard-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.compact-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.sector-members-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
}

.sector-member-label {
    display: flex;
    gap: 10px;
    align-items: center;
    font-size: 0.92rem;
}

.sector-member-role {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.actions-cell {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.warning-card {
    margin-top: 20px;
    border-left: 4px solid var(--warning);
}

.waha-status-text {
    display: block;
    color: #fff;
}

.waha-status-hint {
    display: block;
    font-size: 0.84rem;
    margin-top: 3px;
}

.waha-status-copy {
    margin-top: -6px;
    margin-bottom: 16px;
}

.waha-side-note {
    font-size: 0.82rem;
    line-height: 1.35;
    margin: 16px 0 0;
}

.warning-copy {
    margin: 7px 0 0;
}

.status-ready {
    color: var(--success);
}

.status-warning {
    color: var(--warning);
}

.status-pills {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.status-pills-spaced {
    margin-bottom: 12px;
}

.status-check-copy strong {
    display: block;
    color: #fff;
    font-size: 0.88rem;
}

.status-check-copy span {
    display: block;
    color: var(--text-muted);
    font-size: 0.76rem;
    margin-top: 2px;
}

.custom-model-input {
    margin-top: 8px;
    font-size: 0.9rem;
}

.external-model-note {
    display: block;
    margin-top: 4px;
    color: var(--text-muted);
}

.ai-test-panel {
    margin-top: 18px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.18);
}

.ai-test-result {
    display: none;
    margin-top: 12px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
}

.ai-test-result.is-visible {
    display: block;
}

.ai-test-result.is-success {
    border-color: rgba(34, 197, 94, 0.45);
    color: var(--success);
}

.ai-test-result.is-error {
    border-color: rgba(239, 68, 68, 0.45);
    color: var(--danger);
}

.capture-panel {
    padding: 25px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(var(--primary-rgb), 0.05);
    margin-bottom: 30px;
}

.capture-title,
.webhook-title {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--primary);
}

.capture-title {
    margin-bottom: 20px;
}

.capture-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.capture-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    border: 1px solid var(--border);
    border-left: 4px solid var(--text-muted);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    cursor: grab;
    transition: all 0.2s;
}

.capture-item.is-question {
    border-color: var(--primary);
    border-left-color: var(--primary);
}

.capture-handle {
    color: var(--text-muted);
    cursor: grab;
}

.capture-item-body {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
}

.capture-item-icon {
    color: var(--text-muted);
}

.capture-item-icon.is-question {
    color: var(--primary);
}

.capture-item-label {
    font-weight: 600;
    color: var(--text-primary);
}

.capture-badge {
    font-size: 0.75rem;
    color: var(--primary);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.question-heading {
    margin-bottom: 15px;
    font-size: 1rem;
}

.question-card {
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.2);
}

.question-card h4 {
    color: var(--primary);
    margin-bottom: 15px;
}

.section-divider-title {
    margin-top: 20px;
    margin-bottom: 10px;
    color: var(--text-secondary);
}

.section-divider-title.is-separated {
    margin-top: 30px;
    margin-bottom: 15px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.color-code {
    font-size: 0.9rem;
    font-family: monospace;
}

.icon-selection-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.standard-icons-grid {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.std-icon-option {
    position: relative;
    width: 45px;
    height: 45px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-input);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.std-icon-option.active,
.std-icon-option:hover {
    border-color: var(--primary);
}

.icon-svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.widget-icon-layout {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.emoji-control {
    font-size: 1.5rem;
    text-align: center;
}

.widget-icon-preview-col {
    text-align: center;
}

.widget-icon-preview {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #000;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.widget-icon-preview-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.channel-intro {
    color: var(--text-muted);
    margin-bottom: 25px;
}

.whatsapp-channel-card {
    margin-top: 0;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(37, 211, 102, 0.05);
}

.channel-callout {
    margin: 0 0 18px;
    padding: 14px;
    border: 1px solid rgba(37, 211, 102, 0.18);
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.16);
}

.channel-callout strong,
.channel-callout span {
    display: block;
}

.channel-callout strong {
    margin-bottom: 6px;
    color: #fff;
}

.channel-callout span {
    color: var(--text-muted);
    font-size: 0.82rem;
    line-height: 1.5;
}

.channel-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    font-weight: 600;
}

.webhook-stack {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.webhook-panel {
    padding: 15px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.2);
}

.input-compact-spacer {
    margin-bottom: 5px;
}

.notice-copy {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.inline-code {
    padding: 2px 5px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.3);
    font-family: monospace;
}






.mini-progress,
.metric-progress {
    width: 60px;
    height: 6px;
    overflow: hidden;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
}

.metric-progress {
    width: 100%;
    min-width: 90px;
}

.mini-progress::-webkit-progress-bar,
.metric-progress::-webkit-progress-bar {
    background: rgba(255, 255, 255, 0.08);
}

.mini-progress::-webkit-progress-value,
.metric-progress::-webkit-progress-value {
    background: var(--success);
}

.mini-progress.is-warning::-webkit-progress-value,
.metric-progress.is-warning::-webkit-progress-value {
    background: var(--warning);
}

.metric-progress.is-danger::-webkit-progress-value {
    background: var(--danger);
}

.mini-progress::-moz-progress-bar,
.metric-progress::-moz-progress-bar {
    background: var(--success);
}

.mini-progress.is-warning::-moz-progress-bar,
.metric-progress.is-warning::-moz-progress-bar {
    background: var(--warning);
}

.metric-progress.is-danger::-moz-progress-bar {
    background: var(--danger);
}

.badge-status-active,
.badge-status-success {
    color: var(--success);
    border-color: rgba(16, 185, 129, 0.26);
}

.badge-status-warning {
    color: var(--warning);
    border-color: rgba(245, 158, 11, 0.26);
}

.badge-status-danger {
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.26);
}

.badge-status-admin {
    color: var(--primary);
    border-color: rgba(var(--primary-rgb), 0.28);
}

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

.company-name-field { width: 140px; }
.company-slug-field { width: 120px; }

.result-card {
    border-left: 4px solid var(--border);
}

.result-card.is-success {
    border-left-color: var(--success);
}

.result-card.is-danger {
    border-left-color: var(--danger);
}

.whatsapp-action {
    width: 100%;
    text-decoration: none;
}

.btn-whatsapp {
    background: #25D366;
    color: #000;
    text-decoration: none;
}

.chat-demo {
    height: 650px;
    display: flex;
    flex-direction: column;
}

.chat-log {
    flex: 1;
    overflow-y: auto;
    padding-right: 15px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.message-row {
    display: flex;
    flex-direction: column;
}

.message-row.is-user {
    align-items: flex-end;
}

.message-row.is-bot,
.message-row.is-system {
    align-items: flex-start;
}

.message-bubble {
    max-width: 70%;
    padding: 12px 18px;
    border-radius: 16px;
    font-size: 0.95rem;
    line-height: 1.5;
}

.message-bubble.is-user {
    background: var(--primary);
    color: #000;
    border-bottom-right-radius: 4px;
}

.message-bubble.is-bot {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.message-bubble.is-system {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-muted);
    border: 1px dashed var(--border);
}

.queue-item-age.is-overdue {
    color: var(--danger);
}

/* --- Forms & Buttons --- */

.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

input,
textarea,
select {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    color: #fff;
    font-family: inherit;
    font-size: 0.95rem;
    transition: var(--transition);
}

input[type="checkbox"],
input[type="radio"] {
    width: auto;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    accent-color: var(--primary);
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
}

input[type="checkbox"]:focus,
input[type="radio"]:focus {
    box-shadow: none;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px 18px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: #000;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-sm {
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 0.8rem;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.035);
    color: #fff;
    border-color: var(--border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.07);
}

.btn-icon {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    transition: var(--transition);
    cursor: pointer;
}

.btn-icon:hover {
    background: var(--primary);
    color: #000;
    border-color: var(--primary);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.12);
    color: #fff;
    border-color: rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    background: var(--danger);
    border-color: var(--danger);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}

.alert {
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 20px;
    border: 1px solid transparent;
}

.alert-success {
    background: rgba(16, 185, 129, 0.2);
    border-color: var(--success);
    color: var(--success);
}

.alert-danger {
    background: rgba(239, 68, 68, 0.2);
    border-color: var(--danger);
    color: var(--danger);
}

.alert-info {
    background: rgba(var(--primary-rgb), 0.1);
    border-color: rgba(var(--primary-rgb), 0.28);
    color: var(--primary);
}

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

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

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.5rem;
}

.presence-form {
    display: flex;
    align-items: center;
    gap: 8px;
}

.presence-label {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font-size: 0.82rem;
    margin-bottom: 0;
}

.presence-select {
    width: auto;
    background: var(--bg-main);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: 10px;
    padding: 6px 10px;
}

.company-pill {
    margin-top: 2px;
    color: var(--primary);
}

/* --- Dropdowns --- */

.dropdown {
    position: relative;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    min-width: 180px;
    padding: 8px;
    box-shadow: var(--shadow-main);
    z-index: 100;
}

.dropdown:hover .dropdown-menu {
    display: block;
}

.dropdown-menu a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    border-radius: 8px;
    transition: var(--transition);
}

.dropdown-menu a:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
}

/* --- Tables --- */

.table-wrapper {
    background: var(--bg-card);
    border-radius: 16px;
    border: 1px solid var(--border);
    overflow: hidden;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    background: rgba(0, 0, 0, 0.2);
    padding: 1rem 1.5rem;
    text-align: left;
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    color: var(--text-secondary);
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* --- Responsive --- */

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }

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

    .main-wrapper {
        margin-left: 0;
    }

    .topbar {
        left: 0;
    }

    .split-grid,
    .grid-2 {
        grid-template-columns: minmax(0, 1fr);
    }

    .page-intro,
    .hero-content,
    .header-actions {
        flex-direction: column;
        align-items: stretch;
    }
}

@media (max-width: 768px) {
    .main-content {
        padding: calc(70px + 1.5rem) 1rem 1.5rem;
    }

    .topbar {
        padding: 0 1rem;
    }

    .topbar-right {
        gap: 0.75rem;
    }

    .quick-search {
        width: 100%;
    }

    .user-profile {
        border-left: none;
        padding-left: 0;
    }

    th,
    td {
        padding: 0.95rem 1rem;
    }
}



/* --- Admin page CSS migrated from PHP templates --- */

/* Source: admin\bots.php */
.bot-grid {
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
}

.bot-card {
    padding: 0;
    display: flex;
    flex-direction: column;
}

.bot-card:hover {
    border-color: var(--border-bright);
}

.bot-card-body {
    padding: 1.5rem;
    flex: 1;
}

.bot-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.bot-avatar-wrapper {
    width: 64px;
    height: 64px;
    background: var(--bg-input);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--border);
    overflow: hidden;
}

.bot-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.bot-avatar-emoji {
    font-size: 1.75rem;
}

.bot-avatar-img + .bot-avatar-emoji,
.avatar-preview-img + .bot-avatar-emoji {
    display: none;
}

.bot-card-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 8px;
}

.bot-card-description {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

.bot-meta {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.bot-actions {
    background: rgba(0, 0, 0, 0.2);
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
}

.bot-action-main {
    flex: 1;
}

.bot-action-icon {
    width: 40px;
}

.status-indicator {
    font-size: 0.65rem;
    font-weight: 800;
    padding: 4px 10px;
    border-radius: 99px;
    letter-spacing: 0.05em;
}

.status-indicator.active {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-indicator.inactive {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.dropdown-container {
    position: relative;
}

.dropdown-content {
    display: none;
    position: absolute;
    bottom: 100%;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    min-width: 160px;
    z-index: 30;
    margin-bottom: 8px;
    box-shadow: var(--shadow-main);
}

.dropdown-container.is-open .dropdown-content {
    display: block;
}

.dropdown-content a {
    display: block;
    padding: 10px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
}

.dropdown-content a:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.embed-modal {
    max-width: 600px;
    padding: 2.5rem;
}

.embed-box {
    position: relative;
}

.embed-textarea {
    height: 150px;
    font-family: 'Fira Code', monospace;
    font-size: 0.8rem;
    background: #000;
    border-color: var(--primary);
    resize: none;
}

.embed-copy {
    position: absolute;
    right: 10px;
    bottom: 10px;
}

@media (max-width: 768px) {
    .bot-actions {
        flex-wrap: wrap;
    }

    .bot-action-main {
        width: 100%;
        flex: none;
    }
}

/* Source: admin\waha_connect.php */
.waha-connect-grid { display:grid; grid-template-columns:minmax(0, 1.25fr) minmax(280px, .75fr); gap:20px; align-items:start; }
    .waha-status-card { border:1px solid rgba(37, 211, 102, .28); background:rgba(37, 211, 102, .05); }
    .waha-status-line { display:flex; gap:12px; align-items:center; padding:14px; border-radius:12px; background:rgba(0,0,0,.18); border:1px solid var(--border); }
    .waha-status-dot { width:12px; height:12px; border-radius:50%; background:var(--warning); box-shadow:0 0 0 5px rgba(245, 158, 11, .12); flex:0 0 auto; }
    .waha-status-dot.working { background:var(--success); box-shadow:0 0 0 5px rgba(34, 197, 94, .12); }
    .waha-status-dot.failed { background:var(--danger); box-shadow:0 0 0 5px rgba(239, 68, 68, .12); }
    .waha-qr-wrap { display:none; margin-top:18px; padding:18px; border-radius:14px; text-align:center; background:#fff; }
    .waha-qr-wrap.visible { display:block; }
    .waha-qr-wrap img { display:block; width:min(100%, 280px); margin:0 auto; image-rendering:auto; }
    .waha-qr-caption { margin:12px 0 0; color:#4b5563; font-size:.84rem; line-height:1.45; }
    .waha-info-list { display:grid; gap:12px; margin:0; }
    .waha-info-list div { padding:12px; border:1px solid var(--border); border-radius:10px; background:rgba(0,0,0,.16); }
    .waha-info-list dt { color:var(--text-muted); font-size:.72rem; text-transform:uppercase; letter-spacing:.06em; }
    .waha-info-list dd { margin:5px 0 0; color:var(--text-primary); overflow-wrap:anywhere; }
    .waha-actions { display:flex; gap:10px; flex-wrap:wrap; margin-top:20px; }
    @media (max-width: 900px) { .waha-connect-grid { grid-template-columns:1fr; } }

/* Source: admin\leads.php */
.whatsapp-action {
    color: #25D366;
}

/* Source: admin\conversation_history.php */
.conversation-avatar {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text-muted);
}

/* Source: admin\bot_edit.php */
/* Premium Edit Layout */
    .edit-container {
        display: grid;
        grid-template-columns: 280px 1fr;
        gap: 2.5rem;
        align-items: start;
    }
    
    /* Navigation Sidebar */
    .settings-nav {
        background: var(--bg-card);
        border: 1px solid var(--border);
        border-radius: 16px;
        overflow: hidden;
        position: sticky;
        top: 90px;
        box-shadow: var(--shadow-main);
    }
    
    .nav-item {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 16px 20px;
        cursor: pointer;
        color: var(--text-secondary);
        transition: var(--transition);
        border-right: 3px solid transparent;
        font-weight: 600;
        font-size: 0.9rem;
    }
    
    .nav-item:hover {
        background: rgba(255, 255, 255, 0.03);
        color: #fff;
    }
    
    .nav-item.active {
        background: rgba(var(--primary-rgb), 0.1);
        color: var(--primary);
        border-right-color: var(--primary);
    }
    
    .nav-item i { width: 20px; text-align: center; }

    /* Content Area */
    .settings-content {
        display: flex;
        flex-direction: column;
        gap: 24px;
    }
    
    .settings-section {
        display: none;
        animation: sectionFadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    }
    
    .settings-section.active {
        display: block;
    }
    
    @keyframes sectionFadeIn {
        from { opacity: 0; transform: translateY(15px); }
        to { opacity: 1; transform: translateY(0); }
    }

    /* Modern Forms */
    .form-section-title {
        font-size: 1.25rem;
        font-weight: 600;
        color: var(--text-primary);
        margin-bottom: 1.5rem;
        display: flex;
        align-items: center;
        gap: 10px;
        padding-bottom: 10px;
        border-bottom: 1px solid var(--border);
    }
    
    .avatar-upload-box {
        display: flex;
        align-items: center;
        gap: 2rem;
        padding: 2rem;
        background: rgba(0,0,0,0.2);
        border-radius: 12px;
        border: 1px dashed var(--border);
    }
    
    .avatar-preview {
        width: 100px;
        height: 100px;
        border-radius: 50%;
        background: var(--bg-dark);
        border: 3px solid var(--border);
        overflow: hidden;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 2.5rem;
    }
    
    .toggle-switch-wrapper {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 1rem;
        background: rgba(var(--primary-rgb), 0.05);
        border: 1px solid rgba(var(--primary-rgb), 0.2);
        border-radius: 8px;
        margin-bottom: 1.5rem;
    }

    .publish-mode-box {
        margin-bottom: 24px;
        padding: 18px;
        border: 1px solid rgba(var(--primary-rgb), 0.28);
        border-radius: 14px;
        background: rgba(var(--primary-rgb), 0.05);
    }

    .publish-mode-heading {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 14px;
        margin-bottom: 14px;
    }

    .publish-mode-heading strong {
        color: var(--text-primary);
    }

    .publish-mode-heading p {
        margin: 4px 0 0;
        color: var(--text-muted);
        font-size: 0.84rem;
    }

    .publish-mode-grid {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .publish-mode-option {
        position: relative;
        display: grid;
        grid-template-columns: 42px minmax(0, 1fr);
        gap: 11px;
        align-items: center;
        padding: 13px;
        border: 1px solid var(--border);
        border-radius: 11px;
        background: rgba(0, 0, 0, 0.2);
        cursor: pointer;
    }

    .publish-mode-option:has(input:checked) {
        border-color: var(--primary);
        background: rgba(var(--primary-rgb), 0.1);
    }

    .publish-mode-option input {
        position: absolute;
        opacity: 0;
        pointer-events: none;
    }

    .publish-mode-icon {
        width: 42px;
        height: 42px;
        display: grid;
        place-items: center;
        border-radius: 10px;
        background: rgba(255, 255, 255, 0.06);
        color: var(--text-muted);
    }

    .publish-mode-option:has(input:checked) .publish-mode-icon {
        background: var(--primary);
        color: #111;
    }

    .publish-mode-option strong,
    .publish-mode-option small {
        display: block;
    }

    .publish-mode-option strong {
        color: var(--text-primary);
        font-size: 0.92rem;
    }

    .publish-mode-option small {
        margin-top: 3px;
        color: var(--text-muted);
        font-size: 0.78rem;
        line-height: 1.35;
    }

    #flow-settings-container[hidden] {
        display: none;
    }

    .knowledge-intro {
        margin: -2px 0 14px;
        color: var(--text-muted);
        font-size: 0.86rem;
        line-height: 1.45;
    }

    .knowledge-grid {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }

    .knowledge-field {
        display: block;
        padding: 13px;
        border: 1px solid var(--border);
        border-radius: 11px;
        background: rgba(0, 0, 0, 0.18);
    }

    .knowledge-field > span {
        display: flex;
        align-items: center;
        gap: 7px;
        color: var(--text-primary);
        font-size: 0.88rem;
        font-weight: 700;
    }

    .knowledge-field > span i {
        color: var(--primary);
    }

    .knowledge-field > small {
        display: block;
        min-height: 34px;
        margin: 5px 0 8px;
        color: var(--text-muted);
        font-size: 0.76rem;
        line-height: 1.35;
    }

    .knowledge-field textarea {
        min-height: 122px;
        resize: vertical;
    }

    .knowledge-footer {
        display: flex;
        justify-content: space-between;
        gap: 10px;
        margin-top: 10px;
        color: var(--text-muted);
        font-size: 0.76rem;
    }

    .setup-kicker {
        font-size: .75rem;
        text-transform: uppercase;
        letter-spacing: .08em;
        color: var(--primary);
        font-weight: 800;
    }

.simple-create-guide {
        border: 1px solid var(--border);
        background: var(--bg-card);
        border-radius: 12px;
        padding: 1.25rem;
        margin-bottom: 1.5rem;
    }

    .simple-create-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
        gap: 12px;
        margin-top: 1rem;
    }

    .simple-create-card {
        border: 1px solid var(--border);
        border-radius: 14px;
        padding: 14px;
        background: rgba(0,0,0,0.22);
        display: flex;
        flex-direction: column;
        gap: 10px;
        min-height: 158px;
    }

    .simple-create-card strong,
    .simple-create-card p {
        margin: 0;
    }

    .simple-create-card strong {
        color: #fff;
        font-size: .95rem;
    }

    .simple-create-card p {
        color: var(--text-muted);
        font-size: .84rem;
        line-height: 1.45;
    }

    .simple-create-guide .step-index {
        display: inline-flex;
        width: 28px;
        height: 28px;
        border-radius: 999px;
        align-items: center;
        justify-content: center;
        background: rgba(var(--primary-rgb), 0.15);
        color: var(--primary);
        font-weight: 800;
        font-size: 0.8rem;
    }

.modal-overlay.is-open {
    display: flex;
}

.presence-online { color: #22c55e; }
.presence-busy { color: #f59e0b; }
.presence-away { color: #f59e0b; }
.presence-offline { color: #6b7280; }

.color-picker-wrapper {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 8px;
        background: var(--bg-input);
        border: 1px solid var(--border);
        border-radius: 8px;
    }
    
    .color-picker-wrapper input[type="color"] {
        width: 40px;
        height: 40px;
        border: none;
        background: none;
        cursor: pointer;
        padding: 0;
    }

    .whatsapp-status-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
        gap: 10px;
        margin: 16px 0;
    }

    .whatsapp-provider-stack {
        display: flex;
        flex-direction: column;
        gap: 18px;
        margin-top: 24px;
    }

    .whatsapp-provider-card {
        border: 1px solid rgba(37, 211, 102, 0.15);
        padding: 18px;
        border-radius: 14px;
        background: rgba(37, 211, 102, 0.03);
    }

    .whatsapp-provider-card.active-provider {
        border-color: rgba(37, 211, 102, 0.35);
        box-shadow: inset 0 0 0 1px rgba(37, 211, 102, 0.14);
    }

    .whatsapp-provider-head {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 12px;
        flex-wrap: wrap;
        margin-bottom: 14px;
    }

    .whatsapp-provider-head h5 {
        margin: 0;
        color: #25D366;
        display: flex;
        align-items: center;
        gap: 10px;
    }

    .whatsapp-provider-head p {
        margin: 6px 0 0;
        color: var(--text-muted);
        font-size: 0.83rem;
        line-height: 1.45;
        max-width: 760px;
    }

    .whatsapp-provider-badges {
        display: flex;
        gap: 8px;
        align-items: center;
        flex-wrap: wrap;
    }

    .channel-toggle {
        margin-bottom: 14px;
        padding: 12px 14px;
        border-radius: 12px;
        border: 1px solid var(--border);
        background: rgba(0, 0, 0, 0.16);
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 12px;
        flex-wrap: wrap;
    }

    .channel-toggle label {
        margin: 0;
        display: flex;
        gap: 10px;
        align-items: flex-start;
        color: #fff;
        flex: 1;
    }

    .channel-toggle label input {
        width: 18px;
        height: 18px;
        margin-top: 2px;
        flex: 0 0 auto;
    }

    .channel-toggle-title {
        display: block;
        color: #fff;
        font-size: 0.92rem;
        font-weight: 700;
    }

    .channel-toggle-note {
        display: block;
        margin-top: 4px;
        color: var(--text-muted);
        font-size: 0.78rem;
        line-height: 1.4;
    }

    .whatsapp-field-note {
        display: block;
        margin-top: 6px;
        color: var(--text-muted);
        font-size: 0.76rem;
        line-height: 1.4;
    }

    .meta-pill {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        padding: 5px 10px;
        border-radius: 99px;
        background: rgba(255,255,255,0.05);
        color: var(--text-secondary);
        font-size: 0.75rem;
    }

    .whatsapp-status-item {
        border: 1px solid var(--border);
        border-radius: 12px;
        padding: 10px 12px;
        background: rgba(0,0,0,0.18);
        display: flex;
        gap: 10px;
        align-items: flex-start;
    }

    .whatsapp-status-item i {
        margin-top: 2px;
        color: var(--danger);
    }

    .whatsapp-status-item.done {
        border-color: rgba(34,197,94,.35);
        background: rgba(34,197,94,.08);
    }

    .whatsapp-status-item.done i {
        color: var(--success);
    }

    .whatsapp-copy-box {
        margin-top: 16px;
        padding: 14px;
        border-radius: 10px;
        background: rgba(0,0,0,0.22);
        border: 1px solid var(--border);
        display: flex;
        gap: 12px;
        align-items: center;
        justify-content: space-between;
        flex-wrap: wrap;
    }

    .whatsapp-copy-box code {
        color: var(--primary);
        word-break: break-all;
        flex: 1;
        min-width: min(100%, 260px);
    }

    @media (max-width: 900px) {
        .edit-container { grid-template-columns: 1fr; }
        .settings-nav { display: flex; overflow-x: auto; position: static; margin-bottom: 20px; }
        .nav-item { white-space: nowrap; border-left: none; border-bottom: 3px solid transparent; }
        .nav-item.active { border-left: none; border-bottom-color: var(--primary); }
        .publish-mode-grid,
        .knowledge-grid { grid-template-columns: 1fr; }
        .channel-toggle { flex-direction: column; }
    }

/* --- Minimal product direction --- */

:root {
    --bg-main: #0c0d0f;
    --bg-sidebar: #08090a;
    --bg-card: #141518;
    --bg-input: #1b1c20;
    --border: rgba(255, 255, 255, 0.085);
    --border-bright: rgba(255, 255, 255, 0.16);
    --text-primary: #f7f7f5;
    --text-secondary: #a9adb5;
    --text-muted: #717680;
    --shadow-main: none;
    --transition: all 0.16s ease;
}

body {
    background: var(--bg-main);
}

.main-content {
    padding: calc(70px + 2rem) 2rem 2rem;
}





.header-actions {
    margin-bottom: 1.5rem;
}

.page-header h1 {
    font-size: clamp(1.7rem, 2.4vw, 2.4rem);
}

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

.nav-section {
    margin-bottom: 1.25rem;
}

.nav-section-title {
    margin-bottom: 0.4rem;
    letter-spacing: 0.08em;
}

.nav-links a,
.nav-item {
    border-radius: 8px;
}

.nav-links a.active,
.nav-item.active {
    background: rgba(var(--primary-rgb), 0.065);
}

.btn {
    min-height: 38px;
    padding: 9px 15px;
    border-radius: 9px;
    font-size: 0.86rem;
    font-weight: 650;
}

.btn-primary {
    border-color: rgba(var(--primary-rgb), 0.55);
}

.btn-secondary,
.btn-icon,
.btn-danger {
    background: transparent;
}

.btn-secondary:hover,
.btn-icon:hover {
    background: rgba(255, 255, 255, 0.045);
    color: #fff;
}

input,
textarea,
select {
    border-radius: 9px;
    background: var(--bg-input);
}

input:focus,
textarea:focus,
select:focus {
    box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.09);
}

.card-header,
.bot-card-header,
.form-section-title {
    margin-bottom: 1.1rem;
}

.form-section-title {
    padding-bottom: 0.75rem;
}




.meta-pill,
.status-indicator,
.badge {
    border-radius: 999px;
    background: transparent;
    border: 1px solid var(--border);
}

.stat-icon,
.publish-mode-icon,
.logo-icon {
    box-shadow: none;
}

.surface-box,
.surface-box-dark,
.surface-box-primary,
.surface-box-success,
.notice-row,
.advanced-box,
.channel-callout,
.whatsapp-copy-box {
    background: rgba(255, 255, 255, 0.018);
}

table {
    border-collapse: collapse;
}

th,
td {
    border-bottom: 1px solid var(--border);
}

tr:hover td {
    background: transparent;
}

/* --- CSS migrated from admin\inbox.php --- */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
.inbox-shell {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: .75rem;
    align-items: start;
    --thread-viewport-height: clamp(540px, calc(100vh - 156px), 900px);
}
.inbox-column {
    min-width: 0;
}
.queue-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: var(--shadow-main);
    display: flex;
    flex-direction: column;
    height: var(--thread-viewport-height);
}
.queue-header {
    padding: 1rem 1.1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .75rem;
}
.queue-list {
    flex: 1;
    min-height: 0;
    max-height: none;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    scrollbar-gutter: stable;
}
.queue-item {
    position: relative;
    display: block;
    padding: .68rem .8rem;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    text-decoration: none;
    color: inherit;
    transition: background .18s ease, border-color .18s ease;
    min-width: 0;
}
.queue-item[hidden] {
    display: none !important;
}
.queue-item:hover, .queue-item.active {
    background: rgba(var(--primary-rgb), 0.08);
}
.queue-item.active {
    box-shadow: inset 3px 0 0 var(--primary);
}
.queue-unread {
    display: none;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 99px;
    align-items: center;
    justify-content: center;
    background: #2455a4;
    color: #fff;
    font-size: .68rem;
    font-weight: 800;
}
.queue-item.has-unread .queue-unread { display: inline-flex; }
.thread-card {
    background: linear-gradient(180deg, rgba(17,17,18,0.96), rgba(10,10,11,0.98));
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: var(--shadow-main);
    display: flex;
    flex-direction: column;
    position: relative;
    height: var(--thread-viewport-height);
    min-height: 480px;
    overflow: hidden;
}
.thread-top {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
}
.thread-body {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 1rem 1.1rem;
    display: block;
    background:
        radial-gradient(circle at top left, rgba(var(--primary-rgb),0.06), transparent 28%),
        radial-gradient(circle at bottom right, rgba(var(--primary-rgb),0.035), transparent 26%);
    overscroll-behavior-y: contain;
    scrollbar-gutter: stable;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    overflow-anchor: none;
}
.message-stack {
    min-height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: .6rem;
}
.bubble,
.date-separator {
    overflow-anchor: none;
}
#emptyThread {
    margin: auto;
}
.thread-end-anchor {
    width: 1px;
    height: 1px;
    flex: 0 0 1px;
    overflow-anchor: none;
}
.thread-body::-webkit-scrollbar,
.queue-list::-webkit-scrollbar { width: 11px; }
.thread-body::-webkit-scrollbar-track,
.queue-list::-webkit-scrollbar-track { background: rgba(255,255,255,.015); }
.thread-body::-webkit-scrollbar-thumb,
.queue-list::-webkit-scrollbar-thumb {
    border: 3px solid transparent;
    border-radius: 99px;
    background: rgba(255,255,255,.2);
    background-clip: padding-box;
}
.thread-body::-webkit-scrollbar-thumb:hover,
.queue-list::-webkit-scrollbar-thumb:hover { background-color: rgba(var(--primary-rgb), .55); }
.thread-body, .queue-list { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.22) transparent; }
.bubble {
    inline-size: fit-content;
    max-width: min(64%, 560px);
    height: auto !important;
    min-height: 0 !important;
    padding: .55rem .7rem .5rem;
    border-radius: 16px;
    line-height: 1.35;
    font-size: .9rem;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    flex: 0 0 auto;
    text-align: left;
    animation: bubble-in .22s ease both;
}
.message-content {
    display: block;
    line-height: 1.35;
    white-space: pre-wrap;
    text-align: left;
}
.bubble.incoming {
    align-self: flex-start;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border);
    color: #fff;
    border-bottom-left-radius: 6px;
}
.bubble.bot {
    align-self: flex-start;
    background: rgba(var(--primary-rgb), .1);
    border: 1px solid rgba(var(--primary-rgb), .28);
    color: var(--text-primary);
    border-bottom-left-radius: 6px;
}
.bubble.outgoing {
    align-self: flex-end;
    background: linear-gradient(145deg, var(--primary), #f5a900);
    color: #111;
    border-bottom-right-radius: 6px;
    box-shadow: 0 8px 24px rgba(var(--primary-rgb), .12);
}
.bubble.notice {
    align-self: center;
    max-width: min(88%, 680px);
    padding: .5rem .7rem;
    border: 1px dashed rgba(255,255,255,.14);
    border-radius: 12px;
    background: rgba(255,255,255,.025);
    color: var(--text-muted);
    font-size: .8rem;
}
.bubble.notice .message-meta { justify-content: center; }
.date-separator {
    align-self: center;
    padding: 4px 9px;
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 99px;
    background: rgba(12,12,13,.82);
    color: var(--text-muted);
    font-size: .65rem;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
}
.bubble.pending { opacity: .62; }
.bubble.failed {
    border-color: rgba(239,68,68,.55);
    background: rgba(239,68,68,.08);
}
.message-meta {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: .65rem;
    opacity: .65;
    margin-top: .35rem;
    line-height: 1.2;
    text-transform: uppercase;
    letter-spacing: .07em;
}
.thread-body .bubble {
    display: grid !important;
    grid-template-rows: max-content max-content;
    gap: 5px;
    height: fit-content !important;
    min-height: 0 !important;
    justify-content: flex-start !important;
    align-content: start !important;
    box-sizing: border-box;
}
.thread-body .bubble .message-content {
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
}
.thread-body .bubble .message-meta {
    margin: 0 !important;
    min-height: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}
.delivery-status.is-read { color: var(--success); opacity: 1; }
.delivery-status.is-failed { color: #f87171; opacity: 1; }
.sync-state {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--text-muted);
    font-size: .74rem;
}
.sync-state::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 10px rgba(16,185,129,.55);
}
.sync-state.loading::before { background: var(--primary); animation: sync-pulse 1s infinite; }
.sync-state.offline::before { background: var(--danger); box-shadow: none; }
.new-messages-button {
    position: absolute;
    right: 24px;
    bottom: calc(var(--composer-height, 132px) + 16px);
    z-index: 8;
    display: none;
    border: 1px solid rgba(var(--primary-rgb), .4);
    border-radius: 99px;
    padding: 9px 14px;
    background: #171717;
    color: var(--primary);
    box-shadow: 0 12px 30px rgba(0,0,0,.35);
    cursor: pointer;
}
.new-messages-button.visible { display: inline-flex; align-items: center; gap: 8px; }
.composer {
    border-top: 1px solid var(--border);
    padding: .45rem 1rem;
    background: rgba(12,12,13,.98);
    flex: 0 0 auto;
}
.composer-feedback { margin-top: .45rem; padding: .5rem .7rem; border: 1px solid var(--border); border-radius: 9px; font-size: .75rem; line-height: 1.35; }
.composer-feedback[hidden] { display: none; }
.composer-feedback.success { border-color: var(--success); color: var(--success); }
.composer-feedback.error { border-color: var(--danger); color: var(--danger); }
.inbox-toast-stack {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 1300;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}
.inbox-toast {
    min-width: 260px;
    max-width: 420px;
    padding: 12px 15px;
    border: 1px solid var(--border);
    border-left: 4px solid var(--success);
    border-radius: 13px;
    background: #18181a;
    color: #fff;
    box-shadow: 0 18px 50px rgba(0,0,0,.42);
    animation: toast-in .22s ease both;
}
.inbox-toast.error { border-left-color: var(--danger); }
.mobile-thread-back { display: none; }
@keyframes bubble-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }
@keyframes sync-pulse { 50% { opacity: .3; transform: scale(.8); } }
@keyframes thread-reveal-fallback { to { opacity: 1; } }
.side-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: var(--shadow-main);
    padding: 1.1rem;
    height: 100%;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    box-sizing: border-box;
}
.contact-avatar {
    width: 56px;
    height: 56px;
    border-radius: 18px;
    display:flex;
    align-items:center;
    justify-content:center;
    background: rgba(var(--primary-rgb), 0.12);
    color: var(--primary);
    font-weight: 800;
}
.meta-pill {
    display:inline-flex;
    align-items:center;
    gap:6px;
    padding: 5px 10px;
    border-radius: 99px;
    background: rgba(255,255,255,0.05);
    color: var(--text-secondary);
    font-size: 0.75rem;
    margin: 0 6px 6px 0;
}
.action-row {
    display:flex;
    gap:8px;
    flex-wrap:wrap;
}
.btn-icon {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.04);
    color: var(--text-secondary);
    display:flex;
    align-items:center;
    justify-content:center;
    text-decoration:none;
    transition: var(--transition);
}
.btn-icon:hover {
    transform: translateY(-1px);
    border-color: var(--primary);
    color: #000;
    background: var(--primary);
}
.inbox-command-bar {
    min-height: 34px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .8rem;
    margin-bottom: .65rem;
}
.inbox-summary {
    display: flex;
    align-items: center;
    gap: .45rem;
    color: var(--text-muted);
    font-size: .76rem;
    line-height: 1;
    white-space: nowrap;
}
.inbox-summary strong { color: var(--text-primary); }
.inbox-summary-alert { color: var(--danger); font-weight: 700; }
.inbox-command-bar,
.inbox-shell,
.inbox-command-bar button,
.inbox-shell button,
.inbox-shell input,
.inbox-shell select,
.inbox-shell textarea,
.inbox-shell h1,
.inbox-shell h2,
.inbox-shell h3,
.inbox-shell h4 {
    font-family: 'Inter', system-ui, sans-serif;
}
.inbox-filter-bar {
    display: flex;
    align-items: center;
    gap: .4rem;
    flex-wrap: nowrap !important;
    overflow-x: auto;
    scrollbar-width: none;
    margin-bottom: 0 !important;
    padding: 0;
}
.inbox-filter-bar::-webkit-scrollbar { display: none; }
.inbox-filter {
    flex: 0 0 auto;
    white-space: nowrap;
    border-radius: 999px !important;
    padding: .38rem .7rem;
    font-size: .76rem;
}
.inbox-filter.active {
    border-color: var(--primary);
    background: var(--primary);
    color: #111;
}
.queue-header { padding: .55rem .8rem; }
.queue-header-copy { min-width: 0; }
.queue-header-copy .card-title { font-size: .94rem; line-height: 1.15; }
.queue-header-copy .text-muted { margin: .1rem 0 0; font-size: .66rem; }
.queue-header .btn-icon { width: 32px; height: 32px; border-radius: 10px; }
.queue-tools {
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--border);
    display: grid;
    gap: .65rem;
}
.queue-selects { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.queue-selects .form-control { min-width: 0; font-size: .78rem; }
.queue-item-head,
.queue-item-foot,
.queue-item-timewrap,
.thread-identity,
.thread-identity-copy,
.details-header {
    display: flex;
    align-items: center;
}
.queue-item-head { justify-content: space-between; gap: 8px; margin-bottom: 3px; }
.queue-item-name { color: #fff; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .88rem; line-height: 1.2; }
.queue-item-timewrap { gap: 6px; flex: 0 0 auto; }
.queue-item-age { color: var(--text-muted); font-size: .64rem; }
.queue-item-overdue .queue-item-age { color: var(--danger); }
.queue-item-phone {
    color: var(--text-muted);
    font-size: .66rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.queue-item-preview {
    margin-top: .36rem;
    color: var(--text-secondary);
    font-size: .72rem;
    line-height: 1.28;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.queue-item-foot { justify-content: space-between; gap: 8px; margin-top: .65rem; }
.queue-item-context {
    min-width: 0;
    color: var(--text-muted);
    font-size: .7rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.queue-state {
    flex: 0 0 auto;
    padding: 3px 7px;
    border-radius: 99px;
    background: rgba(var(--primary-rgb), .09);
    color: var(--primary);
    font-size: .62rem;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
}
.queue-state.is-danger { background: rgba(239,68,68,.1); color: var(--danger); }
.thread-top { padding: .45rem .75rem; gap: .75rem; }
.thread-identity { min-width: 0; gap: .55rem; }
.thread-identity-copy { min-width: 0; align-items: flex-start; flex-direction: column; }
.thread-avatar {
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    border-radius: 11px;
    display: grid;
    place-items: center;
    background: rgba(var(--primary-rgb), .12);
    color: var(--primary);
    font-weight: 900;
}
.thread-name { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .98rem; line-height: 1.1; }
.thread-subtitle { font-size: .7rem; color: var(--text-muted); margin-top: 1px; line-height: 1.15; }
.thread-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 2px; }
.thread-tags .meta-pill { margin: 0; padding: 2px 6px; font-size: .6rem; line-height: 1.15; }
.thread-top .btn-icon { width: 34px; height: 34px; border-radius: 10px; }
.thread-top .btn.btn-sm { min-height: 34px; padding: 6px 10px; font-size: .75rem; }
.action-row { align-items: center; flex-wrap: nowrap; gap: 6px; }
.action-row form { margin: 0; }
.thread-actions-menu { position: relative; }
.thread-actions-menu > summary { list-style: none; cursor: pointer; }
.thread-actions-menu > summary::-webkit-details-marker { display: none; }
.thread-actions-popover {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 30;
    width: 210px;
    padding: 8px;
    display: grid;
    gap: 6px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #171719;
    box-shadow: 0 20px 50px rgba(0,0,0,.45);
}
.thread-actions-popover .btn { width: 100%; justify-content: flex-start; }
html.theme-light .thread-actions-popover {
    background: #ffffff;
    border-color: rgba(31, 29, 23, 0.14);
    box-shadow: 0 14px 30px rgba(31, 29, 23, 0.16);
}
html.theme-light .thread-actions-popover .btn {
    color: var(--text-primary);
    background: transparent;
}
html.theme-light .thread-actions-popover .btn:hover {
    background: #fff6d9;
    color: #17130a;
}
.details-column {
    position: fixed;
    top: 78px;
    right: 18px;
    bottom: 18px;
    z-index: 1200;
    width: min(390px, calc(100vw - 24px));
    transform: translateX(calc(100% + 32px));
    opacity: 0;
    pointer-events: none;
    transition: transform .24s ease, opacity .2s ease;
}
body.inbox-details-open .details-column {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
}
.details-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1190;
    border: 0;
    background: rgba(0,0,0,.48);
    backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
}
body.inbox-details-open .details-backdrop { opacity: 1; pointer-events: auto; }
.details-header { justify-content: space-between; gap: 10px; margin-bottom: 1rem; }
.details-close { flex: 0 0 auto; }
@media (max-width: 1380px) {
    .inbox-shell { grid-template-columns: 300px minmax(0, 1fr); }
}
@media (max-width: 900px) {
    .inbox-shell { grid-template-columns: 1fr; }
    .queue-card, .thread-card { min-height: 360px; }
    .thread-top { align-items: center; flex-direction: row; }
    .thread-top .action-row { width: auto; overflow: visible; padding-bottom: 0; }
    .thread-top .action-row form { flex: 0 0 auto; }
    .mobile-thread-back { display: inline-flex; }
    body.inbox-thread-open .queue-column { display: none; }
    body.inbox-thread-open .inbox-command-bar { display: none !important; }
    .thread-avatar, .thread-tags, .action-label, .sync-state { display: none; }
    .thread-name { max-width: 42vw; font-size: .95rem; }
    .thread-subtitle { max-width: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .details-column { top: 68px; right: 8px; bottom: 8px; width: calc(100vw - 16px); }
    .composer { padding: .8rem; }
    .thread-body { padding: .9rem; }
    .bubble { max-width: 88%; }
}

/* --- CSS migrated from admin\simulator.php --- */
.simulator-layout {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 24px;
    height: calc(100vh - 140px);
    min-height: 620px;
}

.sim-controls {
    align-self: start;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px;
}

.control-group + .control-group {
    margin-top: 22px;
}

.control-label {
    display: block;
    margin-bottom: 9px;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.bot-select {
    width: 100%;
    padding: 12px;
    background: var(--bg-body);
    border: 1px solid var(--border);
    border-radius: 9px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.95rem;
    outline: none;
}

.bot-select:focus {
    border-color: var(--primary);
}

.mode-options {
    display: grid;
    gap: 9px;
}

.mode-option {
    position: relative;
    display: grid;
    grid-template-columns: 38px 1fr;
    gap: 11px;
    align-items: center;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--bg-body);
    cursor: pointer;
    transition: border-color 0.18s, background 0.18s;
}

.mode-option:has(input:checked) {
    border-color: var(--primary);
    background: rgba(255, 193, 7, 0.08);
}

.mode-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.mode-icon {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-muted);
}

.mode-option:has(input:checked) .mode-icon {
    background: var(--primary);
    color: #111;
}

.mode-copy strong,
.mode-copy small {
    display: block;
}

.mode-copy strong {
    margin-bottom: 3px;
    color: var(--text-primary);
    font-size: 0.92rem;
}

.mode-copy small {
    color: var(--text-muted);
    font-size: 0.78rem;
    line-height: 1.35;
}

.simulator-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 9px;
    margin-top: 22px;
}

.btn-action {
    min-height: 42px;
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.86rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    text-decoration: none;
    transition: background 0.18s, color 0.18s;
}

.btn-action:hover,
.btn-action:focus,
.btn-action:focus-visible {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    text-decoration: none;
}

.btn-action.primary {
    border-color: var(--primary);
    background: var(--primary);
    color: #111;
    font-weight: 700;
}

.preview-stage {
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px;
    border: 1px dashed var(--border);
    border-radius: 20px;
    background: rgba(0, 0, 0, 0.18);
}

.device-wrapper {
    position: relative;
    width: min(430px, 100%);
    height: 100%;
    max-height: 780px;
    overflow: hidden;
    border: 7px solid #343434;
    border-radius: 36px;
    background: #111;
    box-shadow: 0 24px 50px rgba(0, 0, 0, 0.42);
}

.device-notch {
    position: absolute;
    top: 0;
    left: 50%;
    z-index: 2;
    width: 112px;
    height: 21px;
    border-radius: 0 0 12px 12px;
    background: #343434;
    transform: translateX(-50%);
}

.chat-frame {
    width: 100%;
    height: 100%;
    border: 0;
    background: #121315;
}

@media (max-width: 900px) {
    .simulator-layout {
        grid-template-columns: 1fr;
        height: auto;
    }

    .sim-controls {
        width: 100%;
    }

    .preview-stage {
        min-height: 680px;
    }

    .device-wrapper {
        height: 650px;
    }
}

/* --- CSS migrated from admin\settings.php --- */
.settings-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 2rem;
    align-items: start;
}

.settings-nav {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}

.settings-nav-item {
    padding: 15px 20px;
    cursor: pointer;
    color: var(--text-secondary);
    border-left: 3px solid transparent;
    transition: var(--transition);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
}

.settings-nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.settings-nav-item.active {
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary);
    border-left-color: var(--primary);
}

.settings-panel {
    display: none;
    animation: fadeIn 0.3s ease;
}

.settings-panel.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Laboratório: teste claro, sem área vazia ou moldura excessiva --- */
.laboratory-intro {
    align-items: center;
}

.simulator-layout {
    grid-template-columns: minmax(290px, 340px) minmax(0, 680px);
    align-items: start;
    height: auto;
    min-height: 0;
    gap: var(--space-5);
    max-width: 1040px;
}

.sim-controls,
.preview-stage {
    border-radius: var(--radius-md);
    box-shadow: none;
}

.sim-controls {
    padding: var(--space-5);
}

.sim-controls-head {
    padding-bottom: var(--space-4);
    margin-bottom: var(--space-4);
    border-bottom: 1px solid var(--border);
}

.sim-controls-head h2,
.preview-stage-head h2 {
    margin: 0;
    color: var(--text-primary);
    font-size: var(--title-md);
    font-weight: 720;
    line-height: 1.25;
}

.sim-controls-head p {
    margin: var(--space-1) 0 0;
    color: var(--text-secondary);
    font-size: var(--copy-sm);
}

.control-group + .control-group {
    margin-top: var(--space-5);
}

.mode-option {
    padding: var(--space-3);
    border-radius: var(--radius-sm);
}

.mode-icon {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
}

.simulator-actions {
    margin-top: var(--space-5);
}

.preview-stage {
    display: flex;
    flex-direction: column;
    min-height: 650px;
    padding: var(--space-5);
    border: 1px solid var(--border);
    background: var(--bg-card);
}

.preview-stage-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--border);
}

.preview-kicker {
    display: block;
    margin-bottom: var(--space-1);
    color: var(--text-muted);
    font-size: var(--copy-xs);
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.preview-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    color: var(--text-secondary);
    font-size: var(--copy-xs);
    font-weight: 700;
}

.preview-status.is-ready { color: var(--success); }
.preview-status.is-warning { color: var(--warning); }

.simulator-notice {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
    margin-top: var(--space-4);
    padding: var(--space-3) var(--space-4);
    border: 1px solid rgba(245, 158, 11, .28);
    border-radius: var(--radius-sm);
    background: rgba(245, 158, 11, .07);
    color: var(--text-secondary);
    font-size: var(--copy-sm);
    line-height: 1.45;
}

.simulator-notice i { color: var(--warning); margin-top: .15rem; }

.preview-canvas {
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: center;
    min-height: 540px;
    padding: var(--space-5) 0 0;
}

.device-wrapper {
    width: min(390px, 100%);
    height: 560px;
    max-height: none;
    border-width: 5px;
    border-radius: 28px;
    box-shadow: none;
}

.device-notch {
    width: 96px;
    height: 16px;
    border-radius: 0 0 10px 10px;
}

.device-unavailable {
    display: flex;
    height: 100%;
    padding: var(--space-6);
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: var(--space-2);
    background: #121315;
    color: var(--text-secondary);
    text-align: center;
    font-size: var(--copy-sm);
}

.device-unavailable i {
    margin-bottom: var(--space-2);
    color: var(--warning);
    font-size: 1.5rem;
}

.device-unavailable strong {
    color: var(--text-primary);
    font-size: var(--title-md);
}

@media (max-width: 900px) {
    .laboratory-intro {
        align-items: stretch;
    }

    .simulator-layout {
        grid-template-columns: 1fr;
        max-width: none;
    }

    .preview-stage {
        min-height: 0;
    }

    .preview-canvas {
        min-height: 540px;
    }
}

@media (max-width: 520px) {
    .preview-stage-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .device-wrapper {
        height: 540px;
    }
}

.settings-section-title {
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.settings-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.settings-form-box {
    padding: 20px;
    margin-bottom: 20px;
}

.user-list {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.user-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 15px;
    border-bottom: 1px solid var(--border);
}

.user-row:last-child {
    border-bottom: none;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.2rem;
}

.user-meta {
    display: flex;
    align-items: center;
    gap: 15px;
}

.team-member-name {
    margin-bottom: 2px;
    color: var(--text-primary);
    font-weight: 760;
    line-height: 1.2;
}

.settings-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

@media (max-width: 900px) {
    .settings-layout {
        grid-template-columns: 1fr;
    }

    .settings-nav {
        display: flex;
        overflow-x: auto;
        margin-bottom: 20px;
    }

    .settings-nav-item {
        white-space: nowrap;
        border-left: none;
        border-bottom: 3px solid transparent;
    }

    .settings-nav-item.active {
        border-left: none;
        border-bottom-color: var(--primary);
    }

    .settings-card-header,
    .user-row,
    .user-meta {
        flex-direction: column;
        align-items: stretch;
    }
}



/* --- Minimal interaction cleanup --- */

.btn:hover,
.card:hover,
.stat-card:hover,
.bot-card:hover {
    transform: none !important;
}

.btn-secondary,
.btn-icon,
.btn-danger,
.meta-pill,
.badge {
    background: transparent !important;
}

.btn-primary {
    box-shadow: none !important;
}



/* --- Standardized admin primitives --- */

.section-head,
.section-head-compact,
.action-row-end,
.filter-bar,
.contact-head,
.cards-row,
.user-identity {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.section-head {
    align-items: center;
    justify-content: space-between;
}

.section-head-compact {
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
}

.action-row-end {
    align-items: center;
    justify-content: flex-end;
}

.filter-bar {
    margin-bottom: 1rem;
}

.form-actions-end {
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
}

.contact-head,
.user-identity {
    align-items: center;
    min-width: 0;
}

.cards-row {
    gap: 1rem;
}

.stack-sm,
.note-stack,
.webhook-stack {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.note-stack-scroll {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 340px;
    overflow: auto;
}

.label-kicker {
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.text-value {
    margin-top: 0.25rem;
    color: #fff;
    font-weight: 700;
}

.truncate-title,
.truncate-subtitle {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.truncate-title {
    margin: 0;
    color: #fff;
}

.truncate-subtitle {
    color: var(--text-muted);
    font-size: 0.82rem;
}

.empty-inline,
.empty-card {
    color: var(--text-muted);
    text-align: center;
}

.empty-inline {
    padding: 2rem 1rem;
    font-size: 0.82rem;
}

.empty-card {
    max-width: 420px;
    margin: auto;
    padding: 2rem;
}

.card-quiet,
.note-card,
.team-member-row,
.metric-panel,
.summary-card {
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.018);
    box-shadow: none;
}

.card-quiet {
    margin-bottom: 1rem;
}

.note-card {
    padding: 12px 14px;
    border-radius: 12px;
}

.note-text {
    color: var(--text-secondary);
    white-space: pre-wrap;
}

.team-member-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 10px 12px;
    border-radius: 12px;
}

.chat-demo {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
}

.chat-log {
    padding-right: 0.75rem;
}

.message-meta {
    margin-top: 6px;
    color: var(--text-muted);
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.detail-grid,
.metric-card-grid {
    display: grid;
    gap: 1rem;
}

.detail-grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.metric-card-grid {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.metric-panel {
    padding: 1rem;
    border-radius: 12px;
}

.metric-mini-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.metric-value {
    color: #fff;
    font-size: 1.25rem;
    font-weight: 700;
}

.section-divider {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.table-scroll {
    overflow-x: auto;
}

.table-standard {
    width: 100%;
    border-collapse: collapse;
}

.table-head {
    text-align: left;
    background: transparent;
}

.table-cell,
.table-cell-head {
    padding: 12px;
}

.table-cell-head {
    border-bottom: 2px solid var(--border);
}

.table-row-line {
    border-bottom: 1px solid var(--border);
}

.summary-card {
    flex: 1;
    min-width: 200px;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border-radius: 12px;
}

.summary-icon,
.user-avatar-mini {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
}

.summary-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
}

.summary-icon.is-primary {
    background: var(--primary);
}

.summary-icon.is-success {
    background: var(--success);
}

.user-avatar-mini {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--border);
    font-size: 0.8rem;
}

.btn-outline-muted {
    background: var(--bg-main);
    border: 1px solid var(--border);
}

.btn-teal {
    background: #0f766e;
    color: #fff;
    text-decoration: none;
}

.btn-muted {
    background: #374151;
    color: #fff;
    text-decoration: none;
}

.result-card.is-primary {
    border-left-color: var(--primary);
}

.alert-card {
    border-left: 4px solid var(--border);
}

.alert-card.is-success {
    border-left-color: var(--success);
    color: var(--success);
}

.alert-card.is-danger {
    border-left-color: var(--danger);
    color: var(--danger);
}

.select-narrow { width: 110px; }
.company-name-field { width: 140px; }
.company-slug-field { width: 120px; }

.pre-log {
    max-height: 300px;
    overflow: auto;
    white-space: pre-wrap;
}

/* --- Unified spacing and typography scale --- */

:root {
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-7: 2rem;
    --space-8: 2.5rem;
    --radius-sm: 8px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;
    --title-xl: clamp(1.6rem, 2.2vw, 2.1rem);
    --title-lg: 1.25rem;
    --title-md: 1rem;
    --copy-md: 0.94rem;
    --copy-sm: 0.84rem;
    --copy-xs: 0.74rem;
}

.main-content {
    padding: calc(70px + var(--space-7)) var(--space-7) var(--space-7);
}

.header-actions,
.page-intro,
.card-header,
.settings-card-header,
.wizard-head {
    gap: var(--space-5);
}

.header-actions,
.page-intro {
    margin-bottom: var(--space-6);
}

.page-header h1,
.page-intro h1,
.page-intro h2,
.page-title {
    color: var(--text-primary);
    font-size: var(--title-xl);
    font-weight: 760;
    line-height: 1.08;
    letter-spacing: -0.035em;
    margin: 0 0 var(--space-2);
}

.page-header .subtitle,
.page-subtitle,
.page-intro p,
.section-description,
.panel-description,
.wizard-copy {
    color: var(--text-secondary);
    font-size: var(--copy-md);
    line-height: 1.6;
    margin: 0;
}

.card,
.stat-card,
.settings-panel,
.simple-create-guide,
.advanced-box {
    border-radius: var(--radius-lg);
    box-shadow: none;
}

.card {
    padding: var(--space-6);
    margin-bottom: var(--space-5);
}

.card-header,
.settings-card-header,
.bot-card-header {
    margin-bottom: var(--space-5);
}

.card-title,
.settings-section-title,
.panel-title {
    color: var(--text-primary);
    font-size: var(--title-md);
    font-weight: 720;
    line-height: 1.25;
    margin: 0;
}

.form-section-title,
.section-divider-title,
.wizard-title,
.channel-title,
.webhook-title,
.capture-title,
.question-heading {
    color: var(--text-primary);
    font-size: var(--title-lg);
    font-weight: 720;
    line-height: 1.25;
    letter-spacing: -0.02em;
    margin: 0 0 var(--space-5);
}

.form-section-title {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--border);
}

.form-section-title i,
.section-divider-title i,
.wizard-title i {
    color: var(--primary);
}

.section-divider-title {
    padding-top: var(--space-5);
    border-top: 1px solid var(--border);
}

.section-divider-title.is-separated {
    margin-top: var(--space-7);
    margin-bottom: var(--space-5);
    padding-top: var(--space-5);
}

.section-subtitle,
.settings-section-copy {
    margin-bottom: var(--space-5);
}

.form-group {
    margin-bottom: var(--space-5);
}

label {
    margin-bottom: var(--space-2);
}

.grid-2,
.settings-content,
.cards-row {
    gap: var(--space-5);
}

.edit-container {
    gap: var(--space-6);
    align-items: start;
}

.settings-nav {
    padding: var(--space-2);
    border-radius: var(--radius-lg);
}

.settings-nav-label {
    padding: var(--space-3) var(--space-4) var(--space-2);
    color: var(--text-muted);
    font-size: var(--copy-xs);
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.nav-item {
    min-height: 42px;
    padding: var(--space-3) var(--space-4);
    border: 0;
    border-radius: var(--radius-md);
    font-size: var(--copy-sm);
}

.nav-item.active {
    border: 0;
    background: rgba(var(--primary-rgb), 0.08);
    box-shadow: inset 0 0 0 1px rgba(var(--primary-rgb), 0.2);
}

.simple-create-guide {
    padding: var(--space-6);
    margin-bottom: var(--space-6);
    background: rgba(255, 255, 255, 0.018);
}

.wizard-head {
    align-items: center;
}

.setup-kicker {
    margin-bottom: var(--space-2);
    color: var(--primary);
    font-size: var(--copy-xs);
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.simple-create-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-4);
    margin-top: var(--space-5);
}

.simple-create-card {
    min-height: 0;
    padding: var(--space-5);
    gap: var(--space-3);
    border-radius: var(--radius-lg);
    background: transparent;
}

.simple-create-card strong {
    color: var(--text-primary);
    font-size: var(--title-md);
}

.simple-create-card p {
    color: var(--text-secondary);
    font-size: var(--copy-sm);
}

.config-step .step-index,
.simple-create-guide .step-index {
    width: 26px;
    height: 26px;
    font-size: var(--copy-xs);
}

.compact-actions,
.toolbar-actions,
.action-row-end {
    gap: var(--space-3);
}

.advanced-box {
    margin-top: var(--space-5);
    padding: var(--space-5);
}

@media (max-width: 900px) {
    .main-content {
        padding: calc(70px + var(--space-5)) var(--space-4) var(--space-5);
    }

    .header-actions,
    .page-intro,
    .wizard-head {
        align-items: stretch;
        flex-direction: column;
    }

    .simple-create-grid {
        grid-template-columns: 1fr;
    }

    .settings-nav {
        gap: var(--space-2);
    }

    .settings-nav-label {
        display: none;
    }
}

/* --- Minimal WhatsApp connection and readable Inbox filters --- */

.waha-connect-grid {
    grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
    gap: var(--space-5);
}

.waha-status-card {
    border-color: var(--border);
    background: var(--bg-card);
}

.waha-status-line {
    padding: var(--space-4);
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.018);
}

.waha-status-dot {
    width: 10px;
    height: 10px;
    box-shadow: none;
}

.waha-status-dot.working,
.waha-status-dot.failed {
    box-shadow: none;
}

.waha-actions {
    gap: var(--space-3);
    margin-top: var(--space-5);
}

.waha-info-list div {
    background: rgba(255, 255, 255, 0.018);
    border-radius: var(--radius-md);
}

.inbox-filter.active {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    color: #0b0b0c !important;
}

.inbox-filter.active span,
.inbox-filter.active i {
    color: inherit !important;
}

/* --- UX polish: readable selects, aligned titles and settings standardization --- */

h1,
h2,
h3,
h4,
.card-title,
.form-section-title,
.settings-section-title,
.wizard-title {
    text-shadow: none;
}

.page-header h1,
.page-intro h1,
.page-intro h2 {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.page-header h1 i,
.page-intro h1 i,
.page-intro h2 i {
    color: var(--primary);
    font-size: 0.82em;
    line-height: 1;
}

select,
.form-control,
.bot-select,
.toolbar-select,
.presence-select {
    color: var(--text-primary);
    background-color: var(--bg-input);
    border-color: var(--border);
    color-scheme: dark;
}

select option,
.bot-select option,
.form-control option {
    color: var(--text-primary);
    background-color: #111112;
}

select option:checked,
select option:hover {
    color: #0b0b0c;
    background-color: var(--primary);
}

select:disabled,
select option:disabled {
    color: var(--text-muted);
}

.bot-select {
    background: var(--bg-input);
    border-radius: var(--radius-md);
}

.filter-input {
    width: min(100%, 320px);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    padding: 12px 14px;
}

.table-header-filters,
.settings-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-5);
    margin-bottom: var(--space-5);
    padding-bottom: 0;
    border-bottom: 0;
}

.table-wrapper,
.table-container {
    width: 100%;
    overflow-x: auto;
    background: transparent;
    border-radius: var(--radius-lg);
}

.table-wrapper table,
.table-container table {
    width: 100%;
}

.settings-layout {
    grid-template-columns: minmax(220px, 260px) minmax(0, 1fr);
    gap: var(--space-6);
}

.settings-layout .settings-nav {
    padding: var(--space-2);
}

.settings-nav-item {
    min-height: 44px;
    padding: var(--space-3) var(--space-4);
    border: 0;
    border-radius: var(--radius-md);
    font-size: var(--copy-sm);
}

.settings-nav-item.active {
    border: 0;
    background: rgba(var(--primary-rgb), 0.08);
    box-shadow: inset 0 0 0 1px rgba(var(--primary-rgb), 0.2);
}

.settings-section-title {
    padding-bottom: 0;
    border-bottom: 0;
}

.settings-form-box,
.surface-muted {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.018);
}

.settings-advanced-stack {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
    margin-top: var(--space-5);
}

.advanced-box summary {
    list-style: none;
    cursor: pointer;
    color: var(--text-primary);
    font-size: var(--copy-sm);
    font-weight: 720;
}

.advanced-box summary::-webkit-details-marker {
    display: none;
}

.advanced-box summary::before {
    content: '+';
    display: inline-flex;
    width: 20px;
    height: 20px;
    align-items: center;
    justify-content: center;
    margin-right: var(--space-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--primary);
}

.advanced-box[open] summary::before {
    content: '−';
}

.whatsapp-channel-card,
.channel-card,
.webhook-panel {
    border-radius: var(--radius-lg);
}

@media (max-width: 900px) {
    .settings-layout {
        grid-template-columns: 1fr;
    }

    .settings-card-header,
    .table-header-filters {
        align-items: stretch;
        flex-direction: column;
    }

    .filter-input {
        width: 100%;
    }
}

/* Minimal UX refinements */
.user-profile-link,
.user-profile-link:hover,
.user-profile-link:focus-visible {
    text-decoration: none;
}

.user-profile-link .user-name,
.user-profile-link .user-role,
.user-profile-link .company-pill {
    text-decoration: none;
}

.simple-whatsapp-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: var(--space-4);
    align-items: end;
}

.simple-whatsapp-status {
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.whatsapp-simple-card {
    border-color: var(--border);
    background: rgba(255, 255, 255, 0.018);
}

.simple-whatsapp-main {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-5);
}

.simple-whatsapp-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    margin-top: var(--space-4);
}

.simple-switch {
    margin: 0;
    white-space: nowrap;
}

.queue-list {
    scroll-padding-top: var(--space-3);
}

.message-stack {
    justify-content: flex-end;
}

.advanced-box[open] summary::before {
    content: '-';
}

@media (max-width: 900px) {
    .simple-whatsapp-row,
    .simple-whatsapp-main {
        grid-template-columns: 1fr;
        flex-direction: column;
        align-items: stretch;
    }

    .simple-whatsapp-status {
        justify-content: flex-start;
    }
}

/* --- Sistema visual mínimo: uma hierarquia, menos blocos e menos ruído --- */
.sidebar {
    width: 232px;
}

.main-wrapper {
    margin-left: 232px;
}

.topbar {
    left: 232px;
    height: 64px;
    padding: 0 var(--space-6);
}

.main-content {
    padding: calc(64px + var(--space-6)) var(--space-7) var(--space-7);
}

.sidebar-header {
    padding: var(--space-6) var(--space-5);
}

.sidebar-nav {
    padding: 0 var(--space-3);
}

.nav-section {
    margin-bottom: var(--space-6);
}

.nav-section-title {
    margin-bottom: var(--space-2);
    padding-left: var(--space-3);
}

.nav-links a {
    min-height: 40px;
    padding: 9px var(--space-3);
    border-radius: var(--radius-sm);
}

.nav-links a.active {
    background: rgba(var(--primary-rgb), .09);
}

.topbar-right {
    gap: var(--space-3);
}

.presence-form {
    padding-right: var(--space-3);
    border-right: 1px solid var(--border);
}

.presence-select {
    min-width: 108px;
    height: 34px;
    padding: 0 28px 0 10px;
    font-size: var(--copy-sm);
}

.user-profile {
    height: auto;
    gap: var(--space-2);
    padding-left: 0;
    border-left: 0;
}

.user-profile-link {
    padding: var(--space-1) 0;
}

.user-avatar-circle {
    width: 32px;
    height: 32px;
    font-size: var(--copy-sm);
}

.user-name { font-size: var(--copy-sm); }
.user-role { font-size: .68rem; }

.header-actions,
.page-intro {
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

.page-header h1,
.page-intro h1,
.page-intro h2,
.page-title {
    font-size: var(--title-xl);
}

/* Ícones repetidos nos títulos não ajudam a escanear a página. */
.page-header h1 > i,
.page-intro h1 > i,
.page-intro h2 > i,
.page-title > i,
.form-section-title > i,
.settings-section-title > i {
    display: none;
}

.card,
.stat-card,
.settings-panel,
.advanced-box,
.simple-create-guide,
.settings-form-box,
.surface-muted {
    border-radius: var(--radius-md);
    box-shadow: none;
}

.card {
    padding: var(--space-5);
    margin-bottom: var(--space-4);
}

.card-header,
.settings-card-header,
.bot-card-header {
    margin-bottom: var(--space-4);
}

.btn {
    min-height: 40px;
    padding: 9px 14px;
    border-radius: var(--radius-sm);
    font-size: var(--copy-sm);
    text-decoration: none;
}

.btn:hover,
.btn:focus,
.btn:focus-visible,
.btn-action:hover,
.btn-action:focus,
.btn-action:focus-visible {
    text-decoration: none;
}

.btn-sm {
    min-height: 34px;
    padding: 7px 10px;
}

.form-group {
    margin-bottom: var(--space-4);
}

input,
textarea,
select {
    min-height: 42px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: var(--copy-sm);
}

textarea { min-height: 96px; }

.form-section-title {
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-3);
    font-size: var(--title-md);
}

.advanced-box {
    margin-top: var(--space-4);
    padding: var(--space-4);
    background: rgba(255, 255, 255, .014);
}

.advanced-box summary::before {
    width: 18px;
    height: 18px;
}

/* Indicadores: números e rótulos bastam para leitura rápida. */
.stat-card {
    min-height: 0;
    padding: var(--space-5);
    gap: var(--space-2);
}

.stat-icon { display: none; }
.stat-value { font-size: 1.55rem; }
.stat-trend { margin-top: var(--space-1); }

.dashboard-intro {
    align-items: center;
}

.dashboard-intro p strong { color: var(--text-primary); }

/* Navegações internas ficam textuais e discretas. */
.settings-layout {
    grid-template-columns: minmax(180px, 220px) minmax(0, 1fr);
    gap: var(--space-5);
}

.edit-container {
    gap: var(--space-5);
}

.settings-nav {
    padding: var(--space-2);
    border-radius: var(--radius-md);
}

.settings-nav-item,
.nav-item {
    min-height: 40px;
    padding: 9px var(--space-3);
    border-radius: var(--radius-sm);
}

.settings-nav-item i,
.nav-item i {
    display: none;
}

.settings-nav-item.active,
.nav-item.active {
    box-shadow: none;
    background: rgba(var(--primary-rgb), .09);
}

.settings-nav-label {
    padding: var(--space-3) var(--space-3) var(--space-1);
}

.bot-grid {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: var(--space-4);
}

.bot-card-body { padding: var(--space-5); }
.bot-card-header { margin-bottom: var(--space-4); }
.bot-avatar-wrapper {
    width: 48px;
    height: 48px;
    border-width: 1px;
    border-radius: var(--radius-md);
}
.bot-avatar-emoji { font-size: 1.2rem; }
.bot-card-title { font-size: var(--title-md); }
.bot-card-description { margin-bottom: var(--space-4); }
.bot-actions {
    padding: var(--space-3) var(--space-5);
    background: transparent;
}

.table-wrapper,
.table-container {
    border-radius: var(--radius-md);
}

th,
td { padding: 11px 12px; }

.empty-state {
    padding: var(--space-7) var(--space-5);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.empty-state-icon { display: none; }

@media (max-width: 900px) {
    .sidebar { width: 260px; }
    .main-wrapper { margin-left: 0; }
    .topbar {
        left: 0;
        height: 60px;
        padding: 0 var(--space-4);
    }
    .main-content {
        padding: calc(60px + var(--space-5)) var(--space-4) var(--space-5);
    }
    .dashboard-intro { align-items: flex-start; }
    .settings-layout { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
    .presence-form { display: none; }
    .user-details { display: none; }
    .page-intro,
    .header-actions { align-items: stretch; }
    .header-actions .actions,
    .page-intro > .hero-actions { width: 100%; }
    .header-actions .actions .btn,
    .page-intro > .hero-actions .btn { flex: 1; }
}

/* Dashboard: complete, filterable opportunities queue */
.dashboard-opportunities-card {
    padding: 0;
    overflow: hidden;
}

.dashboard-opportunities-header {
    gap: 1rem 1.5rem;
    padding: 1.25rem 1.25rem 1rem;
    margin-bottom: 0;
}

.dashboard-opportunities-header .card-title {
    margin-bottom: .25rem;
}

.dashboard-filters {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: .65rem;
}

.dashboard-search {
    width: min(290px, 100%);
}

.dashboard-search input {
    color: var(--text-primary);
}

.dashboard-status-strip {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .75rem 1.25rem;
    padding: .8rem 1.25rem;
    background: rgba(var(--primary-rgb), .035);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.dashboard-status-strip .status-pill {
    white-space: nowrap;
}

.dashboard-manage-link,
.dashboard-empty-link {
    color: var(--primary);
    font-size: .82rem;
    font-weight: 700;
    text-decoration: none;
}

.dashboard-manage-link {
    margin-left: auto;
}

.dashboard-manage-link:hover,
.dashboard-empty-link:hover {
    text-decoration: underline;
}

.dashboard-opportunities-table {
    border: 0;
    border-radius: 0;
}

.dashboard-opportunities-table table {
    min-width: 1050px;
}

.dashboard-opportunities-table tbody tr:hover {
    background: rgba(var(--primary-rgb), .035);
}

.dashboard-contact-data {
    display: grid;
    gap: .25rem;
}

.dashboard-summary {
    max-width: 320px;
}

.dashboard-actions-column {
    width: 100px;
}

.dashboard-row-actions {
    flex-wrap: nowrap;
}

@media (max-width: 1180px) {
    .dashboard-opportunities-header {
        align-items: flex-start;
    }

    .dashboard-filters {
        width: 100%;
        justify-content: flex-start;
    }
}

@media (max-width: 680px) {
    .dashboard-opportunities-header {
        padding: 1rem;
    }

    .dashboard-filters,
    .dashboard-search,
    .dashboard-filters .toolbar-select,
    .dashboard-filters .btn {
        width: 100%;
    }

    .dashboard-status-strip {
        align-items: flex-start;
        padding: .85rem 1rem;
    }

    .dashboard-manage-link {
        width: 100%;
        margin-left: 0;
    }
}

.dropdown-content a,
.dropdown-content button {
    display: block;
    width: 100%;
    padding: 10px 12px;
    border: 0;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font: inherit;
    font-size: var(--copy-sm);
    text-align: left;
    text-decoration: none;
}

.dropdown-content a:hover,
.dropdown-content button:hover {
    background: rgba(255, 255, 255, .05);
    color: var(--text-primary);
}

/* Marca e acesso: um sinal técnico discreto, sem efeitos decorativos. */
.logo-icon {
    background: transparent;
    border-radius: 9px;
}

.logo-text {
    letter-spacing: .02em;
}

.sidebar .logo-text {
    display: flex;
    align-items: center;
    gap: .5rem;
    letter-spacing: -.02em;
    white-space: nowrap;
}

.sidebar .logo-chat-badge {
    padding: .125rem .375rem;
    border-radius: .25rem;
    background: #fbbf24;
    color: #151719;
    font-size: .625rem;
    font-weight: 800;
    line-height: 1.5;
    letter-spacing: .5px;
}

body:has(.login-card) {
    display: flex;
    min-height: 100vh;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: var(--bg-main);
}

.login-card {
    width: 100%;
    max-width: 400px;
    padding: 2.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    box-shadow: none;
}

.login-logo {
    margin-bottom: 2rem;
    text-align: center;
}

.login-mark {
    width: 64px;
    height: 64px;
    margin-bottom: var(--space-4);
}

.login-logo h1 {
    color: var(--text-primary);
    font-size: 1.75rem;
    font-weight: 760;
    letter-spacing: .02em;
}

.login-password-group {
    margin-bottom: var(--space-6);
}

.login-submit {
    width: 100%;
    min-height: 46px;
    font-weight: 700;
}

.login-footer {
    margin-top: var(--space-6);
    color: var(--text-muted);
    font-size: var(--copy-xs);
    text-align: center;
}

.login-footer p { margin: 0; }

.error-msg {
    margin-bottom: var(--space-5);
    padding: var(--space-3) var(--space-4);
    border: 1px solid rgba(239, 68, 68, .25);
    border-radius: var(--radius-sm);
    background: rgba(239, 68, 68, .08);
    color: #fca5a5;
    font-size: var(--copy-sm);
    text-align: center;
}

/* --- Tema da área de trabalho ------------------------------------------------
   O menu lateral mantém sua paleta preta. A classe é aplicada no elemento html
   para que a preferência seja carregada antes da página ficar visível. */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 34px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font: inherit;
    font-size: var(--copy-sm);
    font-weight: 650;
    cursor: pointer;
    transition: var(--transition);
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
    border-color: var(--primary);
    color: var(--text-primary);
    outline: none;
}

.theme-toggle i {
    color: var(--primary);
}

html.theme-light {
    color-scheme: light;
    /* Base fria e neutra: o conteúdo continua claro, mas os cartões ganham hierarquia. */
    --bg-main: #ffffff;
    --bg-card: #ffffff;
    --bg-input: #fcfcfa;
    --bg-body: #fcfcfa;
    --bg-dark: #f1f0eb;
    --border: rgba(31, 29, 23, 0.12);
    --border-bright: rgba(31, 29, 23, 0.2);
    --text-primary: #1d1d1b;
    --text-secondary: #5e5b54;
    --text-muted: #858076;
    --primary: #fbbf24;
    --primary-rgb: 251, 191, 36;
    --primary-hover: #fcd34d;
    --primary-light: rgba(251, 191, 36, 0.16);
    --primary-ink: #8a5a00;
    --shadow-main: 0 1px 2px rgba(31, 29, 23, 0.04), 0 10px 24px rgba(31, 29, 23, 0.045);
    --glass: rgba(31, 29, 23, 0.025);
}

/* O menu nunca herda as cores do tema claro. */
html.theme-light .sidebar {
    --bg-sidebar: #070708;
    --primary: #fbbf24;
    --primary-rgb: 251, 191, 36;
    --primary-hover: #fcd34d;
    --primary-light: rgba(251, 191, 36, 0.1);
    --border: rgba(255, 255, 255, 0.075);
    --border-bright: rgba(255, 255, 255, 0.14);
    --text-primary: #f5f5f5;
    --text-secondary: #a7a7ad;
    --text-muted: #707078;
    background: #070708;
}

html.theme-light .sidebar .logo-text,
html.theme-light .sidebar .nav-links a:hover {
    color: #ffffff;
}

/* A barra superior faz parte da seção de conteúdo, não do menu lateral. */
html.theme-light .topbar {
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.08);
}

html.theme-light .topbar .user-avatar-circle {
    color: #ffffff;
}

html.theme-light .topbar .user-name,
html.theme-light .quick-search input {
    color: var(--text-primary);
}

html.theme-light select,
html.theme-light .form-control,
html.theme-light .bot-select,
html.theme-light .toolbar-select,
html.theme-light .presence-select {
    color-scheme: light;
}

html.theme-light select option,
html.theme-light .bot-select option,
html.theme-light .form-control option {
    color: var(--text-primary);
    background-color: #ffffff;
}

/* Superfícies que usam transparência branca no tema escuro. */
html.theme-light .surface-box,
html.theme-light .surface-box-dark,
html.theme-light .surface-muted,
html.theme-light .settings-form-box,
html.theme-light .advanced-box,
html.theme-light .info-panel,
html.theme-light .simple-create-card,
html.theme-light .channel-toggle,
html.theme-light .channel-callout,
html.theme-light .message-bubble.is-system,
html.theme-light .waha-status-line,
html.theme-light .waha-info-list div,
html.theme-light .whatsapp-copy-box,
html.theme-light .publish-mode-option,
html.theme-light .preview-stage,
html.theme-light .bubble.incoming,
html.theme-light .whatsapp-simple-card {
    background: var(--bg-card);
}

html.theme-light .thread-card {
    background: var(--bg-card);
}

html.theme-light .queue-item {
    border-bottom-color: var(--border);
}

html.theme-light .bubble.notice,
html.theme-light .date-separator,
html.theme-light .composer,
html.theme-light .new-messages-button,
html.theme-light .inbox-toast {
    background: var(--bg-card);
    color: var(--text-primary);
}

html.theme-light .bubble.notice,
html.theme-light .date-separator {
    border-color: var(--border);
}

/* Seleções e ações principais seguem o azul do tema claro, sem dourado residual. */
html.theme-light .mode-option:has(input:checked) {
    background: rgba(var(--primary-rgb), 0.08);
}

html.theme-light .bubble.outgoing {
    background: linear-gradient(145deg, var(--primary), var(--primary-hover));
}

html.theme-light .bot-actions {
    background: #f8fafc;
}

/* Compatibilidade para páginas que utilizam as classes utilitárias do Bootstrap. */
html.theme-light .main-content .bg-dark,
html.theme-light .main-content .table-dark,
html.theme-light .main-content .table-dark > :not(caption) > * > * {
    background-color: var(--bg-card) !important;
    color: var(--text-primary) !important;
}

html.theme-light .dropdown-content a:hover,
html.theme-light .dropdown-content button:hover,
html.theme-light .btn-secondary:hover,
html.theme-light .btn-icon:hover,
html.theme-light .nav-item:hover,
html.theme-light .user-profile-link:hover,
html.theme-light .user-profile-link:focus-visible {
    background: rgba(17, 24, 39, 0.06);
    color: var(--text-primary);
}

/* Elementos legados com texto branco explícito acompanham o tema da seção. */
html.theme-light .main-content .card-title,
html.theme-light .main-content .stat-value,
html.theme-light .main-content .page-header h1,
html.theme-light .main-content .page-intro h1,
html.theme-light .main-content .bot-card-title,
html.theme-light .main-content .advanced-box summary,
html.theme-light .main-content .status-check-title,
html.theme-light .main-content .wizard-title,
html.theme-light .main-content .waha-status-text,
html.theme-light .main-content .status-check-copy strong,
html.theme-light .main-content .channel-callout strong,
html.theme-light .main-content .simple-create-card strong,
html.theme-light .main-content .channel-toggle label,
html.theme-light .main-content .queue-item-name,
html.theme-light .main-content .text-value,
html.theme-light .main-content .truncate-title,
html.theme-light .main-content .metric-value,
html.theme-light .main-content .bubble.incoming,
html.theme-light .main-content .text-white {
    color: var(--text-primary);
}

html.theme-light .main-content input,
html.theme-light .main-content textarea,
html.theme-light .main-content select,
html.theme-light .main-content .btn-secondary {
    color: var(--text-primary);
}

html.theme-light .main-content .btn-secondary,
html.theme-light .main-content .btn-icon,
html.theme-light .main-content .btn-danger {
    background: transparent;
}

@media (max-width: 620px) {
    .theme-toggle {
        width: 34px;
        min-width: 34px;
        padding: 0;
    }

    .theme-toggle-label {
        display: none;
    }
}

/* --- Direção visual da marca: preto, grafite e amarelo -------------------- */
/* A área de navegação permanece escura nos dois temas para preservar a marca. */
.sidebar {
    background: #08090a;
    border-right-color: rgba(255, 255, 255, 0.09);
}

.admin-body,
.main-wrapper {
    background: var(--bg-main);
}

.topbar {
    border-top: 0;
    box-shadow: none;
}

.sidebar .nav-links a.active {
    background: rgba(251, 191, 36, 0.075);
    box-shadow: inset 2px 0 0 #fbbf24;
}

.btn-primary,
.btn-action.primary,
.inbox-filter.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #17130a;
}

.btn-primary:hover,
.btn-action.primary:hover,
.inbox-filter.active:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    color: #17130a;
}

html:not(.theme-light) .topbar {
    background: rgba(12, 13, 15, 0.94);
    border-bottom-color: rgba(255, 255, 255, 0.085);
}

html:not(.theme-light) th {
    background: #101114;
}

html:not(.theme-light) .card,
html:not(.theme-light) .stat-card,
html:not(.theme-light) .table-wrapper,
html:not(.theme-light) .settings-nav,
html:not(.theme-light) .queue-card,
html:not(.theme-light) .thread-card,
html:not(.theme-light) .side-panel {
    border-color: rgba(255, 255, 255, 0.085);
}

html:not(.theme-light) .btn-secondary:hover,
html:not(.theme-light) .btn-icon:hover,
html:not(.theme-light) .dropdown-content a:hover,
html:not(.theme-light) .dropdown-content button:hover {
    background: rgba(255, 255, 255, 0.075);
}

html.theme-light .topbar {
    background: #ffffff;
    border-bottom-color: rgba(31, 29, 23, 0.1);
    box-shadow: none;
}

html.theme-light .theme-toggle,
html.theme-light .presence-select {
    background: #ffffff;
    border-color: rgba(31, 29, 23, 0.13);
}

html.theme-light .theme-toggle:hover,
html.theme-light .theme-toggle:focus-visible {
    background: #fff9e7;
    border-color: rgba(var(--primary-rgb), 0.55);
}

html.theme-light th,
html.theme-light .table-head,
html.theme-light .table-cell-head {
    background: #faf6e8;
    color: #806000;
    border-color: rgba(31, 29, 23, 0.1);
}

html.theme-light tr:hover td {
    background: #fffdf7;
}

html.theme-light .main-content .btn-primary,
html.theme-light .main-content .btn-action.primary,
html.theme-light .main-content .inbox-filter.active {
    background: #fbbf24;
    border-color: #fbbf24;
    color: #17130a !important;
}

html.theme-light .main-content .btn-primary:hover,
html.theme-light .main-content .btn-action.primary:hover,
html.theme-light .main-content .inbox-filter.active:hover {
    background: #fcd34d;
    border-color: #fcd34d;
}

/* Em fundo claro, o amarelo é reservado a preenchimentos; textos usam ouro profundo. */
html.theme-light .main-content .text-primary,
html.theme-light .main-content .table-chip--primary,
html.theme-light .main-content .setup-kicker,
html.theme-light .main-content .alert-info,
html.theme-light .main-content .form-section-title i,
html.theme-light .main-content .section-divider-title i,
html.theme-light .main-content .wizard-title i,
html.theme-light .main-content .page-header h1 i,
html.theme-light .main-content .page-intro h1 i,
html.theme-light .main-content .page-intro h2 i,
html.theme-light .main-content .stat-icon,
html.theme-light .main-content .company-pill {
    color: var(--primary-ink);
}

html.theme-light .main-content .table-chip--primary,
html.theme-light .main-content .meta-pill {
    background: #fff6d9 !important;
    border-color: rgba(203, 145, 0, 0.18);
    color: var(--primary-ink);
}

html.theme-light .main-content .nav-item.active,
html.theme-light .main-content .settings-nav-item.active {
    background: #fff6d9;
    color: var(--primary-ink);
    box-shadow: inset 0 0 0 1px rgba(203, 145, 0, 0.2);
}

html.theme-light .main-content .bot-actions,
html.theme-light .main-content .surface-box-dark,
html.theme-light .main-content .info-panel {
    background: #fcfbf7;
}

/* Edição de agente: superfícies claras, sem blocos cinza pesados. */
html.theme-light .main-content .avatar-upload-box,
html.theme-light .main-content .knowledge-field,
html.theme-light .main-content .ai-test-panel,
html.theme-light .main-content .question-card,
html.theme-light .main-content .publish-mode-option {
    background: #fcfbf7;
    border-color: rgba(31, 29, 23, 0.12);
}

html.theme-light .main-content .avatar-preview {
    background: #ffffff;
    border-color: rgba(203, 145, 0, 0.18);
}

html.theme-light .main-content .knowledge-field:focus-within {
    background: #ffffff;
    border-color: rgba(203, 145, 0, 0.42);
    box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.1);
}

html.theme-light .main-content .knowledge-field textarea {
    background: #ffffff;
    border-color: rgba(31, 29, 23, 0.14);
}

/* IA segue a mesma linguagem leve do painel de WhatsApp. */
html.theme-light .main-content .ai-setup-card {
    margin-top: .9rem;
    padding: 1rem;
    border: 1px solid rgba(34, 197, 94, 0.22);
    border-radius: var(--radius-lg);
    background: #f2fcf6;
}

html.theme-light .main-content .ai-setup-card .whatsapp-status-item {
    background: #ffffff;
    border-color: rgba(31, 29, 23, 0.12);
}

html.theme-light .main-content .ai-setup-card .whatsapp-status-item.done {
    background: #f0fdf4;
    border-color: rgba(34, 197, 94, 0.35);
}

html.theme-light .main-content .ai-setup-card .whatsapp-status-item:not(.done) {
    background: #fff8f8;
    border-color: rgba(239, 68, 68, 0.24);
}

html.theme-light .main-content .ai-setup-card .whatsapp-status-item.optional {
    background: #ffffff;
    border-color: rgba(31, 29, 23, 0.12);
}

html.theme-light .main-content .ai-setup-card .whatsapp-status-item.optional i {
    color: var(--primary-ink);
}

html.theme-light .main-content .ai-setup-card .ai-test-panel {
    margin-top: 1rem;
    background: #ffffff;
    border-color: rgba(34, 197, 94, 0.22);
}

html.theme-light .main-content .ai-setup-card .ai-test-panel textarea {
    background: #ffffff;
}

/* Alertas: informação em uma única superfície leve, sem blocos cinza. */
html.theme-light .main-content .notification-panel,
html.theme-light .main-content .smtp-settings {
    background: #fcfbf7;
    border-color: rgba(31, 29, 23, 0.12);
}

html.theme-light .main-content .notification-panel {
    padding: .85rem;
}

html.theme-light .main-content .notification-panel .notice-row {
    padding: .65rem .75rem;
    border: 1px solid rgba(203, 145, 0, 0.22);
    background: #fff9e8;
}

html.theme-light .main-content .smtp-settings {
    margin-top: 1rem !important;
    padding: 1rem;
}

html.theme-light .main-content .smtp-settings .section-subtitle {
    margin-bottom: .9rem;
}

/* Topbar: controles compactos e agrupados como uma area unica de conta. */
.topbar-right {
    gap: 8px;
}

.topbar-right .theme-toggle,
.topbar-right .presence-select,
.topbar-right .user-profile-link {
    height: 36px;
    min-height: 36px;
    border-radius: 10px;
    font-size: .78rem;
}

.topbar-right .theme-toggle {
    padding: 0 11px;
    gap: 7px;
    font-weight: 650;
}

.topbar-right .presence-form {
    margin: 0;
    padding-right: 0;
    border-right: 0;
}

.topbar-right .presence-label {
    position: relative;
    display: inline-flex;
    align-items: center;
    margin: 0;
}

.topbar-right .presence-dot {
    position: absolute;
    left: 11px;
    z-index: 1;
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, .11);
    pointer-events: none;
}

.topbar-right .presence-dot.presence-busy,
.topbar-right .presence-dot.presence-away {
    background: #f59e0b;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, .13);
}

.topbar-right .presence-dot.presence-offline {
    background: #9ca3af;
    box-shadow: 0 0 0 3px rgba(156, 163, 175, .12);
}

.topbar-right .presence-select {
    min-width: 118px;
    padding-left: 29px;
    padding-right: 28px;
}

.topbar-right .user-profile {
    height: auto;
    gap: 0;
    padding-left: 0;
    border-left: 0;
}

.topbar-right .user-profile-link {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 3px 5px 3px 10px;
    border: 1px solid transparent;
}

.topbar-right .user-details {
    align-items: flex-start;
    line-height: 1.05;
}

.topbar-right .user-name {
    max-width: 96px;
    overflow: hidden;
    color: var(--text-primary);
    font-size: .8rem;
    font-weight: 760;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar-right .user-role {
    font-size: .62rem;
}

.topbar-right .user-avatar-circle {
    width: 30px;
    height: 30px;
    font-size: .78rem;
}

.topbar-right .user-profile-link:hover,
.topbar-right .user-profile-link:focus-visible {
    border-color: var(--border);
    background: rgba(255, 255, 255, .055);
    outline: none;
}

html.theme-light .topbar-right .user-profile-link:hover,
html.theme-light .topbar-right .user-profile-link:focus-visible {
    background: #fff9e7;
    border-color: rgba(var(--primary-rgb), .34);
}

@media (max-width: 760px) {
    .topbar-right .theme-toggle-label,
    .topbar-right .user-details {
        display: none;
    }

    .topbar-right .theme-toggle {
        width: 36px;
        padding: 0;
    }

    .topbar-right .presence-select {
        min-width: 104px;
    }
}

/* Inbox: passada senior de densidade, leitura e foco operacional. */
.content-body > .inbox-command-bar {
    margin: -2px 0 12px;
}

.inbox-command-bar {
    min-height: 36px;
    align-items: center;
}

.inbox-summary {
    min-width: max-content;
    gap: 7px;
    font-size: .73rem;
    letter-spacing: -.005em;
}

.inbox-filter-bar {
    gap: 7px;
}

.inbox-filter {
    min-height: 34px;
    padding: 6px 12px;
    border-color: rgba(31, 29, 23, .12);
    box-shadow: none;
    font-size: .74rem;
    font-weight: 720;
    letter-spacing: -.01em;
}

.inbox-filter span {
    margin-left: 4px;
    font-weight: 780;
}

.inbox-shell {
    grid-template-columns: 322px minmax(0, 1fr);
    gap: 12px;
    --thread-viewport-height: clamp(590px, calc(100vh - 142px), 920px);
}

.queue-card,
.thread-card {
    border-radius: 16px;
    box-shadow: 0 14px 34px rgba(31, 29, 23, .07);
}

.queue-header {
    min-height: 48px;
    padding: 10px 13px;
}

.queue-header-copy .card-title {
    font-size: .92rem;
    font-weight: 790;
    letter-spacing: -.02em;
}

.queue-header-copy .text-muted {
    font-size: .64rem;
}

.queue-tools {
    padding: 10px 13px 12px;
    gap: 9px;
}

.queue-tools .quick-search input {
    height: 38px;
    min-height: 38px;
    padding: 8px 12px 8px 39px;
    font-size: .78rem;
}

.queue-selects {
    gap: 8px;
}

.queue-selects .form-control {
    height: 38px;
    min-height: 38px;
    padding: 8px 10px;
    font-size: .72rem;
}

.queue-item {
    padding: 11px 12px;
    border-bottom-color: rgba(31, 29, 23, .08);
}

.queue-item-name {
    font-size: .82rem;
    font-weight: 780;
}

.queue-item-phone {
    font-size: .63rem;
}

.queue-item-preview {
    margin-top: 5px;
    font-size: .68rem;
    line-height: 1.3;
}

.queue-item-foot {
    margin-top: 9px;
}

.queue-item-context {
    font-size: .65rem;
}

.queue-state {
    padding: 3px 7px;
    font-size: .58rem;
}

.thread-top {
    min-height: 58px;
    padding: 8px 14px;
    background: var(--bg-card);
}

.thread-identity {
    gap: 8px;
}

.thread-avatar {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    font-size: .8rem;
}

.thread-name {
    max-width: min(520px, 34vw);
    font-family: 'Inter', system-ui, sans-serif;
    font-size: .92rem;
    font-weight: 790;
    letter-spacing: -.025em;
}

.thread-subtitle {
    font-size: .66rem;
}

.thread-tags {
    margin-top: 3px;
}

.thread-tags .meta-pill {
    padding: 2px 6px;
    font-size: .56rem;
}

.thread-top .btn-icon,
.thread-top .btn.btn-sm {
    min-height: 32px;
    height: 32px;
    border-radius: 9px;
    font-size: .72rem;
}

.thread-top .btn-icon {
    width: 32px;
}

.action-row {
    gap: 7px;
}

.sync-state {
    font-size: .68rem;
}

.thread-actions-popover {
    width: 220px;
    padding: 7px;
    border-radius: 12px;
}

.thread-actions-popover .btn {
    min-height: 34px;
    padding: 7px 9px;
    font-size: .72rem;
}

.thread-body {
    padding: 14px 18px 10px;
    background:
        linear-gradient(90deg, rgba(var(--primary-rgb), .045), transparent 310px),
        radial-gradient(circle at bottom right, rgba(var(--primary-rgb), .025), transparent 30%);
}

.message-stack {
    width: min(780px, 100%);
    max-width: 780px;
    gap: 10px;
}

.date-separator {
    padding: 3px 8px;
    font-size: .58rem;
    opacity: .78;
}

.bubble {
    max-width: min(78%, 590px);
    padding: 8px 11px 7px;
    border-radius: 12px;
    font-size: .84rem;
    line-height: 1.28;
    box-shadow: none;
}

.thread-body .bubble {
    gap: 4px;
}

.message-content,
.thread-body .bubble .message-content {
    line-height: 1.28;
}

.message-meta,
.thread-body .bubble .message-meta {
    gap: 5px;
    font-size: .6rem;
    letter-spacing: .055em;
    opacity: .58;
}

.bubble.incoming {
    border-bottom-left-radius: 4px;
}

.bubble.bot {
    border-bottom-left-radius: 4px;
}

.bubble.outgoing {
    border-bottom-right-radius: 4px;
}

.composer {
    padding: 12px 16px;
}

.composer .form-group {
    margin-bottom: 8px;
}

.composer-heading {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 6px;
}

.composer-heading label {
    margin: 0;
    color: var(--text-primary);
    font-size: .82rem;
    font-weight: 650;
}

.composer-count {
    color: var(--text-muted);
    font-size: .73rem;
    font-variant-numeric: tabular-nums;
}

.composer textarea {
    display: block;
    width: 100%;
    min-height: 64px;
    max-height: clamp(72px, 22vh, 152px);
    overflow-y: auto;
    resize: none;
    padding: 10px 12px;
    border-radius: 12px;
    font-size: 1rem;
    line-height: 1.4;
}

.composer-toolbar,
.composer-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px 16px;
}

.composer-toolbar {
    margin-top: 8px;
    gap: 8px;
}

.composer-actions,
.composer-meta,
.composer-ai {
    display: flex;
    align-items: center;
    gap: 6px 12px;
}

.composer-footer,
.composer-actions,
.composer-meta {
    flex-wrap: wrap;
}

.composer-actions {
    gap: 6px;
}

.composer-footer {
    padding-top: 8px;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: .73rem;
    line-height: 1.35;
}

.composer-ai {
    margin: 0;
    color: var(--text-secondary);
    font-size: inherit;
    cursor: pointer;
}

.composer-ai input {
    flex: none;
    margin: 0;
}

.composer-toolbar .btn {
    flex: none;
    min-height: 40px;
    min-width: 98px;
    padding: 8px 15px;
    border-radius: 10px;
}

.new-messages-button {
    right: 18px;
    bottom: calc(var(--composer-height, 104px) + 12px);
    padding: 7px 11px;
    font-size: .72rem;
}

html.theme-light .content-body > .inbox-command-bar {
    color: #4b5563;
}

html.theme-light .inbox-filter {
    background: #ffffff;
    border-color: rgba(31, 29, 23, .12);
    color: #111827;
}

html.theme-light .inbox-filter:not(.active):hover {
    background: #fffdf7;
    border-color: rgba(203, 145, 0, .22);
}

html.theme-light .queue-card,
html.theme-light .thread-card {
    background: #ffffff;
    border-color: rgba(31, 29, 23, .11);
}

html.theme-light .thread-top,
html.theme-light .composer {
    background: #ffffff;
}

html.theme-light .thread-body {
    background:
        linear-gradient(90deg, rgba(251, 191, 36, .075), rgba(255, 255, 255, 0) 310px),
        linear-gradient(180deg, #ffffff, #fffefa);
}

html.theme-light .queue-item {
    border-bottom-color: rgba(31, 29, 23, .08);
}

html.theme-light .queue-item:hover {
    background: #fffdf6;
}

html.theme-light .queue-item.active {
    background: #fff8e8;
}

html.theme-light .bubble.incoming {
    background: #ffffff;
    border-color: rgba(31, 29, 23, .13);
    color: #1f2937;
}

html.theme-light .bubble.bot {
    background: #fff8e8;
    border-color: rgba(251, 191, 36, .42);
    color: #1f2937;
}

html.theme-light .bubble.outgoing {
    background: #fbbf24;
    border-color: #fbbf24;
    color: #17130a;
}

html.theme-light .date-separator {
    background: #ffffff;
    border-color: rgba(31, 29, 23, .1);
}

html.theme-light .composer textarea {
    background: #ffffff;
    border-color: rgba(31, 29, 23, .14);
    color: #111827;
}

html.theme-light .composer textarea:focus {
    border-color: rgba(203, 145, 0, .42);
    box-shadow: 0 0 0 3px rgba(251, 191, 36, .1);
}

@media (max-width: 1380px) {
    .inbox-shell {
        grid-template-columns: 304px minmax(0, 1fr);
    }

    .thread-name {
        max-width: min(420px, 31vw);
    }
}

@media (max-width: 900px) {
    .content-body > .inbox-command-bar {
        margin-top: 0;
    }

    .inbox-command-bar {
        align-items: flex-start;
        flex-direction: column;
    }

    .inbox-filter-bar {
        width: 100%;
    }

    .inbox-shell {
        --thread-viewport-height: calc(100vh - 132px);
    }

    .thread-body {
        padding: 12px;
    }

    .message-stack {
        width: 100%;
    }

    .bubble {
        max-width: 88%;
    }
}

/* Inbox: comportamento de mensageiro e midias. */
.message-stack {
    width: min(980px, 100%);
    max-width: 980px;
    margin: 0 auto;
}

.bubble.bot {
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    border-bottom-left-radius: 12px;
}

.bubble.outgoing {
    align-self: flex-end;
}

.bubble.incoming {
    align-self: flex-start;
}

.thread-body {
    background:
        linear-gradient(180deg, rgba(255,255,255,.012), transparent),
        rgba(255,255,255,.006);
}

.message-media {
    display: block;
    min-width: 190px;
    max-width: 100%;
    overflow: hidden;
    border-radius: 10px;
}

.message-media img,
.message-media video {
    display: block;
    width: min(360px, 100%);
    max-height: 320px;
    object-fit: contain;
    border-radius: 10px;
}

.message-media audio {
    width: min(320px, 100%);
    height: 38px;
}

.message-media-file {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 210px;
    padding: 10px 11px;
    border: 1px solid rgba(255,255,255,.09);
    border-radius: 10px;
    background: rgba(255,255,255,.04);
    color: inherit;
    text-decoration: none;
}

.message-media-file i {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    flex: 0 0 auto;
    border-radius: 9px;
    background: rgba(var(--primary-rgb), .16);
    color: var(--primary);
}

.message-media-file span {
    min-width: 0;
    overflow: hidden;
    font-size: .78rem;
    font-weight: 720;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-media-file small {
    display: block;
    color: var(--text-muted);
    font-size: .62rem;
    line-height: 1.1;
}

.message-media-load-error {
    margin-top: 8px;
    color: var(--text-muted);
    font-size: .76rem;
    text-decoration: underline;
}

.message-media.is-unavailable .message-media-file {
    border-style: dashed;
    opacity: .82;
}

.composer-attach {
    display: inline-grid;
    place-items: center;
    width: 40px;
    height: 40px;
    margin: 0;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.composer-attach:hover,
.composer-attach:focus-within {
    border-color: rgba(var(--primary-rgb), .45);
    color: var(--primary);
    background: rgba(var(--primary-rgb), .08);
}

.composer-attach input {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
}

.composer-media-preview {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: fit-content;
    max-width: 100%;
    margin-top: 7px;
    padding: 5px 8px;
    border: 1px solid rgba(var(--primary-rgb), .24);
    border-radius: 999px;
    background: rgba(var(--primary-rgb), .08);
    color: var(--text-secondary);
    font-size: .68rem;
}

.composer-media-preview[hidden] {
    display: none !important;
}

.composer-media-preview span {
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.composer-media-preview button {
    display: inline-grid;
    place-items: center;
    width: 20px;
    height: 20px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: inherit;
    cursor: pointer;
}

.composer-media-preview button:hover {
    background: rgba(0,0,0,.08);
}

html.theme-light .thread-body {
    background: #f7f7f4;
}

html.theme-light .bubble.bot {
    background: #fff6d9;
    border-color: rgba(251, 191, 36, .5);
    color: #1f2937;
}

html.theme-light .message-media-file {
    border-color: rgba(31, 29, 23, .12);
    background: #ffffff;
}

html.theme-light .composer-attach {
    background: #ffffff;
    border-color: rgba(31, 29, 23, .14);
}

html.theme-light .composer-media-preview {
    background: #fff8e8;
    border-color: rgba(203, 145, 0, .24);
    color: #6b5a24;
}

@media (max-width: 900px) {
    .message-stack {
        width: 100%;
        margin: 0;
    }
}


/* Conversation tools and queue filters */
.queue-selects {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.queue-selects #filterAttendant {
    grid-column: 1 / -1;
}

.inbox-tools {
    flex: 0 0 auto;
    border-top: 1px solid var(--border);
    background: var(--bg-card);
}

.inbox-tools summary {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    padding: 8px 14px;
    color: var(--text-secondary);
    font-size: .82rem;
    font-weight: 650;
    list-style: none;
    cursor: pointer;
}

.inbox-tools summary::-webkit-details-marker {
    display: none;
}

.inbox-tools summary:hover {
    background: rgba(var(--primary-rgb), .08);
}

.inbox-tools-chevron {
    margin-inline-start: auto;
    font-size: .7rem;
}

.inbox-tools[open] .inbox-tools-chevron {
    transform: rotate(180deg);
}

.inbox-tools-body {
    display: grid;
    gap: 8px;
    max-height: min(32vh, 270px);
    overflow: auto;
    padding: 0 14px 10px;
    scrollbar-gutter: stable;
}

.inbox-tools-section {
    min-width: 0;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
}

.inbox-tools-section h4 {
    margin: 0 0 6px;
    color: var(--text-secondary);
    font-size: .75rem;
    font-weight: 700;
}

#inboxToolsForm,
.inbox-tools-row {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 6px 8px;
    margin: 0;
}

.inbox-tools-field {
    display: grid;
    gap: 3px;
    margin: 0;
    font-size: .74rem;
}

.inbox-tools-field:first-of-type {
    flex: 1 1 150px;
    min-width: 0;
}

.inbox-tools input:not([type="hidden"]),
.inbox-tools select,
.inbox-tools .btn {
    min-height: 32px;
    max-width: 100%;
    padding: 5px 8px;
    font-size: .78rem;
}

.inbox-tools-row input,
.inbox-tools-row select {
    width: auto;
    min-width: 0;
}

#inboxThreadSearch,
#inboxGroupName {
    flex: 1 1 155px;
}

#inboxToolsResult {
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-size: .82rem;
}

#inboxToolsResult:empty {
    display: none;
}

#inboxGroupAvatar {
    overflow: hidden;
}

#inboxGroupAvatar img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.group-mention-picker {
    margin-top: 8px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-card);
}

.group-mention-results {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    max-height: min(20vh, 140px);
    margin-top: 6px;
    overflow: auto;
}

.group-mention-results button {
    max-width: 100%;
    overflow-wrap: anywhere;
}

.group-mention-selected {
    display: block;
    margin-top: 4px;
    color: var(--text-secondary);
}

.group-mention-selected:empty {
    display: none;
}


/* Queue signals and inline mentions */
.queue-item:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}

.queue-unread {
    font-variant-numeric: tabular-nums;
}

.queue-item-timewrap {
    white-space: nowrap;
}

.queue-state:not(.is-danger):not(.is-reminder) {
    background: rgba(128, 137, 148, .15);
    color: var(--text-secondary);
}

.queue-state.is-reminder {
    background: rgba(245, 158, 11, .16);
    color: #a15c00;
}

html:not(.theme-light) .queue-state.is-reminder {
    color: #fbbf24;
}

.message-mention {
    padding: 0 .25em;
    border-radius: 4px;
    background: #e7efff;
    color: #174481;
    font-weight: 650;
    overflow-wrap: anywhere;
}

html:not(.theme-light) .message-mention {
    background: #243655;
    color: #c6dcff;
}

.queue-item-preview .message-mention {
    padding: 0;
    background: transparent;
}

.queue-item.queue-item-group {
    padding-inline-start: 48px;
}

.queue-group-avatar {
    position: absolute;
    inset-inline-start: 11px;
    top: 11px;
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: .7rem;
}

.queue-group-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* WhatsApp message actions and audio tools */
.bubble:has(> .message-action-toggle) {
    position: relative;
    padding-inline-end: 30px;
}

.message-action-toggle {
    position: absolute;
    top: 5px;
    inset-inline-end: 5px;
    display: grid;
    place-items: center;
    width: 21px;
    height: 21px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
}

.message-action-toggle::before {
    content: '';
    width: 6px;
    height: 6px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: translateY(-1px) rotate(45deg);
}

.message-action-toggle:hover,
.message-action-toggle[aria-expanded="true"] {
    background: rgba(128, 137, 148, .15);
}

.message-action-toggle:focus-visible {
    outline: 2px solid var(--primary);
}

@media (hover: hover) and (pointer: fine) {
    .message-action-toggle {
        opacity: 0;
    }

    .bubble:hover > .message-action-toggle,
    .bubble:focus-within > .message-action-toggle,
    .message-action-toggle[aria-expanded="true"] {
        opacity: 1;
    }
}

.message-action-popover {
    position: fixed;
    inset: auto;
    margin: 0;
    width: min(255px, calc(100vw - 16px));
    max-height: calc(100dvh - 16px);
    padding: 0;
    overflow: auto;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--text-primary);
    box-shadow: 0 7px 22px rgba(0, 0, 0, .18);
}

.message-action-content {
    display: grid;
    gap: 4px;
}

.message-reaction-strip,
.message-menu-list,
.message-menu-panel,
#messageActionStatus:not(:empty) {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-card);
}

.message-reaction-strip:not([hidden]),
.message-media-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
}

.message-reaction-strip {
    justify-content: space-between;
    padding: 4px 5px;
}

.message-reaction-strip .btn {
    min-width: 30px;
    padding: 3px 5px;
    border-color: transparent;
    font-size: 1rem;
    line-height: 1.35;
}

.message-reaction-strip .btn[aria-label="Remover reação"] {
    font-size: .75rem;
}

.message-reaction-strip [aria-pressed="true"] {
    border-color: var(--primary);
    background: rgba(var(--primary-rgb), .12);
}

.message-menu-list {
    padding: 4px 0;
}

.message-menu-action {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 34px;
    gap: 9px;
    padding: 6px 11px;
    border: 0;
    background: transparent;
    color: inherit;
    text-align: start;
    font: inherit;
    font-size: .83rem;
    cursor: pointer;
}

.message-menu-action i {
    flex: 0 0 16px;
    text-align: center;
}

.message-menu-action:hover,
.message-menu-action:focus-visible {
    background: rgba(var(--primary-rgb), .12);
}

.message-menu-action:disabled {
    opacity: .6;
    cursor: wait;
}

.message-menu-action.message-action-delete {
    margin-top: 3px;
    border-top: 1px solid var(--border);
    color: var(--danger);
}

.message-menu-panel:not([hidden]) {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 7px;
}

.message-menu-panel select {
    flex: 1 1 120px;
    width: auto;
    min-width: 0;
}

.message-menu-panel p,
#messageActionStatus {
    margin: 0;
    font-size: .78rem;
}

#messageActionStatus:empty {
    display: none;
}

#messageActionStatus:not(:empty) {
    padding: 7px 9px;
}

.message-quote,
.composer-quote {
    margin: 0 0 6px;
    padding: 6px 8px;
    border-inline-start: 3px solid var(--primary);
    border-radius: 5px;
    background: rgba(128, 137, 148, .14);
    font-size: .8rem;
}

.message-quote strong {
    display: block;
}

.composer-quote:not([hidden]) {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.composer-quote p {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    margin: 2px 0 0;
}

.message-forwarded,
.message-reaction {
    display: block;
    margin-block: 3px;
}

.message-media-toolbar {
    justify-content: flex-end;
    margin-top: 6px;
}

.message-audio-timeline {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-top: 4px;
}

.message-audio-timeline input[type="range"] {
    flex: 1;
    min-width: 0;
    width: 100%;
    padding: 0;
    accent-color: #2455a4;
}

.message-audio-timeline span {
    white-space: nowrap;
    font-size: .78rem;
    font-weight: 650;
    font-variant-numeric: tabular-nums;
}

.message-transcript {
    margin-top: 7px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-size: .82rem;
}

button.message-reaction {
    width: fit-content;
    padding: 2px 6px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-card);
    color: var(--text-secondary);
    font: inherit;
    font-size: .78rem;
    cursor: pointer;
}

.message-reactor-list {
    display: grid;
    gap: 6px;
    width: 100%;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: .82rem;
}

.message-reactor-panel > strong {
    width: 100%;
    font-size: .8rem;
}

.message-reactor-list li {
    display: grid;
    grid-template-columns: 20px minmax(0, 1fr);
    gap: 2px 5px;
}

.message-reactor-list li small {
    grid-column: 2;
    color: var(--text-secondary);
    font-size: .72rem;
}

/* Navegação compacta no desktop, com preferência persistente. */
#sidebar-collapse { flex-shrink: 0; }
#sidebar-close { display: none; }
@media (width > 1024px) {
    html.sidebar-collapsed .sidebar { width: 72px; }
    html.sidebar-collapsed .main-wrapper { margin-left: 72px; }
    html.sidebar-collapsed .topbar { left: 72px; }
    html.sidebar-collapsed .sidebar-header { padding: 20px 0; justify-content: center; }
    html.sidebar-collapsed .sidebar .logo { justify-content: center; gap: 0; }
    html.sidebar-collapsed .sidebar .logo-text,
    html.sidebar-collapsed .sidebar .nav-section-title,
    html.sidebar-collapsed .sidebar .nav-links a span,
    html.sidebar-collapsed .sidebar .logout-link span { display: none; }
    html.sidebar-collapsed .sidebar-nav { padding: 12px 8px; }
    html.sidebar-collapsed .sidebar .nav-section { margin-bottom: 16px; }
    html.sidebar-collapsed .sidebar .nav-links a { justify-content: center; padding: 13px 0; gap: 0; }
    html.sidebar-collapsed .sidebar .nav-links a i { margin: 0; width: 24px; text-align: center; font-size: 18px; }
    html.sidebar-collapsed .sidebar-footer { padding: 16px 8px; }
    html.sidebar-collapsed .sidebar .logout-link { display: flex; justify-content: center; padding: 12px 0; }
}

.sidebar-backdrop { display: none; }

@media (max-width: 1024px) {
    .main-wrapper { margin-left: 0; }
    .topbar { left: 0; gap: 8px; }
    .sidebar {
        width: min(280px, calc(100vw - 48px));
        height: 100dvh;
        visibility: hidden;
    }
    .sidebar.open { visibility: visible; }
    .sidebar-footer { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
    .sidebar-backdrop:not([hidden]) {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 999;
        background: rgba(0, 0, 0, .55);
    }
    .mobile-menu-open { overflow: hidden; }
    #sidebar-collapse, #sidebar-close { width: 44px; height: 44px; flex-shrink: 0; }
    #sidebar-close { display: flex; }
    .topbar-left { min-width: 0; gap: 8px; }
    .topbar-right { flex-shrink: 0; }
    .breadcrumb, .breadcrumb-item.active { min-width: 0; }
    .breadcrumb-item.active { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .main-content, .content-body { min-width: 0; }
    .table-wrapper, .table-container, .table-responsive, .table-scroll {
        max-width: 100%;
        overflow-x: auto;
    }
}

@media (max-width: 900px) {
    .content-body > .inbox-shell { grid-template-columns: minmax(0, 1fr); }
    body:not(.inbox-thread-open) .thread-column { display: none; }
    body.inbox-thread-open .main-content { padding: 60px 0 0; }
    body.inbox-thread-open .thread-card {
        min-height: 0;
        border-radius: 0;
        box-shadow: none;
    }
    .thread-top { flex: 0 0 auto; gap: 8px; padding: 6px 8px; }
    .thread-identity, .thread-identity-copy { min-width: 0; }
    .thread-name, .thread-subtitle { max-width: 100%; }
    .thread-top .action-row { flex: 0 0 auto; flex-wrap: nowrap; gap: 4px; }
    .thread-top .btn-icon,
    .thread-top .action-row > .btn,
    .thread-top .action-row > form > .btn,
    .thread-actions-menu > summary {
        width: 44px;
        height: 44px;
        padding: 0;
        justify-content: center;
    }
    .thread-top .action-label, .thread-top .sync-state { display: none; }
    .composer { padding: 8px 10px max(8px, env(safe-area-inset-bottom)); }
    .composer textarea { min-height: 44px; max-height: 96px; }
    .composer-toolbar .btn, .composer-attach { min-height: 44px; }
    .queue-tools .quick-search input, .queue-selects .form-control { font-size: 1rem; }
    .queue-list { scroll-padding-block: 8px; }
}

@media (max-width: 620px) {
    .topbar { padding-inline: 8px; }
    .topbar-right { gap: 4px; }
    .breadcrumb-item:not(.active), .breadcrumb .separator { display: none; }
    .topbar-right .presence-form { display: block; }
    .topbar-right .theme-toggle, .topbar-right .user-profile-link { width: 44px; height: 44px; padding: 0; justify-content: center; }
    .topbar-right .presence-select {
        min-width: 0;
        width: 44px;
        height: 44px;
        padding: 0;
        font-size: 1rem;
        opacity: 0;
        cursor: pointer;
    }
    .topbar-right .presence-label {
        border: 1px solid var(--border);
        border-radius: 10px;
    }
    .topbar-right .presence-label:focus-within { outline: 2px solid var(--primary); }
    .topbar-right .presence-dot { left: 12px; }
    .topbar-right .presence-label::after {
        content: "";
        position: absolute;
        right: 10px;
        width: 5px;
        height: 5px;
        border: solid currentColor;
        border-width: 0 1px 1px 0;
        transform: rotate(45deg);
        pointer-events: none;
    }
    .login-card { padding: 24px; }
    .login-card input { font-size: 1rem; }
}

/* Expandable details used by the agent cards, inbox and laboratory. */
.panel-disclosure {
    min-inline-size: 0;
    overflow-wrap: anywhere;
}
.panel-disclosure > summary {
    cursor: pointer;
    color: inherit;
    font-size: .875rem;
    font-weight: 650;
    padding-block: .55rem;
}
.panel-disclosure > summary:focus-visible,
#queueExceptionsToggle:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 3px;
    border-radius: 4px;
}
.panel-disclosure > p,
.panel-disclosure > form,
.panel-disclosure > ol,
.panel-disclosure > ul {
    margin-block: .45rem .75rem;
}
.panel-disclosure > ol,
.panel-disclosure > ul {
    padding-inline-start: 1.2rem;
}
.panel-disclosure > h4 {
    margin-block: 1rem .35rem;
}
.bot-channels {
    margin-block: .75rem;
    border-block: 1px solid var(--border);
}
.bot-channels > .bot-channel-list {
    display: grid;
    gap: .55rem;
    list-style: none;
    padding: 0;
    margin: .25rem 0 .75rem;
}
.bot-channel-list > li {
    border: 1px solid var(--border);
    border-radius: .55rem;
    padding: .45rem .55rem;
    font-size: .78rem;
}
.bot-channel-heading {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: .3rem .6rem;
}
.bot-channel-list small {
    display: block;
    margin-block-start: .25rem;
}
.bot-channel-status {
    font-size: .72rem;
}
.bot-channel-status.is-enabled {
    font-weight: 700;
}
#queueExceptionsToggle[aria-pressed="true"] {
    border-color: var(--primary);
}
#queueExceptionsCount {
    min-inline-size: 1.5em;
    text-align: center;
    font-variant-numeric: tabular-nums;
}
#botForm input[type="time"] {
    inline-size: 100%;
    min-inline-size: 0;
    color-scheme: dark;
}
html.theme-light #botForm input[type="time"] {
    color-scheme: light;
}
@media (max-width: 620px) {
    .panel-disclosure > summary {
        min-block-size: 44px;
        align-content: center;
    }
    #botForm input[type="time"],
    #botForm #meetingDuration,
    #botForm #meetingWindowDays,
    #traceConversation,
    #routingScenario {
        font-size: 1rem;
    }
}
