:root {
    --ink: #17221e;
    --ink-soft: #57645e;
    --paper: #f4f7f5;
    --surface: #ffffff;
    --line: #dfe7e2;
    --green: #167c5a;
    --green-dark: #0f6045;
    --green-soft: #e4f4ed;
    --lime: #c8f169;
    --navy: #11251f;
    --gold: #d5a542;
    --danger: #b63535;
    --danger-soft: #fff0f0;
    --warning: #9c6300;
    --shadow: 0 16px 42px rgba(19, 54, 42, .08);
    --radius: 18px;
    --sidebar: 254px;
    color: var(--ink);
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 17px;
    line-height: 1.5;
    background: var(--paper);
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html {
    min-height: 100%;
    background: var(--paper);
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background: var(--paper);
}

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

button,
a {
    -webkit-tap-highlight-color: transparent;
}

a {
    color: var(--green);
    text-decoration: none;
}

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

h1 {
    margin-bottom: .35rem;
    font-size: clamp(1.7rem, 2.7vw, 2.45rem);
    line-height: 1.08;
    letter-spacing: -.035em;
}

h2 {
    margin-bottom: .35rem;
    font-size: clamp(1.25rem, 2vw, 1.6rem);
    line-height: 1.2;
    letter-spacing: -.02em;
}

h3 {
    margin: 1.4rem 0 .7rem;
    font-size: 1.05rem;
}

.muted {
    color: var(--ink-soft);
}

.eyebrow {
    margin-bottom: .45rem;
    color: var(--green);
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .13em;
    text-transform: uppercase;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: .75rem;
    color: var(--ink);
}

.brand > div,
.auth-brand > div {
    display: flex;
    flex-direction: column;
    line-height: 1.08;
}

.brand strong,
.auth-brand strong {
    font-size: 1rem;
    letter-spacing: -.02em;
}

.brand small,
.auth-brand small {
    margin-top: .25rem;
    color: var(--ink-soft);
    font-size: .72rem;
}

.brand-mark {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border-radius: 13px;
    color: #132d22;
    background: var(--lime);
    font-weight: 900;
    box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .08);
}

.button {
    display: inline-flex;
    min-height: 43px;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    padding: .68rem 1rem;
    border: 1px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 750;
    transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}

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

.button:disabled {
    opacity: .5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible,
.main-nav a:focus-visible {
    outline: 3px solid rgba(22, 124, 90, .22);
    outline-offset: 2px;
}

.button-primary {
    color: #fff;
    background: var(--green);
    box-shadow: 0 8px 18px rgba(22, 124, 90, .18);
}

.button-primary:hover {
    background: var(--green-dark);
}

.button-secondary {
    border-color: var(--line);
    color: var(--ink);
    background: #fff;
}

.button-quiet {
    min-height: 38px;
    padding: .45rem .75rem;
    color: var(--green);
    background: var(--green-soft);
}

.button-danger {
    border-color: #f2caca;
    color: var(--danger);
    background: var(--danger-soft);
}

.button-large {
    min-height: 52px;
    padding-inline: 1.25rem;
}

.button-row,
.inline-form {
    display: flex;
    align-items: end;
    flex-wrap: wrap;
    gap: .7rem;
}

.input-action {
    display: flex;
    gap: .5rem;
}

.input-action input {
    min-width: 0;
    flex: 1;
}

label {
    display: grid;
    gap: .38rem;
    color: #35413c;
    font-size: .86rem;
    font-weight: 700;
}

label small {
    color: var(--ink-soft);
    font-size: .72rem;
    font-weight: 500;
}

input,
select,
textarea {
    width: 100%;
    min-height: 47px;
    padding: .68rem .8rem;
    border: 1px solid #d6dfda;
    border-radius: 11px;
    color: var(--ink);
    background: #fbfdfc;
    transition: border .16s ease, box-shadow .16s ease;
}

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

input:hover,
select:hover,
textarea:hover {
    border-color: #aebdb5;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--green);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(22, 124, 90, .09);
    outline: none;
}

input[type="checkbox"] {
    width: 20px;
    min-height: 20px;
    accent-color: var(--green);
}

.stack-form {
    display: grid;
    gap: 1rem;
}

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

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

fieldset {
    display: grid;
    gap: .8rem;
    margin: 0;
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: 13px;
}

legend {
    padding: 0 .4rem;
    font-size: .85rem;
    font-weight: 800;
}

.notice {
    padding: .8rem 1rem;
    border-radius: 11px;
    font-size: .84rem;
    font-weight: 650;
}

.notice-error {
    border: 1px solid #f2cece;
    color: #842b2b;
    background: var(--danger-soft);
}

.notice-success {
    border: 1px solid #bfe0cf;
    color: #175f44;
    background: var(--green-soft);
}

.notice-info {
    border: 1px solid #cfded7;
    color: #36554a;
    background: #edf5f1;
}

.auth-body {
    background: #eff5f1;
}

.auth-shell {
    display: grid;
    width: min(1180px, calc(100% - 2rem));
    min-height: calc(100vh - 3rem);
    grid-template-columns: minmax(0, 1.1fr) minmax(360px, .75fr);
    margin: 1.5rem auto;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, .8);
    border-radius: 28px;
    background: var(--surface);
    box-shadow: 0 30px 90px rgba(15, 62, 44, .13);
}

.auth-promise {
    position: relative;
    display: flex;
    min-height: 660px;
    flex-direction: column;
    justify-content: space-between;
    padding: clamp(2rem, 5vw, 4.5rem);
    overflow: hidden;
    color: #fff;
    background:
        radial-gradient(circle at 85% 20%, rgba(200, 241, 105, .23), transparent 26%),
        radial-gradient(circle at 10% 90%, rgba(34, 166, 119, .26), transparent 35%),
        var(--navy);
}

.auth-promise::after {
    position: absolute;
    right: -110px;
    bottom: -105px;
    width: 430px;
    height: 430px;
    border: 1px solid rgba(200, 241, 105, .2);
    border-radius: 50%;
    box-shadow: 0 0 0 60px rgba(200, 241, 105, .035), 0 0 0 120px rgba(200, 241, 105, .02);
    content: "";
}

.brand-light {
    color: #fff;
}

.brand-light small {
    color: #b6c9c0;
}

.promise-copy {
    position: relative;
    z-index: 1;
    max-width: 610px;
}

.promise-copy .eyebrow {
    color: var(--lime);
}

.promise-copy h1 {
    max-width: 600px;
    margin-bottom: 1.2rem;
    font-size: clamp(2.4rem, 5vw, 4.5rem);
}

.promise-copy p:last-child {
    max-width: 520px;
    color: #cbdad3;
    font-size: 1.08rem;
}

.promise-stat {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: .65rem;
    color: #d6e4dd;
    font-size: .85rem;
}

.login-card {
    align-self: center;
    width: min(440px, calc(100% - 3rem));
    margin: auto;
    padding: 2rem;
}

.login-card h2 {
    font-size: 2.1rem;
}

.login-card .stack-form {
    margin: 1.5rem 0 1rem;
}

.text-link {
    display: inline-block;
    margin-top: .35rem;
    font-size: .84rem;
    font-weight: 750;
}

.login-safety {
    margin: 2rem 0 0;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
    color: var(--ink-soft);
    font-size: .72rem;
}

.mobile-brand {
    display: none;
}

.auth-shell-compact {
    display: grid;
    width: min(560px, calc(100% - 2rem));
    min-height: auto;
    margin-block: 6vh;
    grid-template-columns: 1fr;
}

.auth-shell-compact .login-card {
    width: 100%;
    padding: 3rem;
}

.setup-shell {
    width: min(1120px, calc(100% - 2rem));
    margin: 2rem auto;
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: .7rem;
    margin-bottom: 1.5rem;
}

.setup-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 1.25rem;
    align-items: start;
}

.auth-card,
.requirements-card {
    border: 1px solid rgba(218, 231, 224, .9);
    border-radius: 22px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.setup-card {
    padding: clamp(1.25rem, 4vw, 2.5rem);
}

.requirements-card {
    position: sticky;
    top: 1.5rem;
    padding: 1.5rem;
}

.requirements-list {
    display: grid;
    gap: .65rem;
    margin: 1.2rem 0;
    padding: 0;
    list-style: none;
}

.requirements-list li {
    display: flex;
    align-items: center;
    gap: .6rem;
    font-size: .82rem;
}

.requirements-list span {
    display: grid;
    width: 24px;
    height: 24px;
    place-items: center;
    border-radius: 50%;
    font-size: .72rem;
    font-weight: 900;
}

.requirements-list .is-ok span {
    color: var(--green);
    background: var(--green-soft);
}

.requirements-list .is-error span {
    color: var(--danger);
    background: var(--danger-soft);
}

.security-note {
    margin: 1rem 0 0;
    padding: .9rem;
    border-radius: 10px;
    color: #4d5d56;
    background: var(--paper);
    font-size: .74rem;
}

.app-frame {
    display: grid;
    min-height: 100vh;
    grid-template-columns: var(--sidebar) minmax(0, 1fr);
}

.sidebar {
    position: fixed;
    z-index: 20;
    inset: 0 auto 0 0;
    display: flex;
    width: var(--sidebar);
    flex-direction: column;
    padding: 1.35rem 1rem;
    color: #dfeae5;
    background: var(--navy);
}

.sidebar-brand {
    padding: .25rem .55rem 1.5rem;
    color: #fff;
}

.sidebar-brand small {
    color: #9bb0a6;
}

.main-nav {
    display: grid;
    gap: .28rem;
}

.main-nav a {
    display: flex;
    min-height: 48px;
    align-items: center;
    gap: .75rem;
    padding: .7rem .8rem;
    border-radius: 12px;
    color: #aebfb7;
    font-size: .86rem;
    font-weight: 700;
    transition: color .16s ease, background .16s ease;
}

.main-nav a span {
    display: grid;
    width: 24px;
    place-items: center;
    color: #72897e;
    font-size: 1rem;
}

.main-nav a:hover {
    color: #fff;
    background: rgba(255, 255, 255, .05);
}

.main-nav a.is-active {
    color: #fff;
    background: rgba(200, 241, 105, .12);
}

.main-nav a.is-active span {
    color: var(--lime);
}

.sidebar-foot {
    display: grid;
    gap: .8rem;
    margin-top: auto;
    padding: .9rem .55rem 0;
    border-top: 1px solid rgba(255, 255, 255, .08);
}

.user-chip {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: .65rem;
}

.user-chip > div {
    display: grid;
    min-width: 0;
}

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

.user-chip strong {
    color: #fff;
    font-size: .78rem;
}

.user-chip small {
    color: #82988e;
    font-size: .66rem;
}

.avatar {
    display: grid;
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 12px;
    color: var(--navy);
    background: var(--lime);
    font-weight: 900;
}

.logout-button {
    padding: 0;
    border: 0;
    color: #8fa198;
    background: transparent;
    cursor: pointer;
    font-size: .73rem;
}

.app-main {
    min-width: 0;
    grid-column: 2;
}

.topbar {
    display: flex;
    min-height: 104px;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.2rem clamp(1rem, 3vw, 2.5rem);
    border-bottom: 1px solid var(--line);
    background: rgba(244, 247, 245, .93);
    backdrop-filter: blur(12px);
}

.topbar h1 {
    margin: 0;
    font-size: 1.65rem;
}

.topbar-kicker {
    margin: 0 0 .2rem;
    color: var(--ink-soft);
    font-size: .72rem;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: .8rem;
}

.tenant-switcher {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .72rem;
}

.tenant-switcher select {
    width: 220px;
    min-height: 40px;
    padding-block: .45rem;
    background: #fff;
}

.connection-pill,
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: .42rem .7rem;
    border: 1px solid #cee1d7;
    border-radius: 999px;
    color: var(--green-dark);
    background: var(--green-soft);
    font-size: .72rem;
    font-weight: 800;
}

.live-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #32c778;
    box-shadow: 0 0 0 4px rgba(50, 199, 120, .13);
}

.menu-button {
    display: none;
    width: 42px;
    height: 42px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
}

.page-content {
    width: min(1540px, 100%);
    margin: 0 auto;
    padding: clamp(1rem, 3vw, 2.5rem);
}

.page-heading,
.panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.page-heading {
    align-items: center;
    margin-bottom: 1.25rem;
}

.page-heading h2 {
    margin-bottom: .3rem;
    font-size: 1.85rem;
}

.panel {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: 0 5px 24px rgba(16, 54, 40, .04);
}

.panel-head {
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid #edf1ef;
}

.panel-head h2 {
    margin: 0;
    font-size: 1.12rem;
}

.panel-head .eyebrow {
    margin-bottom: .2rem;
}

.panel-head a {
    font-size: .76rem;
    font-weight: 750;
}

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

.metric-card {
    display: grid;
    min-height: 158px;
    align-content: space-between;
    padding: 1.15rem;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}

.metric-card span {
    color: var(--ink-soft);
    font-size: .75rem;
    font-weight: 750;
}

.metric-card strong {
    overflow: hidden;
    font-size: clamp(1.6rem, 3vw, 2.55rem);
    line-height: 1;
    letter-spacing: -.045em;
    text-overflow: ellipsis;
}

.metric-card small {
    color: var(--ink-soft);
    font-size: .72rem;
}

.metric-card small.is-positive {
    color: var(--green);
}

.metric-card small.is-negative {
    color: var(--danger);
}

.metric-card-accent {
    color: #fff;
    background: var(--navy);
}

.metric-card-accent span,
.metric-card-accent small {
    color: #a8bcb2;
}

.metric-card-accent strong {
    color: var(--lime);
    font-size: 1.4rem;
}

.dashboard-grid,
.two-column,
.admin-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(320px, .65fr);
    gap: 1rem;
}

.workflow-overview {
    padding-bottom: 1.25rem;
}

.workflow-overview > p {
    margin: 1rem 1.25rem 0;
    font-size: .82rem;
}

.mini-flow {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .35rem;
    padding: 1.4rem 1.25rem .4rem;
}

.mini-flow span {
    padding: .55rem .68rem;
    border-radius: 9px;
    color: var(--green-dark);
    background: var(--green-soft);
    font-size: .69rem;
    font-weight: 800;
}

.mini-flow i {
    width: 16px;
    height: 1px;
    background: #aabbb2;
}

.conversation-list {
    min-height: 220px;
}

.conversation-item {
    position: relative;
    display: grid;
    width: 100%;
    grid-template-columns: 46px minmax(0, 1fr) auto;
    gap: .75rem;
    padding: 1rem 1.1rem;
    border: 0;
    border-bottom: 1px solid #edf1ef;
    text-align: left;
    background: transparent;
    cursor: pointer;
}

.conversation-item:hover,
.conversation-item.is-active {
    background: #f6faf8;
}

.conversation-item.is-active::before {
    position: absolute;
    inset: 8px auto 8px 0;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--green);
    content: "";
}

.contact-avatar {
    display: grid;
    width: 46px;
    height: 46px;
    place-items: center;
    border-radius: 14px;
    color: var(--green-dark);
    background: var(--green-soft);
    font-size: .82rem;
    font-weight: 900;
}

.conversation-copy {
    min-width: 0;
}

.conversation-title {
    display: flex;
    align-items: center;
    gap: .45rem;
    margin-bottom: .18rem;
}

.conversation-title strong {
    overflow: hidden;
    font-size: .84rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conversation-copy p {
    display: -webkit-box;
    margin: 0;
    overflow: hidden;
    color: var(--ink-soft);
    font-size: .74rem;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.conversation-meta {
    display: grid;
    justify-items: end;
    gap: .42rem;
    color: #728078;
    font-size: .65rem;
}

.unread-badge {
    display: grid;
    min-width: 21px;
    height: 21px;
    padding: 0 5px;
    place-items: center;
    border-radius: 999px;
    color: #fff;
    background: var(--green);
    font-size: .62rem;
    font-weight: 800;
}

.resolution-badge {
    padding: .18rem .4rem;
    border-radius: 999px;
    font-size: .58rem;
    font-weight: 850;
}

.resolution-badge.is-new,
.chat-resolution.is-new {
    color: #125f43;
    background: #dff3e9;
}

.resolution-badge.is-done,
.chat-resolution.is-done {
    color: #59645f;
    background: #e9eeeb;
}

.label-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: #889991;
}

.label-dot.label-green { background: #2aa76f; }
.label-dot.label-gold { background: #d9a63b; }
.label-dot.label-blue { background: #4b82d8; }
.label-dot.label-red { background: #d65d5d; }
.label-dot.label-purple { background: #8e6acb; }

.compact-list .conversation-item {
    grid-template-columns: 42px minmax(0, 1fr) auto;
}

.skeleton-row {
    height: 82px;
    margin: 1px 0;
    background: linear-gradient(90deg, #f4f7f5 20%, #edf3ef 50%, #f4f7f5 80%);
    background-size: 240% 100%;
    animation: shimmer 1.25s infinite;
}

@keyframes shimmer {
    to { background-position: -240% 0; }
}

.filters {
    display: grid;
    grid-template-columns: minmax(220px, 1.7fr) repeat(5, minmax(120px, 1fr));
    gap: .7rem;
    margin-bottom: 1rem;
    padding: .85rem;
}

.filters input,
.filters select {
    min-height: 42px;
    font-size: .78rem;
}

.inbox-layout {
    display: grid;
    min-height: calc(100vh - 250px);
    grid-template-columns: minmax(340px, .78fr) minmax(500px, 1.45fr);
    gap: 1rem;
}

.inbox-list-panel,
.chat-panel {
    min-height: 600px;
    overflow: hidden;
}

.inbox-list-panel {
    display: flex;
    flex-direction: column;
}

.inbox-list-panel .conversation-list {
    flex: 1;
    overflow-y: auto;
}

.icon-button {
    display: grid;
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--ink-soft);
    background: #fff;
    cursor: pointer;
}

.pagination {
    display: flex;
    justify-content: center;
    gap: .35rem;
    padding: .7rem;
    border-top: 1px solid var(--line);
}

.pagination button {
    min-width: 34px;
    height: 34px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: #fff;
}

.pagination button.is-active {
    color: #fff;
    background: var(--green);
}

.empty-chat {
    display: grid;
    height: 100%;
    min-height: 600px;
    align-content: center;
    justify-items: center;
    padding: 2rem;
    color: var(--ink-soft);
    text-align: center;
}

.empty-chat > span {
    display: grid;
    width: 72px;
    height: 72px;
    margin-bottom: 1rem;
    place-items: center;
    border-radius: 24px;
    color: var(--green);
    background: var(--green-soft);
    font-size: 2rem;
}

.chat-panel {
    display: flex;
    flex-direction: column;
}

.chat-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 1rem 1.2rem;
    border-bottom: 1px solid var(--line);
}

.chat-person {
    display: flex;
    align-items: center;
    gap: .7rem;
}

.chat-person strong {
    display: block;
    font-size: .9rem;
}

.chat-person small {
    color: var(--ink-soft);
    font-size: .7rem;
}

.chat-head-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: .55rem;
}

.chat-label {
    max-width: 260px;
    padding: .38rem .65rem;
    overflow: hidden;
    border-radius: 999px;
    color: #4c5d55;
    background: var(--paper);
    font-size: .66rem;
    font-weight: 750;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-resolution {
    padding: .38rem .65rem;
    border-radius: 999px;
    font-size: .66rem;
    font-weight: 800;
    white-space: nowrap;
}

.chat-resolution-button {
    min-height: 34px;
    padding: .35rem .6rem;
    font-size: .66rem;
    white-space: nowrap;
}

.chat-delete-button {
    min-height: 34px;
    padding: .35rem .6rem;
    font-size: .66rem;
    white-space: nowrap;
}

.message-thread {
    display: flex;
    min-height: 0;
    flex: 1;
    flex-direction: column;
    gap: .75rem;
    padding: 1.15rem;
    overflow-y: auto;
    background:
        radial-gradient(circle at 20% 0, rgba(22, 124, 90, .035), transparent 26%),
        #f8faf9;
}

.message-bubble {
    max-width: min(78%, 650px);
    padding: .72rem .88rem;
    border: 1px solid var(--line);
    border-radius: 15px 15px 15px 4px;
    background: #fff;
    box-shadow: 0 3px 12px rgba(19, 54, 42, .04);
}

.message-bubble.is-outbound {
    align-self: flex-end;
    border-color: #c9e5d7;
    border-radius: 15px 15px 4px;
    background: var(--green-soft);
}

.message-bubble p {
    margin: 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-size: .82rem;
}

.message-bubble footer {
    display: flex;
    justify-content: flex-end;
    gap: .4rem;
    margin-top: .35rem;
    color: #73837b;
    font-size: .6rem;
}

.document-bubble {
    display: flex;
    align-items: center;
    gap: .55rem;
}

.document-bubble > span {
    display: grid;
    min-width: 43px;
    height: 38px;
    padding-inline: .3rem;
    place-items: center;
    border-radius: 8px;
    color: var(--green-dark);
    background: rgba(22, 124, 90, .12);
    font-size: .58rem;
    font-weight: 900;
}

.document-bubble > div {
    display: grid;
    min-width: 0;
    flex: 1;
}

.document-bubble strong {
    overflow-wrap: anywhere;
    font-size: .76rem;
}

.document-bubble small {
    color: var(--ink-soft);
    font-size: .62rem;
}

.message-download {
    min-height: 32px;
    padding: .3rem .55rem;
    font-size: .64rem;
    white-space: nowrap;
}

.message-bubble .media-caption {
    margin-top: .55rem;
}

.chat-compose {
    display: flex;
    gap: .65rem;
    padding: .85rem;
    border-top: 1px solid var(--line);
    background: #fff;
}

.chat-compose textarea {
    min-height: 47px;
    max-height: 140px;
    flex: 1;
}

.chat-compose .button {
    align-self: end;
}

.two-column > .panel,
.admin-grid > .panel {
    padding-bottom: 1.25rem;
}

.two-column .stack-form,
.admin-grid .stack-form {
    padding: 1.2rem;
}

.confirmation-box {
    display: flex;
    align-items: flex-start;
    gap: .65rem;
    padding: .9rem;
    border: 1px solid #ead69d;
    border-radius: 11px;
    color: #695221;
    background: #fff9e8;
}

.confirmation-box input {
    flex: 0 0 auto;
    margin-top: .1rem;
}

.template-box {
    display: grid;
    gap: .75rem;
    padding: .9rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--paper);
}

.template-box p {
    margin: 0;
    font-size: .78rem;
}

.template-box small {
    color: var(--ink-soft);
}

.campaign-list {
    display: grid;
}

.campaign-card {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: .3rem .8rem;
    padding: 1rem 1.2rem;
    border-bottom: 1px solid var(--line);
}

.campaign-card strong {
    font-size: .84rem;
}

.campaign-card p,
.campaign-card small {
    margin: 0;
    color: var(--ink-soft);
    font-size: .7rem;
}

.campaign-card .status-badge {
    grid-row: span 2;
    align-self: center;
}

.settings-layout {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 1rem;
    align-items: start;
}

.settings-nav {
    position: sticky;
    top: 1rem;
    display: grid;
    gap: .25rem;
    padding: .65rem;
    border: 1px solid var(--line);
    border-radius: 15px;
    background: #fff;
}

.settings-nav button {
    min-height: 43px;
    padding: .6rem .75rem;
    border: 0;
    border-radius: 9px;
    color: var(--ink-soft);
    text-align: left;
    background: transparent;
    cursor: pointer;
    font-size: .78rem;
    font-weight: 700;
}

.settings-nav button:hover {
    color: var(--ink);
    background: var(--paper);
}

.settings-nav button.is-active {
    color: var(--green-dark);
    background: var(--green-soft);
}

.settings-content {
    min-width: 0;
}

.settings-pane {
    display: none;
    padding-bottom: 1.25rem;
}

.settings-pane.is-active {
    display: block;
}

.settings-pane > .stack-form,
.settings-pane > .inline-form,
.settings-pane > .muted {
    margin: 1.2rem;
}

.narrow-form {
    max-width: 560px;
}

.endpoint-card {
    display: grid;
    gap: .4rem;
    margin: 1.2rem;
    padding: .9rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--paper);
}

.endpoint-card strong {
    font-size: .75rem;
}

.endpoint-card code {
    overflow-wrap: anywhere;
    color: var(--green-dark);
    font-size: .72rem;
}

.verify-token-card {
    border-color: #dfca7f;
    background: #fff9df;
}

.verify-token-card small {
    color: var(--ink-soft);
}

.diagnostics-card {
    display: grid;
    gap: .9rem;
    margin: 1.2rem;
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
}

.diagnostics-card h3 {
    margin: 0;
}

.diagnostics-list {
    display: grid;
    gap: .55rem;
}

.diagnostic-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: .25rem .8rem;
    align-items: center;
    padding: .7rem .8rem;
    border-radius: 10px;
    background: var(--paper);
    font-size: .75rem;
}

.diagnostic-row strong {
    font-size: .75rem;
}

.diagnostic-row small {
    grid-column: 1 / -1;
    overflow-wrap: anywhere;
    color: var(--ink-soft);
}

.diagnostic-state {
    font-weight: 800;
}

.diagnostic-state.is-ok {
    color: var(--green);
}

.diagnostic-state.is-warning {
    color: #9a6b00;
}

.diagnostic-state.is-error {
    color: var(--danger);
}

.workflow-cards {
    display: grid;
    gap: .8rem;
    padding: 1.2rem;
}

.workflow-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(220px, .55fr);
    gap: 1rem;
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: 14px;
}

.workflow-card.is-active {
    border-color: #90c5ac;
    box-shadow: inset 4px 0 var(--green);
}

.workflow-card h3 {
    margin: 0 0 .3rem;
}

.workflow-card p {
    color: var(--ink-soft);
    font-size: .77rem;
}

.workflow-card form {
    display: grid;
    gap: .6rem;
    align-content: start;
}

.workflow-delay-list {
    display: grid;
    gap: .6rem;
}

.workflow-delay-row {
    display: grid;
    grid-template-columns: minmax(120px, 1fr) 100px 100px;
    align-items: end;
    gap: .65rem;
    padding: .75rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #f8faf9;
}

.workflow-delay-row strong,
.workflow-delay-row small {
    display: block;
}

.workflow-delay-row small {
    margin-top: .18rem;
    color: var(--ink-soft);
    font-size: .65rem;
}

.flow-diagram {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .25rem;
    margin-top: .7rem;
}

.flow-diagram span {
    padding: .32rem .45rem;
    border-radius: 7px;
    color: var(--green-dark);
    background: var(--green-soft);
    font-size: .59rem;
    font-weight: 800;
}

.flow-diagram i::before {
    color: #91a39a;
    content: "→";
    font-style: normal;
}

.document-list {
    display: grid;
    margin: 1.2rem;
    border: 1px solid var(--line);
    border-radius: 12px;
}

.document-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: .7rem;
    align-items: center;
    padding: .75rem;
    border-bottom: 1px solid var(--line);
}

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

.document-row strong {
    overflow: hidden;
    font-size: .78rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.document-row small {
    color: var(--ink-soft);
    font-size: .68rem;
}

.admin-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 1rem;
}

.admin-table-panel {
    margin-bottom: 1rem;
    overflow: hidden;
}

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

table {
    width: 100%;
    border-collapse: collapse;
    font-size: .76rem;
}

th,
td {
    padding: .8rem 1rem;
    border-bottom: 1px solid var(--line);
    text-align: left;
    white-space: nowrap;
}

th {
    color: var(--ink-soft);
    background: #f8faf9;
    font-size: .67rem;
    letter-spacing: .03em;
    text-transform: uppercase;
}

td .button {
    min-height: 33px;
    padding: .35rem .55rem;
    font-size: .66rem;
}

.table-actions {
    display: flex;
    gap: .35rem;
}

.app-dialog {
    width: min(520px, calc(100% - 2rem));
    padding: 0;
    border: 0;
    border-radius: 18px;
    box-shadow: 0 28px 80px rgba(10, 34, 26, .3);
}

.app-dialog::backdrop {
    background: rgba(7, 25, 19, .62);
    backdrop-filter: blur(4px);
}

.app-dialog form {
    padding: 1.25rem;
}

.dialog-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.toast-region {
    position: fixed;
    z-index: 100;
    top: 1rem;
    right: 1rem;
    display: grid;
    width: min(390px, calc(100% - 2rem));
    gap: .5rem;
}

.toast {
    padding: .8rem 1rem;
    border: 1px solid #cbded4;
    border-radius: 12px;
    color: #fff;
    background: #183f32;
    box-shadow: var(--shadow);
    font-size: .78rem;
    animation: toast-in .2s ease-out;
}

.toast.is-error {
    border-color: #9f3d3d;
    background: #7d2929;
}

@keyframes toast-in {
    from { transform: translateY(-8px); opacity: 0; }
}

.empty-state {
    padding: 2rem;
    color: var(--ink-soft);
    text-align: center;
    font-size: .78rem;
}

@media (max-width: 1180px) {
    .metric-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

    .search-field {
        grid-column: span 2;
    }

    .inbox-layout {
        grid-template-columns: minmax(310px, .75fr) minmax(420px, 1.25fr);
    }
}

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

    .sidebar {
        transform: translateX(-105%);
        transition: transform .2s ease;
    }

    .sidebar.is-open {
        transform: translateX(0);
        box-shadow: 20px 0 60px rgba(0, 0, 0, .28);
    }

    .app-main {
        grid-column: 1;
    }

    .menu-button {
        display: grid;
        place-items: center;
    }

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

    .topbar-actions {
        margin-left: auto;
    }

    .connection-pill {
        display: none;
    }

    .dashboard-grid,
    .two-column {
        grid-template-columns: 1fr;
    }

    .inbox-layout {
        grid-template-columns: 1fr;
    }

    .chat-panel {
        display: none;
    }

    .chat-panel.is-open {
        position: fixed;
        z-index: 40;
        inset: 0;
        display: flex;
        border: 0;
        border-radius: 0;
    }

    .chat-panel.is-open .chat-head::before {
        margin-right: .35rem;
        content: "←";
        cursor: pointer;
    }

    .chat-head {
        align-items: flex-start;
    }

    .chat-head-actions {
        align-items: flex-end;
        flex-direction: column;
    }

    .chat-label {
        max-width: 150px;
    }

    .settings-layout {
        grid-template-columns: 1fr;
    }

    .settings-nav {
        position: static;
        display: flex;
        overflow-x: auto;
    }

    .settings-nav button {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    .auth-shell {
        grid-template-columns: 1fr;
    }

    .auth-promise {
        display: none;
    }

    .login-card {
        width: min(520px, calc(100% - 2rem));
        padding-block: 3rem;
    }

    .mobile-brand {
        display: flex;
        align-items: center;
        gap: .65rem;
        margin-bottom: 2.5rem;
    }

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

    .requirements-card {
        position: static;
    }
}

@media (max-width: 680px) {
    :root {
        font-size: 16px;
    }

    .topbar {
        min-height: 82px;
        padding: .8rem 1rem;
    }

    .topbar-kicker {
        display: none;
    }

    .topbar h1 {
        font-size: 1.25rem;
    }

    .topbar.has-tenant-switcher {
        flex-wrap: wrap;
    }

    .topbar.has-tenant-switcher .topbar-actions {
        flex: 1 0 100%;
        margin-left: 0;
    }

    .tenant-switcher {
        width: 100%;
    }

    .tenant-switcher select {
        width: auto;
        min-width: 0;
        flex: 1;
    }

    .page-content {
        padding: 1rem;
    }

    .page-heading {
        align-items: flex-start;
        flex-direction: column;
    }

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

    .metric-card {
        min-height: 136px;
        padding: .9rem;
    }

    .metric-card strong {
        font-size: 1.8rem;
    }

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

    .document-bubble {
        flex-wrap: wrap;
    }

    .message-download {
        width: 100%;
        justify-content: center;
    }

    .search-field {
        grid-column: span 2;
    }

    .inbox-list-panel {
        min-height: calc(100vh - 310px);
    }

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

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

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

    .workflow-card {
        grid-template-columns: 1fr;
    }

    .workflow-delay-row {
        grid-template-columns: 1fr 1fr;
    }

    .workflow-delay-row > div {
        grid-column: 1 / -1;
    }

    .inline-form {
        display: grid;
        align-items: stretch;
    }

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

    .auth-shell {
        width: 100%;
        min-height: 100vh;
        margin: 0;
        border: 0;
        border-radius: 0;
    }

    .login-card {
        width: 100%;
        padding: 1.5rem;
    }

    .setup-shell {
        width: calc(100% - 1rem);
        margin: .5rem auto 1rem;
    }

    .setup-card {
        padding: 1rem;
    }
}
