:root {
    --font-sans: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-size-body: 14px;
    --font-size-meta: 12px;
    --font-size-table: 13px;
    --line-height-body: 1.45;
    --line-height-tight: 1.2;
    --weight-medium: 500;
    --weight-semibold: 600;
    --weight-bold: 700;

    --bg-page: #f4f7fb;
    --bg-sidebar: #ffffff;
    --bg-panel: #ffffff;
    --bg-panel-soft: #f8fafc;
    --bg-muted: #f2f5f9;
    --bg-accent: linear-gradient(180deg, rgba(246, 249, 255, 0.96) 0%, rgba(241, 245, 251, 0.96) 100%);

    --text-strong: #142033;
    --text-body: #31435f;
    --text-muted: #76849a;
    --text-faint: #9aa6b7;

    --line-soft: rgba(20, 32, 51, 0.08);
    --line-medium: rgba(20, 32, 51, 0.12);
    --line-strong: rgba(20, 32, 51, 0.18);

    --blue: #3164f4;
    --blue-soft: rgba(49, 100, 244, 0.08);
    --indigo: #5468d8;
    --violet: #6d5ef8;
    --green: #12805c;
    --green-soft: rgba(18, 128, 92, 0.10);
    --amber: #b7791f;
    --amber-soft: rgba(183, 121, 31, 0.12);
    --red: #c65a63;
    --red-soft: rgba(198, 90, 99, 0.10);
    --gray: #6f7d92;
    --gray-soft: rgba(111, 125, 146, 0.10);

    --radius-xs: 10px;
    --radius-sm: 14px;
    --radius-md: 18px;
    --radius-lg: 22px;
    --radius-xl: 24px;

    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-sm: 0 8px 24px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 16px 36px rgba(15, 23, 42, 0.06);

    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-7: 28px;
    --space-8: 32px;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: var(--font-size-body);
    line-height: var(--line-height-body);
    color: var(--text-body);
    background:
        radial-gradient(circle at top left, rgba(49, 100, 244, 0.08), transparent 26%),
        radial-gradient(circle at top right, rgba(109, 94, 248, 0.05), transparent 22%),
        var(--bg-page);
}

body.modal-open {
    overflow: hidden;
}

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

p {
    margin: 0 0 10px;
}

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

.prosperia-shell {
    display: grid;
    grid-template-columns: 248px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 22px 18px;
    background: rgba(255, 255, 255, 0.88);
    border-right: 1px solid var(--line-soft);
    backdrop-filter: blur(16px);
    display: flex;
    flex-direction: column;
    gap: 22px;
}

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

.brand-logo {
    width: 40px;
    height: 40px;
    border-radius: 14px;
    display: block;
    object-fit: cover;
    background: white;
    border: 1px solid rgba(20, 32, 51, 0.08);
    box-shadow: 0 10px 24px rgba(49, 100, 244, 0.16);
}

.sidebar-brand strong {
    display: block;
    margin-bottom: 2px;
    color: var(--text-strong);
    font-size: 14px;
    letter-spacing: -0.02em;
}

.sidebar-brand span {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
}

.sidebar-nav {
    display: grid;
    gap: 0;
}

.sidebar-nav-group {
    display: grid;
    gap: 2px;
}

.sidebar-nav-label {
    padding: 0 10px;
    color: var(--text-faint);
    font-size: 10px;
    font-weight: var(--weight-bold);
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    min-height: 40px;
    padding: 9px 12px;
    border-radius: 14px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: var(--weight-semibold);
    transition: background-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.sidebar-nav a:hover {
    background: var(--bg-muted);
    color: var(--text-strong);
}

.sidebar-nav a.active {
    background: linear-gradient(180deg, rgba(49, 100, 244, 0.10), rgba(49, 100, 244, 0.06));
    color: var(--blue);
    box-shadow: inset 0 0 0 1px rgba(49, 100, 244, 0.12);
}

.sidebar-footer {
    margin-top: auto;
    padding: 14px;
    border-radius: 18px;
    background: var(--bg-panel-soft);
    border: 1px solid var(--line-soft);
    color: var(--text-muted);
    font-size: 12px;
}

.main-panel {
    padding: 22px 24px 28px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
    margin-bottom: 16px;
    padding: 4px 0 2px;
}

.topbar h1,
.login-card h1 {
    margin: 0;
    color: var(--text-strong);
    font-size: clamp(22px, 2vw, 28px);
    line-height: 1.05;
    letter-spacing: -0.04em;
    font-weight: 700;
}

.topbar p,
.muted,
.login-card p {
    margin: 6px 0 0;
    color: var(--text-muted);
    font-size: 13px;
}

.topbar-actions,
.form-actions,
.queue-actions,
.inline-form,
.panel-actions,
.hero-actions,
.table-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.settings-subnav {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 18px;
    padding: 8px;
    border: 1px solid var(--line-soft);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.72);
    width: fit-content;
}

.settings-subnav a {
    min-height: 36px;
    padding: 8px 14px;
    border-radius: 12px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: var(--weight-semibold);
}

.settings-subnav a.active {
    background: rgba(49, 100, 244, 0.1);
    color: var(--blue);
    box-shadow: inset 0 0 0 1px rgba(49, 100, 244, 0.12);
}

.api-hero-grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
    gap: 16px;
    margin-bottom: 18px;
}

.api-hero-card,
.api-hero-side,
.api-card,
.api-monitor-panel {
    position: relative;
    overflow: hidden;
}

.api-hero-card::after,
.api-card::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(135deg, rgba(49, 100, 244, 0.05), transparent 44%);
}

.api-card-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.api-card.is-selected {
    box-shadow: inset 0 0 0 1px rgba(49, 100, 244, 0.18), var(--shadow-sm);
    border-color: rgba(49, 100, 244, 0.16);
}

.api-card-top,
.api-card-actions,
.api-config-highlights {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.api-card-top {
    justify-content: space-between;
    margin-bottom: 10px;
}

.api-card h3,
.api-hero-card h2,
.api-monitor-panel h2 {
    margin: 0;
    color: var(--text-strong);
    font-size: 18px;
    line-height: 1.1;
    letter-spacing: -0.03em;
}

.details-list.compact div {
    gap: 12px;
}

.api-settings-grid {
    grid-template-columns: minmax(0, 1.6fr) minmax(320px, 1fr);
    align-items: start;
}

.api-monitor-panel .details-list,
.api-hero-side .details-list {
    margin-bottom: 0;
}

.api-config-highlights {
    margin-top: 16px;
}

.api-error-log {
    margin-top: 16px;
    padding: 14px 16px;
    border-radius: 16px;
    background: rgba(198, 90, 99, 0.08);
    border: 1px solid rgba(198, 90, 99, 0.14);
}

.api-error-log.subtle {
    background: rgba(20, 32, 51, 0.04);
    border-color: rgba(20, 32, 51, 0.08);
}

.api-error-log p:last-child {
    margin-bottom: 0;
}

.form-span-2 {
    grid-column: span 2;
}

.heading-with-signal {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.pending-signal {
    position: relative;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #f59e0b;
    box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.14);
    flex: 0 0 10px;
    animation: pendingPulse 1.8s ease-in-out infinite;
}

.pending-signal::after {
    content: "";
    position: absolute;
    inset: -6px;
    border-radius: 999px;
    border: 1px solid rgba(245, 158, 11, 0.28);
    animation: pendingRing 1.8s ease-out infinite;
}

@keyframes pendingPulse {
    0%,
    100% {
        transform: scale(1);
        opacity: 0.92;
    }
    50% {
        transform: scale(1.08);
        opacity: 1;
    }
}

@keyframes pendingRing {
    0% {
        transform: scale(0.7);
        opacity: 0.9;
    }
    100% {
        transform: scale(1.4);
        opacity: 0;
    }
}

.bulk-action-bar {
    position: sticky;
    top: 12px;
    z-index: 3;
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    padding: 12px 14px;
    border-radius: 16px;
    border: 1px solid var(--line-soft);
    background: rgba(255, 255, 255, 0.94);
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(12px);
}

.bulk-action-bar.is-active {
    display: flex;
}

.bulk-action-meta,
.bulk-action-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.page-content {
    display: grid;
    gap: 16px;
}

.reply-page {
    display: flex;
    justify-content: center;
}

.reply-page-shell {
    width: min(100%, 1180px);
}

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

.reply-main,
.reply-side {
    display: grid;
    gap: 16px;
}

.reply-thread-card,
.reply-editor-card,
.reply-ai-card {
    padding: 18px;
}

.reply-thread-head,
.reply-editor-head,
.reply-ai-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 14px;
}

.reply-thread-head h2,
.reply-editor-head h2,
.reply-ai-head h2 {
    margin: 4px 0 0;
    color: var(--text-strong);
    font-size: 18px;
    letter-spacing: -0.04em;
}

.reply-thread-actions,
.reply-rewrite-toolbar,
.reply-aux-actions,
.reply-ai-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.reply-conversation {
    max-height: 460px;
    overflow: auto;
    display: grid;
    gap: 10px;
    padding-right: 4px;
}

.reply-message {
    border: 1px solid var(--line-soft);
    border-left: 1px solid var(--line-soft);
    border-radius: 16px;
    padding: 12px 13px;
    background: #fbfcff;
    box-shadow: var(--shadow-xs);
}

.reply-message.outbound {
    background: rgba(109, 94, 248, 0.05);
    border-color: rgba(109, 94, 248, 0.14);
}

.reply-message.is-latest-inbound {
    border-left: 4px solid #16a34a;
    box-shadow: 0 12px 30px rgba(22, 163, 74, 0.08);
}

.mail-new-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px;
    border-radius: 999px;
    background: rgba(22, 163, 74, 0.1);
    color: #15803d;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
}

.reply-message-meta {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 8px;
    color: var(--text-muted);
    font-size: 11px;
}

.reply-message-meta strong {
    color: var(--text-strong);
    font-size: 12px;
}

.reply-message-meta > div:last-child {
    text-align: right;
}

.reply-message-body {
    max-height: 190px;
    overflow: auto;
    color: var(--text-body);
    font-size: 13px;
    line-height: 1.58;
    word-break: break-word;
}

.reply-message-body p:last-child {
    margin-bottom: 0;
}

.reply-quoted-toggle {
    margin-top: 10px;
}

.reply-quoted-toggle summary {
    cursor: pointer;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: var(--weight-semibold);
    list-style: none;
}

.reply-quoted-toggle summary::-webkit-details-marker {
    display: none;
}

.reply-quoted-toggle summary::before {
    content: "+ ";
}

.reply-quoted-toggle[open] summary::before {
    content: "- ";
}

.reply-quoted-history {
    margin-top: 8px;
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--bg-muted);
    border: 1px solid var(--line-soft);
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.reply-inline-note {
    margin-bottom: 12px;
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(49, 100, 244, 0.08);
    border: 1px solid rgba(49, 100, 244, 0.12);
    color: var(--text-body);
    font-size: 13px;
}

.reply-form-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 12px;
}

.reply-field {
    display: grid;
    gap: 6px;
}

.reply-field label {
    color: var(--text-strong);
    font-size: 12px;
    font-weight: var(--weight-semibold);
}

.reply-field small,
.reply-preview-card small {
    color: var(--text-muted);
    font-size: 11px;
}

.reply-field textarea {
    min-height: 220px;
}

.reply-rewrite-toolbar {
    margin-top: 14px;
}

.reply-preview-grid {
    margin-top: 16px;
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 14px;
}

.reply-preview-card {
    border: 1px solid var(--line-soft);
    border-radius: 18px;
    background: #fbfcff;
    padding: 14px;
}

.reply-preview-head {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.reply-preview-head h3 {
    margin: 4px 0 0;
    color: var(--text-strong);
    font-size: 14px;
    letter-spacing: -0.03em;
}

.reply-signature-preview,
.reply-final-preview {
    border: 1px solid var(--line-soft);
    border-radius: 14px;
    background: #fff;
    padding: 14px;
}

.reply-signature-preview {
    min-height: 140px;
    font-size: 13px;
    color: var(--text-body);
    line-height: 1.55;
}

.reply-envelope-meta {
    display: grid;
    gap: 8px;
    margin-bottom: 12px;
}

.reply-envelope-meta div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--line-soft);
    font-size: 12px;
}

.reply-envelope-meta span {
    color: var(--text-muted);
}

.reply-envelope-meta strong {
    color: var(--text-strong);
    font-size: 12px;
    text-align: right;
}

.reply-final-preview {
    display: grid;
    gap: 16px;
}

.reply-final-body,
.reply-final-signature {
    color: var(--text-body);
    font-size: 13px;
    line-height: 1.6;
    word-break: break-word;
}

.reply-final-signature {
    padding-top: 14px;
    border-top: 1px solid var(--line-soft);
}

.reply-aux-actions {
    margin-top: 14px;
}

.reply-ai-stack {
    display: grid;
    gap: 10px;
}

.reply-ai-item {
    border: 1px solid var(--line-soft);
    border-radius: 16px;
    background: #fbfcff;
    padding: 12px;
}

.reply-ai-item p {
    margin: 6px 0 0;
    color: var(--text-body);
    font-size: 13px;
    line-height: 1.5;
}

.reply-ai-actions {
    margin-top: 14px;
}

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

    .reply-side {
        order: -1;
    }
}

@media (max-width: 860px) {
    .reply-form-grid,
    .reply-preview-grid {
        grid-template-columns: 1fr;
    }

    .reply-thread-head,
    .reply-editor-head,
    .reply-ai-head,
    .reply-message-meta {
        flex-direction: column;
    }

    .reply-message-meta > div:last-child,
    .reply-envelope-meta strong {
        text-align: left;
    }

    .persona-card-top {
        flex-direction: column;
    }

    .persona-tone {
        text-align: left;
    }
}

.messages-stack {
    display: grid;
    gap: 8px;
    margin-bottom: 14px;
}

.flash {
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line-soft);
    background: rgba(255, 255, 255, 0.92);
    box-shadow: var(--shadow-xs);
    font-size: 13px;
}

.flash.success {
    border-left: 3px solid var(--green);
}

.flash.error {
    border-left: 3px solid var(--red);
}

.flash.info {
    border-left: 3px solid var(--blue);
}

.modal-shell {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

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

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(20, 32, 51, 0.34);
    backdrop-filter: blur(10px);
}

.modal-card {
    position: relative;
    z-index: 1;
    width: min(100%, 460px);
    padding: 20px;
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.55);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 28px 80px rgba(15, 23, 42, 0.18);
}

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

.modal-head h2 {
    margin: 0;
    color: var(--text-strong);
    font-size: 18px;
    letter-spacing: -0.04em;
}

.modal-copy {
    margin: 0 0 18px;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.55;
}

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

.modal-close {
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--line-soft);
    border-radius: 12px;
    background: #fbfcfe;
    color: var(--text-muted);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

.modal-close:hover {
    color: var(--text-strong);
    border-color: var(--line-medium);
}

.stat-grid,
.grid.two-col,
.grid.three-col,
.card-grid,
.dashboard-grid,
.surface-grid {
    display: grid;
    gap: 16px;
}

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

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

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

.align-start {
    align-items: start;
}

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

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

.panel,
.stat-card,
.queue-card,
.persona-card,
.login-card {
    background: var(--bg-panel);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.panel {
    padding: 18px;
}

.mt-16 {
    margin-top: 16px;
}

.crm-object-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    min-height: 46px;
    padding: 6px;
    border: 1px solid var(--line-soft);
    border-radius: 14px;
    background: #ffffff;
    box-shadow: var(--shadow-xs);
    overflow-x: auto;
}

.crm-object-nav a {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 8px 12px;
    border-radius: 10px;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: var(--weight-semibold);
    white-space: nowrap;
}

.crm-object-nav a:hover,
.crm-object-nav a.active {
    background: rgba(49, 100, 244, 0.08);
    color: var(--blue);
}

.crm-record-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    padding: 14px 16px;
    border: 1px solid var(--line-soft);
    border-radius: 16px;
    background: #ffffff;
    box-shadow: var(--shadow-sm);
}

.crm-record-header .hero-header {
    width: 100%;
}

.crm-record-main {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.crm-record-main h2 {
    margin: 0;
    color: var(--text-strong);
    font-size: 20px;
    line-height: 1.1;
    letter-spacing: -0.03em;
}

.crm-record-main p {
    margin: 4px 0 0;
    color: var(--text-muted);
    font-size: 12px;
}

.crm-object-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    border-radius: 10px;
    background: #1b96ff;
    color: #ffffff;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.04em;
    box-shadow: inset 0 -1px 0 rgba(20, 32, 51, 0.18);
}

.crm-list-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
}

.crm-list-toolbar > div:first-child {
    display: grid;
    gap: 2px;
}

.crm-list-toolbar strong {
    color: var(--text-strong);
    font-size: 13px;
}

.crm-path {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 4px;
}

.crm-path-step {
    position: relative;
    min-height: 36px;
    padding: 9px 12px;
    background: #e8edf5;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: var(--weight-bold);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%, 10px 50%);
}

.crm-path-step:first-child {
    clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%);
}

.crm-path-step strong {
    float: right;
    color: var(--text-strong);
}

.crm-path-step.has-items,
.crm-path-step.active {
    background: #2e844a;
    color: #ffffff;
}

.crm-path-step.has-items strong,
.crm-path-step.active strong {
    color: #ffffff;
}

.panel-subtle {
    background: var(--bg-panel-soft);
}

.panel-heading,
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 14px;
}

.panel-heading h2,
.panel-header h2,
.persona-card h3,
.queue-card h2 {
    margin: 0;
    color: var(--text-strong);
    font-size: 15px;
    letter-spacing: -0.03em;
    font-weight: var(--weight-bold);
}

.panel-intro {
    margin: 4px 0 0;
    color: var(--text-muted);
    font-size: 12px;
}

.quick-link-card {
    min-height: 132px;
}

.quick-link-card h3 {
    margin: 6px 0 8px;
    font-size: 15px;
    color: var(--text-strong);
}

.quick-link-card p {
    margin: 0;
    color: var(--text-muted);
    font-size: 12px;
}

.stat-card {
    padding: 16px 18px;
    display: grid;
    gap: 4px;
}

.stat-card .kpi-label,
.stat-card span {
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.3;
}

.stat-card strong {
    color: var(--text-strong);
    font-size: 24px;
    line-height: 1;
    letter-spacing: -0.05em;
    font-weight: 700;
}

.kpi-meta {
    color: var(--text-faint);
    font-size: 12px;
}

.chip,
.badge,
.score-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 26px;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 11px;
    line-height: 1;
    font-weight: var(--weight-semibold);
    white-space: nowrap;
}

.chip {
    background: var(--bg-muted);
    color: var(--text-body);
}

.chip-glow {
    background: rgba(49, 100, 244, 0.10);
    color: var(--blue);
}

.score-pill {
    background: linear-gradient(180deg, rgba(49, 100, 244, 0.12), rgba(109, 94, 248, 0.10));
    color: var(--blue);
}

.badge-amber {
    background: var(--amber-soft);
    color: var(--amber);
}

.badge-blue {
    background: rgba(49, 100, 244, 0.10);
    color: var(--blue);
}

.badge-indigo {
    background: rgba(84, 104, 216, 0.10);
    color: var(--indigo);
}

.badge-violet {
    background: rgba(109, 94, 248, 0.10);
    color: var(--violet);
}

.badge-green {
    background: var(--green-soft);
    color: var(--green);
}

.badge-red {
    background: var(--red-soft);
    color: var(--red);
}

.badge-gray {
    background: var(--gray-soft);
    color: var(--gray);
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 36px;
    padding: 8px 12px;
    border-radius: 12px;
    border: 1px solid transparent;
    font-size: 12px;
    font-weight: var(--weight-semibold);
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease, color 0.18s ease;
}

.button-sm {
    min-height: 34px;
    padding: 7px 11px;
    font-size: 12px;
}

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

.button-primary {
    color: white;
    background: linear-gradient(180deg, #3b6df6 0%, #2f62ec 100%);
    box-shadow: 0 10px 22px rgba(49, 100, 244, 0.18);
}

.button-secondary {
    background: #fbfcfe;
    color: var(--text-body);
    border-color: var(--line-medium);
}

.button-ghost {
    background: transparent;
    color: var(--text-muted);
    border-color: var(--line-soft);
}

.button-full {
    width: 100%;
}

.eyebrow,
.mini-label {
    display: inline-block;
    margin-bottom: 5px;
    color: var(--text-faint);
    font-size: 11px;
    line-height: 1.2;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: var(--weight-semibold);
}

.form-panel form,
.draft-form,
.filter-grid {
    display: grid;
    gap: 14px;
}

.campaign-builder,
.builder-stack {
    display: grid;
    gap: 16px;
}

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

.filter-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    align-items: end;
}

.field-full {
    grid-column: 1 / -1;
}

label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-body);
    font-size: 12px;
    font-weight: var(--weight-semibold);
}

input,
select,
textarea {
    width: 100%;
    min-height: 40px;
    padding: 9px 11px;
    border-radius: 12px;
    border: 1px solid var(--line-medium);
    background: #fbfcfe;
    color: var(--text-strong);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

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

input[type="checkbox"] {
    width: 16px;
    min-height: auto;
    padding: 0;
    border-radius: 6px;
    accent-color: var(--blue);
    box-shadow: none;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    background: #ffffff;
    border-color: rgba(49, 100, 244, 0.35);
    box-shadow: 0 0 0 3px rgba(49, 100, 244, 0.10);
}

small,
.field-error,
.form-help {
    display: block;
    margin-top: 6px;
    font-size: 11px;
}

small,
.form-help {
    color: var(--text-faint);
}

.field-error {
    color: var(--red);
}

.subsection-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
}

.toggle-field {
    display: grid;
    align-content: start;
}

.toggle-inline {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    min-height: 40px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--line-medium);
    background: #fbfcfe;
}

.inline-link {
    color: var(--blue);
    font-size: 12px;
    font-weight: var(--weight-semibold);
}

.hint-box {
    margin-top: 10px;
    padding: 12px 14px;
    border-radius: 16px;
    border: 1px solid rgba(49, 100, 244, 0.10);
    background: rgba(49, 100, 244, 0.04);
}

.hint-box p {
    margin: 6px 0 0;
    font-size: 12px;
    color: var(--text-muted);
}

.signature-preview-shell {
    display: grid;
    gap: 12px;
}

.signature-preview-frame,
.signature-text-preview {
    padding: 14px;
    border-radius: 16px;
    border: 1px solid var(--line-soft);
    background: #fbfcfe;
}

.signature-preview-frame {
    min-height: 180px;
}

.signature-text-preview {
    margin: 0;
    white-space: pre-wrap;
    color: var(--text-body);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
    line-height: 1.55;
}

.signature-text-preview.compact {
    min-height: 120px;
}

.picker-card {
    padding: 16px 18px;
    border: 1px solid var(--line-soft);
    border-radius: 18px;
    background: var(--bg-panel-soft);
}

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

.picker-header h3 {
    margin: 0;
    color: var(--text-strong);
    font-size: 14px;
}

.picker-header p {
    margin: 4px 0 0;
    font-size: 12px;
    color: var(--text-muted);
}

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

.choice-grid > div {
    display: contents;
}

.choice-grid label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0;
    min-height: 44px;
    padding: 11px 12px;
    border-radius: 14px;
    border: 1px solid var(--line-soft);
    background: #ffffff;
    color: var(--text-body);
    font-size: 12px;
    font-weight: var(--weight-medium);
    cursor: pointer;
}

.choice-grid label:hover {
    border-color: rgba(49, 100, 244, 0.18);
    background: rgba(49, 100, 244, 0.03);
}

.choice-grid label:has(input:checked) {
    border-color: rgba(49, 100, 244, 0.30);
    background: rgba(49, 100, 244, 0.06);
    box-shadow: inset 0 0 0 1px rgba(49, 100, 244, 0.08);
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line-soft);
    border-radius: 16px;
}

.premium-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-table);
}

.premium-table thead th {
    padding: 11px 14px;
    text-align: left;
    color: var(--text-faint);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: var(--weight-semibold);
    background: var(--bg-panel-soft);
    border-bottom: 1px solid var(--line-soft);
}

.premium-table tbody td {
    padding: 12px 14px;
    color: var(--text-body);
    border-bottom: 1px solid var(--line-soft);
    vertical-align: top;
}

.premium-table tbody tr:last-child td {
    border-bottom: none;
}

.premium-table tbody tr:hover {
    background: rgba(49, 100, 244, 0.025);
}

.cell-title {
    display: grid;
    gap: 3px;
}

.cell-title strong,
.cell-title a,
.premium-table strong {
    color: var(--text-strong);
    font-weight: var(--weight-semibold);
}

.cell-meta,
.meta,
.muted,
small.muted {
    color: var(--text-muted);
    font-size: 12px;
}

.metric-list,
.details-list,
.thread-list,
.queue-list,
.summary-list {
    display: grid;
    gap: 0;
    margin: 0;
    padding: 0;
    list-style: none;
}

.metric-list li,
.details-list div,
.summary-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 11px 0;
    border-bottom: 1px solid var(--line-soft);
}

.metric-list li:last-child,
.details-list div:last-child,
.summary-item:last-child {
    border-bottom: none;
}

.details-list span {
    color: var(--text-faint);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: var(--weight-semibold);
}

.details-list strong {
    color: var(--text-strong);
    text-align: right;
    font-size: 13px;
    font-weight: var(--weight-semibold);
}

.activity-chart {
    display: grid;
    gap: 10px;
}

.activity-row {
    display: grid;
    grid-template-columns: 50px 1fr 24px;
    gap: 10px;
    align-items: center;
    color: var(--text-muted);
    font-size: 12px;
}

.activity-row strong {
    color: var(--text-body);
    font-size: 12px;
}

.bar-track {
    height: 8px;
    border-radius: 999px;
    overflow: hidden;
    background: #edf2f8;
}

.bar-fill {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--blue), var(--violet));
}

.empty-state {
    padding: 18px;
    border-radius: 16px;
    border: 1px dashed var(--line-medium);
    background: var(--bg-panel-soft);
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
}

.queue-card {
    padding: 18px;
    display: grid;
    gap: 14px;
}

.queue-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.queue-head p,
.queue-body p {
    margin: 0;
}

.queue-body {
    display: grid;
    gap: 12px;
}

.inbox-layout {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr) 344px;
    gap: 16px;
}

.inbox-column {
    min-height: 70vh;
}

.threads-column,
.ai-column {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
}

.thread-list {
    gap: 6px;
}

.thread-item {
    display: grid;
    gap: 2px;
    padding: 12px;
    border: 1px solid transparent;
    border-radius: 16px;
    background: transparent;
    transition: border-color 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease;
}

.thread-item strong {
    color: var(--text-strong);
    font-size: 13px;
    font-weight: var(--weight-semibold);
}

.thread-item span,
.thread-item small {
    color: var(--text-muted);
    font-size: 12px;
}

.thread-item:hover,
.thread-item.active {
    border-color: rgba(49, 100, 244, 0.12);
    background: rgba(49, 100, 244, 0.035);
    box-shadow: inset 0 0 0 1px rgba(49, 100, 244, 0.05);
}

.thread-item-compact {
    gap: 6px;
    padding: 10px 11px;
    cursor: pointer;
}

.thread-row,
.thread-row-meta,
.thread-row-foot {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
}

.thread-row-meta,
.thread-row-foot {
    color: var(--text-muted);
    font-size: 11px;
}

.thread-row strong {
    display: block;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.thread-row-meta span:first-child,
.thread-row-foot span:first-child {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.conversation-column {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
}

.conversation-stream {
    display: grid;
    gap: 12px;
}

.message-bubble {
    max-width: 88%;
    padding: 12px 14px;
    border-radius: 16px;
    border: 1px solid var(--line-soft);
    background: #fbfcfe;
}

.message-bubble > span {
    display: block;
    margin-bottom: 6px;
    color: var(--text-faint);
    font-size: 11px;
    font-weight: var(--weight-semibold);
}

.message-bubble p {
    margin: 0;
    color: var(--text-body);
    font-size: 13px;
    line-height: 1.5;
}

.message-bubble.inbound {
    background: #f8fbff;
}

.message-bubble.outbound {
    margin-left: auto;
    background: #f8f7ff;
}

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

.ai-block,
.draft-preview,
.summary-block {
    padding: 12px 14px;
    border-radius: 16px;
    background: var(--bg-panel-soft);
    border: 1px solid var(--line-soft);
}

.ai-block p,
.draft-preview p,
.summary-block p {
    margin: 0;
    font-size: 13px;
    overflow-wrap: anywhere;
}

.draft-form {
    gap: 10px;
}

.composer-shell {
    gap: 14px;
}

.composer-meta {
    display: grid;
    gap: 10px;
}

.compact-preview {
    gap: 8px;
}

.preview-card {
    padding: 14px;
    border-radius: 16px;
    border: 1px solid var(--line-soft);
    background: #fbfcfe;
    color: var(--text-body);
    font-size: 13px;
    line-height: 1.6;
}

.preview-card p {
    margin: 0;
}

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

.stacked {
    justify-content: flex-start;
}

.hero-card {
    display: grid;
    gap: 14px;
}

.hero-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
}

.hero-header h2 {
    margin: 0;
    color: var(--text-strong);
    font-size: 20px;
    letter-spacing: -0.04em;
}

.thread-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 18px;
    align-items: start;
}

.thread-workspace-wide {
    grid-template-columns: minmax(0, 1.2fr) minmax(320px, 420px);
}

.workspace-main,
.workspace-side {
    display: grid;
    gap: 16px;
}

.hero-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.compact-list li {
    padding: 9px 0;
}

.timeline {
    position: relative;
    display: grid;
    gap: 12px;
}

.timeline::before {
    content: "";
    position: absolute;
    top: 4px;
    bottom: 4px;
    left: 9px;
    width: 1px;
    background: linear-gradient(180deg, rgba(49, 100, 244, 0.18), rgba(20, 32, 51, 0.08));
}

.timeline-item {
    position: relative;
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    gap: 12px;
    align-items: start;
}

.timeline-dot {
    position: relative;
    z-index: 1;
    width: 18px;
    height: 18px;
    margin-top: 2px;
    border-radius: 999px;
    border: 4px solid rgba(49, 100, 244, 0.10);
    background: #ffffff;
    box-shadow: 0 0 0 1px rgba(49, 100, 244, 0.12);
}

.timeline-content {
    min-width: 0;
    padding: 12px 14px;
    border-radius: 16px;
    border: 1px solid var(--line-soft);
    background: #fbfcfe;
}

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

.timeline-head strong {
    color: var(--text-strong);
    font-size: 13px;
    font-weight: var(--weight-semibold);
}

.timeline-content .cell-meta {
    display: block;
    overflow-wrap: anywhere;
}

.surface-grid .panel,
.dashboard-grid .panel {
    min-height: 100%;
}

.kanban-board {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(270px, 1fr);
    gap: 14px;
    overflow-x: auto;
    padding-bottom: 8px;
}

.kanban-column {
    min-height: 420px;
    padding: 12px;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.72);
    box-shadow: var(--shadow-xs);
}

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

.kanban-column-head h2 {
    margin: 0;
    color: var(--text-strong);
    font-size: 14px;
}

.kanban-column-head span,
.kanban-column-head strong {
    color: var(--text-muted);
    font-size: 11px;
}

.kanban-dropzone {
    display: grid;
    gap: 10px;
    min-height: 340px;
}

.kanban-card {
    display: grid;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: var(--shadow-xs);
    cursor: grab;
}

.kanban-card.is-dragging {
    opacity: 0.55;
}

.kanban-card-head,
.kanban-metrics {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

.kanban-card-head strong {
    color: var(--text-strong);
    font-size: 13px;
}

.kanban-card p {
    margin: 0;
    color: var(--text-body);
    font-size: 12px;
    line-height: 1.45;
}

.kanban-metrics span {
    padding: 4px 7px;
    border-radius: 999px;
    background: var(--bg-muted);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: var(--weight-semibold);
}

.kanban-stage-form select {
    min-height: 34px;
    font-size: 12px;
}

.persona-card {
    padding: 16px;
    display: grid;
    gap: 8px;
    min-width: 0;
    overflow: hidden;
}

.persona-card-identity {
    min-width: 0;
}

.persona-chip {
    width: 100%;
    justify-content: flex-start;
}

.persona-chip strong,
.persona-chip small {
    max-width: 100%;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.persona-card h3 {
    font-size: 15px;
    max-width: 100%;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.persona-card p {
    margin: 0;
    font-size: 13px;
    color: var(--text-body);
    max-width: 100%;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.persona-library-grid .persona-card {
    align-content: start;
}

.persona-card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    min-width: 0;
}

.persona-role-chip,
.persona-tone,
.persona-keyword-chip {
    max-width: 100%;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.persona-role-chip,
.persona-keyword-chip {
    min-height: 24px;
    align-items: flex-start;
    line-height: 1.25;
}

.persona-tone {
    flex-shrink: 1;
    text-align: right;
}

.persona-description,
.persona-system-prompt {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.persona-description {
    -webkit-line-clamp: 3;
    line-clamp: 3;
}

.persona-system-prompt {
    -webkit-line-clamp: 4;
    line-clamp: 4;
}

.persona-section {
    display: grid;
    gap: 6px;
    min-width: 0;
}

.persona-label {
    color: var(--text-faint);
    font-size: 10px;
    font-weight: var(--weight-bold);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.persona-keywords {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-width: 100%;
    overflow: hidden;
}

.persona-keywords .persona-keyword-chip:nth-child(n + 7) {
    display: none;
}

.persona-form-hero {
    margin-bottom: 16px;
    padding: 14px;
    border-radius: 16px;
    border: 1px solid var(--line-soft);
    background: var(--bg-panel-soft);
}

.persona-hero-chip {
    background: rgba(255, 255, 255, 0.92);
}

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

.team-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    padding: 14px;
    border-radius: 16px;
    border: 1px solid var(--line-soft);
    background: var(--bg-panel-soft);
}

.team-meta {
    display: grid;
    gap: 6px;
    justify-items: end;
    color: var(--text-muted);
    font-size: 12px;
}

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    border-radius: 14px;
    background: var(--bg-panel);
    border: 1px solid var(--line-soft);
}

.user-chip img,
.user-chip span {
    width: 94px;
    height: 94px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    object-fit: cover;
    color: white;
    font-size: 12px;
    font-weight: var(--weight-bold);
    background: linear-gradient(135deg, var(--blue), var(--violet));
}

.user-chip.large img,
.user-chip.large span {
    width: 44px;
    height: 44px;
}

.user-chip strong {
    display: block;
    color: var(--text-strong);
    font-size: 12px;
    font-weight: var(--weight-semibold);
}

.user-chip small {
    display: block;
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 11px;
}

.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at top left, rgba(49, 100, 244, 0.10), transparent 25%),
        var(--bg-page);
}

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

.login-card form {
    display: grid;
    gap: 12px;
    margin-top: 18px;
}

.login-card p label {
    margin-bottom: 6px;
}

.login-card p {
    margin: 0;
}

.login-card ul.errorlist {
    margin: 0 0 6px;
    padding-left: 18px;
    color: var(--red);
    font-size: 12px;
}

.mt-16 {
    margin-top: 16px;
}

@media (max-width: 1380px) {
    .inbox-layout {
        grid-template-columns: 260px minmax(0, 1fr) 300px;
    }

    .thread-workspace {
        grid-template-columns: minmax(0, 1fr) 320px;
    }
}

@media (max-width: 1180px) {
    .stat-grid,
    .grid.two-col,
    .grid.three-col,
    .card-grid,
    .api-card-grid,
    .api-hero-grid,
    .api-settings-grid,
    .dashboard-grid,
    .surface-grid,
    .inbox-layout,
    .filter-grid,
    .thread-workspace,
    .choice-grid {
        grid-template-columns: 1fr;
    }

    .thread-item,
    .message-bubble {
        max-width: 100%;
    }
}

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

    .sidebar {
        position: static;
        height: auto;
        border-right: 0;
        border-bottom: 1px solid var(--line-soft);
    }

    .main-panel {
        padding: 18px;
    }

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

    .crm-record-header,
    .crm-list-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .crm-path {
        grid-template-columns: 1fr;
    }

    .crm-path-step,
    .crm-path-step:first-child {
        clip-path: none;
        border-radius: 10px;
    }

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

    .form-span-2 {
        grid-column: span 1;
    }
}
