@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700;800&display=swap');

:root {
    --bg: #130c1d;
    --bg-alt: #20132e;
    --panel: rgba(34, 20, 48, 0.72);
    --panel-soft: rgba(255, 255, 255, 0.06);
    --border: rgba(255, 255, 255, 0.12);
    --text: #f3effa;
    --text-muted: #bcaed0;
    --text-dark: #3c3c3c;
    --primary: #4b275b;
    --primary-bright: #a16ed6;
    --accent: #f38fff;
    --success: #4ec7a5;
    --warning: #ffb86c;
    --danger: #ff7f96;
    --radius: 22px;
    --radius-sm: 14px;
    --shadow: 0 30px 80px rgba(7, 3, 13, 0.55);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: 'Montserrat', 'Segoe UI', sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at 10% 10%, rgba(156, 87, 255, 0.26), transparent 26%),
        radial-gradient(circle at 90% 12%, rgba(255, 125, 182, 0.18), transparent 20%),
        radial-gradient(circle at 50% 90%, rgba(92, 65, 255, 0.2), transparent 32%),
        linear-gradient(160deg, #09060f 0%, #140c1f 44%, #1d1530 100%);
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select,
textarea {
    font: inherit;
}

img {
    max-width: 100%;
}

.app-shell {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 100vh;
}

.glass,
.glass-soft {
    border: 1px solid var(--border);
    background: var(--panel);
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
    box-shadow: var(--shadow);
}

.glass-soft {
    background: var(--panel-soft);
    box-shadow: none;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    margin: 18px;
    padding: 22px;
    border-radius: 28px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: auto;
}

.brand-lockup strong,
.login-card h1 {
    display: block;
    font-size: clamp(2rem, 3vw, 2.8rem);
    font-weight: 800;
    letter-spacing: -0.04em;
}

.brand-lockup p,
.muted,
small {
    color: var(--text-muted);
}

.brand-eyebrow,
.pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.06);
    color: #ebd6ff;
}

.nav {
    display: grid;
    gap: 10px;
    margin: 24px 0;
}

.nav a {
    padding: 14px 16px;
    border-radius: 18px;
    color: var(--text-muted);
    transition: all 0.2s ease;
}

.nav a:hover,
.nav a.is-active {
    color: var(--text);
    background: linear-gradient(135deg, rgba(161, 110, 214, 0.18), rgba(76, 39, 91, 0.6));
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-footer {
    display: grid;
    gap: 16px;
}

.user-chip {
    padding: 16px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.04);
}

.user-chip span {
    display: block;
    font-weight: 700;
}

.main-content {
    padding: 20px 20px 40px 0;
}

.topbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    margin: 6px 0 18px;
}

.topbar h1,
.section-head h2,
.empty-state h2 {
    margin: 10px 0 0;
    font-size: clamp(1.55rem, 2vw, 2.25rem);
    line-height: 1.05;
    letter-spacing: -0.04em;
}

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

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

.two-col-layout {
    grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.9fr);
    align-items: start;
}

.dashboard-grid,
.conversation-layout {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
}

.panel {
    padding: 20px;
    border-radius: var(--radius);
}

.stat-card {
    padding: 22px;
    border-radius: 24px;
}

.stat-card span {
    display: block;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.stat-card strong {
    font-size: clamp(2rem, 3vw, 2.7rem);
    font-weight: 800;
    letter-spacing: -0.05em;
}

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

.toolbar,
.upload-bar,
.quick-actions,
.quick-actions form,
.inline-form,
.checkbox-row,
.field-grid,
.compact-form {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.quick-actions form {
    margin: 0;
}

.toolbar > *,
.upload-bar > *,
.inline-form > * {
    flex: 1 1 160px;
}

.toolbar.compact > * {
    flex: 0 1 auto;
}

.gateway-test-form {
    margin-top: 14px;
    align-items: center;
}

.gateway-test-form small {
    flex: 1 1 260px;
}

.field-grid.two > * {
    flex: 1 1 calc(50% - 6px);
}

.stack-form {
    display: grid;
    gap: 16px;
}

label {
    display: grid;
    gap: 8px;
}

label > span,
.field-group h3 {
    font-size: 0.82rem;
    font-weight: 700;
    color: #e9ddf7;
}

label small,
.panel-hint {
    color: var(--text-muted);
    font-size: 0.84rem;
    line-height: 1.5;
}

code {
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

input,
select,
textarea {
    width: 100%;
    padding: 12px 14px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    outline: none;
}

textarea {
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: rgba(243, 143, 255, 0.5);
    box-shadow: 0 0 0 3px rgba(243, 143, 255, 0.14);
}

.button {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 12px 16px;
    border: 0;
    border-radius: 999px;
    background: linear-gradient(135deg, #7f46b1 0%, #4b275b 100%);
    color: #fff;
    cursor: pointer;
    font-weight: 700;
    box-shadow: 0 16px 30px rgba(75, 39, 91, 0.42);
}

.button.secondary {
    background: linear-gradient(135deg, rgba(118, 88, 168, 0.94), rgba(68, 49, 107, 0.94));
}

.button.ghost {
    background: rgba(255, 255, 255, 0.05);
    box-shadow: none;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.button.tiny {
    min-height: 32px;
    padding: 7px 11px;
    font-size: 0.82rem;
}

.button.full {
    width: 100%;
}

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

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

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

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

td strong {
    display: block;
}

.status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 7px 11px;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.08);
}

.status.sent,
.status.delivered,
.status.completed,
.status.confirmed {
    color: #d6ffee;
    background: rgba(78, 199, 165, 0.16);
}

.status.failed,
.status.cancelled,
.status.opt_out,
.status.declined {
    color: #ffd0d9;
    background: rgba(255, 127, 150, 0.16);
}

.status.running,
.status.sending,
.status.pending,
.status.planned,
.status.open,
.status.processed {
    color: #ffe3c0;
    background: rgba(255, 184, 108, 0.16);
}

.status.paused,
.status.draft,
.status.retry,
.status.retrying,
.status.inactive {
    color: #dad0ea;
    background: rgba(255, 255, 255, 0.08);
}

.flash-stack {
    display: grid;
    gap: 12px;
    margin-bottom: 20px;
}

.flash {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 14px 16px;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.flash.success {
    background: rgba(78, 199, 165, 0.12);
}

.flash.warning {
    background: rgba(255, 184, 108, 0.14);
}

.flash.error {
    background: rgba(255, 127, 150, 0.14);
}

.card-list,
.activity-feed,
.message-list,
.thread-list,
.stack-panels {
    display: grid;
    gap: 14px;
}

.card-item,
.message-row,
.thread-item,
.activity-item {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    padding: 15px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.07);
}

.thread-item:hover {
    transform: translateY(-1px);
}

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

.list-metric {
    display: grid;
    gap: 12px;
}

.list-metric > div {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.panel-hint {
    margin: 12px 0 0;
}

.preview-box,
.empty-state,
.login-meta,
.catalog-grid {
    display: grid;
    gap: 12px;
}

.preview-box,
.empty-state,
.login-meta > div {
    padding: 15px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

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

.chat-thread {
    display: grid;
    gap: 16px;
}

.bubble {
    max-width: 78%;
    padding: 14px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.06);
}

.bubble.outbound {
    margin-left: auto;
    border-top-right-radius: 8px;
    background: linear-gradient(135deg, rgba(161, 110, 214, 0.22), rgba(75, 39, 91, 0.48));
}

.bubble.inbound {
    border-top-left-radius: 8px;
}

.tag-cloud {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.tag {
    padding: 7px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.82rem;
}

.bubble-tags {
    margin-top: 12px;
}

.message-details,
details {
    margin-top: 12px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 12px 14px;
}

.message-details summary,
details summary {
    cursor: pointer;
    color: rgba(255, 255, 255, 0.82);
    font-weight: 600;
}

.message-details pre,
details pre {
    margin: 12px 0 0;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.82);
}

.file-field input {
    padding: 12px;
}

.blank-body {
    display: grid;
    place-items: center;
    padding: 32px 16px;
}

.login-screen {
    width: min(560px, 100%);
}

.login-card {
    padding: 28px;
    border-radius: 28px;
}

.conversation-shell {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(280px, 360px);
    gap: 18px;
    align-items: start;
}

.conversation-main-panel {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 14px;
    min-height: calc(100vh - 120px);
}

.conversation-side-panel {
    position: sticky;
    top: 20px;
    display: grid;
    gap: 14px;
}

.conversation-header-bar,
.conversation-header-main,
.conversation-index-header,
.compact-thread-topline,
.compact-thread-subline,
.chat-bubble-meta,
.chat-composer-row,
.chat-send-actions,
.conversation-side-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.conversation-header-bar,
.conversation-index-header {
    justify-content: space-between;
    flex-wrap: wrap;
}

.conversation-header-main {
    min-width: 0;
}

.conversation-header-copy,
.compact-thread-body,
.conversation-side-block {
    display: grid;
    gap: 6px;
}

.conversation-header-copy h2 {
    margin: 0;
    font-size: 1.35rem;
}

.conversation-header-copy p,
.compact-thread-body p {
    margin: 0;
    color: var(--text-muted);
}

.conversation-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.conversation-search,
.conversation-index-toolbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.conversation-search input,
.conversation-index-toolbar input {
    min-width: min(420px, 100%);
}

.chat-avatar {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    font-weight: 800;
    letter-spacing: 0.04em;
    color: #fff;
    background: linear-gradient(135deg, rgba(161, 110, 214, 0.9), rgba(75, 39, 91, 0.95));
    box-shadow: 0 10px 24px rgba(75, 39, 91, 0.3);
}

.chat-avatar.small {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    font-size: 0.86rem;
}

.compact-chat-thread {
    min-height: 48vh;
    max-height: calc(100vh - 320px);
    overflow: auto;
    padding-right: 6px;
    display: grid;
    gap: 10px;
}

.chat-day-separator {
    display: flex;
    justify-content: center;
    margin: 4px 0;
}

.chat-day-separator span {
    padding: 5px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
    font-size: 0.74rem;
    font-weight: 600;
}

.chat-bubble {
    display: grid;
    gap: 8px;
    max-width: min(78%, 720px);
    padding: 12px 14px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.06);
}

.chat-bubble.outbound {
    margin-left: auto;
    border-top-right-radius: 8px;
    background: linear-gradient(135deg, rgba(161, 110, 214, 0.24), rgba(75, 39, 91, 0.52));
}

.chat-bubble.inbound {
    border-top-left-radius: 8px;
}

.chat-bubble-meta {
    justify-content: space-between;
    flex-wrap: wrap;
    font-size: 0.76rem;
    color: var(--text-muted);
}

.chat-role {
    font-weight: 700;
    color: var(--text);
}

.chat-bubble-text {
    line-height: 1.5;
    white-space: normal;
    word-break: break-word;
}

.compact-status-hint {
    margin: 0.45rem 0 0;
    font-size: 0.8rem;
    line-height: 1.45;
}

.chat-bubble-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.compact-details {
    margin-top: 2px;
    padding: 10px 12px;
}

.chat-composer {
    position: sticky;
    bottom: 0;
    display: grid;
    gap: 10px;
    padding: 12px;
    border-radius: 18px;
    background: rgba(19, 12, 29, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(18px);
}

.chat-composer textarea {
    min-height: 52px;
    max-height: 180px;
}

.chat-composer-row {
    justify-content: space-between;
    align-items: flex-end;
    flex-wrap: wrap;
}

.chat-advanced {
    flex: 1 1 280px;
    margin-top: 0;
}

.chat-advanced-grid {
    display: grid;
    gap: 12px;
    margin-top: 10px;
}

.chat-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-toggle input {
    width: auto;
}

.chat-send-actions {
    margin-left: auto;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.chat-send-actions small {
    font-size: 0.76rem;
}

.conversation-facts {
    display: grid;
    gap: 10px;
}

.conversation-facts > div {
    display: grid;
    gap: 3px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.conversation-facts span {
    color: var(--text-muted);
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.conversation-side-actions {
    flex-wrap: wrap;
}

.conversation-index-panel {
    display: grid;
    gap: 16px;
}

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

.compact-thread-item {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 12px;
    align-items: start;
    padding: 12px 14px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.compact-thread-item:hover {
    transform: translateY(-1px);
    border-color: rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.06);
}

.status.success,
.status.info {
    color: #f3effa;
    background: rgba(161, 110, 214, 0.18);
}

.status.warning {
    color: #ffe3c0;
    background: rgba(255, 184, 108, 0.16);
}

.status.danger {
    color: #ffd0d9;
    background: rgba(255, 127, 150, 0.16);
}

.dashboard-lead {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(220px, 0.7fr);
    gap: 18px;
    align-items: start;
}

.dashboard-lead-copy {
    display: grid;
    gap: 14px;
}

.dashboard-lead-text {
    margin: 0;
    color: var(--text-muted);
    line-height: 1.6;
}

.dashboard-kpi-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.dashboard-kpi,
.dashboard-system-card {
    display: grid;
    gap: 5px;
    padding: 12px 14px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.07);
}

.dashboard-kpi span,
.dashboard-system-card span {
    color: var(--text-muted);
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.dashboard-kpi strong,
.dashboard-system-card strong {
    font-size: 1.28rem;
    line-height: 1;
    letter-spacing: -0.04em;
}

.dashboard-action-stack,
.dashboard-toolbox {
    display: grid;
    gap: 10px;
}

.dashboard-alert-strip {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.dashboard-alert {
    display: grid;
    gap: 6px;
    padding: 13px 15px;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.04);
    transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.dashboard-alert:hover {
    transform: translateY(-1px);
    border-color: rgba(255, 255, 255, 0.16);
}

.dashboard-alert strong {
    font-size: 0.92rem;
}

.dashboard-alert span {
    color: var(--text-muted);
    font-size: 0.84rem;
    line-height: 1.45;
}

.dashboard-alert-success {
    background: rgba(78, 199, 165, 0.08);
}

.dashboard-alert-warning {
    background: rgba(255, 184, 108, 0.1);
}

.dashboard-alert-danger {
    background: rgba(255, 127, 150, 0.1);
}

.dashboard-alert-info {
    background: rgba(161, 110, 214, 0.1);
}

.dashboard-smart-grid {
    grid-template-columns: minmax(0, 1.3fr) minmax(320px, 0.9fr);
    align-items: start;
}

.dashboard-work-panel,
.dashboard-system-panel {
    display: grid;
    gap: 16px;
}

.dashboard-reply-stack,
.dashboard-diagnostics-list,
.dashboard-campaign-list,
.dashboard-activity-list {
    display: grid;
    gap: 14px;
}

.dashboard-subsection {
    display: grid;
    gap: 12px;
}

.dashboard-subsection-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
}

.dashboard-subsection-head small,
.dashboard-message-item p,
.dashboard-thread-body p,
.dashboard-system-card small,
.dashboard-campaign-row small,
.dashboard-activity-item p {
    color: var(--text-muted);
}

.dashboard-message-feed,
.dashboard-thread-stack {
    display: grid;
    gap: 10px;
}

.dashboard-message-item,
.dashboard-thread-item,
.dashboard-campaign-row,
.dashboard-activity-item,
.dashboard-diagnostic-item {
    display: grid;
    gap: 10px;
    padding: 13px 14px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.07);
    transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.dashboard-message-item,
.dashboard-campaign-row,
.dashboard-activity-item {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
}

.dashboard-thread-item {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
}

.dashboard-message-item:hover,
.dashboard-thread-item:hover,
.dashboard-campaign-row:hover {
    transform: translateY(-1px);
    border-color: rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.055);
}

.dashboard-message-main,
.dashboard-thread-body,
.dashboard-campaign-main {
    display: grid;
    gap: 8px;
    min-width: 0;
}

.dashboard-message-head,
.dashboard-thread-head,
.dashboard-campaign-head {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
}

.dashboard-message-head strong,
.dashboard-thread-head strong,
.dashboard-campaign-head strong,
.dashboard-activity-left strong {
    font-size: 0.96rem;
}

.dashboard-message-item p,
.dashboard-thread-body p,
.dashboard-activity-item p {
    margin: 0;
    line-height: 1.45;
    word-break: break-word;
}

.thread-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(161, 110, 214, 0.34), rgba(75, 39, 91, 0.8));
    color: var(--text);
    font-weight: 800;
    font-size: 0.9rem;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

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

.dashboard-diagnostic-item strong {
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #f6dfb5;
}

.dashboard-diagnostic-item p {
    margin: 0;
    color: var(--text-muted);
    line-height: 1.5;
}

.dashboard-campaign-bar {
    position: relative;
    overflow: hidden;
    height: 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
}

.dashboard-campaign-bar span {
    position: absolute;
    inset: 0 auto 0 0;
    border-radius: inherit;
    background: linear-gradient(90deg, rgba(78, 199, 165, 0.92), rgba(161, 110, 214, 0.92));
}

.dashboard-campaign-meta {
    display: grid;
    justify-items: end;
    gap: 4px;
    min-width: 56px;
}

.dashboard-campaign-meta strong {
    font-size: 1.15rem;
    line-height: 1;
}

.dashboard-activity-left {
    display: flex;
    gap: 12px;
    min-width: 0;
}

.dashboard-activity-left > div {
    display: grid;
    gap: 6px;
    min-width: 0;
}

.compact-empty h2 {
    margin: 0;
    font-size: 1.15rem;
}

.compact-empty p {
    margin: 0;
    color: var(--text-muted);
}

.compact-thread-topline {
    justify-content: space-between;
    align-items: baseline;
}

.compact-thread-topline strong {
    font-size: 0.98rem;
}

.compact-thread-topline small,
.compact-thread-subline,
.compact-thread-body p {
    color: var(--text-muted);
}

.compact-thread-subline {
    justify-content: space-between;
    flex-wrap: wrap;
    font-size: 0.82rem;
}

.thread-direction-chip {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    margin-right: 8px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
}

.thread-direction-chip.inbound {
    color: #d8fff3;
    background: rgba(78, 199, 165, 0.16);
}

.thread-direction-chip.outbound {
    color: #f0dbff;
    background: rgba(161, 110, 214, 0.16);
}

.login-meta {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 20px;
}

.centered {
    width: min(640px, 100%);
}

code {
    padding: 3px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
}

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

    .sidebar {
        position: static;
        height: auto;
        margin: 18px 18px 0;
    }

    .main-content {
        padding: 20px 18px 48px;
    }

    .cards-4,
    .dashboard-grid,
    .dashboard-smart-grid,
    .dashboard-lead,
    .two-col-layout,
    .conversation-layout,
    .conversation-shell,
    .catalog-grid,
    .login-meta {
        grid-template-columns: 1fr;
    }

    .conversation-main-panel {
        min-height: auto;
    }

    .conversation-side-panel {
        position: static;
    }
}

@media (max-width: 720px) {
    .topbar,
    .section-head,
    .dashboard-subsection-head,
    .card-item,
    .activity-item,
    .dashboard-message-head,
    .dashboard-thread-head,
    .dashboard-campaign-head,
    .dashboard-activity-item,
    .dashboard-message-item,
    .dashboard-campaign-row,
    .conversation-header-bar,
    .conversation-header-main,
    .conversation-index-header,
    .chat-composer-row {
        flex-direction: column;
        align-items: stretch;
    }

    .panel,
    .stat-card,
    .login-card {
        padding: 16px;
        border-radius: 20px;
    }

    .field-grid.two > * {
        flex-basis: 100%;
    }

    .dashboard-kpi-strip,
    .dashboard-system-cards {
        grid-template-columns: 1fr 1fr;
    }

    .bubble,
    .chat-bubble {
        max-width: 100%;
    }

    .compact-chat-thread {
        max-height: none;
    }

    .conversation-search input,
    .conversation-index-toolbar input {
        min-width: 0;
    }

    .dashboard-message-item,
    .dashboard-campaign-row,
    .dashboard-activity-item,
    .dashboard-thread-item {
        grid-template-columns: 1fr;
    }

    .dashboard-campaign-meta,
    .card-meta,
    .thread-meta {
        justify-items: start;
    }
}

/* Light workspace redesign */

:root {
    --bg: #f5f6f8;
    --bg-alt: #eceff4;
    --panel: #ffffff;
    --panel-soft: #f7f8fb;
    --border: #dde3ec;
    --text: #18212f;
    --text-muted: #667085;
    --text-dark: #18212f;
    --primary: #4b275b;
    --primary-bright: #6e4a84;
    --accent: #8c68ab;
    --success: #18805d;
    --warning: #b66a11;
    --danger: #bf3f52;
    --radius: 18px;
    --radius-sm: 12px;
    --shadow: 0 10px 30px rgba(21, 31, 48, 0.06);
}

body,
.blank-body {
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(140, 104, 171, 0.08), transparent 22%),
        linear-gradient(180deg, #fbfbfc 0%, #f3f5f8 52%, #eef2f6 100%);
}

.glass,
.glass-soft {
    background: var(--panel);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.glass-soft {
    background: var(--panel-soft);
    box-shadow: none;
}

.sidebar {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(247, 248, 251, 0.98) 100%);
    border-right: 1px solid var(--border);
}

.brand-lockup p,
.muted,
small,
.panel-hint,
label small {
    color: var(--text-muted);
}

.brand-eyebrow,
.pill {
    background: #f4eef9;
    color: #5d4172;
    border-color: #e5d8f0;
}

.nav a {
    color: #4c5868;
}

.nav a:hover,
.nav a.is-active {
    color: #1c2430;
    background: #f3eef8;
    border: 1px solid #e2d7ee;
}

.user-chip,
.card-item,
.message-row,
.thread-item,
.activity-item,
.preview-box,
.empty-state,
.chat-composer,
.compact-thread-item,
.dashboard-alert,
.dashboard-kpi,
.dashboard-system-card,
.dashboard-message-item,
.dashboard-thread-item,
.dashboard-campaign-row,
.dashboard-activity-item,
.dashboard-diagnostic-item {
    background: #fafbfd;
    border-color: #e7ebf1;
    box-shadow: none;
}

.main-content {
    padding: 20px 24px 36px 0;
}

.topbar {
    align-items: center;
    margin: 2px 0 16px;
}

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

.topbar h1,
.section-head h2,
.empty-state h2 {
    color: #15202c;
}

.panel,
.stat-card,
.login-card {
    padding: 18px;
    border-radius: 18px;
}

.stat-card span {
    margin-bottom: 10px;
}

.stat-card strong {
    font-size: clamp(1.6rem, 2.3vw, 2.2rem);
}

input,
select,
textarea {
    padding: 11px 13px;
    color: var(--text);
    background: #fff;
    border: 1px solid #d6dde7;
}

input:focus,
select:focus,
textarea:focus {
    border-color: rgba(75, 39, 91, 0.32);
    box-shadow: 0 0 0 3px rgba(75, 39, 91, 0.08);
}

.button {
    background: #4b275b;
    box-shadow: none;
}

.button.secondary {
    background: #6e4a84;
}

.button.ghost {
    background: #fff;
    color: #243041;
    border: 1px solid #d6dde7;
}

table {
    background: transparent;
}

th,
td {
    padding: 12px 10px;
    border-bottom: 1px solid #edf1f5;
}

th {
    color: #7b8797;
}

code {
    background: #f3f5f9;
    border-color: #e0e7f0;
    color: #334155;
}

.flash {
    background: #fff;
    border-color: #dde3ec;
    color: var(--text);
}

.flash.success {
    background: #effaf5;
    border-color: #cfeadc;
}

.flash.warning {
    background: #fff7ec;
    border-color: #f1dfc2;
}

.flash.error {
    background: #fff1f3;
    border-color: #f2cfd6;
}

.list-metric > div {
    border-bottom-color: #edf1f5;
}

.status {
    background: #eef2f6;
    color: #425062;
}

.status.paused,
.status.draft,
.status.retry,
.status.retrying,
.status.inactive {
    background: #eef2f6;
    color: #5b6778;
}

.conversation-shell,
.conversation-main-panel,
.conversation-side-panel {
    background: transparent;
}

.compact-chat-thread {
    background: #f8fafc;
    border-radius: 16px;
    border: 1px solid #e7ebf1;
    padding: 14px;
}

.chat-composer {
    bottom: 0;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid #dde3ec;
    box-shadow: 0 -8px 20px rgba(21, 31, 48, 0.05);
}

.chat-bubble,
.bubble {
    border: 1px solid #e5e9f0;
    box-shadow: none;
}

.chat-bubble.outbound,
.bubble.outbound {
    background: #f4eef9;
    border-color: #e2d7ee;
}

.chat-bubble.inbound,
.bubble.inbound {
    background: #ffffff;
}

.thread-avatar {
    background: #f3eef8;
    color: #4b275b;
    border-color: #e2d7ee;
}

.dashboard-campaign-bar {
    background: #ebeef4;
}

.dashboard-campaign-bar span {
    background: linear-gradient(90deg, #4b275b 0%, #8c68ab 100%);
}

.login-screen {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 32px 18px;
}

.login-card {
    width: min(520px, 100%);
}

.login-meta > div {
    padding: 14px;
    border-radius: 14px;
    background: #f7f8fb;
    border: 1px solid #e7ebf1;
}

@media (max-width: 1100px) {
    .main-content {
        padding: 20px 18px 40px;
    }
}

@media (max-width: 720px) {
    .topbar-actions {
        width: 100%;
    }

    .topbar-actions .button {
        flex: 1 1 auto;
    }

    .dashboard-kpi-strip,
    .dashboard-system-cards {
        grid-template-columns: 1fr;
    }
}

/* Operational refinement */

:root {
    --bg: #f1f3f5;
    --bg-alt: #e8ebef;
    --panel: #ffffff;
    --panel-soft: #f7f8fa;
    --border: #d8dde4;
    --text: #111418;
    --text-muted: #5f6977;
    --text-dark: #111418;
    --primary: #12161c;
    --primary-bright: #2d333b;
    --accent: #4b275b;
    --success: #0f6a4f;
    --warning: #8c5b12;
    --danger: #a13647;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 6px 18px rgba(16, 24, 40, 0.05);
}

body,
.blank-body {
    background:
        linear-gradient(180deg, #f8f9fb 0%, #f1f3f5 46%, #eceff3 100%);
}

.workspace-shell {
    min-height: 100vh;
}

.workspace-header {
    position: sticky;
    top: 0;
    z-index: 40;
    background: rgba(248, 249, 251, 0.92);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.workspace-header-inner {
    max-width: 1680px;
    margin: 0 auto;
    padding: 10px 24px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 18px;
    align-items: center;
}

.workspace-brand-block {
    display: grid;
    gap: 2px;
}

.workspace-brand {
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    color: #111418;
}

.workspace-subtitle {
    font-size: 0.73rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.workspace-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-width: 0;
}

.workspace-nav a {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 7px 11px;
    border-radius: 9px;
    border: 1px solid transparent;
    color: #485465;
    font-size: 0.9rem;
    font-weight: 600;
    transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.workspace-nav a:hover,
.workspace-nav a.is-active {
    background: #ffffff;
    border-color: var(--border);
    color: #111418;
}

.workspace-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.workspace-user {
    display: grid;
    gap: 2px;
    justify-items: end;
}

.workspace-user strong {
    font-size: 0.88rem;
    font-weight: 700;
}

.workspace-user small {
    font-size: 0.76rem;
    color: var(--text-muted);
}

.main-content.workspace-main {
    max-width: 1680px;
    margin: 0 auto;
    padding: 18px 24px 32px;
}

.topbar {
    margin: 0 0 14px;
    align-items: center;
}

.topbar h1,
.section-head h2,
.empty-state h2 {
    font-size: clamp(1.35rem, 1.9vw, 1.9rem);
}

.pill {
    padding: 5px 8px;
    border-radius: 999px;
    background: #f3f4f6;
    color: #566171;
    border: 1px solid #e1e6ec;
    font-size: 0.68rem;
    letter-spacing: 0.05em;
}

.panel,
.stat-card,
.login-card {
    padding: 16px;
    border-radius: 12px;
}

.section-head {
    margin-bottom: 14px;
}

.grid,
.card-list,
.activity-feed,
.message-list,
.thread-list,
.stack-panels,
.dashboard-reply-stack,
.dashboard-diagnostics-list,
.dashboard-campaign-list,
.dashboard-activity-list {
    gap: 12px;
}

.button {
    min-height: 38px;
    padding: 9px 13px;
    border-radius: 9px;
    background: #111418;
    font-size: 0.92rem;
    font-weight: 700;
}

.button.secondary {
    background: #2d333b;
}

.button.ghost {
    background: #ffffff;
    color: #111418;
    border: 1px solid #d8dde4;
}

.button.tiny {
    min-height: 30px;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 0.8rem;
}

input,
select,
textarea {
    padding: 10px 12px;
    border-radius: 9px;
}

label > span,
.field-group h3 {
    font-size: 0.78rem;
}

th,
td {
    padding: 10px 8px;
}

.data-table table {
    font-size: 0.92rem;
}

.card-item,
.message-row,
.thread-item,
.activity-item,
.preview-box,
.empty-state,
.chat-composer,
.compact-thread-item,
.dashboard-alert,
.dashboard-kpi,
.dashboard-system-card,
.dashboard-message-item,
.dashboard-thread-item,
.dashboard-campaign-row,
.dashboard-activity-item,
.dashboard-diagnostic-item,
.login-meta > div {
    border-radius: 10px;
}

.dashboard-lead,
.dashboard-smart-grid {
    gap: 14px;
}

.dashboard-action-stack,
.dashboard-toolbox {
    gap: 8px;
}

.dashboard-alert strong,
.dashboard-message-head strong,
.dashboard-thread-head strong,
.dashboard-campaign-head strong,
.dashboard-activity-left strong {
    font-size: 0.92rem;
}

.dashboard-kpi strong,
.dashboard-system-card strong {
    font-size: 1.12rem;
}

.dashboard-message-item p,
.dashboard-thread-body p,
.dashboard-activity-item p,
.dashboard-diagnostic-item p,
.dashboard-campaign-row small,
.dashboard-system-card small {
    font-size: 0.84rem;
}

.thread-avatar {
    width: 34px;
    height: 34px;
    font-size: 0.84rem;
    border-radius: 10px;
    background: #f3f4f6;
    color: #111418;
    border-color: #e1e6ec;
}

.status.success,
.status.info {
    color: #1f2937;
    background: #edf0f4;
}

.status.warning {
    color: #7a4d0f;
    background: #fbf3e7;
}

.status.danger {
    color: #8f3040;
    background: #faecef;
}

.status.sent,
.status.delivered,
.status.completed,
.status.confirmed {
    color: #0f6a4f;
    background: #eaf6f2;
}

.status.failed,
.status.cancelled,
.status.opt_out,
.status.declined {
    color: #a13647;
    background: #faecef;
}

.status.running,
.status.sending,
.status.pending,
.status.planned,
.status.open,
.status.processed {
    color: #8c5b12;
    background: #fbf3e7;
}

.status.paused,
.status.draft,
.status.retry,
.status.retrying,
.status.inactive {
    color: #4d5968;
    background: #edf0f4;
}

.login-card {
    border-radius: 14px;
}

.login-card h1 {
    font-size: clamp(1.9rem, 2.8vw, 2.4rem);
}

.compact-chat-thread {
    border-radius: 12px;
}

.chat-composer {
    border-radius: 12px;
    box-shadow: 0 -4px 12px rgba(16, 24, 40, 0.04);
}

@media (max-width: 1100px) {
    .workspace-header-inner {
        grid-template-columns: 1fr;
        align-items: start;
    }

    .workspace-header-actions,
    .workspace-user {
        justify-items: start;
        justify-content: flex-start;
    }

    .main-content.workspace-main {
        padding: 18px 18px 28px;
    }
}

@media (max-width: 720px) {
    .workspace-header-inner {
        padding: 10px 14px;
    }

    .workspace-nav {
        gap: 5px;
    }

    .workspace-nav a {
        font-size: 0.85rem;
        padding: 7px 9px;
    }

    .main-content.workspace-main {
        padding: 16px 14px 26px;
    }
}
