:root {
  --purple: #6c3cff;
  --purple-dark: #5524d6;
  --purple-soft: #f1ecff;
  --navy: #0f172a;
  --slate: #64748b;
  --muted: #94a3b8;
  --line: #e5e7eb;
  --line-strong: #d5d9e2;
  --surface: #f7f8fc;
  --card: #ffffff;
  --green: #22c55e;
  --green-soft: #dcfce7;
  --blue: #0ea5e9;
  --blue-soft: #e0f2fe;
  --amber: #f59e0b;
  --amber-soft: #fef3c7;
  --red: #ef4444;
  --red-soft: #fee2e2;
  --radius: 18px;
  --shadow: 0 8px 30px rgba(15, 23, 42, .06);
  --sidebar-width: 248px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; font-family: "Lexend", system-ui, sans-serif; color: var(--navy); background: var(--surface); font-size: 14px; line-height: 1.5; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
button { color: inherit; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { letter-spacing: -.025em; }
small { display: block; color: var(--slate); margin-top: 3px; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; overflow-wrap: anywhere; }

.icon { width: 20px; height: 20px; flex: 0 0 auto; }
.muted { color: var(--slate); font-size: 12px; }
.mobile-only, .mobile-menu { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 18px 14px; border-right: 1px solid var(--line); background: rgba(255,255,255,.96); display: flex; flex-direction: column; z-index: 30; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 11px; padding: 6px 9px 24px; font-size: 25px; font-weight: 700; color: var(--navy); }
.brand > span:last-child > span { color: var(--purple); }
.brand-icon { width: 40px; height: 40px; border-radius: 13px 13px 13px 5px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #7d4dff, #5422d8); box-shadow: 0 10px 24px rgba(108,60,255,.25); }
.brand-icon .icon { width: 23px; height: 23px; }
.sidebar nav { display: grid; gap: 5px; }
.nav-link, .nav-action { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 11px 13px; border-radius: 12px; color: #475569; font-weight: 500; transition: background .18s ease, color .18s ease, transform .18s ease; }
.nav-link:hover, .nav-link.active { color: var(--purple); background: var(--purple-soft); transform: translateX(2px); }
.nav-link.active { font-weight: 600; }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--line); padding: 16px 4px 2px; }
.workspace-chip { display: flex; align-items: center; gap: 9px; font-weight: 600; padding: 0 8px 12px; }
.workspace-mark { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 10px; color: var(--purple); background: var(--purple-soft); }
.link-button { border: 0; background: transparent; width: 100%; cursor: pointer; }
.sidebar-backdrop { display: none; }

.main-content { min-width: 0; }
.topbar { height: 68px; padding: 0 30px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.86); backdrop-filter: blur(14px); position: sticky; top: 0; z-index: 20; }
.topbar-title { display: grid; gap: 1px; }
.user-chip { display: flex; align-items: center; gap: 9px; padding: 5px 11px 5px 5px; border-radius: 999px; background: var(--purple-soft); font-weight: 500; }
.user-avatar { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--purple); font-size: 12px; font-weight: 700; }
.page { padding: 28px 32px 48px; max-width: 1540px; margin: 0 auto; }
.page-content { animation: fadeUp .28s ease both; }
.page-content.is-loading { display: none; }

.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.page-heading h1 { font-size: 31px; margin-bottom: 4px; }
.page-heading p { color: var(--slate); margin-bottom: 0; max-width: 740px; }
.heading-with-back, .heading-actions { display: flex; align-items: center; gap: 12px; }
.heading-actions { flex-wrap: wrap; justify-content: flex-end; }
.eyebrow { display: block; margin-bottom: 4px; color: var(--purple); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.eyebrow.light { color: #ddd2ff; }
.danger-text { color: var(--red); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card:not(.table-card):not(.inbox-shell) { padding: 22px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; margin-bottom: 18px; }
.card-head h2 { font-size: 20px; margin-bottom: 4px; }
.card-head p { color: var(--slate); font-size: 13px; margin-bottom: 0; }
.decor-icon { color: var(--purple); opacity: .35; width: 28px; height: 28px; }
.text-link { display: inline-flex; align-items: center; gap: 4px; color: var(--purple); font-weight: 600; font-size: 13px; white-space: nowrap; }
.text-link .icon { width: 16px; height: 16px; transition: transform .18s ease; }
.text-link:hover .icon { transform: translateX(3px); }

.stat-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat-card { display: flex; align-items: center; gap: 13px; min-height: 118px; padding: 17px; border: 1px solid var(--line); border-radius: 15px; background: #fff; box-shadow: 0 4px 14px rgba(15,23,42,.035); transition: transform .18s ease, box-shadow .18s ease; }
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(15,23,42,.07); }
.stat-card > div { min-width: 0; }
.stat-card span:not(.stat-icon) { color: var(--slate); font-size: 12px; font-weight: 600; }
.stat-card strong { display: block; margin-top: 2px; font-size: 27px; line-height: 1.15; }
.stat-card strong small { display: inline; color: var(--muted); font-size: 16px; }
.stat-card p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.stat-card .small-value { font-size: 16px; overflow-wrap: anywhere; }
.stat-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; }
.stat-icon.purple { color: var(--purple); background: var(--purple-soft); }
.stat-icon.blue { color: var(--blue); background: var(--blue-soft); }
.stat-icon.green { color: #16a34a; background: var(--green-soft); }
.stat-icon.amber { color: #d97706; background: var(--amber-soft); }
.stat-icon.red { color: var(--red); background: var(--red-soft); }

.dashboard-grid { display: grid; grid-template-columns: 1.12fr .88fr; gap: 18px; margin-bottom: 18px; }
.device-detail-grid { align-items: start; }
.stack { display: grid; gap: 15px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: grid; gap: 6px; }
.field label, .field-label { color: #334155; font-weight: 600; font-size: 13px; }
input, textarea, select { width: 100%; border: 1px solid var(--line-strong); border-radius: 11px; background: #fff; color: var(--navy); padding: 11px 12px; outline: none; transition: border-color .18s ease, box-shadow .18s ease, background .18s ease; }
textarea { resize: vertical; min-height: 100px; }
input:focus, textarea:focus, select:focus { border-color: var(--purple); box-shadow: 0 0 0 4px rgba(108,60,255,.1); }
.helper-text { margin: 0; color: var(--slate); font-size: 11px; line-height: 1.5; }
.helper-text.centered { text-align: center; }
.field-meta { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.sms-counter { color: var(--slate); font-size: 11px; white-space: nowrap; }
.errorlist, .field-error { list-style: none; margin: 0; padding: 0; color: #b91c1c; font-size: 11px; }

.btn { min-height: 42px; border: 0; border-radius: 11px; padding: 10px 15px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: fit-content; cursor: pointer; font-weight: 600; transition: transform .16s ease, box-shadow .16s ease, background .16s ease, opacity .16s ease; }
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn .icon { width: 17px; height: 17px; }
.btn-primary { color: #fff; background: linear-gradient(135deg, #7b49ff, #5b24df); box-shadow: 0 9px 20px rgba(108,60,255,.22); }
.btn-primary:hover { box-shadow: 0 12px 26px rgba(108,60,255,.3); }
.btn-secondary { color: #334155; background: #fff; border: 1px solid var(--line-strong); }
.btn-secondary:hover { background: #f8fafc; }
.btn-danger { color: #fff; background: var(--red); }
.btn-danger-outline { color: #b91c1c; background: #fff; border: 1px solid #fecaca; }
.btn-disabled { color: var(--muted); background: #eef0f4; cursor: not-allowed; }
.full-width { width: 100%; }
.button-loading { display: none; align-items: center; gap: 8px; }
.is-busy .button-label { display: none; }
.is-busy .button-loading { display: inline-flex; }
.spinner { width: 15px; height: 15px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.icon-button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 10px; display: inline-grid; place-items: center; background: #fff; color: #475569; cursor: pointer; transition: color .16s ease, background .16s ease, transform .16s ease, border-color .16s ease; }
.icon-button:hover { color: var(--purple); border-color: #d7c8ff; background: var(--purple-soft); transform: translateY(-1px); }
.icon-button.danger:hover { color: var(--red); border-color: #fecaca; background: #fff1f2; }
.icon-button .icon { width: 18px; height: 18px; }

/* Sidebar navigation controls only appear on mobile. This rule comes after
   .icon-button so its display value cannot override the desktop state. */
.topbar [data-sidebar-open],
.sidebar [data-sidebar-close] { display: none; }

.secret-panel { display: grid; grid-template-columns: 1fr minmax(300px, .8fr); gap: 18px; align-items: center; margin-bottom: 18px; padding: 20px; border-radius: var(--radius); color: #fff; background: linear-gradient(135deg, #21104f, #4e23a4); box-shadow: 0 15px 42px rgba(61,28,132,.18); }
.secret-panel h2 { margin-bottom: 5px; }
.secret-panel p { color: #ddd2ff; margin-bottom: 0; }
.copy-field { min-height: 46px; display: flex; align-items: center; justify-content: space-between; gap: 10px; border: 1px solid var(--line-strong); border-radius: 11px; background: #f8fafc; padding: 6px 6px 6px 12px; }
.copy-field.dark { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.18); }
.copy-field.dark .icon-button { color: #fff; border-color: rgba(255,255,255,.18); background: rgba(255,255,255,.08); }

.device-list { display: grid; }
.device-row { display: grid; grid-template-columns: 45px 1fr auto; gap: 12px; align-items: center; padding: 13px 4px; border-bottom: 1px solid var(--line); transition: background .16s ease, padding .16s ease; }
.device-row:last-child { border-bottom: 0; }
.device-row:hover { background: #faf9ff; padding-left: 8px; padding-right: 8px; border-radius: 11px; }
.device-avatar { width: 42px; height: 42px; position: relative; display: grid; place-items: center; border-radius: 12px; color: var(--purple); background: var(--purple-soft); }
.status-dot { position: absolute; right: -2px; bottom: -2px; width: 11px; height: 11px; border: 2px solid #fff; border-radius: 50%; background: var(--muted); }
.status-dot.online { background: var(--green); }
.status-dot.offline { background: var(--muted); }

.table-card .card-head { padding: 20px 22px 0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; min-width: 840px; border-collapse: collapse; }
th, td { padding: 14px 16px; border-top: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--slate); background: #fafbfc; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
td { font-size: 13px; }
.actions-col { width: 140px; text-align: right; }
.row-actions { display: flex; justify-content: flex-end; gap: 6px; }
.device-name-link { display: flex; align-items: center; gap: 10px; }
.table-device-icon { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; color: var(--purple); background: var(--purple-soft); }
.table-device-icon .icon { width: 18px; height: 18px; }
.message-cell { max-width: 320px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty-cell { padding: 42px 20px; text-align: center; color: var(--slate); }
.empty-inline { display: flex; justify-content: center; align-items: center; gap: 9px; }
.battery-value, .direction { display: inline-flex; align-items: center; gap: 5px; }
.battery-value .icon, .direction .icon { width: 16px; height: 16px; }
.direction-inbound { color: #15803d; }
.direction-outbound { color: #0369a1; }

.badge { display: inline-flex; align-items: center; padding: 5px 8px; border-radius: 999px; font-size: 10px; font-weight: 600; letter-spacing: .02em; color: #475569; background: #e2e8f0; }
.status-online, .status-delivered, .status-received { color: #166534; background: var(--green-soft); }
.status-sent { color: #075985; background: var(--blue-soft); }
.status-queued, .status-assigned, .status-sending { color: #92400e; background: var(--amber-soft); }
.status-failed, .status-revoked { color: #991b1b; background: var(--red-soft); }
.status-offline, .status-pending, .status-paused, .status-unknown { color: #475569; background: #e2e8f0; }
.status-text-delivered, .status-text-received { color: #16a34a; }
.status-text-sent { color: #0284c7; }
.status-text-failed { color: var(--red); }

.limit-card { display: grid; grid-template-columns: auto 1fr minmax(180px, 300px); gap: 14px; align-items: center; margin-bottom: 18px; padding: 16px 18px; border: 1px solid #ddd2ff; border-radius: 15px; background: linear-gradient(90deg, #faf8ff, #fff); }
.limit-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; color: var(--purple); background: var(--purple-soft); }
.limit-copy p { margin: 3px 0 0; color: var(--slate); font-size: 12px; }
.progress { height: 9px; overflow: hidden; border-radius: 999px; background: #e9e5f4; }
.progress span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #8a5aff, #5f28e5); transition: width .45s ease; }

.sim-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.sim-card { display: grid; gap: 5px; padding: 15px; border: 1px solid var(--line); border-radius: 13px; background: #fbfbfd; transition: transform .16s ease, border-color .16s ease; }
.sim-card:hover { transform: translateY(-2px); border-color: #d8ccfa; }
.sim-card > span { color: var(--purple); font-size: 11px; font-weight: 700; }
.sim-card-head { display: flex; align-items: center; justify-content: space-between; }
.sim-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; color: var(--purple); background: var(--purple-soft); }
.sim-flags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; color: var(--slate); font-size: 10px; }
.sim-flags span { display: inline-flex; align-items: center; gap: 4px; }
.sim-flags .icon { width: 13px; height: 13px; }
.settings-summary { min-height: 100%; }
.details-list { margin: 0; display: grid; }
.details-list > div { display: flex; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.details-list > div:last-child { border-bottom: 0; }
.details-list dt { color: var(--slate); }
.details-list dd { margin: 0; text-align: right; font-weight: 500; }
.form-card.narrow { max-width: 760px; }
.settings-section-heading { display: grid; gap: 4px; margin-top: 8px; padding-top: 20px; border-top: 1px solid var(--line); }
.settings-section-heading h2, .settings-section-heading p { margin: 0; }
.settings-section-heading h2 { font-size: 17px; }
.settings-section-heading p { color: var(--muted); font-size: 11px; line-height: 1.6; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 4px; }
.toggle-card { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #fbfbfd; }
.toggle-card p { margin: 3px 0 0; color: var(--slate); font-size: 11px; }
.switch { position: relative; display: inline-flex; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch span { width: 48px; height: 27px; border-radius: 999px; background: #cbd5e1; position: relative; transition: background .2s ease; }
.switch span::after { content: ""; width: 21px; height: 21px; border-radius: 50%; background: #fff; position: absolute; left: 3px; top: 3px; box-shadow: 0 2px 7px rgba(15,23,42,.2); transition: transform .2s ease; }
.switch input:checked + span { background: var(--purple); }
.switch input:checked + span::after { transform: translateX(21px); }

.inbox-shell { min-height: 720px; display: grid; grid-template-columns: 370px minmax(0, 1fr); }
.conversation-list { min-width: 0; border-right: 1px solid var(--line); background: #fff; }
.conversation-head { padding: 18px 16px 12px; border-bottom: 1px solid var(--line); }
.conversation-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.conversation-title-actions { display: flex; align-items: center; gap: 7px; }
.conversation-title h2 { margin-bottom: 2px; font-size: 19px; }
.conversation-title p { margin: 0; color: var(--slate); font-size: 11px; }
.inbox-search { position: relative; }
.inbox-search input { padding-left: 38px; padding-right: 38px; }
.search-icon, .search-clear { position: absolute; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-icon { left: 12px; pointer-events: none; }
.search-clear { right: 10px; display: grid; place-items: center; }
.search-icon .icon, .search-clear .icon { width: 17px; height: 17px; }
.inbox-tabs { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 12px; border-bottom: 1px solid var(--line); }
.inbox-tabs a { position: relative; display: flex; align-items: center; justify-content: center; gap: 5px; padding: 10px 4px; color: var(--slate); font-size: 12px; font-weight: 500; }
.inbox-tabs a::after { content: ""; position: absolute; left: 15%; right: 15%; bottom: -1px; height: 2px; border-radius: 2px; background: transparent; }
.inbox-tabs a.active { color: var(--purple); }
.inbox-tabs a.active::after { background: var(--purple); }
.inbox-tabs span { min-width: 18px; height: 18px; padding: 0 5px; display: grid; place-items: center; border-radius: 999px; color: #fff; background: var(--purple); font-size: 9px; }
.conversation-scroll { max-height: 610px; overflow-y: auto; }
.conversation-item { display: grid; grid-template-columns: 44px minmax(0,1fr); gap: 11px; padding: 14px 15px; border-bottom: 1px solid var(--line); transition: background .16s ease; }
.conversation-item:hover, .conversation-item.active { background: #f6f2ff; }
.conversation-item.active { box-shadow: inset 3px 0 0 var(--purple); }
.avatar { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; color: var(--purple); background: #e9e1ff; font-weight: 700; }
.avatar.large { width: 46px; height: 46px; }
.conversation-copy { min-width: 0; }
.conversation-line { display: flex; justify-content: space-between; gap: 8px; min-width: 0; }
.conversation-line strong, .conversation-line small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conversation-line time { color: var(--muted); font-size: 10px; white-space: nowrap; }
.conversation-line.preview { margin-top: 3px; align-items: center; }
.unread { min-width: 20px; height: 20px; padding: 0 6px; display: grid; place-items: center; border-radius: 999px; color: #fff; background: var(--purple); font-size: 9px; }
.conversation-device { display: flex; align-items: center; gap: 4px; margin-top: 5px; color: var(--muted); font-size: 9px; }
.conversation-device .icon { width: 12px; height: 12px; }
.thread-panel { min-width: 0; display: flex; flex-direction: column; background: #fbfcff; }
.thread-head { min-height: 78px; padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 14px; background: #fff; }
.thread-contact, .thread-actions { display: flex; align-items: center; gap: 10px; }
.thread-contact { min-width: 0; }
.thread-contact > div { min-width: 0; }
.thread-contact h2 { margin-bottom: 1px; font-size: 18px; }
.thread-contact p { display: flex; align-items: center; gap: 4px; margin: 0; color: var(--slate); font-size: 11px; }
.thread-contact p .icon { width: 13px; height: 13px; }
.thread-messages { flex: 1; max-height: 510px; overflow-y: auto; padding: 20px 24px; background: radial-gradient(circle at 15% 10%, #f5f1ff, transparent 25%), #fbfcff; }
.date-divider { display: flex; justify-content: center; margin: 8px 0 18px; }
.date-divider span { padding: 4px 9px; border-radius: 999px; color: var(--slate); background: #edf0f5; font-size: 9px; font-weight: 500; }
.bubble-row { display: flex; margin-bottom: 10px; animation: bubbleIn .22s ease both; }
.bubble-row.outbound { justify-content: flex-end; }
.bubble { max-width: min(72%, 650px); padding: 10px 12px; border: 1px solid var(--line); border-radius: 15px 15px 15px 5px; background: #fff; box-shadow: 0 4px 14px rgba(15,23,42,.04); }
.outbound .bubble { color: #fff; border-color: var(--purple); border-radius: 15px 15px 5px 15px; background: linear-gradient(135deg, #7947ff, #5d27de); }
.bubble p { margin-bottom: 6px; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble-meta { display: flex; align-items: center; justify-content: flex-end; gap: 8px; color: var(--muted); font-size: 9px; }
.outbound .bubble-meta { color: #ded6ff; }
.message-state { display: inline-flex; align-items: center; gap: 3px; }
.message-state .icon { width: 12px; height: 12px; }
.outbound .message-state { color: inherit; }
.bubble-error { color: #fecaca; font-size: 9px; }
.composer { padding: 12px 15px 14px; border-top: 1px solid var(--line); background: #fff; }
.composer-routing-toggle { border: 0; background: transparent; }
.composer-routing { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.routing-field { position: relative; }
.routing-field > span { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); z-index: 2; }
.routing-field .icon { width: 15px; height: 15px; }
.routing-field select { padding: 8px 10px 8px 32px; font-size: 11px; }
.composer-input-wrap { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; }
.composer textarea { min-height: 68px; max-height: 160px; padding-right: 12px; }
.send-button { width: 44px; height: 44px; margin-bottom: 1px; border: 0; border-radius: 12px; display: grid; place-items: center; color: #fff; background: var(--purple); cursor: pointer; box-shadow: 0 8px 18px rgba(108,60,255,.25); transition: transform .16s ease, box-shadow .16s ease; }
.send-button:hover { transform: translateY(-1px); box-shadow: 0 11px 22px rgba(108,60,255,.32); }
.send-button .icon { width: 19px; height: 19px; }
.composer-footer { display: flex; justify-content: space-between; gap: 12px; margin-top: 5px; }
.thread-empty { margin: auto; }

.empty-state { text-align: center; padding: 58px 20px; color: var(--slate); }
.empty-state.compact { padding: 30px 16px; }
.empty-state h2, .empty-state h3 { color: var(--navy); margin-bottom: 5px; }
.empty-state p { max-width: 430px; margin: 0 auto 14px; }
.empty-icon { width: 58px; height: 52px; margin: 0 auto 14px; display: grid; place-items: center; border-radius: 16px; color: var(--purple); background: var(--purple-soft); }
.empty-icon.large { width: 72px; height: 64px; }

.modal { position: fixed; inset: 0; display: none; place-items: center; z-index: 100; padding: 20px; }
.modal.is-open { display: grid; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15,23,42,.56); backdrop-filter: blur(4px); animation: fadeIn .18s ease; }
.modal-dialog { position: relative; width: min(760px, 100%); max-height: calc(100vh - 40px); overflow-y: auto; border: 1px solid rgba(255,255,255,.3); border-radius: 20px; background: #fff; box-shadow: 0 28px 80px rgba(15,23,42,.25); animation: modalIn .22s ease; }
.modal-dialog.small { width: min(500px, 100%); }
.modal-header, .modal-footer { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 18px 20px; }
.modal-header { border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 0; font-size: 21px; }
.modal-body { padding: 20px; }
.modal-footer { justify-content: flex-end; border-top: 1px solid var(--line); }
.connect-grid { display: grid; grid-template-columns: 300px 1fr; gap: 22px; }
.qr-panel { padding: 14px; border: 1px solid var(--line); border-radius: 15px; background: #fbfbfd; }
.qr-image { display: block; width: 100%; height: auto; border-radius: 10px; }
.connect-details { display: grid; align-content: start; gap: 9px; }
.notice { display: flex; gap: 10px; padding: 12px; border-radius: 11px; }
.notice p { margin: 2px 0 0; font-size: 11px; }
.notice .icon { margin-top: 1px; }
.notice-warning { color: #854d0e; background: #fef9c3; }
.notice-danger { color: #991b1b; background: #fef2f2; }
.steps-list { margin: 8px 0 0; padding-left: 20px; color: var(--slate); font-size: 12px; }
.steps-list li { margin-bottom: 6px; }
body.modal-open { overflow: hidden; }

.toast-stack { position: fixed; top: 82px; right: 24px; z-index: 130; width: min(380px, calc(100vw - 32px)); display: grid; gap: 9px; pointer-events: none; }
.toast { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 13px; background: #fff; box-shadow: 0 14px 36px rgba(15,23,42,.14); pointer-events: auto; animation: toastIn .24s ease; }
.toast-success { border-color: #bbf7d0; }
.toast-error { border-color: #fecaca; }
.toast-icon { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 9px; color: var(--purple); background: var(--purple-soft); }
.toast-success .toast-icon { color: #15803d; background: var(--green-soft); }
.toast-error .toast-icon { color: #b91c1c; background: var(--red-soft); }
.toast-close { border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.toast-close .icon { width: 16px; height: 16px; }
.toast.is-leaving { animation: toastOut .18s ease forwards; }

.page-skeleton { display: grid; gap: 18px; }
.skeleton { position: relative; overflow: hidden; border-radius: 12px; background: #e9ecf2; }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.72), transparent); animation: shimmer 1.25s infinite; }
.skeleton-title { width: min(380px, 75%); height: 58px; }
.skeleton-grid { display: grid; gap: 14px; }
.skeleton-grid.five { grid-template-columns: repeat(5, 1fr); }
.skeleton-grid.four { grid-template-columns: repeat(4, 1fr); }
.skeleton-grid.two { grid-template-columns: 1.1fr .9fr; }
.skeleton-card { height: 116px; }
.skeleton-panel { height: 330px; }
.skeleton-inbox { height: 720px; }

.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at top, #ece5ff, #f8fafc 50%); }
.auth-toast-stack { position: fixed; top: 18px; right: 18px; z-index: 100; }
.auth-card { width: min(430px, 100%); padding: 30px; border: 1px solid var(--line); border-radius: 20px; background: #fff; box-shadow: 0 22px 60px rgba(15,23,42,.11); }
.auth-card.wide { width: min(520px, 100%); }
.auth-brand { padding: 0 0 24px; }
.auth-card h1 { margin-bottom: 7px; }
.auth-switch { margin: 18px 0 0; color: var(--slate); text-align: center; }
.auth-help { margin: 14px 0 0; color: var(--purple); text-align: center; font-size: 12px; font-weight: 600; }
.auth-icon { width: 48px; height: 48px; display: grid; place-items: center; margin-bottom: 18px; border-radius: 14px; color: var(--purple); background: var(--purple-soft); }
.auth-code-form { margin-top: 22px; }
.otp-input { min-height: 58px; text-align: center; font-size: 26px; font-weight: 700; letter-spacing: .35em; font-variant-numeric: tabular-nums; }
.auth-inline-form { margin-top: 14px; text-align: center; }
.auth-inline-form .link-button { width: auto; padding: 5px; color: var(--purple); font-size: 12px; font-weight: 600; }
.auth-full-button { width: 100%; margin-top: 22px; }
.narrow-page { max-width: 720px; margin: 0 auto; }

.session-list { display: grid; }
.session-row { display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 14px; padding: 16px 0; border-top: 1px solid var(--line); }
.session-row:first-child { border-top: 0; }
.session-device-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; color: var(--purple); background: var(--purple-soft); }
.session-device-icon .icon { width: 20px; height: 20px; }
.session-copy { min-width: 0; }
.session-copy > div { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.session-copy strong { font-size: 13px; }
.session-copy small { overflow-wrap: anywhere; }
.session-footer { display: flex; justify-content: flex-end; padding-top: 18px; border-top: 1px solid var(--line); }

@keyframes fadeUp { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(12px) scale(.985); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes bubbleIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastIn { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(15px); } }
@keyframes shimmer { 100% { transform: translateX(100%); } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1180px) {
  .stat-grid { grid-template-columns: repeat(3, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .inbox-shell { grid-template-columns: 330px minmax(0,1fr); }
  .limit-card { grid-template-columns: auto 1fr; }
  .limit-card .progress { grid-column: 1 / -1; }
  .skeleton-grid.five { grid-template-columns: repeat(3, 1fr); }
  .skeleton-grid.two { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; transform: translateX(-105%); width: min(290px, 86vw); transition: transform .22s ease; box-shadow: 18px 0 40px rgba(15,23,42,.16); }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-backdrop { position: fixed; inset: 0; z-index: 25; background: rgba(15,23,42,.42); }
  body.sidebar-open .sidebar-backdrop { display: block; }
  .mobile-only, .mobile-menu,
  .topbar [data-sidebar-open],
  .sidebar [data-sidebar-close] { display: inline-grid; }
  .topbar { padding: 0 16px; }
  .topbar-title { margin-right: auto; }
  .page { padding: 20px 14px 36px; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .heading-actions { justify-content: flex-start; }
  .session-row { grid-template-columns: auto minmax(0,1fr); }
  .session-row > form { grid-column: 1 / -1; }
  .session-row > form .btn { width: 100%; }
  .stat-grid, .stat-grid.four, .skeleton-grid.five, .skeleton-grid.four { grid-template-columns: repeat(2, 1fr); }
  .two-col, .secret-panel, .connect-grid { grid-template-columns: 1fr; }
  .inbox-shell { display: block; min-height: auto; }
  .conversation-list { border-right: 0; }
  .conversation-scroll { max-height: 440px; }
  .thread-panel { min-height: 620px; border-top: 1px solid var(--line); }
  .bubble { max-width: 88%; }
  .connect-modal { width: min(540px, 100%); }
  .qr-panel { max-width: 320px; margin: auto; }
}

@media (max-width: 560px) {
  .topbar-title span, .user-chip > span:last-child { display: none; }
  .page-heading h1 { font-size: 27px; }
  .stat-grid, .stat-grid.four, .skeleton-grid.five, .skeleton-grid.four { grid-template-columns: 1fr; }
  .stat-card { min-height: 96px; }
  .composer-routing { grid-template-columns: 1fr; }
  .composer-footer { align-items: flex-start; flex-direction: column; }
  .field-meta { flex-direction: column; }
  .limit-card { grid-template-columns: 1fr; text-align: center; }
  .limit-icon { margin: auto; }
  .modal { padding: 10px; }
  .modal-header, .modal-footer, .modal-body { padding: 15px; }
  .modal-footer { flex-wrap: wrap; }
  .modal-footer .btn, .modal-footer form { width: 100%; }
  .modal-footer form .btn { width: 100%; }
  .toast-stack { top: 74px; right: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* External messaging integration */
.integration-notice { margin-bottom: 18px; }
.integration-grid { display: grid; grid-template-columns: .9fr 1.1fr; gap: 18px; margin-bottom: 18px; }
.connection-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-bottom: 18px; }
.connection-summary > div { display: grid; gap: 5px; min-width: 0; }
.connection-summary code { color: var(--slate); }
.connection-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.endpoint-list { display: grid; gap: 12px; }
.endpoint-row { display: grid; grid-template-columns: minmax(165px,.6fr) minmax(0,1fr) auto; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 13px; background: #fbfbfd; }
.endpoint-row > div { min-width: 0; }
.endpoint-row code { padding: 8px 10px; border-radius: 9px; background: #fff; border: 1px solid var(--line); color: #475569; }
.status-badge { display: inline-flex; width: fit-content; align-items: center; min-height: 25px; padding: 4px 9px; border-radius: 999px; font-size: 10px; font-weight: 700; background: #eef2f7; color: #475569; }
.status-connected, .status-completed, .status-processed, .status-synced { background: var(--green-soft); color: #15803d; }
.status-needs_attention, .status-pending, .status-processing { background: var(--amber-soft); color: #a16207; }
.status-disconnected, .status-uninstalled, .status-failed { background: var(--red-soft); color: #b91c1c; }
.subaccount-card { margin-bottom: 18px; }
.subaccount-list { display: grid; gap: 12px; }
.subaccount-row { display: grid; grid-template-columns: minmax(210px,1fr) minmax(130px,.5fr) minmax(230px,1fr) auto; align-items: center; gap: 16px; padding: 15px; border: 1px solid var(--line); border-radius: 15px; background: #fff; transition: transform .18s ease, box-shadow .18s ease; }
.subaccount-row:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(15,23,42,.055); }
.subaccount-identity, .assigned-device { display: flex; align-items: center; gap: 11px; min-width: 0; }
.subaccount-identity > div, .assigned-device > div { min-width: 0; display: grid; gap: 2px; }
.assigned-device-list { display: grid; gap: 9px; margin-bottom: 9px; }
.assigned-device-list .assigned-device { padding: 8px 9px; border: 1px solid var(--line); border-radius: 10px; background: #fbfbfd; }
.assigned-device-list .assigned-device > div { flex: 1; }
.assigned-device-list form { margin: 0 0 0 auto; }
.subaccount-identity code { color: var(--slate); font-size: 10px; }
.subaccount-icon { width: 40px; height: 40px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 12px; color: var(--purple); background: var(--purple-soft); }
.subaccount-state { display: grid; gap: 5px; }
.device-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 4px #eef2f7; }
.device-dot.online { background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }
.binding-form { grid-column: 3 / -1; display: grid; grid-template-columns: minmax(210px,1fr) minmax(210px,1fr) auto; align-items: end; gap: 12px; }
.check-row { min-height: 42px; display: flex; align-items: center; gap: 8px; color: #475569; font-size: 11px; }
.check-row input { width: auto; }
.compact-list { display: grid; gap: 1px; }
.compact-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.compact-row:last-child { border-bottom: 0; }
.compact-row > div { min-width: 0; }
.event-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.event-processed, .event-completed { background: var(--green); }
.event-pending, .event-processing { background: var(--amber); }
.event-failed { background: var(--red); }

@media (max-width: 1180px) {
  .integration-grid { grid-template-columns: 1fr; }
  .subaccount-row { grid-template-columns: 1fr 1fr; }
  .binding-form { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .connection-summary { grid-template-columns: 1fr; }
  .endpoint-row { grid-template-columns: 1fr auto; }
  .endpoint-row > div { grid-column: 1 / -1; }
  .subaccount-row { grid-template-columns: 1fr; }
  .binding-form { grid-template-columns: 1fr; }
}

/* Multiple external authorization accounts */
.integration-connect-actions { align-items: center; }
.integration-metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 18px; }
.compact-metric-card { display: flex; align-items: center; gap: 13px; padding: 16px; }
.compact-metric-card > div { display: grid; gap: 3px; }
.compact-metric-card strong { color: var(--navy); font-size: 22px; line-height: 1; }
.stat-icon.blue { color: #0369a1; background: #e0f2fe; }
.account-list-card { min-width: 0; }
.authorization-account-list { display: grid; gap: 11px; }
.authorization-account-row { display: grid; grid-template-columns: minmax(220px,1fr) minmax(145px,.55fr) auto; align-items: center; gap: 14px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: #fff; transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease; }
.authorization-account-row:hover { transform: translateY(-1px); border-color: #ddd6fe; box-shadow: 0 8px 20px rgba(15,23,42,.055); }
.authorization-account-main { display: flex; align-items: center; gap: 11px; min-width: 0; }
.authorization-account-main > div { display: grid; gap: 3px; min-width: 0; }
.authorization-account-main code { width: fit-content; max-width: 100%; color: var(--slate); font-size: 9px; overflow: hidden; text-overflow: ellipsis; }
.account-title-row { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.authorization-account-meta { display: grid; gap: 4px; color: #475569; font-size: 11px; }
.authorization-account-actions { display: flex; align-items: center; gap: 7px; }
.icon-button.danger { color: #b91c1c; }
.icon-button.danger:hover { color: #991b1b; background: #fef2f2; }
.account-error { grid-column: 1 / -1; margin: 0; }
.endpoint-helper { margin-top: 14px; }
.assignment-disabled { color: var(--slate); }
.subaccount-identity small { color: var(--muted); font-size: 9px; }
.notice-info { color: #075985; background: #f0f9ff; }

@media (max-width: 1040px) {
  .integration-metric-grid { grid-template-columns: 1fr; }
  .authorization-account-row { grid-template-columns: 1fr auto; }
  .authorization-account-meta { grid-column: 1 / 2; }
  .authorization-account-actions { grid-column: 2; grid-row: 1 / 3; }
}

@media (max-width: 620px) {
  .integration-connect-actions { width: 100%; }
  .integration-connect-actions .btn { width: 100%; justify-content: center; }
  .authorization-account-row { grid-template-columns: 1fr; }
  .authorization-account-actions { grid-column: auto; grid-row: auto; }
}

/* Direct sub-account controls */
.subaccount-inline-actions { display: flex; align-items: center; gap: 7px; margin-top: 5px; }
.subaccount-inline-actions form { margin: 0; }

/* Disabled and upcoming navigation */
.nav-link-disabled { color: #a1a8b3; background: #f5f6f8; cursor: not-allowed; transform: none !important; }
.nav-link-disabled:hover { color: #a1a8b3; background: #f5f6f8; }
.nav-link-disabled small { margin: 0 0 0 auto; padding: 2px 6px; border-radius: 999px; color: #7c8592; background: #e7e9ee; font-size: 8px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }

/* Shared compact tables */
.responsive-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; }
.data-table { min-width: 900px; }
.data-table th:first-child, .data-table td:first-child { padding-left: 14px; }
.data-table th:last-child, .data-table td:last-child { padding-right: 14px; }
.data-table tbody tr { background: #fff; transition: background .16s ease; }
.data-table tbody tr:hover { background: #fbfbfe; }
.btn-small { min-height: 34px; padding: 7px 10px; border-radius: 9px; font-size: 11px; }
.table-actions { width: 1%; white-space: nowrap; text-align: right; }
.table-action-group { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.table-identity { display: flex; align-items: center; gap: 10px; min-width: 210px; }
.table-identity > div { min-width: 0; display: grid; gap: 2px; }
.table-identity code { max-width: 230px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--slate); font-size: 9px; }
.assignment-table-card { margin-bottom: 18px; }
.assignment-table-card .card-head { margin-bottom: 14px; }
.assignment-table { min-width: 1160px; }
.assignment-table th:nth-child(1) { width: 23%; }
.assignment-table th:nth-child(3) { width: 26%; }
.table-binding-form { display: grid; grid-template-columns: minmax(180px, 1fr) auto; gap: 7px; align-items: center; min-width: 280px; }
.table-binding-form select { min-height: 36px; padding: 7px 9px; font-size: 11px; }
.contact-setting-form { min-width: 155px; }
.switch-row { display: flex; align-items: center; gap: 7px; color: #475569; font-size: 10px; line-height: 1.35; }
.switch-row input { width: auto; }

/* Billing and credits */
.billing-warning { margin-bottom: 18px; }
.billing-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.billing-metric { min-height: 116px; display: flex; align-items: center; gap: 13px; padding: 17px !important; }
.billing-metric > div { display: grid; gap: 2px; min-width: 0; }
.billing-metric > div > span { color: var(--slate); font-size: 11px; font-weight: 600; }
.billing-metric strong { color: var(--navy); font-size: 27px; line-height: 1.15; }
.billing-metric strong small { display: inline; font-size: 14px; color: var(--muted); }
.credit-plan-card { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 18px; background: linear-gradient(135deg, #ffffff, #faf8ff); }
.credit-plan-copy { display: flex; align-items: center; gap: 16px; }
.credit-plan-copy h2 { margin-bottom: 5px; font-size: 23px; }
.credit-plan-copy p { margin: 0; color: var(--slate); max-width: 760px; }
.plan-icon { width: 58px; height: 58px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 17px; color: var(--purple); background: var(--purple-soft); }
.plan-icon .icon { width: 28px; height: 28px; }
.invoice-card { margin-bottom: 18px; }
.invoice-table { min-width: 780px; }
.status-paid { color: #166534; background: var(--green-soft); }
.status-submitted { color: #075985; background: var(--blue-soft); }
.status-cancelled, .status-expired { color: #991b1b; background: var(--red-soft); }
.credit-calculator { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 14px; border: 1px solid #ddd6fe; border-radius: 12px; color: #4c1d95; background: #faf5ff; }
.credit-calculator span { font-size: 11px; font-weight: 600; }
.credit-calculator strong { font-size: 14px; }
.invoice-modal { width: min(780px, 100%); }
.invoice-payment-grid { display: grid; grid-template-columns: minmax(260px, .85fr) minmax(280px, 1.15fr); gap: 22px; }
.payment-qr-panel { display: grid; justify-items: center; align-content: start; gap: 8px; padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: #fbfbfd; text-align: center; }
.payment-qr-panel img { width: min(100%, 330px); height: auto; border-radius: 10px; background: #fff; }
.payment-qr-panel strong { font-size: 27px; }
.payment-qr-panel small { max-width: 290px; }
.invoice-summary { align-content: start; }
.invoice-status-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.notice-success { color: #166534; background: #f0fdf4; }

@media (max-width: 1120px) {
  .billing-metrics { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .billing-metrics { grid-template-columns: 1fr; }
  .credit-plan-card { align-items: stretch; flex-direction: column; }
  .credit-plan-card .btn { width: 100%; }
  .invoice-payment-grid { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .credit-plan-copy { align-items: flex-start; }
  .plan-icon { width: 48px; height: 48px; }
}

/* Activation wizard */
.activation-shell { max-width: 1160px; margin: 0 auto; }
.activation-hero { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 18px; padding: 25px 27px; border: 1px solid #ddd6fe; border-radius: 20px; background: linear-gradient(135deg, #fff 0%, #f7f3ff 100%); box-shadow: 0 12px 30px rgba(76,29,149,.06); }
.activation-hero h1 { margin: 4px 0 7px; font-size: clamp(27px, 4vw, 40px); }
.activation-hero p { max-width: 760px; margin: 0; color: var(--slate); line-height: 1.65; }
.activation-progress-ring { width: 100px; height: 100px; display: grid; place-content: center; flex: 0 0 auto; border: 8px solid #e9e2ff; border-top-color: var(--purple); border-radius: 50%; text-align: center; animation: soft-pop .45s ease both; }
.activation-progress-ring strong { color: var(--navy); font-size: 23px; line-height: 1; }
.activation-progress-ring span { margin-top: 4px; color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .08em; }
.activation-status-bar { display: flex; align-items: center; margin-bottom: 20px; padding: 13px 16px; overflow-x: auto; border: 1px solid var(--line); border-radius: 15px; background: #fff; }
.setup-pill { display: inline-flex; align-items: center; gap: 7px; flex: 0 0 auto; padding: 7px 10px; border-radius: 999px; color: #64748b; background: #f4f5f7; font-size: 10px; font-weight: 700; }
.setup-pill .icon { width: 15px; height: 15px; }
.setup-pill.done { color: #166534; background: #dcfce7; }
.setup-line { width: 38px; height: 1px; flex: 0 0 auto; background: #d8dce4; }
.activation-grid { display: grid; gap: 15px; }
.activation-step { position: relative; display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 18px; padding: 21px; overflow: visible; transition: border-color .2s ease, transform .2s ease, box-shadow .2s ease; }
.activation-step:hover { transform: translateY(-1px); box-shadow: 0 12px 25px rgba(15,23,42,.055); }
.activation-step.is-complete { border-color: #bbf7d0; background: linear-gradient(135deg, #fff, #fbfffc); }
.step-number { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; color: #fff; background: var(--purple); font-size: 17px; font-weight: 800; box-shadow: 0 7px 16px rgba(108,60,255,.2); }
.activation-step.is-complete .step-number { background: #16a34a; }
.activation-step-body { min-width: 0; }
.step-heading { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.step-heading h2 { margin: 0 0 4px; font-size: 18px; }
.step-heading p { margin: 0; color: var(--slate); line-height: 1.55; }
.step-icon { width: 38px; height: 38px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 11px; color: var(--purple); background: var(--purple-soft); }
.step-icon .icon { width: 20px; height: 20px; }
.instruction-list { display: grid; gap: 8px; margin: 0 0 16px; padding-left: 20px; color: #475569; line-height: 1.55; }
.connected-summary { display: flex; align-items: center; gap: 11px; width: fit-content; max-width: 100%; padding: 12px 14px; border: 1px solid #bbf7d0; border-radius: 13px; color: #166534; background: #f0fdf4; }
.connected-summary > .icon { width: 22px; height: 22px; flex: 0 0 auto; }
.connected-summary strong, .connected-summary p { display: block; }
.connected-summary p { margin: 3px 0 0; color: #52745e; font-size: 10px; }
.wizard-assign-form { display: grid; grid-template-columns: minmax(220px, 1fr) auto; gap: 12px; align-items: end; max-width: 720px; }
.wizard-assign-form label { margin: 0; }
.provider-action-panel { display: grid; gap: 13px; padding: 15px; border: 1px solid var(--line); border-radius: 14px; background: #fbfbfd; }
.provider-action-panel + .provider-action-panel { margin-top: 10px; }
.provider-action-panel p { margin: 4px 0 0; }
.final-checklist { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; margin: 0 0 17px; padding: 0; list-style: none; }
.final-checklist li { display: flex; align-items: center; gap: 7px; padding: 9px 11px; border-radius: 10px; color: #94a3b8; background: #f7f7f9; font-size: 11px; font-weight: 650; }
.final-checklist li.done { color: #166534; background: #ecfdf3; }
.final-checklist .icon { width: 15px; height: 15px; }
.small-dialog { width: min(520px, 100%); }
.sidebar-download { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; padding: 10px 11px; border: 1px solid rgba(255,255,255,.13); border-radius: 10px; color: #e9e3ff; background: rgba(255,255,255,.06); font-size: 10px; font-weight: 650; text-decoration: none; transition: background .16s ease, transform .16s ease; }
.sidebar-download:hover { color: #fff; background: rgba(255,255,255,.11); transform: translateY(-1px); }
.sidebar-download .icon { width: 16px; height: 16px; }

/* Support and error pages */
.support-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(280px, .6fr); gap: 18px; }
.support-tips { align-self: start; }
.support-tips h2 { margin-bottom: 14px; }
.error-page { min-height: 60vh; display: grid; justify-items: center; align-content: center; text-align: center; }
.error-code { color: var(--purple); font-size: clamp(68px, 14vw, 130px); font-weight: 800; line-height: .85; opacity: .13; }
.error-icon { width: 70px; height: 70px; display: grid; place-items: center; margin-top: -25px; border-radius: 22px; color: var(--purple); background: var(--purple-soft); }
.error-icon .icon { width: 32px; height: 32px; }
.error-page h1 { margin: 18px 0 6px; }
.error-page p { margin: 0 0 20px; color: var(--slate); }
.error-auth-card { text-align: center; }

@keyframes soft-pop { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: scale(1); } }
@media (max-width: 780px) {
  .activation-hero { align-items: flex-start; }
  .activation-progress-ring { width: 78px; height: 78px; border-width: 6px; }
  .activation-progress-ring strong { font-size: 18px; }
  .activation-step { grid-template-columns: 38px minmax(0, 1fr); gap: 12px; padding: 16px; }
  .step-number { width: 36px; height: 36px; border-radius: 11px; }
  .wizard-assign-form, .support-grid { grid-template-columns: 1fr; }
  .final-checklist { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .activation-hero { flex-direction: column; }
  .activation-progress-ring { align-self: flex-end; }
  .activation-step { grid-template-columns: 1fr; }
  .step-number { position: absolute; top: 14px; right: 14px; }
  .step-heading { padding-right: 45px; }
  .provider-action-panel .button-row, .provider-action-panel .button-row > * { width: 100%; }
}

/* v1.1 navigation, developer tools, and super admin */
.nav-link { white-space: nowrap; }
.nav-link > span { min-width: 0; white-space: nowrap; }
.nav-label-nowrap { white-space: nowrap !important; }
.nav-link-disabled small { flex: 0 0 auto; }
.admin-nav-link { margin-top: 5px; color: #4c1d95; background: #faf7ff; border: 1px solid #eee7ff; }
.admin-nav-link:hover, .admin-nav-link.active { color: #fff; background: linear-gradient(135deg, #6c3cff, #4f1bc6); border-color: transparent; }
.sidebar-download { color: #4c1d95; background: #f3efff; border-color: #ddd2ff; }
.sidebar-download:hover { color: #fff; background: linear-gradient(135deg, #7b49ff, #5b24df); }
.sidebar-download.is-unavailable { color: #64748b; background: #f1f5f9; border-color: #e2e8f0; }

.developer-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(330px, .65fr); gap: 18px; align-items: start; }
.api-secret-panel { grid-template-columns: 1fr minmax(320px, .95fr); }
.api-guide-card { position: sticky; top: 92px; }
.api-step { display: grid; grid-template-columns: 29px minmax(0, 1fr); gap: 11px; margin-bottom: 16px; }
.api-step > span { width: 29px; height: 29px; border-radius: 9px; display: grid; place-items: center; color: var(--purple); background: var(--purple-soft); font-weight: 700; font-size: 12px; }
.api-step strong { display: block; margin: 4px 0 7px; }
.api-step pre { margin: 0; padding: 12px; overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; color: #d8e3f3; background: #111827; font: 11px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; }
.api-step .copy-field code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.small-modal { max-width: 480px; }
.strong-link { color: var(--navy); font-weight: 650; }
.strong-link:hover { color: var(--purple); }
.compact-table { min-width: 650px; }
.compact-table th, .compact-table td { padding-top: 11px; padding-bottom: 11px; }

.control-tabs { display: flex; gap: 7px; overflow-x: auto; margin: -3px 0 18px; padding: 4px; border: 1px solid var(--line); border-radius: 13px; background: #fff; width: fit-content; max-width: 100%; }
.control-tabs a { display: inline-flex; align-items: center; gap: 7px; min-height: 36px; padding: 8px 11px; border-radius: 9px; color: var(--slate); font-size: 12px; font-weight: 600; white-space: nowrap; }
.control-tabs a.active, .control-tabs a:hover { color: var(--purple); background: var(--purple-soft); }
.control-tabs .icon { width: 15px; height: 15px; }
.admin-stat-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.admin-stat-grid .stat-card { min-height: 108px; padding: 14px; }
.admin-stat-grid .stat-card strong { font-size: 23px; }
.admin-dashboard-grid { grid-template-columns: 1fr 1fr; }
.admin-filter-bar { padding: 16px 18px; border-bottom: 1px solid var(--line); background: #fafbfc; }
.search-form { display: grid; grid-template-columns: auto minmax(220px, 1fr) auto; align-items: center; gap: 9px; max-width: 650px; }
.search-form > span { color: var(--muted); }
.search-form > span .icon { width: 18px; height: 18px; }
.invoice-search { grid-template-columns: auto minmax(220px, 1fr) 190px auto; max-width: 880px; }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-top: 1px solid var(--line); color: var(--slate); font-size: 12px; }
.pagination > div { display: flex; gap: 7px; }
.admin-workspace-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
.mini-list { display: grid; gap: 10px; }
.mini-list > div { position: relative; display: grid; grid-template-columns: 1fr; padding: 10px 12px 10px 30px; border: 1px solid var(--line); border-radius: 11px; background: #fafbfc; }
.mini-list .status-dot { left: 11px; right: auto; bottom: auto; top: 16px; border-color: #fafbfc; }
.mini-list small, td small { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; }

@media (max-width: 1280px) {
  .admin-stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 980px) {
  .developer-grid, .admin-workspace-grid, .admin-dashboard-grid { grid-template-columns: 1fr; }
  .api-guide-card { position: static; }
  .admin-stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .admin-stat-grid { grid-template-columns: 1fr; }
  .search-form, .invoice-search { grid-template-columns: auto minmax(0, 1fr); }
  .search-form .btn, .invoice-search select, .invoice-search .btn { grid-column: 1 / -1; width: 100%; }
  .pagination { align-items: stretch; flex-direction: column; }
  .pagination > div .btn { flex: 1; }
  .api-secret-panel { grid-template-columns: 1fr; }
}
.sidebar nav { min-height: 0; overflow-y: auto; overflow-x: hidden; scrollbar-width: thin; }

/* v1.2 role-specific navigation and global credit balance */
.topbar-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; min-width: 0; }
.global-credit-pill { display: flex; align-items: center; gap: 9px; min-height: 43px; padding: 6px 13px; border: 1px solid #ded4ff; border-radius: 13px; color: #4c1d95; background: linear-gradient(135deg, #faf8ff, #f1ecff); transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease; }
.global-credit-pill:hover { transform: translateY(-1px); border-color: #cfc0ff; box-shadow: 0 7px 18px rgba(76,29,149,.08); }
.global-credit-pill .icon { width: 19px; height: 19px; }
.global-credit-pill > span { display: grid; line-height: 1.1; }
.global-credit-pill strong { font-size: 15px; }
.global-credit-pill small { margin: 2px 0 0; color: #76679b; font-size: 8px; text-transform: uppercase; letter-spacing: .04em; }
.sidebar-credit-card { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 9px; margin-bottom: 10px; padding: 11px; border: 1px solid #ded4ff; border-radius: 12px; color: #4c1d95; background: linear-gradient(135deg, #faf8ff, #f1ecff); transition: transform .16s ease, border-color .16s ease; }
.sidebar-credit-card:hover { transform: translateY(-1px); border-color: #cdbfff; }
.sidebar-credit-icon { width: 33px; height: 33px; display: grid; place-items: center; border-radius: 10px; color: #fff; background: var(--purple); }
.sidebar-credit-icon .icon { width: 17px; height: 17px; }
.sidebar-credit-card > span:nth-child(2) { display: grid; min-width: 0; }
.sidebar-credit-card small { margin: 0; color: #76679b; font-size: 8px; text-transform: uppercase; letter-spacing: .04em; }
.sidebar-credit-card strong { font-size: 16px; line-height: 1.2; }
.sidebar-credit-arrow { width: 15px; height: 15px; }

/* Dedicated Super Admin shell */
.admin-sidebar { background: linear-gradient(180deg, #17112b 0%, #211542 100%); border-right: 0; color: #fff; }
.admin-sidebar .brand { color: #fff; }
.admin-sidebar .brand > span:last-child > span { color: #bca9ff; }
.admin-sidebar .brand-icon { background: linear-gradient(135deg, #8e68ff, #6732eb); }
.admin-sidebar .nav-link { color: #d9d2eb; }
.admin-sidebar .nav-link:hover, .admin-sidebar .nav-link.active { color: #fff; background: rgba(255,255,255,.12); }
.admin-sidebar .sidebar-foot { border-color: rgba(255,255,255,.13); }
.admin-sidebar .nav-action { color: #d9d2eb; }
.admin-sidebar .nav-action:hover { color: #fff; background: rgba(255,255,255,.09); }
.admin-account-label { display: flex; align-items: center; gap: 11px; margin: 0 5px 17px; padding: 12px; border: 1px solid rgba(255,255,255,.12); border-radius: 13px; background: rgba(255,255,255,.075); }
.admin-account-label > span { width: 35px; height: 35px; display: grid; place-items: center; border-radius: 10px; color: #fff; background: rgba(142,104,255,.42); }
.admin-account-label > span .icon { width: 18px; height: 18px; }
.admin-account-label > div { display: grid; min-width: 0; }
.admin-account-label strong { font-size: 12px; }
.admin-account-label small { margin: 2px 0 0; color: #bfb6d3; font-size: 8px; }
.admin-profile-card { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; padding: 8px; border-radius: 11px; background: rgba(255,255,255,.07); }
.admin-profile-card > div { min-width: 0; }
.admin-profile-card strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #fff; font-size: 11px; }
.admin-profile-card small { margin: 2px 0 0; color: #bfb6d3; font-size: 8px; }
.admin-sidebar .user-avatar { background: #845cff; }
.nav-trailing-icon { width: 13px; height: 13px; margin-left: auto; opacity: .6; }
.admin-topbar { border-bottom-color: #e7e2f2; background: rgba(255,255,255,.93); }
.admin-user-chip { padding-right: 9px; }
.admin-user-chip small { display: inline-flex; margin: 0 0 0 2px; padding: 3px 6px; border-radius: 999px; color: #fff; background: var(--purple); font-size: 7px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.admin-stat-link { cursor: pointer; }
.admin-stat-link:hover { transform: translateY(-2px); border-color: #d9cefb; box-shadow: 0 12px 30px rgba(76,29,149,.08); }

/* User-centric credit administration */
.admin-credit-table { min-width: 1060px; }
.credit-adjustment { position: relative; }
.credit-adjustment > summary { width: fit-content; list-style: none; cursor: pointer; }
.credit-adjustment > summary::-webkit-details-marker { display: none; }
.credit-adjustment[open] > summary { color: #fff; background: var(--purple); border-color: var(--purple); }
.credit-adjustment-form { position: absolute; z-index: 15; right: 0; top: calc(100% + 7px); width: 330px; display: grid; gap: 10px; padding: 14px; border: 1px solid #ddd5f3; border-radius: 13px; background: #fff; box-shadow: 0 18px 45px rgba(15,23,42,.16); }
.credit-adjustment-form .field { gap: 4px; }
.credit-adjustment-form label { font-size: 10px; }
.credit-adjustment-form input { min-height: 37px; padding: 8px 10px; }
.credit-adjustment-form .helper-text { margin: -2px 0 0; font-size: 9px; }
.credit-adjustment-form .btn { justify-content: center; }

@media (max-width: 760px) {
  .topbar-actions { gap: 6px; }
  .global-credit-pill { min-height: 38px; padding: 5px 9px; }
  .global-credit-pill small { display: none; }
  .global-credit-pill strong { font-size: 13px; }
  .user-chip > span:last-of-type { display: none; }
  .admin-user-chip small { display: none; }
  .credit-adjustment-form { position: fixed; left: 16px; right: 16px; top: 50%; width: auto; transform: translateY(-50%); }
}

/* v1.2.1 account menu and API key modal fixes */
.admin-sidebar-note {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #bfb6d3;
}
.admin-sidebar-note > span {
  display: grid;
  place-items: center;
}
.admin-sidebar-note .icon {
  width: 16px;
  height: 16px;
}
.admin-sidebar-note small {
  margin: 0;
  color: inherit;
  font-size: 9px;
}

.user-menu {
  position: relative;
  flex: 0 0 auto;
}
.user-menu-trigger {
  border: 0;
  cursor: pointer;
  transition: background .16s ease, box-shadow .16s ease, transform .16s ease;
}
.user-menu-trigger:hover,
.user-menu.is-open .user-menu-trigger {
  background: #e9e1ff;
  box-shadow: 0 7px 18px rgba(76,29,149,.1);
}
.user-menu-trigger:focus-visible {
  outline: 3px solid rgba(108,60,255,.2);
  outline-offset: 2px;
}
.user-menu-chevron {
  width: 15px;
  height: 15px;
  margin-left: 1px;
  transition: transform .16s ease;
}
.user-menu.is-open .user-menu-chevron {
  transform: rotate(180deg);
}
.user-menu-popover {
  position: absolute;
  top: calc(100% + 9px);
  right: 0;
  z-index: 80;
  width: 255px;
  display: none;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 20px 48px rgba(15,23,42,.16);
  animation: menuIn .16s ease both;
}
.user-menu.is-open .user-menu-popover {
  display: block;
}
.user-menu-summary {
  padding: 14px 15px 12px;
  border-bottom: 1px solid var(--line);
  background: #fafbff;
}
.user-menu-summary strong,
.user-menu-summary small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-menu-summary strong {
  font-size: 12px;
}
.user-menu-summary small {
  margin: 2px 0 0;
  font-size: 9px;
}
.user-menu-popover > a,
.user-menu-popover form button {
  width: 100%;
  min-height: 43px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 0;
  color: #475569;
  background: #fff;
  cursor: pointer;
  text-align: left;
  font-weight: 550;
  transition: color .15s ease, background .15s ease;
}
.user-menu-popover > a:hover,
.user-menu-popover form button:hover,
.user-menu-popover > a:focus-visible,
.user-menu-popover form button:focus-visible {
  color: var(--purple);
  background: var(--purple-soft);
  outline: none;
}
.user-menu-popover .icon {
  width: 17px;
  height: 17px;
}
.user-menu-popover a strong {
  margin-left: auto;
  color: var(--purple);
  font-size: 11px;
}
.user-menu-popover form {
  margin: 0;
  border-top: 1px solid var(--line);
}
.user-menu-popover form button:hover {
  color: var(--red);
  background: var(--red-soft);
}

.api-key-notice {
  margin: 16px 0 0;
}
.field-errors {
  color: var(--red);
  font-size: 11px;
}
.field-errors ul,
.errorlist {
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
}
.modal-header p {
  max-width: 420px;
  margin: 4px 0 0;
  color: var(--slate);
  font-size: 12px;
}
.modal-dialog.small form .modal-body {
  display: grid;
  gap: 4px;
}

@keyframes menuIn {
  from { opacity: 0; transform: translateY(-5px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 760px) {
  .user-menu-name,
  .user-menu-trigger > small {
    display: none;
  }
  .user-menu-trigger {
    padding-right: 7px;
  }
  .user-menu-chevron {
    display: none;
  }
  .user-menu-popover {
    position: fixed;
    top: 62px;
    right: 12px;
    width: min(280px, calc(100vw - 24px));
  }
}

/* Mobile inbox: list and thread behave like separate messaging app screens. */
@media (max-width: 820px) {
  .inbox-page-content {
    margin: -20px -14px -36px;
  }
  .inbox-page-heading {
    display: none;
  }
  .inbox-shell {
    min-height: 0;
    height: calc(100dvh - 68px);
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: #fff;
  }
  .inbox-shell.has-selected .conversation-list,
  .inbox-shell.is-list-view .thread-panel {
    display: none;
  }
  .conversation-list {
    height: 100%;
    display: flex;
    flex-direction: column;
    border: 0;
  }
  .conversation-head {
    flex: 0 0 auto;
    padding: 16px 14px 10px;
    background: rgba(255,255,255,.96);
    backdrop-filter: blur(14px);
    z-index: 2;
  }
  .conversation-title {
    margin-bottom: 11px;
  }
  .conversation-title h2 {
    font-size: 23px;
  }
  .conversation-title p {
    font-size: 10px;
  }
  .conversation-title-actions .icon-button {
    width: 42px;
    height: 42px;
    border-radius: 50%;
  }
  .inbox-search input {
    min-height: 44px;
    border-color: transparent;
    border-radius: 22px;
    background: #f1f3f7;
  }
  .inbox-tabs {
    margin-top: 9px;
  }
  .inbox-tabs a {
    min-height: 42px;
    padding: 9px 4px;
  }
  .conversation-scroll {
    flex: 1;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
  .conversation-item {
    grid-template-columns: 50px minmax(0,1fr);
    gap: 12px;
    min-height: 78px;
    padding: 13px 15px;
  }
  .conversation-item.active {
    box-shadow: none;
  }
  .conversation-item .avatar {
    width: 48px;
    height: 48px;
  }
  .conversation-line strong {
    font-size: 13px;
  }
  .conversation-line.preview small {
    font-size: 11px;
  }
  .conversation-device {
    margin-top: 4px;
  }
  .thread-panel {
    height: 100%;
    min-height: 0;
    border: 0;
    background: #f4f2f8;
  }
  .thread-head {
    min-height: 66px;
    flex: 0 0 auto;
    padding: 9px 10px;
    gap: 8px;
    box-shadow: 0 1px 8px rgba(15,23,42,.05);
    z-index: 3;
  }
  .thread-back {
    width: 42px;
    height: 42px;
    flex: 0 0 auto;
    border: 0;
    border-radius: 50%;
  }
  .thread-contact {
    flex: 1;
    gap: 9px;
    overflow: hidden;
  }
  .thread-contact .avatar.large {
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
    font-size: 12px;
  }
  .thread-contact h2,
  .thread-contact p {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .thread-contact h2 {
    margin: 0;
    font-size: 14px;
  }
  .thread-contact p {
    max-width: 42vw;
    font-size: 9px;
  }
  .thread-actions {
    flex: 0 0 auto;
    gap: 4px;
  }
  .thread-actions form {
    display: block;
  }
  .thread-actions form:first-of-type {
    display: none;
  }
  .thread-actions .icon-button {
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: 50%;
  }
  .thread-messages {
    flex: 1;
    min-height: 0;
    max-height: none;
    padding: 16px 12px 10px;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    background:
      radial-gradient(circle at 10% 8%, rgba(108,60,255,.055), transparent 26%),
      #f4f2f8;
  }
  .date-divider {
    margin: 5px 0 14px;
  }
  .date-divider span {
    padding: 4px 10px;
    background: rgba(100,116,139,.12);
    font-size: 8px;
  }
  .bubble-row {
    margin-bottom: 7px;
  }
  .bubble {
    max-width: 86%;
    padding: 9px 11px 7px;
    border: 0;
    border-radius: 17px 17px 17px 5px;
    box-shadow: 0 1px 3px rgba(15,23,42,.06);
  }
  .outbound .bubble {
    border: 0;
    border-radius: 17px 17px 5px 17px;
    background: linear-gradient(145deg, #7545f5, #5f2bd8);
  }
  .bubble p {
    margin-bottom: 4px;
    font-size: 12px;
    line-height: 1.45;
  }
  .bubble-meta {
    gap: 6px;
    font-size: 8px;
  }
  .composer {
    flex: 0 0 auto;
    padding: 7px 10px calc(8px + env(safe-area-inset-bottom));
    border-top-color: rgba(148,163,184,.24);
    box-shadow: 0 -3px 14px rgba(15,23,42,.05);
  }
  .composer-routing-toggle {
    width: 100%;
    min-height: 32px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 7px 6px;
    color: var(--slate);
    cursor: pointer;
    font-size: 9px;
    font-weight: 600;
  }
  .composer-routing-toggle .icon {
    width: 13px;
    height: 13px;
  }
  .composer-routing-chevron {
    margin-left: auto;
    transition: transform .18s ease;
  }
  .composer-routing-toggle[aria-expanded="true"] .composer-routing-chevron {
    transform: rotate(180deg);
  }
  .composer-routing {
    display: none;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-bottom: 7px;
  }
  .composer-routing.is-open {
    display: grid;
  }
  .routing-field select {
    min-height: 39px;
    padding-top: 7px;
    padding-bottom: 7px;
    border-radius: 10px;
    font-size: 10px;
  }
  .composer-input-wrap {
    grid-template-columns: minmax(0,1fr) 46px;
    gap: 7px;
    align-items: end;
  }
  .composer textarea {
    min-height: 46px;
    max-height: 120px;
    padding: 12px 14px;
    resize: none;
    border-color: transparent;
    border-radius: 22px;
    background: #f1f3f7;
    line-height: 1.35;
  }
  .composer textarea:focus {
    border-color: #d9cdfc;
    background: #fff;
  }
  .send-button {
    width: 46px;
    height: 46px;
    margin: 0;
    border-radius: 50%;
  }
  .composer-footer {
    min-height: 17px;
    margin: 3px 5px 0;
    align-items: center;
    justify-content: flex-end;
    flex-direction: row;
  }
  .composer-footer .helper-text {
    display: none;
  }
  .composer-footer .sms-counter {
    font-size: 8px;
  }
  .thread-empty {
    min-height: 0;
  }
}

@media (max-width: 390px) {
  .thread-contact .avatar.large {
    display: none;
  }
  .thread-contact p {
    max-width: 48vw;
  }
  .bubble {
    max-width: 90%;
  }
  .composer-routing.is-open {
    grid-template-columns: 1fr;
  }
}

/* Desktop inbox: keep the messaging workspace in the viewport and scroll panes independently. */
@media (min-width: 821px) {
  body.inbox-body {
    overflow: hidden;
  }
  .inbox-body .main-content {
    height: 100vh;
    overflow: hidden;
  }
  .inbox-body .page {
    width: 100%;
    max-width: none;
    height: calc(100vh - 68px);
    padding: 14px 18px 18px;
  }
  .inbox-body .page-skeleton,
  .inbox-page-content {
    height: 100%;
  }
  .inbox-page-heading {
    display: none;
  }
  .inbox-shell {
    width: 100%;
    height: 100%;
    min-height: 0;
    grid-template-columns: clamp(300px, 27vw, 380px) minmax(0, 1fr);
    border-radius: 14px;
    box-shadow: 0 8px 28px rgba(15,23,42,.055);
  }
  .conversation-list {
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  .conversation-head {
    flex: 0 0 auto;
    padding: 13px 14px 0;
  }
  .conversation-title {
    min-height: 36px;
    margin-bottom: 9px;
  }
  .conversation-title h2 {
    margin: 0;
    font-size: 18px;
  }
  .conversation-title p {
    font-size: 10px;
  }
  .conversation-title-actions {
    gap: 5px;
  }
  .conversation-title-actions .icon-button,
  .thread-actions .icon-button {
    width: 34px;
    height: 34px;
    border-radius: 9px;
  }
  .conversation-title-actions .icon {
    width: 17px;
    height: 17px;
  }
  .inbox-search input {
    min-height: 38px;
    padding-top: 8px;
    padding-bottom: 8px;
    border-color: transparent;
    border-radius: 10px;
    background: #f3f5f8;
    font-size: 12px;
  }
  .inbox-tabs {
    margin-top: 7px;
  }
  .inbox-tabs a {
    min-height: 37px;
    padding: 7px 4px;
    font-size: 11px;
  }
  .conversation-scroll {
    flex: 1;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .conversation-item {
    grid-template-columns: 40px minmax(0,1fr);
    gap: 10px;
    min-height: 69px;
    padding: 10px 13px;
  }
  .conversation-item .avatar {
    width: 40px;
    height: 40px;
    font-size: 12px;
  }
  .conversation-line strong {
    font-size: 12px;
  }
  .conversation-line.preview {
    margin-top: 1px;
  }
  .conversation-line.preview small {
    margin: 0;
    font-size: 10px;
  }
  .conversation-device {
    margin-top: 3px;
  }
  .thread-panel {
    position: relative;
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }
  .thread-panel.is-thread-loading {
    pointer-events: none;
  }
  .thread-panel.is-thread-loading::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 20;
    background: rgba(248,250,252,.7);
    backdrop-filter: blur(1px);
  }
  .thread-panel.is-thread-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 21;
    width: 30px;
    height: 30px;
    margin: -15px 0 0 -15px;
    border: 3px solid rgba(108,60,255,.2);
    border-right-color: var(--purple);
    border-radius: 50%;
    animation: spin .65s linear infinite;
  }
  .thread-head {
    min-height: 64px;
    flex: 0 0 auto;
    padding: 9px 15px;
  }
  .thread-contact {
    overflow: hidden;
  }
  .thread-contact .avatar.large {
    width: 40px;
    height: 40px;
    font-size: 12px;
  }
  .thread-contact h2,
  .thread-contact p {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .thread-contact h2 {
    margin: 0;
    font-size: 15px;
  }
  .thread-contact p {
    font-size: 10px;
  }
  .thread-actions {
    flex: 0 0 auto;
    gap: 5px;
  }
  .thread-messages {
    flex: 1;
    min-height: 0;
    max-height: none;
    padding: 18px clamp(20px, 4vw, 56px);
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
  }
  .date-divider {
    margin: 4px 0 14px;
  }
  .bubble-row {
    margin-bottom: 7px;
  }
  .bubble {
    max-width: min(68%, 680px);
    padding: 9px 11px 7px;
    box-shadow: 0 2px 8px rgba(15,23,42,.035);
  }
  .bubble p {
    margin-bottom: 4px;
    line-height: 1.42;
  }
  .composer {
    flex: 0 0 auto;
    padding: 9px 13px 10px;
    box-shadow: 0 -4px 16px rgba(15,23,42,.035);
  }
  .composer-routing {
    grid-template-columns: minmax(180px, 260px) minmax(180px, 260px);
    justify-content: end;
    gap: 6px;
    margin-bottom: 6px;
  }
  .routing-field select {
    min-height: 34px;
    padding-top: 6px;
    padding-bottom: 6px;
    border-radius: 9px;
    background: #f8fafc;
    font-size: 10px;
  }
  .composer-input-wrap {
    grid-template-columns: minmax(0,1fr) 42px;
    gap: 7px;
  }
  .composer textarea {
    min-height: 44px;
    max-height: 104px;
    padding: 11px 13px;
    resize: none;
    border-color: transparent;
    border-radius: 13px;
    background: #f3f5f8;
    line-height: 1.35;
  }
  .composer textarea:focus {
    border-color: #d9cdfc;
    background: #fff;
  }
  .send-button {
    width: 42px;
    height: 42px;
    margin: 1px 0;
    border-radius: 11px;
  }
  .composer-footer {
    min-height: 15px;
    margin: 3px 2px 0;
  }
  .composer-footer .helper-text {
    display: none;
  }
  .composer-footer .sms-counter {
    margin-left: auto;
    font-size: 9px;
  }
  .skeleton-inbox {
    height: calc(100% - 52px);
  }
}
