* {
    box-sizing: border-box;
}

:root {
    --bg: #f5efe5;
    --panel: #fffdf8;
    --accent: #0d8a7b;
    --accent-soft: rgba(13, 138, 123, 0.14);
    --ink: #1f2b2c;
    --muted: #67767a;
    --line: rgba(31, 43, 44, 0.12);
    --danger: #c73b30;
    --warning: #c5851f;
    --shadow: 0 18px 40px rgba(63, 51, 37, 0.12);
}

body {
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(255, 221, 166, 0.45), transparent 28%),
        linear-gradient(180deg, #fbf7ef 0%, #f4ede2 100%);
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

a {
    color: inherit;
}

.layout-shell {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    grid-template-columns: 280px 1fr;
    align-items: stretch;
}

.sidebar {
    background: #102126;
    color: #eef4f1;
    padding: 28px 22px;
    position: sticky;
    top: 0;
    align-self: stretch;
    min-height: 100vh;
    min-height: 100dvh;
    height: auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.brand-block h1,
.page-intro h2,
.panel h3,
.metric-card h3 {
    margin: 0;
}

.eyebrow {
    margin: 0 0 8px;
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.18em;
    color: #8fd6cc;
}

.nav-list {
    display: grid;
    gap: 6px;
    margin-top: 26px;
}

.nav-list a {
    text-decoration: none;
    padding: 12px 14px;
    border-radius: 14px;
    color: #e6f1ef;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-list a.active,
.nav-list a:hover {
    background: rgba(255, 255, 255, 0.08);
}

.pill {
    min-width: 24px;
    height: 24px;
    display: inline-grid;
    place-items: center;
    border-radius: 999px;
    background: #ff805c;
    color: white;
    font-size: 0.8rem;
}

.pill.is-hidden {
    display: none;
}

.main-area {
    padding: 24px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 22px;
}

.page-intro p,
.brand-block p {
    margin: 6px 0 0;
    color: var(--muted);
}

.content-shell {
    display: grid;
    gap: 18px;
}

.panel,
.metric-card,
.login-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 24px;
    padding: 22px;
    box-shadow: var(--shadow);
}

.grid {
    display: grid;
    gap: 18px;
}

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

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

.metric-card {
    background: linear-gradient(180deg, #fffefc 0%, #fff8ed 100%);
}

.metric-card strong {
    display: block;
    margin-top: 12px;
    font-size: 2rem;
}

.table-wrap {
    overflow: auto;
}

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

th,
td {
    text-align: left;
    padding: 14px 10px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

th {
    font-size: 0.82rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.stack {
    display: grid;
    gap: 14px;
}

.stack.two-columns {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

label {
    display: grid;
    gap: 8px;
    font-weight: 600;
}

input,
select,
textarea {
    width: 100%;
    border-radius: 14px;
    border: 1px solid rgba(31, 43, 44, 0.16);
    background: white;
    padding: 12px 14px;
    color: var(--ink);
    font: inherit;
}

textarea {
    min-height: 120px;
    resize: vertical;
}

.button,
button {
    border: 0;
    border-radius: 14px;
    padding: 12px 18px;
    font: inherit;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.button-primary,
button,
.button {
    background: var(--accent);
    color: white;
}

.button-light {
    background: rgba(16, 33, 38, 0.08);
    color: var(--ink);
}

.button-danger {
    background: var(--danger);
    color: white;
}

.button-warning {
    background: var(--warning);
    color: white;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
}

.toolbar form {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: end;
}

.flash {
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid transparent;
}

.flash-success {
    background: rgba(13, 138, 123, 0.12);
    border-color: rgba(13, 138, 123, 0.25);
}

.flash-error {
    background: rgba(199, 59, 48, 0.12);
    border-color: rgba(199, 59, 48, 0.24);
}

.flash-warning {
    background: rgba(197, 133, 31, 0.12);
    border-color: rgba(197, 133, 31, 0.24);
}

.stats-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.stat-chip {
    padding: 10px 14px;
    border-radius: 999px;
    background: var(--accent-soft);
}

.split {
    display: grid;
    gap: 18px;
    grid-template-columns: 1.5fr 1fr;
}

.empty-state {
    padding: 24px;
    border-radius: 18px;
    background: rgba(16, 33, 38, 0.04);
    color: var(--muted);
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-shell {
    width: min(780px, 100%);
}

.login-card {
    display: grid;
    gap: 20px;
}

.wide-card {
    max-width: 920px;
    margin: 0 auto;
}

.chat-layout {
    display: grid;
    gap: 18px;
    grid-template-columns: 320px minmax(0, 1fr);
    align-items: start;
}

.chat-sidebar,
.chat-detail {
    min-width: 0;
}

.chat-sidebar-head,
.chat-detail-head {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 16px;
}

.chat-sidebar-head p,
.chat-detail-head p {
    margin: 6px 0 0;
    color: var(--muted);
}

.chat-conversation-list {
    display: grid;
    gap: 10px;
    max-height: 72vh;
    overflow: auto;
    padding-right: 4px;
}

.chat-conversation-card {
    display: grid;
    gap: 8px;
    padding: 14px;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.74);
    text-decoration: none;
    transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease;
}

.chat-conversation-card:hover,
.chat-conversation-card.active {
    border-color: rgba(13, 138, 123, 0.36);
    background: rgba(13, 138, 123, 0.10);
    transform: translateY(-1px);
}

.chat-conversation-card p {
    margin: 0;
    color: var(--muted);
}

.chat-conversation-top,
.chat-conversation-meta {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}

.chat-conversation-meta {
    font-size: 0.85rem;
    color: var(--muted);
}

.chat-thread {
    max-height: 65vh;
    overflow: auto;
    padding-right: 6px;
}

.chat-form {
    margin-top: 16px;
}

.whatsapp-thread {
    display: grid;
    gap: 12px;
}

.whatsapp-layout {
    display: grid;
    gap: 18px;
    grid-template-columns: 340px minmax(0, 1fr);
    align-items: start;
}

.whatsapp-sidebar,
.whatsapp-detail {
    min-width: 0;
}

.whatsapp-sidebar-head,
.whatsapp-detail-head {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 16px;
}

.whatsapp-sidebar-head p,
.whatsapp-detail-head p {
    margin: 6px 0 0;
    color: var(--muted);
}

.whatsapp-conversation-list {
    display: grid;
    gap: 10px;
    max-height: 72vh;
    overflow: auto;
    padding-right: 4px;
}

.whatsapp-conversation-card {
    display: grid;
    gap: 8px;
    padding: 14px;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.74);
    text-decoration: none;
    transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease;
}

.whatsapp-conversation-card:hover,
.whatsapp-conversation-card.active {
    border-color: rgba(13, 138, 123, 0.36);
    background: rgba(13, 138, 123, 0.10);
    transform: translateY(-1px);
}

.whatsapp-conversation-card p {
    margin: 0;
    color: var(--muted);
}

.whatsapp-conversation-top,
.whatsapp-conversation-meta {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}

.whatsapp-conversation-meta {
    font-size: 0.85rem;
    color: var(--muted);
}

.whatsapp-thread-panel {
    margin-top: 18px;
    max-height: 70vh;
    overflow: auto;
    padding-right: 6px;
}

.whatsapp-message {
    max-width: 720px;
    padding: 14px 16px;
    border-radius: 20px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.9);
}

.whatsapp-message.outbound {
    justify-self: end;
    background: rgba(13, 138, 123, 0.12);
}

.whatsapp-message-meta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 0.82rem;
    color: var(--muted);
    margin-bottom: 8px;
}

.whatsapp-message-caption {
    margin-top: 10px;
    color: var(--muted);
}

.whatsapp-reply-form {
    margin-top: 16px;
}

/* WhatsApp-like chat UI */
.wa-app.whatsapp-layout {
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 0;
    padding: 0;
    overflow: hidden;
}

.wa-sidebar {
    border-right: 1px solid #d1d7db;
    background: #fff;
    min-height: 72vh;
}

.wa-sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    background: #f0f2f5;
    border-bottom: 1px solid #d1d7db;
}

.wa-sidebar-head h3 {
    margin: 0;
    font-size: 1rem;
}

.wa-sidebar-head span {
    color: var(--muted);
    font-size: 0.85rem;
}

.wa-chat-list {
    max-height: calc(72vh - 58px);
}

.wa-chat-item {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    border-radius: 0;
    border: 0;
    border-bottom: 1px solid #f0f2f5;
    background: #fff;
    padding: 12px 16px;
}

.wa-chat-item:hover,
.wa-chat-item.active {
    background: #f0f2f5;
    transform: none;
}

.wa-chat-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: #dfe5e7;
    color: #54656f;
    font-weight: 700;
}

.wa-chat-item-body {
    min-width: 0;
}

.wa-chat-item-body p {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wa-chat-pane {
    display: flex;
    flex-direction: column;
    min-height: 72vh;
    background: #efeae2;
    border-radius: 0;
    overflow: hidden;
    position: relative;
}

.wa-chat-pane.is-loading::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(239, 234, 226, 0.55);
    pointer-events: none;
    z-index: 2;
}

.wa-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    background: #f0f2f5;
    border-bottom: 1px solid #d1d7db;
}

.wa-chat-header-main {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    border: 0;
    background: transparent;
    padding: 0;
    text-align: left;
    cursor: pointer;
    color: inherit;
    font: inherit;
}

.wa-chat-header-main:hover .wa-chat-header-text h3 {
    text-decoration: underline;
}

.wa-chat-header-text {
    min-width: 0;
}

.wa-chat-header h3,
.wa-chat-header p {
    margin: 0;
}

.wa-chat-header h3 {
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wa-chat-header p {
    color: #667781;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wa-chat-header-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.wa-chat-pane {
    position: relative;
}

.wa-profile-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(360px, 100%);
    z-index: 30;
    background: #fff;
    border-left: 1px solid #d1d7db;
    box-shadow: -8px 0 24px rgba(11, 20, 26, 0.12);
    display: flex;
    flex-direction: column;
}

.wa-profile-panel[hidden] {
    display: none !important;
}

.wa-profile-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    background: #008069;
    color: #fff;
}

.wa-profile-panel-head h3 {
    margin: 0;
    font-size: 1rem;
}

.wa-profile-close {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    cursor: pointer;
}

.wa-profile-panel-body {
    padding: 24px 18px;
    overflow: auto;
    display: grid;
    gap: 14px;
    justify-items: center;
}

.wa-profile-avatar {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: #dfe5e7;
    color: #54656f;
    font-size: 2rem;
    font-weight: 700;
}

.wa-profile-phone {
    color: #667781;
    font-size: 0.95rem;
}

.wa-profile-form {
    width: 100%;
    display: grid;
    gap: 12px;
}

.wa-profile-form label {
    display: grid;
    gap: 6px;
}

.wa-profile-form span {
    color: #667781;
    font-size: 0.82rem;
}

.wa-profile-form input,
.wa-profile-form textarea {
    width: 100%;
    border: 1px solid #d1d7db;
    border-radius: 10px;
    padding: 10px 12px;
    font: inherit;
    background: #fff;
}

.wa-profile-form textarea {
    resize: vertical;
    min-height: 110px;
}

.wa-chat-subheader {
    padding: 8px 16px;
    background: #fafafa;
    color: #667781;
    font-size: 0.82rem;
    border-bottom: 1px solid #e9edef;
}

.wa-chat-body {
    flex: 1;
    min-height: 0;
    background:
        linear-gradient(rgba(229, 221, 213, 0.92), rgba(229, 221, 213, 0.92)),
        url("data:image/svg+xml,%3Csvg width='80' height='80' viewBox='0 0 80 80' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23d9d0c6' fill-opacity='0.35'%3E%3Cpath d='M0 0h20v20H0zM40 40h20v20H40zM20 20h20v20H20zM60 0h20v20H60zM0 60h20v20H0zM60 60h20v20H60z'/%3E%3C/g%3E%3C/svg%3E");
}

.wa-chat-thread {
    height: 100%;
    max-height: calc(72vh - 170px);
    overflow-y: auto;
    padding: 18px 24px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.wa-bubble {
    display: flex;
    max-width: min(72%, 520px);
}

.wa-date-sep {
    align-self: center;
    margin: 10px 0 8px;
    max-width: 100%;
}

.wa-date-sep span {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 1px 1px rgba(11, 20, 26, 0.08);
    color: #54656f;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: none;
}

.wa-bubble.is-in {
    align-self: flex-start;
}

.wa-bubble.is-out {
    align-self: flex-end;
}

.wa-bubble-body {
    position: relative;
    padding: 6px 8px 20px;
    border-radius: 8px;
    box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
    background: #fff;
    min-width: 80px;
}

.wa-bubble.is-out .wa-bubble-body {
    background: #d9fdd3;
}

.wa-bubble.is-reply-target .wa-bubble-body {
    outline: 2px solid rgba(0, 168, 132, 0.55);
}

.wa-quote {
    display: grid;
    gap: 2px;
    margin: 0 0 6px;
    padding: 6px 8px 6px 10px;
    border-radius: 6px;
    border-left: 4px solid #53bdeb;
    background: rgba(11, 20, 26, 0.06);
    cursor: default;
}

.wa-bubble.is-out .wa-quote {
    border-left-color: #06cf9c;
    background: rgba(0, 0, 0, 0.06);
}

.wa-quote-author {
    font-size: 0.78rem;
    font-weight: 600;
    color: #027eb5;
    line-height: 1.2;
}

.wa-bubble.is-out .wa-quote-author {
    color: #1fa855;
}

.wa-quote-text {
    font-size: 0.82rem;
    color: #667781;
    line-height: 1.3;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.wa-reply-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 26px;
    height: 26px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    color: #54656f;
    font-size: 0.85rem;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    box-shadow: 0 1px 3px rgba(11, 20, 26, 0.18);
    transition: opacity 0.12s ease;
}

.wa-bubble.is-out .wa-reply-btn {
    right: auto;
    left: 4px;
}

.wa-bubble:hover .wa-reply-btn,
.wa-bubble:focus-within .wa-reply-btn {
    opacity: 1;
    pointer-events: auto;
}

.wa-reply-btn:hover {
    background: #fff;
    color: #111b21;
}

.wa-reply-bar {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    align-items: center;
    padding: 8px 16px;
    background: #f0f2f5;
    border-top: 1px solid #d1d7db;
}

.wa-reply-bar[hidden] {
    display: none !important;
}

.wa-reply-bar-main {
    min-width: 0;
    padding: 6px 10px;
    border-left: 4px solid #00a884;
    border-radius: 8px;
    background: #fff;
}

.wa-reply-bar-author {
    font-size: 0.8rem;
    font-weight: 600;
    color: #00a884;
}

.wa-reply-bar-text {
    font-size: 0.85rem;
    color: #667781;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wa-reply-bar-close {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #54656f;
    font-size: 1rem;
    cursor: pointer;
}

.wa-reply-bar-close:hover {
    background: rgba(0, 0, 0, 0.06);
}

.wa-bubble-text,
.wa-bubble-caption {
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.95rem;
    line-height: 1.45;
}

.wa-bubble-caption {
    margin-top: 4px;
    color: #667781;
    font-size: 0.85rem;
}

.wa-bubble-meta {
    position: absolute;
    right: 8px;
    bottom: 4px;
    display: flex;
    gap: 4px;
    align-items: center;
    font-size: 0.68rem;
    color: #667781;
}

.wa-bubble-status {
    color: #53bdeb;
}

.wa-media-image,
.wa-media-image img {
    display: block;
    max-width: 280px;
    border-radius: 6px;
}

.wa-media-image img {
    width: 100%;
    height: auto;
}

.wa-bubble.is-sticker {
    max-width: 120px !important;
}

.wa-bubble.is-sticker .wa-bubble-body,
.wa-bubble.is-sticker .wa-bubble-body.is-sticker {
    background: transparent !important;
    box-shadow: none !important;
    padding: 0 2px 16px !important;
    min-width: 0 !important;
}

.wa-media-sticker {
    display: block;
    line-height: 0;
}

.wa-media-sticker img,
.wa-bubble.is-sticker img,
.wa-bubble.is-sticker .wa-media-image img,
.wa-bubble.is-sticker .wa-media-image {
    display: block !important;
    width: 96px !important;
    max-width: 96px !important;
    height: auto !important;
    max-height: 96px !important;
    object-fit: contain !important;
    background: transparent !important;
    border-radius: 0 !important;
}

.wa-media-audio,
.wa-media-video {
    display: block;
    width: min(280px, 100%);
    margin-bottom: 4px;
}

.wa-voice {
    display: grid;
    grid-template-columns: 42px 28px minmax(140px, 1fr);
    gap: 8px;
    align-items: center;
    min-width: 220px;
    max-width: 280px;
    margin: 2px 0 6px;
    user-select: none;
}

.wa-voice audio {
    display: none;
}

.wa-voice-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(145deg, #6b4f3a, #3d2a22);
    position: relative;
    flex: 0 0 auto;
}

.wa-voice-avatar::after {
    content: '';
    position: absolute;
    inset: 10px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
}

.wa-voice-mic {
    position: absolute;
    right: -2px;
    bottom: -2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #00a884;
    color: #fff;
    font-size: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 0 2px #d9fdd3;
    z-index: 1;
}

.wa-bubble.is-in .wa-voice-mic {
    box-shadow: 0 0 0 2px #fff;
}

.wa-voice-play {
    width: 28px;
    height: 28px;
    border: 0;
    padding: 0;
    background: transparent;
    color: #54656f;
    font-size: 0.95rem;
    line-height: 1;
    cursor: pointer;
}

.wa-bubble.is-out .wa-voice-play {
    color: #1f2c34;
}

.wa-voice.is-playing .wa-voice-play {
    letter-spacing: -1px;
    font-size: 0.78rem;
}

.wa-voice-track {
    min-width: 0;
    display: grid;
    gap: 4px;
}

.wa-voice-wave {
    position: relative;
    height: 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
}

.wa-voice-bars {
    display: flex;
    align-items: center;
    gap: 2px;
    width: 100%;
    height: 100%;
}

.wa-voice-bars span {
    flex: 1 1 0;
    height: var(--h, 12px);
    border-radius: 999px;
    background: #8696a0;
    opacity: 0.75;
}

.wa-bubble.is-out .wa-voice-bars span {
    background: #6aa58a;
}

.wa-voice-bars span.is-played {
    background: #00a884 !important;
    opacity: 1;
}

.wa-voice-fill {
    display: none;
}

.wa-voice-thumb {
    position: absolute;
    top: 50%;
    left: 0;
    width: 12px;
    height: 12px;
    margin-left: -6px;
    margin-top: -6px;
    border-radius: 50%;
    background: #00a884;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    pointer-events: none;
    z-index: 2;
}

.wa-voice-time {
    font-size: 0.72rem;
    color: #667781;
    line-height: 1;
}

.wa-doc-card {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 210px;
    max-width: 280px;
    margin: 2px 0 8px;
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.55);
    color: inherit;
    text-decoration: none;
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.wa-bubble.is-out .wa-doc-card {
    background: rgba(255, 255, 255, 0.35);
}

.wa-doc-card.is-missing {
    opacity: 0.85;
}

.wa-doc-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 168, 132, 0.12);
    font-size: 1.1rem;
    flex: 0 0 auto;
}

.wa-doc-meta {
    min-width: 0;
    display: grid;
    gap: 2px;
}

.wa-doc-meta strong {
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wa-doc-meta small {
    color: #667781;
    font-size: 0.75rem;
}

.wa-media-video {
    display: block;
    width: min(280px, 100%);
    max-height: 320px;
    border-radius: 8px;
    margin-bottom: 4px;
    background: #000;
}

.wa-composer {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 10px;
    align-items: end;
    padding: 10px 16px 14px;
    background: #f0f2f5;
    border-top: 1px solid #d1d7db;
}

.wa-attach-btn {
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #54656f;
    font-size: 1.25rem;
    cursor: pointer;
    line-height: 1;
}

.wa-attach-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

.wa-file-input {
    display: none !important;
}

.wa-drop-overlay {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(7, 94, 84, 0.72);
    pointer-events: none;
}

.wa-drop-overlay[hidden] {
    display: none !important;
}

.wa-drop-overlay-inner {
    width: min(520px, 100%);
    min-height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px dashed rgba(255, 255, 255, 0.95);
    border-radius: 18px;
    color: #fff;
    font-size: clamp(1.4rem, 2.4vw, 2rem);
    font-weight: 600;
    text-align: center;
    padding: 24px;
}

.wa-chat-pane.is-drop-active,
.wa-chat-pane.is-uploading {
    position: relative;
}

.wa-chat-pane.is-uploading::before {
    content: 'Отправка файла...';
    position: absolute;
    left: 50%;
    top: 16px;
    transform: translateX(-50%);
    z-index: 15;
    background: rgba(17, 27, 33, 0.88);
    color: #fff;
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 0.85rem;
}

.wa-composer textarea {
    min-height: 42px;
    max-height: 120px;
    resize: none;
    border-radius: 24px;
    border: 0;
    padding: 11px 16px;
    background: #fff;
    font: inherit;
}

.wa-send-btn {
    width: 48px;
    height: 48px;
    border: 0;
    border-radius: 50%;
    background: #00a884;
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
}

.wa-send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.wa-chat-empty {
    margin: auto;
}

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

    .wa-chat-thread {
        max-height: calc(60vh - 150px);
    }

    .wa-bubble {
        max-width: 88%;
    }
}

.wa-chat-pane--embedded {
    min-height: 520px;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid #d1d7db;
}

.wa-client-chat-wrap {
    padding: 0;
    overflow: hidden;
}

.wa-chat-pane--embedded .wa-chat-thread {
    max-height: 360px;
}

@media (max-width: 900px) {
    .wa-chat-pane--embedded .wa-chat-thread {
        max-height: 300px;
    }
}

.wa-chat-preview-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 2px;
}

.wa-chat-preview {
    margin: 0;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #667781;
    font-size: 0.86rem;
}

.wa-chat-time.has-unread {
    color: #25d366;
    font-weight: 600;
}

.wa-chat-item .wa-unread-badge,
a.wa-chat-item .wa-unread-badge {
    flex: 0 0 auto !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: 22px !important;
    height: 22px !important;
    padding: 0 7px !important;
    border-radius: 999px !important;
    background: #25d366 !important;
    color: #111b21 !important;
    font-size: 0.75rem !important;
    font-weight: 700 !important;
    line-height: 1 !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15) !important;
    text-decoration: none !important;
}

.wa-chat-item .wa-unread-badge.is-hidden,
a.wa-chat-item .wa-unread-badge.is-hidden {
    display: none !important;
}

.wa-chat-item.has-unread .wa-chat-time {
    color: #25d366 !important;
    font-weight: 600 !important;
}

.wa-chat-item.has-unread strong {
    font-weight: 700;
    color: #111b21;
}

.wa-chat-item-updated {
    background: #e7f8ef !important;
    animation: waChatPulse 1.2s ease;
}

@keyframes waChatPulse {
    0% { background: #d9fdd3; }
    100% { background: #f0f2f5; }
}

.toast-stack {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 50;
    display: grid;
    gap: 12px;
    width: min(360px, calc(100vw - 36px));
}

.toast-card {
    background: rgba(16, 33, 38, 0.96);
    color: #f6fbfa;
    border-radius: 18px;
    padding: 14px 16px;
    box-shadow: 0 14px 38px rgba(10, 20, 22, 0.28);
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast-card.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.toast-card.is-link {
    cursor: pointer;
}

.toast-card p,
.toast-card small {
    margin: 8px 0 0;
    color: rgba(246, 251, 250, 0.82);
}

.toast-card-head {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 10px;
}

.toast-close {
    min-width: auto;
    padding: 0;
    background: transparent;
    color: rgba(255, 255, 255, 0.78);
    font-size: 1.2rem;
    line-height: 1;
}

.menu-toggle {
    display: none;
}

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

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: 260px;
        height: 100vh;
        height: 100dvh;
        min-height: 100vh;
        min-height: 100dvh;
        overflow-y: auto;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        z-index: 20;
    }

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

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

    .menu-toggle {
        display: inline-flex;
        background: rgba(16, 33, 38, 0.08);
        color: var(--ink);
    }

    .split,
    .grid.two,
    .grid.three {
        grid-template-columns: 1fr;
    }

    .chat-layout,
    .whatsapp-layout {
        grid-template-columns: 1fr;
    }

    .chat-conversation-list,
    .chat-thread,
    .whatsapp-conversation-list,
    .whatsapp-thread-panel {
        max-height: none;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar form {
        grid-template-columns: 1fr;
    }
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(16, 33, 38, 0.45);
    z-index: 19;
}

.mobile-cards {
    display: none;
}

.desktop-table {
    display: block;
}

.phone-link {
    color: var(--accent);
    font-weight: 600;
    text-decoration: none;
}

.phone-link:hover {
    text-decoration: underline;
}

.bottom-nav {
    display: none;
}

.fab-quick {
    display: none;
}

.quick-action-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    background: linear-gradient(135deg, var(--accent-soft), rgba(255, 255, 255, 0.9));
}

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

.pipeline-scroll {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 6px;
}

.pipeline-card {
    flex: 0 0 140px;
    display: grid;
    gap: 6px;
    padding: 14px;
    border-radius: 16px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-top: 4px solid var(--pipeline-color, var(--accent));
    text-decoration: none;
}

.pipeline-count {
    font-size: 1.7rem;
    font-weight: 700;
}

.pipeline-label {
    color: var(--muted);
    font-size: 0.88rem;
}

.kanban-board {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(280px, 1fr);
    gap: 16px;
    overflow-x: auto;
}

.kanban-column {
    min-height: 360px;
}

.kanban-column-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 3px solid var(--kanban-color, var(--accent));
}

.kanban-cards {
    display: grid;
    gap: 10px;
}

.kanban-card {
    padding: 14px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid var(--line);
    display: grid;
    gap: 8px;
}

.kanban-card select {
    width: 100%;
}

.setup-guide ol {
    margin: 0;
    padding-left: 20px;
    display: grid;
    gap: 10px;
    line-height: 1.55;
}

.setup-guide code {
    display: inline-block;
    margin-top: 4px;
    padding: 4px 8px;
    border-radius: 8px;
    background: rgba(16, 33, 38, 0.06);
    word-break: break-all;
}

@media (max-width: 640px) {
    .main-area {
        padding: 14px 14px 88px;
    }

    .desktop-table {
        display: none;
    }

    .mobile-cards {
        display: grid;
        gap: 12px;
    }

    .mobile-card {
        display: grid;
        gap: 10px;
        padding: 16px;
        border-radius: 16px;
        background: var(--panel);
        border: 1px solid var(--line);
    }

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

    .mobile-card-meta {
        display: grid;
        gap: 6px;
        color: var(--muted);
        font-size: 0.92rem;
    }

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

    .bottom-nav {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(62px, 1fr));
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
        background: rgba(255, 253, 248, 0.96);
        backdrop-filter: blur(12px);
        border-top: 1px solid var(--line);
        z-index: 30;
    }

    .bottom-nav a {
        display: grid;
        place-items: center;
        gap: 4px;
        padding: 8px 4px;
        border-radius: 12px;
        color: var(--muted);
        font-size: 0.72rem;
        text-decoration: none;
        text-align: center;
    }

    .bottom-nav a.active {
        color: var(--accent);
        background: var(--accent-soft);
        font-weight: 700;
    }

    .fab-quick {
        display: grid;
        place-items: center;
        position: fixed;
        right: 16px;
        bottom: calc(76px + env(safe-area-inset-bottom));
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background: linear-gradient(135deg, #ff805c, #e85a35);
        color: white;
        font-size: 1.8rem;
        font-weight: 700;
        text-decoration: none;
        box-shadow: 0 14px 30px rgba(255, 128, 92, 0.35);
        z-index: 31;
    }

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

    .kanban-board {
        grid-auto-columns: minmax(85vw, 1fr);
    }

    .quick-action-banner {
        flex-direction: column;
        align-items: stretch;
    }
}

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

.global-search-form input[type="search"] {
    min-width: 160px;
}

.topbar-search {
    flex: 1;
    max-width: 280px;
}

.hint-text {
    color: var(--muted);
    font-weight: 400;
    font-size: 0.86rem;
}

.hint-found {
    color: var(--accent);
}

.hint-new {
    color: var(--warning);
}

.task-comment-form {
    margin-bottom: 20px;
}

.task-comments-thread {
    margin-top: 8px;
}

.timeline {
    display: grid;
    gap: 14px;
}

.timeline-item {
    display: grid;
    grid-template-columns: 14px 1fr;
    gap: 12px;
}

.timeline-dot {
    width: 10px;
    height: 10px;
    margin-top: 6px;
    border-radius: 50%;
    background: var(--accent);
}

.integration-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin: 16px 0;
}

.integration-card {
    padding: 16px;
    border-radius: 16px;
    border: 1px solid var(--line);
}

.integration-card.is-on {
    background: rgba(13, 138, 123, 0.1);
}

.integration-card.is-off {
    background: rgba(199, 59, 48, 0.08);
}

.integration-card code {
    display: block;
    margin-top: 8px;
    font-size: 0.78rem;
    word-break: break-all;
}

.row-overdue,
.card-overdue {
    background: rgba(199, 59, 48, 0.06) !important;
    border-color: rgba(199, 59, 48, 0.2) !important;
}

.inline-form {
    display: inline;
}

.inline-badge {
    display: inline-block;
    margin-top: 8px;
    padding: 6px 10px;
}

.callback-fieldset {
    border: 1px dashed var(--line);
    border-radius: 16px;
    padding: 14px;
    display: grid;
    gap: 12px;
}

.checkbox-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.checkbox-inline input {
    width: auto;
}

.is-hidden {
    display: none !important;
}

.wa-call-btn {
    white-space: nowrap;
}

#wa-voip-remote-audio {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.wa-voip-bar {
    position: fixed;
    left: 50%;
    bottom: 22px;
    transform: translateX(-50%);
    z-index: 80;
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: min(420px, calc(100vw - 24px));
    padding: 12px 14px;
    border-radius: 16px;
    background: #111b21;
    color: #fff;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
}

.wa-voip-bar[hidden],
.wa-voip-incoming[hidden] {
    display: none !important;
}

.wa-voip-bar-main {
    display: grid;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.wa-voip-bar-main strong {
    font-size: 0.95rem;
}

.wa-voip-bar-main span {
    color: #aebac1;
    font-size: 0.8rem;
}

.wa-voip-end,
.wa-voip-reject,
.wa-voip-accept {
    border: 0;
    border-radius: 999px;
    padding: 10px 16px;
    font: inherit;
    cursor: pointer;
}

.wa-voip-end,
.wa-voip-reject {
    background: #ea4335;
    color: #fff;
}

.wa-voip-accept {
    background: #25d366;
    color: #111b21;
    font-weight: 700;
}

.wa-voip-incoming {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(17, 27, 33, 0.55);
}

.wa-voip-incoming-card {
    width: min(420px, 100%);
    padding: 22px;
    border-radius: 18px;
    background: #fff;
    text-align: center;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.25);
}

.wa-voip-incoming-label {
    color: #667781;
    font-size: 0.9rem;
}

.wa-voip-incoming-phone {
    margin: 10px 0 18px;
    font-size: 1.45rem;
    font-weight: 700;
    color: #111b21;
}

.wa-voip-incoming-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

@media (max-width: 980px) {
    .topbar-search {
        display: none;
    }
}
