/* Relay — design tokens
   Paper #F5F7F6 · Ink #18222C · Rail #0E2D28 (deep green-slate, a nod to the channel without copying it)
   Signal #1C8F62 (window open / success) · Amber #C98A12 (expiring / warning) · Alert #B83A33 (failed / danger)
   Type: IBM Plex Sans, tabular numbers wherever money or counts appear. */
:root {
    --paper: #F5F7F6;
    --panel: #FFFFFF;
    --ink: #18222C;
    --ink-soft: #55616C;
    --line: #DDE3E1;
    --rail: #0E2D28;
    --rail-ink: #C9DAD5;
    --rail-ink-strong: #FFFFFF;
    --signal: #1C8F62;
    --signal-soft: #E3F3EC;
    --amber: #C98A12;
    --amber-soft: #FBF1DC;
    --alert: #B83A33;
    --alert-soft: #FBE7E5;
    --radius-s: 6px;
    --radius-m: 10px;
    --bs-body-font-family: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --bs-body-color: var(--ink);
    --bs-body-bg: var(--paper);
    --bs-primary: var(--signal);
    --bs-primary-rgb: 28, 143, 98;
    --bs-link-color: #17744F;
    --bs-link-color-rgb: 23, 116, 79;
    --bs-link-hover-color: #0F5A3C;
    --bs-border-color: var(--line);
}

body { font-size: 0.9375rem; line-height: 1.5; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { font-weight: 600; letter-spacing: -0.01em; }
code, .stat-value, .data-table td { font-variant-numeric: tabular-nums; }

.btn-primary { --bs-btn-bg: var(--signal); --bs-btn-border-color: var(--signal); --bs-btn-hover-bg: #17774F; --bs-btn-hover-border-color: #17774F; --bs-btn-active-bg: #125F40; --bs-btn-disabled-bg: var(--signal); }
.btn-outline-primary { --bs-btn-color: #17744F; --bs-btn-border-color: #9ACDB6; --bs-btn-hover-bg: var(--signal); --bs-btn-hover-border-color: var(--signal); }
.btn-quiet { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.btn-quiet:hover { background: #EBF0EE; color: var(--ink); }
.btn:focus-visible, .form-control:focus, .form-select:focus, a:focus-visible, .rail-link:focus-visible {
    outline: 3px solid rgba(28, 143, 98, .45); outline-offset: 2px; box-shadow: none;
}
.form-control, .form-select { border-color: #CBD4D1; border-radius: var(--radius-s); background-color: #fff; }
.form-label { font-weight: 500; font-size: .875rem; margin-bottom: .3rem; }
.form-text { color: var(--ink-soft); }
#f_country { text-transform: uppercase; }

/* ---------- App shell ---------- */
.shell { display: flex; min-height: 100vh; }
.rail { background-color: var(--rail) !important; /* Bootstrap makes .offcanvas-lg transparent on desktop */ color: var(--rail-ink); width: 256px; flex-shrink: 0; display: flex; flex-direction: column; }
@media (min-width: 992px) {
    .rail { position: sticky; top: 0; height: 100vh; overflow-y: auto; }
}
.rail.offcanvas-lg { --bs-offcanvas-bg: var(--rail); --bs-offcanvas-width: 260px; }
.rail-head { display: flex; align-items: center; justify-content: space-between; padding: 1.1rem 1.1rem .6rem; }
.brand { display: inline-flex; align-items: center; gap: .55rem; color: var(--rail-ink-strong); font-weight: 700; font-size: 1.1rem; text-decoration: none; }
.brand:hover { color: var(--rail-ink-strong); }
/* Brand mark: a speech bubble whose tail is a clock hand — the 24-hour window, the idea the product is built around. */
.brand-mark { width: 22px; height: 22px; border-radius: 50% 50% 50% 4px; background: var(--signal); position: relative; }
.brand-mark::after { content: ""; position: absolute; left: 10px; top: 5px; width: 2px; height: 7px; background: #fff; border-radius: 1px; box-shadow: 3px 5px 0 -0.5px #fff; }
.rail-scope { margin: .4rem .75rem 1rem; padding: .7rem .8rem; border: 1px solid rgba(255,255,255,.12); border-radius: var(--radius-s); display: flex; flex-direction: column; }
.rail-scope-name { color: var(--rail-ink-strong); font-weight: 600; font-size: .9rem; overflow-wrap: anywhere; }
.rail-scope-role { font-size: .8rem; }
.rail-nav { display: flex; flex-direction: column; padding: 0 .5rem 1.5rem; gap: 1px; }
.rail-link { display: flex; align-items: center; gap: .7rem; padding: .5rem .75rem; border-radius: var(--radius-s); color: var(--rail-ink); text-decoration: none; font-size: .9rem; }
.rail-link:hover { background: rgba(255,255,255,.06); color: var(--rail-ink-strong); }
.rail-link.is-active { background: rgba(28, 143, 98, .28); color: var(--rail-ink-strong); box-shadow: inset 3px 0 0 var(--signal); }
.rail-link.is-soon { opacity: .45; cursor: default; }
.rail-link.is-soon:hover { background: none; color: var(--rail-ink); }
.rail-link span { white-space: nowrap; }
.rail-link small { margin-left: auto; font-size: .7rem; }
.rail-link .bi { font-size: 1rem; width: 1.1rem; text-align: center; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: .75rem; padding: .9rem clamp(1rem, 3vw, 2rem); border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 10; }
.page-title { font-size: 1.2rem; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-btn { display: inline-flex; align-items: center; gap: .5rem; border: 0; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--signal-soft); color: #17744F; display: inline-grid; place-items: center; font-weight: 600; font-size: .85rem; }
.content { padding: clamp(1rem, 3vw, 2rem); max-width: 1280px; width: 100%; }

.impersonation-bar { background: var(--amber); color: #1F1600; font-weight: 600; padding: .55rem 1rem; text-align: center; }

/* ---------- Panels, tables, tags ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 1.25rem; margin-bottom: 1.25rem; }
.panel-danger { border-color: #E9B7B3; }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.panel-head .panel-title { margin: 0; }
.panel-title { font-size: 1rem; margin-bottom: 1rem; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.grid-2 > .panel, .stack > .panel { margin-bottom: 0; }
.stack { display: flex; flex-direction: column; gap: 1.25rem; }
@media (max-width: 991.98px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }

.table-wrap { overflow-x: auto; margin: 0 -1.25rem; padding: 0 1.25rem; }
.data-table { margin: 0; font-size: .9rem; --bs-table-bg: transparent; }
.data-table th { font-weight: 500; color: var(--ink-soft); font-size: .8rem; border-bottom-color: var(--line); white-space: nowrap; }
.data-table td { vertical-align: middle; border-bottom-color: #EDF1EF; }
.data-table tr.is-disabled td { color: var(--ink-soft); }
.data-table .empty { text-align: center; color: var(--ink-soft); padding: 2.5rem 1rem; }
.sub { color: var(--ink-soft); font-size: .82rem; }
.nowrap { white-space: nowrap; }
.inline-form { display: flex; gap: .4rem; align-items: center; min-width: 110px; max-width: 160px; }
code.action { color: var(--ink); background: #EEF2F0; padding: .1rem .35rem; border-radius: 4px; font-size: .82rem; }
.meta-cell pre { font-size: .75rem; max-width: 420px; white-space: pre-wrap; margin: .4rem 0 0; }
.meta-cell summary { cursor: pointer; color: var(--bs-link-color); font-size: .85rem; }

.tag { display: inline-block; font-size: .75rem; font-weight: 500; padding: .12rem .5rem; border-radius: 999px; background: #EEF2F0; color: var(--ink-soft); white-space: nowrap; }
.tag-ok { background: var(--signal-soft); color: #146B48; }
.tag-bad { background: var(--alert-soft); color: #97302A; }
.tag-warn { background: var(--amber-soft); color: #7A5308; }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: .2rem; color: var(--ink); text-decoration: none; }
a.stat:hover { border-color: #9ACDB6; color: var(--ink); }
.stat-label { font-size: .82rem; color: var(--ink-soft); }
.stat-value { font-size: 1.6rem; font-weight: 600; }
.stat.is-muted .stat-value { color: #A7B1AE; }
.stat.is-warn { border-color: #E8C77F; background: var(--amber-soft); }

.welcome { margin-bottom: 1.25rem; }
.welcome h2 { font-size: 1.45rem; margin-bottom: .2rem; }
.welcome p { color: var(--ink-soft); margin: 0; }

.checklist { list-style: none; margin: 0; padding: 0; counter-reset: step; }
.checklist li { display: flex; align-items: center; gap: .9rem; padding: .8rem 0; border-top: 1px solid #EDF1EF; }
.checklist li:first-child { border-top: 0; padding-top: 0; }
.checklist .check { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #C5CFCB; flex-shrink: 0; display: grid; place-items: center; color: #fff; }
.checklist li.is-done .check { background: var(--signal); border-color: var(--signal); }
.checklist li.is-locked .checklist-body { opacity: .6; }
.checklist-body { flex: 1; display: flex; flex-direction: column; }
.checklist-body span { color: var(--ink-soft); font-size: .86rem; }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: .5rem 1.25rem; margin-bottom: 1rem; }
.facts dt { font-weight: 500; color: var(--ink-soft); font-size: .86rem; }
.facts dd { margin: 0; overflow-wrap: anywhere; }

.field { margin-bottom: 1rem; }
fieldset.field { border: 0; padding: 0; }
.form-section { font-size: .95rem; margin: 1.5rem 0 .9rem; padding-top: 1.1rem; border-top: 1px solid var(--line); }
.choice { display: flex; gap: .7rem; padding: .75rem .85rem; border: 1px solid var(--line); border-radius: var(--radius-s); margin-bottom: .5rem; cursor: pointer; }
.choice:has(input:checked) { border-color: var(--signal); background: #F4FAF7; }
.choice input { margin-top: .3rem; accent-color: var(--signal); }
.choice span { display: flex; flex-direction: column; }
.choice small { color: var(--ink-soft); }

.filters { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; margin-bottom: 1.25rem; }
.filters > div { min-width: 160px; }
.filters-inline { margin: 0; align-items: center; }
.filters-inline .form-control { min-width: 240px; }
.filters-inline .form-select { width: auto; }
.filters-actions { display: flex; gap: .5rem; }
.pager { display: flex; justify-content: space-between; align-items: center; padding-top: 1rem; gap: 1rem; flex-wrap: wrap; }
.pager-info { color: var(--ink-soft); font-size: .85rem; }
.pager-links { display: flex; gap: .5rem; }
.back { margin-bottom: 1rem; }
.back a { text-decoration: none; font-size: .9rem; }

/* ---------- Flash messages ---------- */
.flash { display: flex; align-items: flex-start; gap: .6rem; padding: .75rem .9rem; border-radius: var(--radius-s); margin-bottom: 1.25rem; border: 1px solid; }
.flash span { flex: 1; }
.flash-success { background: var(--signal-soft); border-color: #A9D8C3; color: #0F5A3C; }
.flash-error { background: var(--alert-soft); border-color: #EBB8B4; color: #7F2621; }
.flash-notice { background: #EAF1F7; border-color: #BCD0E2; color: #203A52; }
.flash-close { background: none; border: 0; font-size: 1.2rem; line-height: 1; color: inherit; opacity: .6; }
.flash-close:hover { opacity: 1; }

/* ---------- Sign-in ---------- */
.auth-body { background: var(--paper); }
.auth-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); min-height: 100vh; }
.auth-aside { background: var(--rail); color: var(--rail-ink); padding: 2.5rem clamp(2rem, 5vw, 4.5rem); display: flex; flex-direction: column; justify-content: space-between; }
.brand-lg { font-size: 1.35rem; }
.convo { max-width: 360px; display: flex; flex-direction: column; gap: .7rem; }
.bubble { padding: .6rem .8rem .45rem; border-radius: 10px; font-size: .95rem; max-width: 85%; position: relative; }
.bubble time { display: block; text-align: right; font-size: .7rem; opacity: .7; margin-top: .15rem; }
.bubble-in { background: #1B423B; color: #E6F0ED; border-top-left-radius: 3px; }
.bubble-out { background: #DDF4E8; color: #10301F; align-self: flex-end; border-top-right-radius: 3px; }
.bubble-out .bi { color: #2A8FD6; }
.window-meter { margin-top: 1.1rem; }
.window-meter-bar { height: 6px; border-radius: 3px; background: rgba(255,255,255,.12); overflow: hidden; }
.window-meter-bar span { display: block; height: 100%; width: 99%; background: var(--signal); border-radius: 3px; transform-origin: left; animation: window-drain 2.4s ease-out .3s both; }
.window-meter p { font-size: .82rem; margin: .45rem 0 0; }
@keyframes window-drain { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@media (prefers-reduced-motion: reduce) { .window-meter-bar span { animation: none; } }
.auth-aside-note { max-width: 26ch; font-size: 1.05rem; color: var(--rail-ink-strong); margin: 0; }
.auth-main { display: grid; place-items: center; padding: 2rem 1.25rem; }
.auth-form { width: 100%; max-width: 380px; }
.auth-form h1 { font-size: 1.6rem; margin-bottom: .35rem; }
.lead-quiet { color: var(--ink-soft); margin-bottom: 1.5rem; }
.auth-foot { color: var(--ink-soft); font-size: .85rem; margin-top: 1.1rem; }
@media (max-width: 767.98px) {
    .auth-split { grid-template-columns: 1fr; }
    .auth-aside { padding: 1.5rem; gap: 1.5rem; }
    .auth-aside .convo, .auth-aside-note { display: none; }
}

.error-page { max-width: 460px; margin: 12vh auto; padding: 0 1.25rem; }
.error-code { font-size: 3.5rem; font-weight: 700; color: #B7C2BE; margin: 0; line-height: 1; }
.error-page h1 { font-size: 1.5rem; margin: .6rem 0; }

/* ---------- Contacts (Phase 3) ---------- */
/* Tag colours are classes, not inline styles, because the CSP forbids inline style attributes. */
.chip { display: inline-flex; align-items: center; gap: .3rem; font-size: .75rem; font-weight: 500; padding: .12rem .5rem; border-radius: 999px; white-space: nowrap; margin: 0 .25rem .25rem 0; }
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; }
.tc-1c8f62 { background: #E1F0EB; color: #146747; }
.sw-1c8f62 { background: #1C8F62; }
.tc-2f6fb3 { background: #E4ECF5; color: #225081; }
.sw-2f6fb3 { background: #2F6FB3; }
.tc-8a5cc2 { background: #F0EAF7; color: #63428C; }
.sw-8a5cc2 { background: #8A5CC2; }
.tc-c98a12 { background: #F8F0E0; color: #91630D; }
.sw-c98a12 { background: #C98A12; }
.tc-b85c1e { background: #F6EAE2; color: #844216; }
.sw-b85c1e { background: #B85C1E; }
.tc-3a8c8c { background: #E5F0F0; color: #2A6565; }
.sw-3a8c8c { background: #3A8C8C; }
.tc-55616c { background: #E9EAEC; color: #3D464E; }
.sw-55616c { background: #55616C; }
.tc-b83a33 { background: #F6E5E4; color: #842A25; }
.sw-b83a33 { background: #B83A33; }
.tc-a13f7a { background: #F3E6EE; color: #742D58; }
.sw-a13f7a { background: #A13F7A; }
.tc-4a6b2a { background: #E7ECE3; color: #354D1E; }
.sw-4a6b2a { background: #4A6B2A; }

.window { display: inline-flex; align-items: center; gap: .35rem; font-size: .78rem; font-weight: 500; white-space: nowrap; }
.window::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #B7C2BE; }
.window-active { color: #146B48; } .window-active::before { background: var(--signal); box-shadow: 0 0 0 3px var(--signal-soft); }
.window-expired { color: #7A5308; } .window-expired::before { background: var(--amber); }
.window-none { color: var(--ink-soft); }
.contact-name { font-weight: 600; color: var(--ink); text-decoration: none; }
.contact-name:hover { text-decoration: underline; }
.check-col { width: 34px; }
.bulk-bar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding: .75rem 0 0; border-top: 1px solid var(--line); margin-top: .5rem; }
.bulk-bar .form-select { width: auto; }
.bulk-count { color: var(--ink-soft); font-size: .85rem; margin-right: .25rem; }
.head-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.summary-line { color: var(--ink-soft); font-size: .88rem; margin: -.25rem 0 1rem; }
.contact-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; }
.contact-head h2 { font-size: 1.35rem; margin: 0 0 .15rem; }
.contact-head .phone { font-variant-numeric: tabular-nums; color: var(--ink-soft); }
.tag-picker { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }
.tag-picker label { cursor: pointer; }
.tag-picker input { position: absolute; opacity: 0; pointer-events: none; }
.tag-picker .chip { border: 1px solid transparent; opacity: .55; margin: 0; padding: .25rem .65rem; font-size: .82rem; }
.tag-picker input:checked + .chip { opacity: 1; border-color: currentColor; }
.tag-picker input:focus-visible + .chip { outline: 3px solid rgba(28,143,98,.45); outline-offset: 2px; }
.color-picker { display: flex; flex-wrap: wrap; gap: .35rem; }
.color-picker label { cursor: pointer; }
.color-picker input { position: absolute; opacity: 0; }
.color-picker .swatch { width: 24px; height: 24px; border-radius: 6px; border: 2px solid transparent; }
.color-picker input:checked + .swatch { border-color: var(--ink); box-shadow: inset 0 0 0 2px #fff; }
.color-picker input:focus-visible + .swatch { outline: 3px solid rgba(28,143,98,.45); outline-offset: 2px; }
.note { padding: .75rem 0; border-top: 1px solid #EDF1EF; }
.note:first-child { border-top: 0; }
.note-body { white-space: pre-wrap; overflow-wrap: anywhere; margin-bottom: .3rem; }
.note-meta { display: flex; gap: .75rem; align-items: center; font-size: .8rem; color: var(--ink-soft); }
.note-meta form { margin-left: auto; }
.link-btn { background: none; border: 0; padding: 0; color: var(--bs-link-color); font-size: .8rem; }
.link-btn:hover { text-decoration: underline; }
.link-danger { color: var(--alert); }
.convo-row { display: flex; justify-content: space-between; gap: 1rem; padding: .6rem 0; border-top: 1px solid #EDF1EF; }
.convo-row:first-child { border-top: 0; }
.convo-preview { color: var(--ink-soft); font-size: .86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 36ch; }
.import-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.import-stats div { border: 1px solid var(--line); border-radius: var(--radius-s); padding: .6rem .75rem; }
.import-stats strong { display: block; font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.import-stats span { font-size: .8rem; color: var(--ink-soft); }
.steps { padding-left: 1.2rem; margin: 0 0 1rem; }
.steps li { margin-bottom: .4rem; }
.subnav { display: flex; gap: .25rem; margin-bottom: 1.25rem; border-bottom: 1px solid var(--line); }
.subnav a { padding: .5rem .8rem; color: var(--ink-soft); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; font-size: .9rem; }
.subnav a:hover { color: var(--ink); }
.subnav a.is-active { color: var(--ink); border-bottom-color: var(--signal); font-weight: 500; }
.edit-row summary { cursor: pointer; color: var(--bs-link-color); font-size: .85rem; list-style: none; }
.edit-row summary::-webkit-details-marker { display: none; }
.edit-row[open] summary { margin-bottom: .6rem; }
.edit-row form { display: grid; gap: .6rem; max-width: 420px; }
/* Keep the dark rail full height on long pages (the rail itself is sticky at 100vh). */
@media (min-width: 992px) { .shell { background: linear-gradient(to right, var(--rail) 256px, transparent 256px); } }
.filters-inline .form-control { width: auto; flex: 1 1 220px; min-width: 200px; }
.subnav { overflow-x: auto; scrollbar-width: none; }
.subnav a { white-space: nowrap; }
@media (max-width: 575.98px) { .filters-inline > .form-select { flex: 1 1 45%; } }
/* ---------- WhatsApp connection (Phase 4) ---------- */
.connect-hero h2 { font-size: 1.3rem; margin-bottom: .4rem; }
.connect-hero p { color: var(--ink-soft); max-width: 70ch; }
.connect-options { display: flex; flex-wrap: wrap; gap: 1.5rem; align-items: flex-start; }
.connect-options > * { flex: 1 1 260px; }
.advanced { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.advanced summary { cursor: pointer; font-weight: 500; }
.advanced[open] summary { margin-bottom: .75rem; }
.secret-box { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; background: #EEF2F0; padding: .5rem .7rem; border-radius: var(--radius-s); overflow-wrap: anywhere; }
.wa-admin { padding: .75rem 0; border-top: 1px solid #EDF1EF; }
.wa-admin:first-of-type { border-top: 0; padding-top: 0; }
.wa-credit { max-width: none; flex-wrap: wrap; }
.wa-credit .form-select { width: auto; }
.payload { font-size: .78rem; background: #0F1B19; color: #D8E6E1; padding: 1rem; border-radius: var(--radius-s); max-height: 70vh; overflow: auto; white-space: pre; }
.simulate-form { display: grid; gap: .5rem; max-width: 420px; }
/* ---------- Conversations (Phase 6) ---------- */
.pills { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: 1rem; }
.pills a { padding: .3rem .75rem; border-radius: 999px; border: 1px solid var(--line); color: var(--ink-soft); text-decoration: none; font-size: .85rem; }
.pills a:hover { color: var(--ink); border-color: #BFCBC7; }
.pills a.is-active { background: var(--rail); border-color: var(--rail); color: #fff; }
.convo-list { list-style: none; margin: 0; padding: 0; }
.convo-list .empty { padding: 2.5rem 1rem; text-align: center; color: var(--ink-soft); }
.convo-item { display: flex; gap: .8rem; padding: .8rem .5rem; border-top: 1px solid #EDF1EF; color: var(--ink); text-decoration: none; border-radius: var(--radius-s); }
.convo-list li:first-child .convo-item { border-top: 0; }
.convo-item:hover { background: #F4F7F6; color: var(--ink); }
.convo-item .avatar { width: 40px; height: 40px; flex-shrink: 0; font-size: 1rem; }
.convo-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .15rem; }
.convo-top, .convo-bottom { display: flex; justify-content: space-between; gap: .75rem; align-items: center; }
.convo-top time { font-size: .78rem; color: var(--ink-soft); white-space: nowrap; }
.convo-item .convo-preview { color: var(--ink-soft); font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: none; flex: 1; }
.convo-item.is-unread strong, .convo-item.is-unread .convo-preview { color: var(--ink); font-weight: 600; }
.convo-meta { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.unread-badge { background: var(--signal); color: #fff; font-size: .72rem; font-weight: 600; min-width: 20px; height: 20px; border-radius: 10px; display: inline-grid; place-items: center; padding: 0 6px; }

.chat-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1.25rem; align-items: start; }
@media (max-width: 991.98px) { .chat-layout { grid-template-columns: minmax(0, 1fr); } }
.chat-panel { padding: 0; display: flex; flex-direction: column; overflow: hidden; }
.chat-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); }
.chat-head h2 { font-size: 1.1rem; margin: 0; }
.thread { background: #EFEAE2; padding: 1rem clamp(.75rem, 3vw, 1.5rem); display: flex; flex-direction: column; gap: .35rem; min-height: 320px; max-height: 62vh; overflow-y: auto; }
.thread .empty { color: var(--ink-soft); text-align: center; margin: auto; }
.day-sep { text-align: center; margin: .6rem 0; }
.day-sep span { background: #fff; color: var(--ink-soft); font-size: .75rem; padding: .2rem .6rem; border-radius: 6px; box-shadow: 0 1px 0 rgba(0,0,0,.05); }
.msg { max-width: min(75%, 560px); padding: .45rem .65rem .3rem; border-radius: 9px; box-shadow: 0 1px 0 rgba(0,0,0,.06); overflow-wrap: anywhere; }
.msg-in { background: #fff; align-self: flex-start; border-top-left-radius: 2px; }
.msg-out { background: #DCF5E5; align-self: flex-end; border-top-right-radius: 2px; }
.msg-failed { background: #FBE7E5; }
.msg-reaction { background: transparent; box-shadow: none; padding: 0 .3rem; }
.msg-label { font-size: .75rem; color: #146B48; font-weight: 500; margin-bottom: .2rem; }
.msg-body { white-space: normal; line-height: 1.45; }
.msg-meta { display: flex; gap: .4rem; justify-content: flex-end; align-items: center; font-size: .7rem; color: #667781; margin-top: .15rem; }
.msg-img { display: block; max-width: 100%; max-height: 320px; border-radius: 6px; margin-bottom: .25rem; }
.msg-file { display: inline-flex; gap: .4rem; align-items: center; padding: .35rem 0; }
.msg-error { font-size: .78rem; color: #97302A; margin-top: .25rem; }
.ticks { display: inline-flex; align-items: center; gap: .2rem; color: #667781; }
.ticks-read { color: #2A8FD6; }
.ticks-failed { color: var(--alert); font-weight: 500; }
.composer { border-top: 1px solid var(--line); padding: .75rem 1rem; background: #F7F8F8; }
.composer-form textarea { resize: vertical; min-height: 44px; }
.composer-actions { display: flex; align-items: center; gap: .5rem; margin-top: .5rem; flex-wrap: wrap; }
.window-closed { display: flex; gap: .75rem; align-items: center; background: var(--amber-soft); color: #5E4106; border: 1px solid #E8C77F; border-radius: var(--radius-s); padding: .7rem .9rem; flex-wrap: wrap; }
.window-closed span { flex: 1 1 260px; }
