:root {
    --brand: #00C853;
    --brand-dark: #009688;
    --brand-light: #69F0AE;
    --ink: #0B1220;
    --muted: #64748B;
    --surface: #F4F7FB;
    --card: #FFFFFF;
    --border: rgba(15, 23, 42, 0.08);
    --sidebar-w: 16.5rem;
    --topbar-h: 3.25rem;
    --radius: 0.875rem;
    --scrollbar-size: 6px;
    --scrollbar-track: transparent;
    --scrollbar-thumb: rgba(15, 23, 42, 0.14);
    --scrollbar-thumb-hover: rgba(15, 23, 42, 0.24);
}

.dark {
    --surface: #070B12;
    --card: #0F1623;
    --border: rgba(148, 163, 184, 0.12);
    --muted: #94A3B8;
    --scrollbar-thumb: rgba(148, 163, 184, 0.16);
    --scrollbar-thumb-hover: rgba(148, 163, 184, 0.28);
    color-scheme: dark;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

body {
    font-family: "Plus Jakarta Sans", system-ui, sans-serif;
    background: var(--surface);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
}

/* Scrollbars discretas (Firefox + WebKit) */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

*::-webkit-scrollbar {
    width: var(--scrollbar-size);
    height: var(--scrollbar-size);
}

*::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}

*::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 999px;
    border: 1px solid transparent;
    background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
    background-clip: padding-box;
}

*::-webkit-scrollbar-corner {
    background: transparent;
}

.dark body,
html.dark body {
    color: #E2E8F0;
}

.font-display {
    font-family: Sora, system-ui, sans-serif;
}

/* ---------- Shell: fixed sidebar + topbar ---------- */
.app-shell {
    min-height: 100vh;
}

.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    z-index: 40;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, #FFFFFF 0%, #F8FBFF 100%);
    border-right: 1px solid var(--border);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.dark .app-sidebar {
    background: linear-gradient(180deg, #0C1422 0%, #0A101A 100%);
}

.app-topbar {
    position: fixed;
    top: 0;
    left: var(--sidebar-w);
    right: 0;
    height: var(--topbar-h);
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0 1.25rem;
    background: rgba(255, 255, 255, 0.82);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.dark .app-topbar {
    background: rgba(11, 18, 32, 0.85);
}

.app-main {
    margin-left: var(--sidebar-w);
    padding-top: var(--topbar-h);
    min-height: 100vh;
}

.app-main-inner {
    padding: 1.25rem 1.5rem 2rem;
    width: 100%;
    max-width: none;
}

.app-main-inner > .panel,
.app-main-inner > form.panel,
.app-main-inner > .form-shell,
.app-main-inner form.form-shell {
    width: 100%;
    max-width: none;
}

.app-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(7, 11, 18, 0.55);
    backdrop-filter: blur(2px);
}

/* Mobile drawer */
@media (max-width: 1023px) {
    .app-sidebar {
        transform: translateX(-105%);
        box-shadow: none;
    }

    .app-shell.sidebar-open .app-sidebar {
        transform: translateX(0);
        box-shadow: 16px 0 48px rgba(0, 0, 0, 0.28);
    }

    .app-shell.sidebar-open .app-overlay {
        display: block;
    }

    .app-topbar {
        left: 0;
    }

    .app-main {
        margin-left: 0;
    }
}

.form-shell {
    width: 100%;
    max-width: none;
}

.form-shell .panel,
form.panel {
    width: 100%;
    max-width: none;
}

/* Logos */
.brand-logo {
    height: 4rem;
    width: auto;
    max-width: 10.5rem;
    object-fit: contain;
    display: block;
}

.brand-logo-lg {
    height: 4.75rem;
    max-width: 14rem;
}

.logo-light {
    display: block;
}

.logo-dark {
    display: none;
}

.dark .logo-light {
    display: none;
}

.dark .logo-dark {
    display: block;
}

/* Sidebar nav */
.sidebar-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0.15rem 0.75rem;
    padding: 0.55rem 0.85rem;
    border-radius: 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #475569;
    transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.dark .sidebar-link {
    color: #94A3B8;
}

.sidebar-link:hover {
    background: rgba(0, 200, 83, 0.08);
    color: var(--brand-dark);
}

.dark .sidebar-link:hover {
    background: rgba(105, 240, 174, 0.08);
    color: var(--brand-light);
}

.sidebar-link.active {
    background: linear-gradient(135deg, rgba(0, 200, 83, 0.18), rgba(0, 150, 136, 0.12));
    color: #047857;
    font-weight: 600;
    box-shadow: inset 0 0 0 1px rgba(0, 200, 83, 0.22);
}

.dark .sidebar-link.active {
    background: linear-gradient(135deg, rgba(0, 200, 83, 0.22), rgba(0, 150, 136, 0.14));
    color: #69F0AE;
    box-shadow: inset 0 0 0 1px rgba(105, 240, 174, 0.28);
}

.sidebar-link.active::before {
    content: "";
    position: absolute;
    left: 0.25rem;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 1.15rem;
    border-radius: 99px;
    background: linear-gradient(180deg, var(--brand-light), var(--brand-dark));
}

.sidebar-link svg {
    opacity: 0.85;
}

/* Dropdown de grupos (ex.: Automação) */
.sidebar-group {
    margin: 0.15rem 0;
}

.sidebar-group > summary {
    list-style: none;
    cursor: pointer;
    user-select: none;
}

.sidebar-group > summary::-webkit-details-marker {
    display: none;
}

.sidebar-group__chevron {
    transition: transform 0.18s ease;
}

.sidebar-group[open] > .sidebar-group__toggle .sidebar-group__chevron,
.sidebar-group.is-open > .sidebar-group__toggle .sidebar-group__chevron {
    transform: rotate(180deg);
}

.sidebar-group__toggle.is-active-group {
    color: #047857;
}

.dark .sidebar-group__toggle.is-active-group {
    color: #69F0AE;
}

.sidebar-group__panel {
    padding: 0.15rem 0 0.35rem;
}

.sidebar-link--nested {
    margin-left: 1.15rem;
    margin-right: 0.75rem;
    padding-left: 0.75rem;
    font-size: 0.8125rem;
}

/* Brand bits */
.brand-gradient {
    background: linear-gradient(135deg, #009688 0%, #00C853 55%, #69F0AE 100%);
}

.btn-brand {
    background: linear-gradient(135deg, #00C853, #009688);
    color: #fff;
    box-shadow: 0 8px 20px rgba(0, 150, 136, 0.25);
}

.btn-brand:hover {
    filter: brightness(1.05);
}

.btn-brand:active {
    transform: translateY(1px);
}

.input-focus:focus {
    border-color: rgba(0, 200, 83, 0.55);
    box-shadow: 0 0 0 3px rgba(0, 200, 83, 0.18);
    outline: none;
}

/* Surfaces */
.panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
    color: inherit;
}

.field-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.375rem;
    color: #475569;
}

.dark .field-label {
    color: #CBD5E1;
}

.field {
    width: 100%;
    border-radius: 0.75rem;
    border: 1px solid var(--border);
    background-color: #F8FAFC;
    color: inherit;
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.dark .field {
    background-color: rgba(255, 255, 255, 0.035);
    color: #E2E8F0;
}

.field::placeholder {
    color: #94A3B8;
}

.dark .field::placeholder {
    color: #64748B;
}

.field:focus {
    border-color: rgba(0, 200, 83, 0.55);
    box-shadow: 0 0 0 3px rgba(0, 200, 83, 0.18);
}

select.field {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-color: #F8FAFC;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748B'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1rem 1rem;
    padding-right: 2.5rem;
}

.dark select.field {
    background-color: rgba(255, 255, 255, 0.035);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394A3B8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1rem 1rem;
    color: #E2E8F0;
}

select.field option {
    background-color: #ffffff;
    color: #0B1220;
}

.dark select.field option {
    background-color: #0F1623;
    color: #E2E8F0;
}

.btn-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1rem;
    border-radius: 0.75rem;
    border: 1px solid var(--border);
    font-size: 0.875rem;
    font-weight: 500;
    color: inherit;
    background: transparent;
    transition: background 0.15s ease;
}

.btn-ghost:hover {
    background: rgba(15, 23, 42, 0.04);
}

.dark .btn-ghost:hover {
    background: rgba(255, 255, 255, 0.05);
}

.topbar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 0.65rem;
    color: #64748B;
    transition: background 0.15s ease, color 0.15s ease;
}

.topbar-btn:hover {
    background: rgba(15, 23, 42, 0.06);
    color: var(--ink);
}

.dark .topbar-btn:hover {
    background: rgba(148, 163, 184, 0.1);
    color: #E2E8F0;
}

/* Icon action buttons in tables */
.action-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 0.6rem;
    color: #64748B;
    border: 1px solid transparent;
    transition: all 0.15s ease;
}

.action-icon:hover {
    background: rgba(0, 200, 83, 0.1);
    color: #047857;
    border-color: rgba(0, 200, 83, 0.2);
}

.action-icon.danger:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #DC2626;
    border-color: rgba(239, 68, 68, 0.2);
}

.action-icon.warn:hover {
    background: rgba(245, 158, 11, 0.12);
    color: #D97706;
    border-color: rgba(245, 158, 11, 0.25);
}

.action-icon.success:hover {
    background: rgba(16, 185, 129, 0.12);
    color: #059669;
    border-color: rgba(16, 185, 129, 0.25);
}

/* Login */
.login-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.05fr 0.95fr;
}

.login-hero {
    position: relative;
    overflow: hidden;
    background:
        radial-gradient(ellipse 80% 60% at 20% 20%, rgba(0, 200, 83, 0.28), transparent 55%),
        radial-gradient(ellipse 70% 50% at 80% 80%, rgba(0, 150, 136, 0.35), transparent 50%),
        linear-gradient(160deg, #061018 0%, #0B1220 45%, #0E1A24 100%);
    color: #fff;
    padding: 3rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.login-hero::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: radial-gradient(ellipse at center, black 20%, transparent 75%);
    pointer-events: none;
}

.login-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.5rem;
    background:
        radial-gradient(circle at top right, rgba(0, 200, 83, 0.08), transparent 40%),
        var(--surface);
}

.login-card {
    width: 100%;
    max-width: 26rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 1.25rem;
    padding: 2rem;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.08);
}

.dark .login-card {
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

.field-wrap {
    position: relative;
}

.field-wrap .eye-toggle {
    position: absolute;
    right: 0.65rem;
    top: 50%;
    transform: translateY(-50%);
    width: 2rem;
    height: 2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #94A3B8;
    border-radius: 0.5rem;
}

.field-wrap .eye-toggle:hover {
    color: var(--brand-dark);
    background: rgba(0, 200, 83, 0.08);
}

.field-wrap .field.has-eye,
.field-wrap input.has-eye {
    padding-right: 2.75rem;
}

@media (max-width: 960px) {
    .login-shell {
        grid-template-columns: 1fr;
    }

    .login-hero {
        min-height: 12rem;
        padding: 1.75rem;
    }

    .login-hero .hero-copy {
        display: none;
    }
}

.flash-enter {
    animation: flashSlide 0.25s ease-out;
}

@keyframes flashSlide {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-up {
    animation: fadeUp 0.45s ease-out both;
}

.kanban-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    color: inherit;
}

.kanban-column {
    background: rgba(15, 23, 42, 0.04);
    border: 1px solid var(--border);
    border-radius: 0.875rem;
}

.dark .kanban-column {
    background: rgba(255, 255, 255, 0.03);
}

/* —— PWA install (mobile only) —— */
.pwa-install-btn {
    display: none;
    position: fixed;
    right: auto;
    left: 1rem;
    bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
    z-index: 60;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.1rem;
    border-radius: 999px;
    border: none;
    background: linear-gradient(135deg, #00C853, #009688);
    color: #fff;
    font-size: 0.875rem;
    font-weight: 600;
    box-shadow: 0 8px 28px rgba(0, 150, 136, 0.35);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.pwa-install-btn:active {
    transform: scale(0.97);
}

.pwa-ios-tip {
    display: none;
    position: fixed;
    left: 1rem;
    right: 1rem;
    bottom: calc(5.5rem + env(safe-area-inset-bottom, 0px));
    z-index: 61;
    padding: 1rem 1.25rem 1rem 1rem;
    border-radius: 1rem;
    background: var(--card);
    border: 1px solid var(--border);
    box-shadow: 0 12px 40px rgba(15, 23, 42, 0.18);
}

.pwa-ios-tip-close {
    position: absolute;
    top: 0.35rem;
    right: 0.5rem;
    width: 1.75rem;
    height: 1.75rem;
    border: none;
    background: transparent;
    color: var(--muted);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
}

@media (max-width: 768px) {
    .pwa-install-btn:not([hidden]) {
        display: inline-flex;
    }
    .pwa-ios-tip:not([hidden]) {
        display: block;
    }
}

@media (min-width: 769px) {
    .pwa-install-btn,
    .pwa-ios-tip {
        display: none !important;
    }
}

@media (display-mode: standalone), (display-mode: fullscreen) {
    .pwa-install-btn,
    .pwa-ios-tip {
        display: none !important;
    }
}
.bg-brand {
    --tw-bg-opacity: 1;
    background-color: #009962 !important;
}

.msg-ad-preview {
    display: block;
    overflow: hidden;
    border-radius: 0.75rem;
    margin-bottom: 0.5rem;
    text-decoration: none;
    color: inherit;
    background: rgba(15, 23, 42, 0.06);
    border: 1px solid rgba(148, 163, 184, 0.35);
}
.dark .msg-ad-preview,
.bg-brand .msg-ad-preview {
    background: rgba(0, 0, 0, 0.18);
    border-color: rgba(255, 255, 255, 0.18);
}
.msg-ad-preview__media {
    display: block;
    width: 100%;
    max-height: 10rem;
    object-fit: cover;
    background: rgba(0, 0, 0, 0.2);
}
.msg-ad-preview__body {
    padding: 0.55rem 0.7rem 0.65rem;
}
.msg-ad-preview__title {
    font-weight: 600;
    font-size: 0.8125rem;
    line-height: 1.3;
}
.msg-ad-preview__text {
    margin-top: 0.15rem;
    font-size: 0.75rem;
    opacity: 0.85;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.msg-ad-preview__host {
    margin-top: 0.25rem;
    font-size: 0.6875rem;
    opacity: 0.65;
    text-transform: lowercase;
}
.msg-ad-preview__badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    margin-bottom: 0.35rem;
    font-size: 0.625rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    opacity: 0.8;
}

/* WhatsApp-style message context menu + reaction bar */
.msg-bubble-wrap {
    position: relative;
    max-width: 75%;
}
.msg-bubble-wrap .msg-bubble {
    position: relative;
}
.msg-menu-btn {
    position: absolute;
    top: 0.15rem;
    right: 0.15rem;
    width: 1.5rem;
    height: 1.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9999px;
    opacity: 0;
    transition: opacity 0.15s ease, background 0.15s ease;
    background: rgba(0, 0, 0, 0.12);
    color: inherit;
    z-index: 2;
    border: 0;
    cursor: pointer;
    padding: 0;
}
.msg-bubble-wrap:hover .msg-menu-btn,
.msg-bubble-wrap.msg-menu-open .msg-menu-btn,
.msg-menu-btn:focus-visible {
    opacity: 1;
}
.msg-bubble-wrap--in .msg-menu-btn {
    right: auto;
    left: 0.15rem;
}
.dark .msg-bubble-wrap--in .msg-menu-btn,
.msg-bubble-wrap--out .msg-menu-btn {
    background: rgba(0, 0, 0, 0.2);
}
.msg-menu-btn svg {
    width: 0.9rem;
    height: 0.9rem;
}
.msg-ctx {
    position: fixed;
    z-index: 80;
    min-width: 11.5rem;
    padding: 0.35rem 0;
    border-radius: 0.75rem;
    background: #1f2c34;
    color: #e9edef;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.06);
}
.msg-ctx[hidden] {
    display: none !important;
}
.msg-ctx button {
    display: flex;
    width: 100%;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 0.9rem;
    font-size: 0.875rem;
    text-align: left;
    background: transparent;
    border: 0;
    color: inherit;
    cursor: pointer;
}
.msg-ctx button:hover,
.msg-ctx button:focus-visible {
    background: rgba(255, 255, 255, 0.08);
}
.msg-ctx button.msg-ctx--danger {
    color: #f87171;
}
.msg-ctx__sep {
    height: 1px;
    margin: 0.25rem 0;
    background: rgba(255, 255, 255, 0.1);
}
.msg-ctx svg {
    width: 1.05rem;
    height: 1.05rem;
    flex-shrink: 0;
    opacity: 0.9;
}
.msg-react-bar {
    position: fixed;
    z-index: 81;
    display: flex;
    align-items: center;
    gap: 0.15rem;
    padding: 0.35rem 0.45rem;
    border-radius: 9999px;
    background: #1f2c34;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.06);
}
.msg-react-bar[hidden] {
    display: none !important;
}
.msg-react-bar button {
    width: 2.1rem;
    height: 2.1rem;
    border: 0;
    border-radius: 9999px;
    background: transparent;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.msg-react-bar button:hover,
.msg-react-bar button:focus-visible {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.12);
}
.msg-react-more {
    color: #e9edef;
    font-size: 0 !important;
}
.msg-react-more svg {
    width: 1.05rem;
    height: 1.05rem;
}
.msg-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem;
    margin-top: -0.35rem;
    margin-bottom: 0.15rem;
    padding: 0 0.35rem;
    position: relative;
    z-index: 1;
}
.msg-bubble-wrap--out .msg-reactions {
    justify-content: flex-end;
}
.msg-bubble-wrap--in .msg-reactions {
    justify-content: flex-start;
}
.msg-reaction {
    display: inline-flex;
    align-items: center;
    gap: 0.15rem;
    min-height: 1.35rem;
    padding: 0.1rem 0.4rem;
    border-radius: 9999px;
    background: #fff;
    border: 1px solid rgb(226 232 240);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
    font-size: 0.85rem;
    line-height: 1;
}
.dark .msg-reaction {
    background: #0f172a;
    border-color: rgb(51 65 85);
}
.msg-reaction__count {
    font-size: 0.65rem;
    font-weight: 600;
    color: rgb(100 116 139);
}
.dark .msg-reaction__count {
    color: rgb(148 163 184);
}
.msg-emoji-picker {
    position: fixed;
    z-index: 82;
    width: min(18.5rem, calc(100vw - 1rem));
    max-height: min(16rem, 50vh);
    display: flex;
    flex-direction: column;
    border-radius: 0.85rem;
    background: #1f2c34;
    color: #e9edef;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.08);
    overflow: hidden;
}
.msg-emoji-picker[hidden] {
    display: none !important;
}
.msg-emoji-picker__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.55rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.msg-emoji-picker__head button {
    border: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
    opacity: 0.7;
    font-size: 0.85rem;
    line-height: 1;
    padding: 0.15rem 0.35rem;
}
.msg-emoji-picker__head button:hover,
.msg-emoji-picker__head button:focus-visible {
    opacity: 1;
}
.msg-emoji-picker__grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 0.1rem;
    padding: 0.45rem;
    overflow-y: auto;
    overscroll-behavior: contain;
}
.msg-emoji-picker__grid button {
    width: 100%;
    aspect-ratio: 1;
    border: 0;
    border-radius: 0.45rem;
    background: transparent;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.msg-emoji-picker__grid button:hover,
.msg-emoji-picker__grid button:focus-visible {
    background: rgba(255, 255, 255, 0.1);
}
.msg-reply-preview {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    padding: 0.55rem 0.75rem;
    border-radius: 0.75rem;
    border: 1px solid rgb(226 232 240);
    background: rgb(248 250 252);
}
.dark .msg-reply-preview {
    border-color: rgb(51 65 85);
    background: rgb(15 23 42 / 0.7);
}
.msg-reply-preview__bar {
    width: 3px;
    align-self: stretch;
    border-radius: 9999px;
    background: var(--color-brand, #25d366);
    flex-shrink: 0;
}
.msg-reply-preview__label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--color-brand, #25d366);
}
.msg-reply-preview__text {
    font-size: 0.8rem;
    color: rgb(100 116 139);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.dark .msg-reply-preview__text {
    color: rgb(148 163 184);
}
.msg-quote {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
    padding: 0.35rem 0.5rem;
    border-radius: 0.5rem;
    background: rgba(0, 0, 0, 0.08);
    font-size: 0.75rem;
    line-height: 1.3;
}
.msg-bubble-wrap--out .msg-quote {
    background: rgba(0, 0, 0, 0.15);
}
.msg-quote__bar {
    width: 3px;
    border-radius: 9999px;
    background: currentColor;
    opacity: 0.55;
    flex-shrink: 0;
}
.msg-quote__text {
    opacity: 0.9;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.msg-fwd-modal {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(15, 23, 42, 0.55);
}
.msg-fwd-modal[hidden] {
    display: none !important;
}
.msg-fwd-panel {
    width: min(28rem, 100%);
    max-height: min(32rem, 85vh);
    display: flex;
    flex-direction: column;
    border-radius: 1rem;
    background: #fff;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
    overflow: hidden;
}
.dark .msg-fwd-panel {
    background: #0f172a;
    border: 1px solid rgb(51 65 85);
}
.msg-fwd-list {
    overflow-y: auto;
    flex: 1;
}
.msg-fwd-item {
    display: flex;
    width: 100%;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    text-align: left;
    border: 0;
    background: transparent;
    cursor: pointer;
    color: inherit;
}
.msg-fwd-item:hover,
.msg-fwd-item:focus-visible {
    background: rgb(241 245 249);
}
.dark .msg-fwd-item:hover,
.dark .msg-fwd-item:focus-visible {
    background: rgb(30 41 59);
}
@media (hover: none) {
    .msg-menu-btn {
        opacity: 0.85;
    }
}

/* WhatsApp-style delivery ticks on outbound bubbles */
.msg-ticks {
    display: inline-flex;
    align-items: center;
    line-height: 1;
    flex-shrink: 0;
}
.msg-ticks svg {
    width: 1rem;
    height: 0.7rem;
    display: block;
}
.msg-ticks--pending,
.msg-ticks--queued {
    opacity: 0.65;
}
.msg-ticks--sent,
.msg-ticks--delivered {
    opacity: 0.85;
}
.msg-ticks--read {
    opacity: 1;
    color: #53bdeb;
}
.msg-ticks--failed {
    opacity: 1;
    color: #fecaca;
}
.msg-ticks--failed svg {
    width: 0.75rem;
    height: 0.75rem;
}

.wa-msg-body .wa-fmt-bold {
    font-weight: 700;
}
.wa-msg-body .wa-fmt-italic {
    font-style: italic;
}
.wa-msg-body .wa-fmt-strike {
    text-decoration: line-through;
}
.wa-msg-body .wa-fmt-mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.9em;
    padding: 0.05em 0.25em;
    border-radius: 0.25rem;
    background: rgba(0, 0, 0, 0.12);
}
.dark .wa-msg-body .wa-fmt-mono,
.bg-brand .wa-msg-body .wa-fmt-mono {
    background: rgba(255, 255, 255, 0.14);
}

/* Compact audio player — native <audio controls> menus clip inside narrow bubbles on mobile */
.msg-audio-player {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin-top: 0.35rem;
    min-width: 11.5rem;
    max-width: 100%;
    padding: 0.35rem 0.15rem 0.15rem;
}
.msg-audio-play {
    flex-shrink: 0;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 9999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.12);
    color: inherit;
    border: 0;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.bg-brand .msg-audio-play {
    background: rgba(255, 255, 255, 0.22);
}
.msg-audio-play svg {
    width: 1rem;
    height: 1rem;
}
.msg-audio-track {
    flex: 1;
    min-width: 0;
    height: 0.3rem;
    border-radius: 9999px;
    background: rgba(0, 0, 0, 0.14);
    overflow: hidden;
}
.bg-brand .msg-audio-track {
    background: rgba(255, 255, 255, 0.28);
}
.msg-audio-bar {
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: currentColor;
    opacity: 0.85;
    transition: width 0.1s linear;
}
.msg-audio-time {
    flex-shrink: 0;
    font-size: 0.7rem;
    opacity: 0.8;
    font-variant-numeric: tabular-nums;
    min-width: 2.1rem;
    text-align: right;
}
.msg-audio-el {
    display: none !important;
}

.composer-file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
    opacity: 0;
    pointer-events: none;
}

/* Inbox layout: bottom nav (mobile attendants) */
.inbox-mobile-nav {
    display: none;
}

@media (max-width: 768px) {
    :root {
        --inbox-mobile-nav-h: calc(3.25rem + env(safe-area-inset-bottom, 0px));
    }

    .inbox-mobile-nav {
        display: flex;
        align-items: stretch;
        justify-content: space-around;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 55;
        height: var(--inbox-mobile-nav-h);
        padding-bottom: env(safe-area-inset-bottom, 0px);
        box-sizing: border-box;
        background: var(--card);
        border-top: 1px solid var(--border);
        box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.08);
    }

    .inbox-mobile-nav__item,
    .inbox-mobile-nav__more > summary {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.15rem;
        font-size: 0.65rem;
        font-weight: 600;
        color: var(--muted);
        text-decoration: none;
        list-style: none;
        cursor: pointer;
        user-select: none;
    }

    .inbox-mobile-nav__item.is-active,
    .inbox-mobile-nav__more[open] > summary {
        color: var(--brand, #00c853);
    }

    .inbox-mobile-nav__more {
        flex: 1;
        position: relative;
    }

    .inbox-mobile-nav__menu {
        position: absolute;
        bottom: calc(100% + 0.35rem);
        right: 0.5rem;
        min-width: 10rem;
        background: var(--card);
        border: 1px solid var(--border);
        border-radius: 0.75rem;
        box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
        overflow: hidden;
        z-index: 60;
    }

    .inbox-mobile-nav__menu a {
        display: block;
        padding: 0.65rem 1rem;
        font-size: 0.8125rem;
        font-weight: 500;
        color: inherit;
        text-decoration: none;
        border-bottom: 1px solid var(--border);
    }

    .inbox-mobile-nav__menu a:last-child {
        border-bottom: none;
    }

    body:has(.inbox-mobile-nav) .app-main main {
        padding-bottom: 0;
        max-height: calc(100dvh - var(--topbar-h) - var(--inbox-mobile-nav-h));
        height: calc(100dvh - var(--topbar-h) - var(--inbox-mobile-nav-h));
    }

    /* Composer sits flush on the mobile nav (nav already owns the safe-area). */
    body:has(.inbox-mobile-nav) #composer-bar {
        padding-bottom: 0.5rem !important;
    }

    .contact-drawer-fab {
        right: 1rem;
        bottom: calc(var(--inbox-mobile-nav-h, 3.25rem) + 4.5rem);
    }
}

/* —— Data tables → cards (mobile) —— */
@media (max-width: 768px) {
    .table-cards-wrap {
        overflow-x: visible !important;
    }

    table.table-cards {
        display: block;
        width: 100%;
        min-width: 0 !important;
        border-collapse: separate;
        border-spacing: 0;
    }

    table.table-cards thead {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }

    table.table-cards tbody {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }

    table.table-cards tbody tr {
        display: block;
        background: var(--card);
        border: 1px solid var(--border);
        border-radius: 0.9rem;
        padding: 0.65rem 0.85rem;
        box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    }

    .dark table.table-cards tbody tr {
        box-shadow: none;
        background: rgba(15, 22, 35, 0.92);
    }

    /* Avoid double frame spacing when already inside .panel */
    .panel > .overflow-x-auto > table.table-cards tbody,
    .panel.overflow-hidden > .overflow-x-auto > table.table-cards tbody {
        gap: 0.65rem;
        padding: 0.65rem;
    }

    table.table-cards tbody tr.hover\:bg-slate-50:hover,
    table.table-cards tbody tr:hover {
        background: var(--card);
    }

    .dark table.table-cards tbody tr:hover {
        background: rgba(15, 22, 35, 0.92);
    }

    table.table-cards tbody tr.table-cards__empty {
        text-align: center;
        padding: 1.5rem 1rem;
        color: #64748b;
    }

    table.table-cards tbody tr.table-cards__empty td {
        display: block;
        padding: 0 !important;
        border: none !important;
    }

    table.table-cards tbody tr.table-cards__empty td::before {
        display: none;
    }

    table.table-cards tbody td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 0.75rem;
        width: 100%;
        padding: 0.45rem 0 !important;
        border: none !important;
        text-align: right;
        word-break: break-word;
    }

    table.table-cards tbody td + td {
        border-top: 1px solid var(--border) !important;
    }

    table.table-cards tbody td::before {
        content: attr(data-label);
        flex: 0 0 auto;
        max-width: 42%;
        font-size: 0.68rem;
        font-weight: 650;
        letter-spacing: 0.03em;
        text-transform: uppercase;
        color: #64748b;
        text-align: left;
        line-height: 1.35;
        padding-top: 0.15rem;
    }

    table.table-cards tbody td > * {
        min-width: 0;
        max-width: 62%;
    }

    /* First column (usually name) as card title */
    table.table-cards tbody td:first-child {
        flex-direction: column;
        align-items: stretch;
        gap: 0.15rem;
        text-align: left;
        padding-bottom: 0.55rem !important;
        border-top: none !important;
    }

    table.table-cards tbody td:first-child::before {
        display: none;
    }

    table.table-cards tbody td:first-child > * {
        max-width: 100%;
    }

    table.table-cards tbody td.table-cards__actions {
        justify-content: flex-end;
        align-items: center;
        padding-top: 0.7rem !important;
        border-top: 1px solid var(--border) !important;
    }

    table.table-cards tbody td.table-cards__actions::before {
        display: none;
    }

    table.table-cards tbody td.table-cards__actions > * {
        max-width: 100%;
    }

    table.table-cards tbody td.table-cards__blank::before {
        display: none;
    }

    table.table-cards tbody td.table-cards__blank {
        justify-content: flex-end;
    }
}
