:root {
    --wa-bg: radial-gradient(circle at top left, rgba(26, 211, 150, 0.18), transparent 24%),
             radial-gradient(circle at top right, rgba(75, 131, 255, 0.16), transparent 22%),
             linear-gradient(180deg, #06111c 0%, #081421 50%, #0b1727 100%);
    --wa-panel: rgba(12, 20, 32, 0.84);
    --wa-line: rgba(148, 163, 184, 0.14);
    --wa-text: #eef7ff;
    --wa-soft: #96abc6;
    --wa-accent: #1dd3b0;
    --wa-accent-2: #60a5fa;
    --wa-warm: #f59e0b;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
    margin: 0;
    font-family: 'Inter', sans-serif;
    color: var(--wa-text);
    background: var(--wa-bg);
}

.glass-card {
    border: 1px solid var(--wa-line);
    background: var(--wa-panel);
    backdrop-filter: blur(18px);
    border-radius: 24px;
    box-shadow: 0 22px 48px rgba(0, 0, 0, 0.24);
}

.wa-topbar {
    width: min(1480px, calc(100% - 24px));
    margin: 16px auto 0;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

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

.wa-brand-mark {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    font-size: 1.25rem;
    color: #09131f;
    background: linear-gradient(135deg, rgba(29, 211, 176, 0.96), rgba(96, 165, 250, 0.95));
    box-shadow: 0 12px 28px rgba(29, 211, 176, 0.24);
}

.wa-brand-copy {
    display: grid;
    gap: 2px;
}

.wa-brand h1 {
    margin: 0;
    font-family: 'Outfit', sans-serif;
    font-size: clamp(1.15rem, 2vw, 1.55rem);
    line-height: 1.1;
}

.wa-top-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.wa-shell {
    width: min(1480px, calc(100% - 24px));
    margin: 12px auto 24px;
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
    gap: 16px;
}

.wa-sidebar,
.wa-workspace {
    min-width: 0;
}

.wa-sidebar {
    padding: 18px;
    position: sticky;
    top: 16px;
    height: calc(100vh - 32px);
    overflow: auto;
}

.wa-workspace {
    display: grid;
    gap: 16px;
}

.sidebar-block,
.wa-thread-card,
.wa-compose-card,
.panel-card {
    padding: 18px;
}

.sidebar-block + .sidebar-block {
    margin-top: 12px;
    padding-top: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

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

.block-head h2,
.block-head h3 {
    margin: 0;
    font-family: 'Outfit', sans-serif;
}

.helper-copy {
    margin: 6px 0 0;
    color: var(--wa-soft);
    font-size: 0.8rem;
    line-height: 1.45;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    padding: 7px 10px;
    background: rgba(255, 255, 255, 0.08);
    color: #dce9f7;
    font-size: 0.73rem;
    font-weight: 700;
    white-space: nowrap;
}

.segmented-toggle,
.channel-chip-row,
.channel-selectors {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.seg-btn,
.channel-chip {
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    color: #edf5ff;
    padding: 9px 12px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.seg-btn:hover,
.channel-chip:hover {
    transform: translateY(-1px);
}

.seg-btn.active,
.channel-chip.active {
    background: rgba(29, 211, 176, 0.14);
    border-color: rgba(29, 211, 176, 0.4);
    color: #dcfffa;
}

.channel-chip.all-active {
    background: rgba(96, 165, 250, 0.14);
    border-color: rgba(96, 165, 250, 0.44);
}

.field-grid {
    display: grid;
    gap: 12px;
}

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

.field {
    display: grid;
    gap: 7px;
}

.field label {
    font-size: 0.73rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--wa-soft);
}

.add-input {
    width: 100%;
    min-height: 42px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.06);
    color: #f3f9ff;
    outline: none;
    font: inherit;
}

.add-input:focus {
    border-color: rgba(29, 211, 176, 0.48);
    box-shadow: 0 0 0 3px rgba(29, 211, 176, 0.12);
}

.wa-message {
    min-height: 140px;
    resize: vertical;
    line-height: 1.6;
}

.sidebar-actions,
.compose-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.sidebar-actions {
    margin-top: 14px;
}

.summary-strip {
    margin-top: 14px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.summary-strip div {
    padding: 12px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.summary-strip span {
    display: block;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--wa-soft);
    margin-bottom: 6px;
}

.summary-strip strong {
    font-family: 'Outfit', sans-serif;
    font-size: 1.2rem;
}

.contact-list {
    display: grid;
    gap: 10px;
    max-height: 40vh;
    overflow: auto;
    padding-right: 2px;
}

.contact-list.loading {
    place-items: center;
    min-height: 180px;
}

.contact-loading {
    display: grid;
    gap: 10px;
    justify-items: center;
    text-align: center;
    color: var(--wa-soft);
}

.contact-spinner {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.14);
    border-top-color: var(--wa-accent);
    animation: wa-spin 0.85s linear infinite;
}

.contact-card {
    display: grid;
    gap: 8px;
    padding: 12px;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
    cursor: pointer;
    transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.contact-card:hover {
    transform: translateY(-1px);
    border-color: rgba(29, 211, 176, 0.28);
    background: rgba(29, 211, 176, 0.05);
}

.contact-card.active {
    border-color: rgba(29, 211, 176, 0.5);
    background: linear-gradient(180deg, rgba(29, 211, 176, 0.12), rgba(96, 165, 250, 0.07));
}

.contact-top {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.contact-check {
    margin-top: 4px;
}

.contact-avatar {
    width: 40px;
    height: 40px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    font-size: 0.92rem;
    font-weight: 800;
    color: #06111c;
    background: linear-gradient(135deg, rgba(29, 211, 176, 0.98), rgba(96, 165, 250, 0.92));
    flex-shrink: 0;
}

.contact-copy {
    min-width: 0;
    flex: 1;
}

.contact-copy h4,
.contact-copy p {
    margin: 0;
}

.contact-copy h4 {
    font-size: 0.98rem;
    line-height: 1.3;
}

.contact-copy p {
    margin-top: 4px;
    color: var(--wa-soft);
    font-size: 0.84rem;
    line-height: 1.45;
}

.contact-meta,
.mini-note {
    color: var(--wa-soft);
    font-size: 0.8rem;
    line-height: 1.45;
}

.contact-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag {
    border-radius: 999px;
    padding: 5px 8px;
    background: rgba(255, 255, 255, 0.06);
    font-size: 0.68rem;
    font-weight: 700;
    color: #d7e5f7;
}

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

.thread-top {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 14px;
    align-items: start;
}

.thread-avatar {
    width: 62px;
    height: 62px;
    border-radius: 20px;
    display: grid;
    place-items: center;
    font-family: 'Outfit', sans-serif;
    font-size: 1.15rem;
    font-weight: 800;
    color: #051018;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(29, 211, 176, 0.92));
}

.thread-kicker {
    margin: 0 0 6px;
    color: var(--wa-soft);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-weight: 800;
}

.thread-copy h2 {
    margin: 0;
    font-family: 'Outfit', sans-serif;
    font-size: clamp(1.2rem, 2vw, 1.55rem);
}

.thread-copy p {
    margin: 8px 0 0;
    color: #bfd0e4;
    line-height: 1.6;
}

.thread-meta {
    display: grid;
    gap: 8px;
    justify-items: end;
}

.recipient-tray {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 8px;
    padding: 12px;
    border-radius: 18px;
    border: 1px dashed rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.03);
    min-height: 58px;
}

.recipient-tray.empty {
    align-items: center;
    color: var(--wa-soft);
    font-size: 0.85rem;
}

.recipient-pill {
    display: grid;
    gap: 6px;
    justify-items: start;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    padding: 10px 12px;
    color: #eff7ff;
    cursor: grab;
    user-select: none;
    transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
    width: 100%;
    text-align: left;
    border-radius: 18px;
    min-height: 92px;
}

.recipient-pill:active {
    cursor: grabbing;
}

.recipient-pill.active {
    background: rgba(29, 211, 176, 0.16);
    border-color: rgba(29, 211, 176, 0.48);
}

.recipient-pill small {
    color: var(--wa-soft);
    font-size: 0.73rem;
}

.recipient-pill .recipient-pdf {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.recipient-pill .recipient-pdf span {
    border-radius: 999px;
    padding: 4px 8px;
    background: rgba(255, 255, 255, 0.06);
    color: #dce9f7;
    font-size: 0.68rem;
    font-weight: 700;
}

.recipient-pill.dragging {
    opacity: 0.62;
    transform: scale(0.98);
}

.thread-preview {
    min-height: 96px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background:
        radial-gradient(circle at top right, rgba(29, 211, 176, 0.18), transparent 30%),
        radial-gradient(circle at bottom left, rgba(96, 165, 250, 0.16), transparent 32%),
        rgba(255, 255, 255, 0.03);
    padding: 16px;
    display: grid;
    gap: 10px;
}

.thread-preview.drag-over {
    outline: 2px solid rgba(29, 211, 176, 0.36);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(29, 211, 176, 0.08);
}

.bubble {
    max-width: min(78%, 640px);
    padding: 12px 14px;
    border-radius: 18px;
    line-height: 1.55;
    font-size: 0.92rem;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.16);
}

.bubble.incoming {
    background: rgba(255, 255, 255, 0.09);
    color: #f7fbff;
    border-top-left-radius: 8px;
}

.bubble.outgoing {
    margin-left: auto;
    background: linear-gradient(135deg, rgba(29, 211, 176, 0.9), rgba(96, 165, 250, 0.84));
    color: #041018;
    border-top-right-radius: 8px;
}

.bubble strong {
    display: block;
    margin-bottom: 4px;
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.wa-compose-card {
    display: grid;
    gap: 12px;
}

.template-picker {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.template-picker .add-input {
    min-width: 240px;
}

.channel-selectors {
    padding: 12px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.07);
}

.channel-selectors .channel-chip {
    min-width: 110px;
    text-align: center;
}

.placeholder-bank {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.placeholder-chip {
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.05);
    color: #eef7ff;
    padding: 8px 11px;
    cursor: pointer;
    font: inherit;
    font-size: 0.8rem;
    font-weight: 700;
}

.placeholder-chip small {
    display: block;
    color: var(--wa-soft);
    font-weight: 500;
    margin-top: 2px;
}

.attachment-toolbar {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    padding-top: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.file-button {
    position: relative;
    overflow: hidden;
}

.attachment-list {
    display: grid;
    gap: 10px;
}

.attachment-item {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.attachment-item h4,
.attachment-item p {
    margin: 0;
}

.attachment-item h4 {
    font-size: 0.92rem;
}

.attachment-item p {
    margin-top: 5px;
    color: var(--wa-soft);
    font-size: 0.8rem;
}

.attachment-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.wa-tools {
    display: grid;
    gap: 12px;
    padding: 16px 18px 18px;
}

.compact-head {
    margin-bottom: 0;
    align-items: center;
}

.mini-panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.mini-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: #dce9f7;
    font-weight: 700;
}

.tool-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.tool-tab {
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.05);
    color: #edf5ff;
    padding: 8px 12px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.tool-tab.active {
    background: rgba(29, 211, 176, 0.14);
    border-color: rgba(29, 211, 176, 0.4);
    color: #dcfffa;
}

.tool-panel {
    display: none;
    gap: 12px;
}

.tool-panel.active {
    display: grid;
}

.wa-panel-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
}

.data-summary {
    display: grid;
    gap: 8px;
    color: #dce8f5;
    font-size: 0.86rem;
    line-height: 1.6;
    min-height: 68px;
}

.data-summary .summary-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.05);
}

.data-summary .summary-row strong {
    color: #ffffff;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 14px;
    background: rgba(29, 211, 176, 0.11);
    border: 1px solid rgba(29, 211, 176, 0.18);
    color: #ddfff8;
    font-size: 0.85rem;
}

.btn {
    border: 0;
}

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

    .wa-sidebar {
        position: static;
        height: auto;
    }

}

@media (max-width: 760px) {
    .wa-topbar,
    .wa-shell {
        width: calc(100% - 16px);
    }

    .thread-top {
        grid-template-columns: 1fr;
    }

    .thread-meta {
        justify-items: start;
    }

    .field-grid.two-up {
        grid-template-columns: 1fr;
    }

    .summary-strip {
        grid-template-columns: 1fr;
    }
}

@keyframes wa-spin {
    to {
        transform: rotate(360deg);
    }
}
