:root {
    color-scheme: light;
    --page: #f3f5f7;
    --surface: #ffffff;
    --surface-soft: #f7f9fb;
    --surface-muted: #eef2f5;
    --ink: #18212b;
    --ink-soft: #33404d;
    --muted: #6d7885;
    --quiet: #9aa4ae;
    --border: #e0e6eb;
    --border-strong: #ced7df;
    --nav: #17212b;
    --nav-soft: #22303c;
    --blue: #3567db;
    --blue-soft: #edf2ff;
    --green: #16785c;
    --green-soft: #e9f6f1;
    --amber: #946119;
    --amber-soft: #fff5df;
    --red: #ae3028;
    --red-soft: #fff0ef;
    --shadow: 0 18px 44px rgba(29, 42, 55, 0.08);
    --small-shadow: 0 8px 24px rgba(29, 42, 55, 0.08);
    --radius: 16px;
    font-family:
        Inter,
        ui-sans-serif,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
}

* {
    box-sizing: border-box;
}

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

body {
    margin: 0;
    overflow: hidden;
    background: var(--page);
    color: var(--ink);
}

button,
input,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

button:disabled,
input:disabled,
textarea:disabled {
    cursor: not-allowed;
}

p,
h1,
h2 {
    margin-top: 0;
}

h1 {
    margin-bottom: 0;
    font-size: 27px;
    line-height: 1.15;
    letter-spacing: -0.03em;
}

h2 {
    margin-bottom: 8px;
    font-size: 20px;
    line-height: 1.25;
    letter-spacing: -0.02em;
}

.eyebrow {
    margin-bottom: 7px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.15em;
}

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

.sidebar {
    display: flex;
    min-width: 0;
    flex-direction: column;
    padding: 22px 15px 16px;
    background: var(--nav);
    color: #fff;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 8px 27px;
}

.brand-mark,
.empty-mark {
    display: grid;
    place-items: center;
    border-radius: 13px;
    font-weight: 800;
}

.brand-mark {
    width: 39px;
    height: 39px;
    background: #fff;
    color: var(--nav);
}

.brand-copy {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.brand-copy strong {
    font-size: 14px;
}

.brand-copy span {
    margin-top: 2px;
    color: #9fabb6;
    font-size: 11px;
}

.main-navigation {
    display: grid;
    gap: 6px;
}

.nav-button {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 11px 12px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #aab5bf;
    text-align: left;
}

.nav-button:hover,
.nav-button.active {
    background: rgba(255, 255, 255, 0.09);
    color: #fff;
}

.nav-icon {
    color: #71808d;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.08em;
}

.nav-button.active .nav-icon {
    color: #cfd8e0;
}

.nav-count {
    min-width: 22px;
    padding: 3px 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    font-size: 10px;
    text-align: center;
}

.nav-status {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #687683;
}

.sidebar-line {
    display: flex;
    flex-direction: column;
    margin: 25px 6px 0;
    padding: 14px;
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
}

.sidebar-line span,
.sidebar-line small {
    color: #8e9aa5;
    font-size: 10px;
}

.sidebar-line strong {
    margin: 7px 0 5px;
    font-size: 12px;
}

.sidebar-footer {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 10px;
    margin-top: auto;
    padding: 17px 7px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.09);
}

.account-copy {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.account-copy span {
    color: #8c99a4;
    font-size: 10px;
}

.account-copy strong {
    margin-top: 4px;
    overflow: hidden;
    font-size: 12px;
    text-overflow: ellipsis;
}

.sign-out-button {
    padding: 0;
    border: 0;
    background: transparent;
    color: #a7b2bc;
    font-size: 11px;
}

.main-area {
    min-width: 0;
    height: 100vh;
    padding: 16px;
}

.workspace-view {
    display: none;
    height: 100%;
}

.workspace-view.active {
    display: grid;
}

#phoneView {
    grid-template-columns: 350px minmax(0, 1fr);
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.conversation-panel {
    display: flex;
    min-width: 0;
    flex-direction: column;
    border-right: 1px solid var(--border);
}

.conversation-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 23px 20px 16px;
}

.new-message-button {
    padding: 8px 12px;
    border: 1px solid var(--border-strong);
    border-radius: 9px;
    background: var(--surface);
    color: var(--ink-soft);
    font-size: 12px;
    font-weight: 750;
}

.new-message-button:hover {
    border-color: #b9c5cf;
    background: var(--surface-soft);
}

.search-wrap {
    padding: 0 16px 12px;
}

.search-wrap input {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-soft);
    color: var(--ink);
    outline: none;
}

.search-wrap input:focus {
    border-color: #aebfe9;
    box-shadow: 0 0 0 3px var(--blue-soft);
}

.conversation-summary {
    display: flex;
    justify-content: space-between;
    padding: 0 18px 12px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 650;
}

.conversation-list {
    min-height: 0;
    flex: 1;
    overflow-y: auto;
    border-top: 1px solid var(--border);
}

.conversation-row {
    display: grid;
    grid-template-columns: 43px minmax(0, 1fr) auto;
    align-items: center;
    gap: 11px;
    width: 100%;
    padding: 14px 16px;
    border: 0;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    text-align: left;
}

.conversation-row:hover,
.conversation-row.active {
    background: var(--surface-soft);
}

.conversation-row.active {
    box-shadow: inset 3px 0 0 var(--blue);
}

.conversation-avatar,
.thread-avatar {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 50%;
    background: var(--blue-soft);
    color: var(--blue);
    font-weight: 800;
}

.conversation-avatar {
    width: 43px;
    height: 43px;
    font-size: 13px;
}

.conversation-copy {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 4px;
}

.conversation-title-row {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 7px;
}

.conversation-copy strong,
.conversation-copy small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conversation-copy strong {
    font-size: 13px;
}

.conversation-copy small {
    color: var(--muted);
    font-size: 11px;
}

.opted-out-mark {
    color: var(--red);
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
}

.conversation-meta {
    display: flex;
    align-items: flex-end;
    flex-direction: column;
    gap: 7px;
}

.conversation-time {
    color: var(--quiet);
    font-size: 9px;
}

.unread-badge {
    min-width: 20px;
    padding: 3px 6px;
    border-radius: 999px;
    background: var(--blue);
    color: #fff;
    font-size: 9px;
    font-weight: 750;
    text-align: center;
}

.loading-state,
.empty-conversations {
    display: grid;
    min-height: 280px;
    place-items: center;
    padding: 30px;
    color: var(--muted);
    font-size: 12px;
    text-align: center;
}

.empty-conversations div {
    max-width: 220px;
}

.empty-conversations strong {
    display: block;
    margin-bottom: 7px;
    color: var(--ink);
}

.thread-panel {
    position: relative;
    min-width: 0;
    overflow: hidden;
    background:
        linear-gradient(
            rgba(255, 255, 255, 0.94),
            rgba(255, 255, 255, 0.94)
        ),
        radial-gradient(circle at top right, #dfe7fb, transparent 48%);
}

.thread-empty-state {
    display: grid;
    height: 100%;
    place-items: center;
    align-content: center;
    padding: 40px;
    text-align: center;
}

.empty-mark {
    width: 56px;
    height: 56px;
    margin-bottom: 18px;
    background: var(--nav);
    color: #fff;
    font-size: 18px;
}

.thread-empty-state p {
    max-width: 460px;
    margin-bottom: 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.65;
}

.security-chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 7px;
    margin-top: 20px;
}

.security-chips span {
    padding: 6px 9px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--muted);
    font-size: 10px;
}

.thread-workspace {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    height: 100%;
}

.thread-header {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 12px;
    padding: 15px 19px;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.96);
}

.mobile-back {
    display: none;
}

.thread-avatar {
    width: 39px;
    height: 39px;
    font-size: 12px;
}

.thread-contact {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.thread-contact strong,
.thread-contact span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.thread-contact strong {
    font-size: 13px;
}

.thread-contact span {
    margin-top: 3px;
    color: var(--muted);
    font-size: 11px;
}

.thread-state {
    margin-left: auto;
}

.connection-pill,
.phase-pill,
.success-pill,
.waiting-pill,
.locked-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 9px;
    border-radius: 999px;
    white-space: nowrap;
    font-size: 10px;
    font-weight: 750;
}

.connection-pill.locked,
.waiting-pill,
.locked-label {
    background: var(--amber-soft);
    color: var(--amber);
}

.connection-pill.ready,
.success-pill {
    background: var(--green-soft);
    color: var(--green);
}

.phase-pill {
    background: var(--blue-soft);
    color: var(--blue);
}

.message-scroll {
    min-height: 0;
    overflow-y: auto;
    padding: 22px;
}

.message-list {
    display: flex;
    min-height: 100%;
    flex-direction: column;
    justify-content: flex-end;
    gap: 9px;
}

.message-row {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.message-row.outbound {
    align-items: flex-end;
}

.message-bubble {
    max-width: min(72%, 620px);
    padding: 10px 13px;
    border: 1px solid var(--border);
    border-radius: 15px 15px 15px 4px;
    background: var(--surface);
    box-shadow: 0 4px 12px rgba(24, 33, 43, 0.04);
    font-size: 13px;
    line-height: 1.48;
    white-space: pre-wrap;
    word-break: break-word;
}

.message-row.outbound .message-bubble {
    border-color: #d9e2fb;
    border-radius: 15px 15px 4px 15px;
    background: var(--blue-soft);
}

.message-details {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-top: 4px;
    color: var(--quiet);
    font-size: 9px;
}

.message-status.failed {
    color: var(--red);
}

.message-status.delivered {
    color: var(--green);
}

.thread-no-messages {
    display: grid;
    min-height: 260px;
    place-items: center;
    color: var(--muted);
    font-size: 12px;
    text-align: center;
}

.composer {
    padding: 11px 16px 13px;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

.composer-warning {
    margin-bottom: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    background: var(--amber-soft);
    color: var(--amber);
    font-size: 10px;
    line-height: 1.4;
}

.composer-warning.opted-out {
    background: var(--red-soft);
    color: var(--red);
}

.composer-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 9px;
}

.composer textarea {
    width: 100%;
    min-height: 44px;
    max-height: 132px;
    resize: none;
    padding: 11px 12px;
    border: 1px solid var(--border-strong);
    border-radius: 11px;
    background: var(--surface-soft);
    color: var(--ink);
    outline: none;
}

.composer textarea:focus {
    border-color: #aec0ea;
    box-shadow: 0 0 0 3px var(--blue-soft);
}

.composer textarea:disabled {
    color: var(--quiet);
}

.composer-row button {
    min-width: 72px;
    height: 44px;
    padding: 0 16px;
    border: 0;
    border-radius: 10px;
    background: var(--blue);
    color: #fff;
    font-weight: 750;
}

.composer-row button:disabled {
    background: #cbd3da;
    color: #7d8993;
}

.composer-meta {
    display: flex;
    justify-content: space-between;
    margin-top: 7px;
    color: var(--quiet);
    font-size: 9px;
}

.page-view {
    align-content: start;
    gap: 22px;
    overflow-y: auto;
    padding: 29px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

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

.page-header p:not(.eyebrow) {
    max-width: 650px;
    margin: 9px 0 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.6;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 13px;
}

.metric-card,
.surface-card,
.settings-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.metric-card {
    display: flex;
    min-height: 125px;
    flex-direction: column;
    padding: 18px;
}

.metric-card span,
.metric-card small {
    color: var(--muted);
}

.metric-card span {
    font-size: 11px;
    font-weight: 700;
}

.metric-card strong {
    margin: 17px 0 5px;
    font-size: 25px;
    letter-spacing: -0.025em;
}

.metric-card small {
    margin-top: auto;
    font-size: 10px;
}

.bot-grid {
    display: grid;
    grid-template-columns:
        minmax(0, 1.18fr)
        minmax(320px, 0.82fr);
    gap: 15px;
}

.surface-card {
    padding: 21px;
}

.card-heading {
    display: flex;
    justify-content: space-between;
    gap: 15px;
}

.upload-shell {
    display: grid;
    place-items: center;
    margin-top: 14px;
    padding: 42px 25px;
    border: 1px dashed var(--border-strong);
    border-radius: 13px;
    background: var(--surface-soft);
    text-align: center;
}

.upload-symbol {
    display: grid;
    place-items: center;
    width: 52px;
    height: 42px;
    margin-bottom: 13px;
    border-radius: 11px;
    background: var(--blue-soft);
    color: var(--blue);
    font-size: 11px;
    font-weight: 800;
}

.upload-shell p {
    max-width: 430px;
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.6;
}

.bot-control-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 9px;
    margin-top: 13px;
}

.bot-control-grid button,
.jump-control button {
    padding: 10px 13px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface-soft);
    color: var(--quiet);
}

.jump-control {
    display: grid;
    gap: 8px;
    margin-top: 19px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
}

.jump-control div {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
}

.jump-control input {
    width: 100%;
    padding: 10px 11px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface-soft);
}

.settings-card {
    overflow: hidden;
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 30px;
    padding: 20px 22px;
    border-bottom: 1px solid var(--border);
}

.setting-row:last-child {
    border-bottom: 0;
}

.setting-row strong {
    font-size: 13px;
}

.setting-row p {
    margin: 5px 0 0;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.5;
}

.primary-button,
.secondary-button {
    padding: 10px 14px;
    border-radius: 9px;
    font-weight: 750;
}

.primary-button {
    border: 0;
    background: var(--blue);
    color: #fff;
}

.secondary-button {
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--ink-soft);
}

.notice-box {
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-soft);
    color: var(--ink-soft);
    font-size: 12px;
}

.notice-box.success {
    border-color: #c9e8dc;
    background: var(--green-soft);
    color: var(--green);
}

.notice-box.error {
    border-color: #f0c8c4;
    background: var(--red-soft);
    color: var(--red);
}

.modal-backdrop {
    position: fixed;
    z-index: 50;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(13, 20, 27, 0.48);
    backdrop-filter: blur(4px);
}

.modal-backdrop[hidden] {
    display: none;
}

.modal-card {
    width: min(100%, 430px);
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: 17px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

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

.modal-close {
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 9px;
    background: var(--surface-soft);
    color: var(--muted);
    font-size: 20px;
}

.modal-card form {
    display: grid;
    gap: 15px;
    margin-top: 20px;
}

.modal-card label {
    display: grid;
    gap: 7px;
    color: var(--ink-soft);
    font-size: 11px;
    font-weight: 750;
}

.modal-card input {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid var(--border-strong);
    border-radius: 9px;
    outline: none;
}

.modal-card input:focus {
    border-color: #aec0ea;
    box-shadow: 0 0 0 3px var(--blue-soft);
}

.form-error {
    padding: 9px 10px;
    border-radius: 8px;
    background: var(--red-soft);
    color: var(--red);
    font-size: 11px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 9px;
    margin-top: 4px;
}

/* Login page compatibility */

.auth-body {
    display: grid;
    min-height: 100vh;
    overflow: auto;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(
            circle at 20% 10%,
            #e2e9ff,
            transparent 34%
        ),
        var(--page);
}

.auth-shell {
    width: min(100%, 420px);
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.auth-brand h1 {
    font-size: 20px;
}

.auth-brand .brand-mark {
    background: var(--nav);
    color: #fff;
}

.auth-card {
    padding: 30px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.auth-card .muted {
    margin-bottom: 24px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.55;
}

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

.auth-form label {
    display: grid;
    gap: 7px;
    color: var(--ink-soft);
    font-size: 12px;
    font-weight: 700;
}

.auth-form input {
    width: 100%;
    padding: 12px 13px;
    border: 1px solid var(--border-strong);
    border-radius: 9px;
    outline: none;
}

.auth-form input:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px var(--blue-soft);
}

.error-box {
    margin-bottom: 18px;
    padding: 11px 12px;
    border: 1px solid #f0c8c4;
    border-radius: 9px;
    background: var(--red-soft);
    color: var(--red);
    font-size: 12px;
}

@media (max-width: 1000px) {
    .app-shell {
        grid-template-columns: 78px minmax(0, 1fr);
    }

    .brand {
        justify-content: center;
        padding-inline: 0;
    }

    .brand-copy,
    .sidebar-line,
    .account-copy,
    .sign-out-button,
    .nav-button > span:nth-child(2) {
        display: none;
    }

    .nav-button {
        grid-template-columns: 1fr;
        justify-items: center;
    }

    .nav-count,
    .nav-status {
        position: absolute;
        margin: -25px 0 0 29px;
    }

    #phoneView {
        grid-template-columns: 320px minmax(0, 1fr);
    }

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

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

@media (max-width: 720px) {
    body {
        overflow: auto;
    }

    .app-shell {
        display: block;
        height: auto;
        min-height: 100vh;
    }

    .sidebar {
        position: fixed;
        z-index: 30;
        right: 0;
        bottom: 0;
        left: 0;
        height: 67px;
        flex-direction: row;
        padding: 8px 11px;
    }

    .brand,
    .sidebar-footer,
    .sidebar-line {
        display: none;
    }

    .main-navigation {
        grid-template-columns: repeat(3, 1fr);
        width: 100%;
    }

    .nav-button {
        grid-template-columns: auto auto;
        justify-content: center;
    }

    .nav-button > span:nth-child(2) {
        display: inline;
    }

    .nav-count,
    .nav-status {
        position: static;
        margin: 0;
    }

    .main-area {
        height: calc(100vh - 67px);
        padding: 8px 8px 75px;
    }

    #phoneView {
        grid-template-columns: 1fr;
    }

    .conversation-panel {
        border-right: 0;
    }

    .thread-panel {
        position: absolute;
        z-index: 20;
        inset: 8px 8px 75px;
        display: none;
        border: 1px solid var(--border);
        border-radius: 16px;
        background: var(--surface);
    }

    .thread-panel.mobile-open {
        display: block;
    }

    .mobile-back {
        display: inline-flex;
        padding: 7px 9px;
        border: 1px solid var(--border);
        border-radius: 8px;
        background: var(--surface);
        color: var(--muted);
        font-size: 10px;
    }

    .message-bubble {
        max-width: 86%;
    }

    .page-view {
        height: auto;
        min-height: calc(100vh - 91px);
        padding: 20px 15px;
    }

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

    .setting-row {
        align-items: flex-start;
        flex-direction: column;
        gap: 12px;
    }
}

/* TEXTORA BOT PHONE — PRODUCTION BOT PHASE 3A */

.production-bot-grid {
    align-items: start;
}

.active-upload {
    gap: 12px;
}

.active-upload input[type="file"] {
    width: min(100%, 430px);
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface);
    color: var(--ink-soft);
    font-size: 11px;
}

.active-upload .primary-button {
    min-width: 140px;
}

.upload-status {
    width: min(100%, 520px);
    padding: 9px 11px;
    border-radius: 8px;
    background: var(--surface);
    color: var(--muted);
    font-size: 11px;
}

.upload-status.success {
    background: var(--green-soft);
    color: var(--green);
}

.upload-status.error {
    background: var(--red-soft);
    color: var(--red);
}

.csv-preview {
    margin-top: 16px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 11px;
}

.preview-empty {
    padding: 25px;
    color: var(--muted);
    font-size: 11px;
    text-align: center;
}

.preview-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.preview-table th,
.preview-table td {
    padding: 9px 10px;
    border-bottom: 1px solid var(--border);
    font-size: 10px;
    text-align: left;
    vertical-align: top;
}

.preview-table th {
    background: var(--surface-soft);
    color: var(--muted);
    font-weight: 800;
}

.preview-table tr:last-child td {
    border-bottom: 0;
}

.preview-table .row-column {
    width: 55px;
}

.preview-table .phone-column {
    width: 145px;
}

.preview-table .status-column {
    width: 90px;
}

.preview-message {
    overflow: hidden;
    color: var(--ink-soft);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.row-status {
    display: inline-flex;
    padding: 4px 6px;
    border-radius: 999px;
    background: var(--surface-muted);
    color: var(--muted);
    font-size: 9px;
    font-weight: 750;
}

.row-status.delivered,
.row-status.sent,
.row-status.queued {
    background: var(--green-soft);
    color: var(--green);
}

.row-status.failed,
.row-status.invalid {
    background: var(--red-soft);
    color: var(--red);
}

.row-status.suppressed {
    background: var(--amber-soft);
    color: var(--amber);
}

.bot-job-message,
.delay-notice {
    margin-top: 17px;
    padding: 12px;
    border-radius: 10px;
    background: var(--surface-soft);
    color: var(--muted);
    font-size: 11px;
    line-height: 1.55;
}

.bot-job-message.error {
    background: var(--red-soft);
    color: var(--red);
}

.bot-job-message.success {
    background: var(--green-soft);
    color: var(--green);
}

.delay-notice {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.delay-notice strong {
    color: var(--ink-soft);
}

@media (max-width: 1160px) {
    .production-bot-grid {
        grid-template-columns: 1fr;
    }
}

/* TEXTORA_THREAD_VISIBILITY_FIX_V1 */
.thread-empty-state[hidden],
.thread-workspace[hidden] {
    display: none !important;
}

.thread-workspace:not([hidden]) {
    display: flex !important;
    flex-direction: column;
    min-width: 0;
    height: 100%;
}

.thread-empty-state:not([hidden]) {
    display: flex !important;
}

/* TEXTORA_THREAD_LAYOUT_POLISH_V1 */

.thread-panel {
    min-width: 0;
    height: 100%;
}

.thread-workspace {
    display: flex !important;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    height: 100%;
}

.thread-header {
    flex: 0 0 auto;
}

.message-scroll {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 18px 18px 12px 18px;
    overflow-y: auto;
    overflow-x: hidden;
}

.message-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    margin-top: auto;
}

.message-row {
    display: flex;
    width: 100%;
}

.message-row.inbound {
    justify-content: flex-start;
}

.message-row.outbound {
    justify-content: flex-end;
}

.message-bubble {
    max-width: min(72%, 540px);
    word-break: break-word;
    white-space: pre-wrap;
}

.message-row.inbound .message-bubble {
    margin-right: auto;
}

.message-row.outbound .message-bubble {
    margin-left: auto;
}

.message-details {
    margin-top: 6px;
}

.composer {
    flex: 0 0 auto;
    margin-top: auto;
    padding: 10px 16px 14px 16px;
    border-top: 1px solid rgba(15, 23, 42, 0.08);
    background: #ffffff;
}

.composer-warning {
    margin-bottom: 8px;
}

.composer-row {
    display: flex;
    align-items: flex-end;
    gap: 10px;
}

#messageComposer {
    flex: 1 1 auto;
    min-height: 44px;
    max-height: 132px;
}

#sendMessageButton {
    flex: 0 0 auto;
    align-self: stretch;
    min-width: 96px;
}

.composer-meta {
    margin-top: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.thread-no-messages {
    width: 100%;
    min-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

@media (max-width: 900px) {
    .message-bubble {
        max-width: 84%;
    }

    .composer {
        padding: 10px 12px 12px 12px;
    }

    #sendMessageButton {
        min-width: 84px;
    }
}
