:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: rgba(255, 255, 255, 0.88);
  --surface-solid: #ffffff;
  --surface-soft: #edf2ec;
  --text: #202522;
  --muted: #69716c;
  --border: rgba(32, 37, 34, 0.1);
  --accent: #176b4d;
  --accent-dark: #0f4d37;
  --gold: #9a7a45;
  --green: #248a3d;
  --red: #d70015;
  --orange: #b56a00;
  --shadow: 0 26px 70px rgba(35, 46, 39, 0.11);
  --shadow-soft: 0 18px 44px rgba(35, 46, 39, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(246, 247, 244, 0.96) 46%, rgba(232, 237, 231, 0.92)),
    var(--bg);
  color: var(--text);
  font-family: "Geist", "Satoshi", "Aptos", "Segoe UI", system-ui, sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(32, 37, 34, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(32, 37, 34, 0.035) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(180deg, rgba(32, 37, 34, 0.72), transparent 78%);
}

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

button {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
  min-height: 38px;
  padding: 0 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.28s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.28s cubic-bezier(0.16, 1, 0.3, 1), transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

button:hover {
  background: #fff;
  border-color: rgba(23, 107, 77, 0.42);
}

button:active {
  transform: scale(0.98);
}

button.primary {
  background: var(--accent) !important;
  border-color: var(--accent) !important;
  color: white !important;
}

button.primary:hover {
  background: var(--accent-dark) !important;
  border-color: var(--accent-dark) !important;
}

button.ghost {
  min-height: 32px;
  padding: 0 10px;
  background: transparent;
}

button.ghost.danger {
  color: var(--red);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(23, 107, 77, 0.62);
  box-shadow: 0 0 0 4px rgba(23, 107, 77, 0.1);
}

textarea {
  resize: vertical;
  min-height: 170px;
  line-height: 1.45;
  font-family: inherit;
  font-size: 15px;
}

#csvInput,
.preview {
  font-family: "SF Mono", "Cascadia Mono", Consolas, monospace;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 260px;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  background:
    linear-gradient(180deg, rgba(15, 15, 17, 0.98), rgba(31, 31, 35, 0.96)),
    #161816;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  color: #f5f5f7;
  backdrop-filter: blur(24px);
}

@supports not ((backdrop-filter: blur(10px)) or (-webkit-backdrop-filter: blur(10px))) {
  .sidebar {
    background: #121214;
  }

  .metrics article,
  .panel {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.08);
  }
}

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

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(180deg, #f5f5f7, #9aa0aa);
  color: #151817;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small,
.sidebar-status small {
  margin-top: 2px;
  color: rgba(245, 245, 247, 0.58);
}

nav {
  display: grid;
  gap: 6px;
}

.nav-button {
  width: 100%;
  text-align: left;
  background: transparent;
  border-color: transparent;
  color: rgba(245, 245, 247, 0.72);
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.sidebar-status {
  margin-top: auto;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-account {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.06);
}

.sidebar-account span,
.sidebar-account small {
  display: block;
}

.sidebar-account small {
  margin-top: 2px;
  color: rgba(245, 245, 247, 0.58);
}

.sidebar-account button {
  min-width: 62px;
  color: rgba(245, 245, 247, 0.8);
  border-color: rgba(255, 255, 255, 0.14);
}

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 28px;
}

.login-shell {
  width: min(100%, 440px);
}

.login-card {
  display: grid;
  gap: 24px;
  padding: 32px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

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

.login-brand strong,
.login-brand small {
  display: block;
}

.login-brand small {
  margin-top: 2px;
  color: var(--muted);
}

.login-card h1 {
  margin: 6px 0 8px;
  font-size: clamp(32px, 6vw, 46px);
  letter-spacing: 0;
}

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

.login-form button {
  min-height: 46px;
}

.login-error {
  min-height: 20px;
  margin: 0;
  color: var(--red);
  font-size: 14px;
}

.sidebar-status span,
.sidebar-status small {
  display: block;
}

.sidebar-status span {
  font-weight: 700;
}

.app-shell {
  margin-left: 260px;
  padding: 34px;
  max-width: 100%;
  overflow-x: hidden;
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 22px;
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 34px;
  line-height: 1.1;
  font-weight: 750;
}

h2 {
  font-size: 17px;
  line-height: 1.2;
}

.eyebrow {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

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

.metrics article,
.panel {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(249, 250, 252, 0.92)),
    var(--surface-solid);
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.metrics article {
  min-height: 126px;
  padding: 20px;
  display: grid;
  align-content: space-between;
  position: relative;
  overflow: hidden;
}

.metrics article::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--gold));
}

.metrics span {
  color: var(--muted);
}

.metrics strong {
  font-size: 34px;
  line-height: 1;
  font-weight: 760;
}

.panel {
  padding: 20px;
  display: grid;
  gap: 18px;
}

.status-panel {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.setup-grid,
.status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

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

.status-card,
.template-card,
.conversation-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  padding: 14px;
  display: grid;
  gap: 8px;
}

.status-card.ok {
  border-color: rgba(52, 199, 89, 0.3);
  background: rgba(52, 199, 89, 0.08);
}

.status-card.danger {
  border-color: rgba(255, 59, 48, 0.28);
  background: rgba(255, 59, 48, 0.08);
}

.checklist,
.template-list,
.conversation-list {
  display: grid;
  gap: 10px;
}

.check-item,
.copy-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  padding: 10px 0;
}

.copy-box {
  align-items: flex-start;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.7);
}

.copy-box code {
  width: 100%;
  overflow-wrap: anywhere;
  color: var(--accent-dark);
}

.csv-guide {
  display: grid;
  gap: 6px;
  border: 1px solid rgba(23, 107, 77, 0.16);
  border-radius: 12px;
  padding: 12px 14px;
  background: rgba(23, 107, 77, 0.06);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.csv-guide strong {
  color: var(--text);
}

.csv-guide code {
  color: var(--accent-dark);
  font-family: "Geist Mono", "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
}

.panel-header,
.campaign-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.badge {
  min-height: 28px;
  display: inline-grid;
  place-items: center;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.badge.ok {
  background: rgba(52, 199, 89, 0.14);
  color: var(--green);
}

.badge.warn {
  background: rgba(255, 149, 0, 0.16);
  color: var(--orange);
}

.badge.danger {
  background: rgba(255, 59, 48, 0.13);
  color: var(--red);
}

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

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

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

.composer-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 22px;
  align-items: start;
}

.composer-panel {
  gap: 20px;
}

.message-label {
  color: var(--muted);
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  color: var(--text);
}

.checkbox input {
  width: 18px;
  height: 18px;
}

.token-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.token-row button {
  min-height: 34px;
  border-color: transparent;
  background: var(--surface-soft);
  color: #424245;
}

.composer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.phone-preview {
  position: sticky;
  top: 24px;
}

.phone-shell {
  width: 100%;
  min-height: 620px;
  border: 1px solid rgba(0, 0, 0, 0.13);
  border-radius: 32px;
  padding: 14px;
  background: linear-gradient(180deg, #151817, #2c2c2e);
  box-shadow: 0 34px 90px rgba(21, 24, 23, 0.28);
}

.phone-top {
  width: 92px;
  height: 25px;
  margin: 0 auto 10px;
  border-radius: 999px;
  background: #111412;
}

.chat-header {
  min-height: 58px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px 8px 0 0;
  background: rgba(247, 247, 247, 0.96);
}

.avatar {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #34c759;
  color: white;
  font-weight: 800;
}

.chat-header strong,
.chat-header small {
  display: block;
}

.chat-header small {
  color: var(--muted);
}

.chat-body {
  min-height: 500px;
  padding: 18px 12px;
  border-radius: 0 0 8px 8px;
  background:
    linear-gradient(180deg, rgba(238, 245, 238, 0.95), rgba(215, 226, 218, 0.95)),
    #e7eee8;
}

.message-bubble {
  width: min(100%, 272px);
  margin-left: auto;
  padding: 11px 12px;
  border-radius: 8px;
  background: #d9fdd3;
  color: #1f2b20;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.4;
  font-size: 14px;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}

th,
td {
  border-bottom: 1px solid var(--border);
  padding: 12px 10px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.preview {
  margin: 0;
  min-height: 120px;
  max-height: 320px;
  overflow: auto;
  border-radius: 8px;
  background: #1d1d1f;
  color: #f5f5f7;
  padding: 14px;
  font-size: 13px;
  line-height: 1.45;
}

.recipient-preview-panel {
  gap: 14px;
}

.recipient-pager {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button {
  width: 38px;
  min-width: 38px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
}

.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.recipient-summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

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

.campaign-recipient-card {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  padding: 12px;
}

.recipient-index {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(0, 113, 227, 0.1);
  color: var(--accent-dark);
  font-weight: 800;
  font-size: 13px;
}

.campaign-recipient-card strong {
  display: block;
  margin-bottom: 5px;
}

.campaign-recipient-card p {
  margin: 8px 0 0;
  color: #3a3a3c;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.recipient-empty {
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
  color: var(--muted);
  padding: 16px;
  line-height: 1.45;
}

.campaign-list,
.inbox-list {
  display: grid;
  gap: 12px;
}

.campaign-item,
.inbox-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  display: grid;
  gap: 8px;
  background: rgba(255, 255, 255, 0.7);
}

.campaign-item p,
.inbox-item p {
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.error-text {
  color: var(--red);
  background: rgba(255, 59, 48, 0.1);
  border: 1px solid rgba(255, 59, 48, 0.18);
  border-radius: 8px;
  padding: 10px 12px;
}

.campaign-meta,
.inbox-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  color: var(--muted);
  font-size: 13px;
}

.delivery-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.delivery-pill {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  display: grid;
  gap: 3px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.66);
}

.delivery-pill strong {
  color: var(--text);
  font-size: 20px;
}

.delivery-pill.danger {
  border-color: rgba(255, 59, 48, 0.22);
  background: rgba(255, 59, 48, 0.08);
}

.recipient-details {
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

.recipient-details summary {
  color: var(--muted);
  cursor: pointer;
}

.recipient-list {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.recipient-list div {
  display: grid;
  grid-template-columns: 160px 90px 1fr;
  gap: 8px;
  align-items: start;
  font-size: 13px;
}

.recipient-list small {
  color: var(--red);
}

.template-card p,
.conversation-card p {
  overflow-wrap: anywhere;
  line-height: 1.45;
}

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

.template-stats article {
  min-height: 112px;
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(249, 250, 252, 0.92)),
    var(--surface-solid);
  box-shadow: var(--shadow);
  padding: 18px;
  display: grid;
  align-content: space-between;
}

.template-stats span {
  color: var(--muted);
}

.template-stats strong {
  font-size: 30px;
}

.template-control-panel {
  grid-template-columns: minmax(260px, 1fr) repeat(3, minmax(160px, 220px));
  align-items: end;
}

.template-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 18px;
}

.template-editor-panel,
.template-preview-panel {
  align-content: start;
}

.template-token-row,
.template-chip-row,
.template-token-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.template-token-row button {
  min-height: 32px;
  padding: 0 10px;
  background: rgba(0, 113, 227, 0.08);
  border-color: rgba(0, 113, 227, 0.16);
  color: var(--accent-dark);
}

.template-chip-row span,
.template-token-list span {
  min-height: 28px;
  display: inline-grid;
  place-items: center;
  border: 1px solid rgba(0, 113, 227, 0.14);
  border-radius: 999px;
  padding: 4px 9px;
  background: rgba(0, 113, 227, 0.06);
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
}

.template-phone-preview {
  min-height: 300px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background:
    radial-gradient(circle at 20% 18%, rgba(52, 199, 89, 0.08), transparent 32%),
    #eef1f0;
  padding: 18px;
  display: grid;
  align-content: end;
}

.template-chat-bubble {
  max-width: 100%;
  margin-left: auto;
  border-radius: 8px;
  background: #d9fdd3;
  padding: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  box-shadow: 0 8px 24px rgba(24, 27, 34, 0.08);
}

.template-list.rich {
  gap: 12px;
}

.template-section-label {
  margin-top: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.template-section-label strong {
  color: var(--text);
  font-size: 15px;
}

.template-card {
  background: rgba(255, 255, 255, 0.86);
}

.template-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.template-card-head > div {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.template-card-head strong,
.template-card-head span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.template-card-head > div > span {
  color: var(--muted);
  font-size: 12px;
}

.template-empty {
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 14px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.58);
}

.template-empty strong,
.template-empty span {
  display: block;
}

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

.template-campaign-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  padding: 14px;
  display: grid;
  gap: 14px;
}

.template-campaign-card p {
  margin: 10px 0 0;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.status-card small {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.45;
}

.inbox-view {
  min-height: calc(100vh - 68px);
}

.inbox-workspace {
  min-height: 680px;
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.76);
  box-shadow: var(--shadow);
}

.inbox-sidebar {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  border-right: 1px solid var(--border);
  background: rgba(248, 249, 251, 0.94);
}

.inbox-toolbar {
  padding: 16px;
  display: grid;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}

.search-field {
  gap: 6px;
}

.search-field input {
  min-height: 40px;
  background: #ffffff;
}

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

.inbox-counters span {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  padding: 10px;
  color: var(--muted);
  font-size: 12px;
}

.inbox-counters strong {
  display: block;
  color: var(--text);
  font-size: 20px;
}

.conversation-list.rich {
  gap: 0;
  overflow: auto;
}

.conversation-row {
  width: 100%;
  min-height: 86px;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.07);
  border-radius: 0;
  background: transparent;
  text-align: left;
}

.conversation-row:hover,
.conversation-row.active {
  background: #ffffff;
}

.conversation-row.active {
  box-shadow: inset 4px 0 0 #34c759;
}

.conversation-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #34c759, #1f7a39);
  color: #ffffff;
  font-weight: 800;
  letter-spacing: 0;
}

.conversation-avatar.large {
  width: 52px;
  height: 52px;
  font-size: 17px;
}

.conversation-main {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.conversation-title,
.conversation-meta-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.conversation-title strong,
.conversation-preview,
.conversation-meta-line span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-title small,
.conversation-meta-line,
.conversation-status {
  color: var(--muted);
  font-size: 12px;
}

.conversation-preview {
  color: #3a3a3c;
  font-size: 14px;
}

.conversation-preview b {
  color: var(--text);
  font-weight: 700;
}

.conversation-status {
  align-self: end;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.9);
}

.conversation-status.warn {
  color: var(--orange);
  border-color: rgba(181, 106, 0, 0.28);
  background: rgba(255, 149, 0, 0.1);
}

.chat-panel {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(245, 247, 250, 0.9)),
    #f4f6f8;
}

.chat-contact-header {
  min-height: 82px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.92);
}

.chat-contact-copy {
  min-width: 0;
  display: grid;
  gap: 4px;
}

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

.chat-contact-copy span {
  color: var(--muted);
  font-size: 13px;
}

.chat-contact-tags {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.chat-messages {
  min-height: 0;
  overflow: auto;
  padding: 22px;
  display: grid;
  align-content: end;
  gap: 10px;
  background:
    radial-gradient(circle at 15% 20%, rgba(52, 199, 89, 0.07), transparent 32%),
    radial-gradient(circle at 85% 10%, rgba(0, 113, 227, 0.06), transparent 28%),
    #eef1f0;
}

.chat-message-row {
  display: flex;
}

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

.chat-bubble {
  max-width: min(72%, 680px);
  border: 1px solid rgba(0, 0, 0, 0.07);
  border-radius: 8px;
  padding: 10px 12px 8px;
  background: #ffffff;
  box-shadow: 0 8px 24px rgba(24, 27, 34, 0.08);
}

.chat-message-row.outbound .chat-bubble {
  background: #d9fdd3;
}

.chat-bubble.failed {
  border-color: rgba(215, 0, 21, 0.22);
  background: #fff4f4;
}

.chat-bubble p {
  margin: 0;
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.chat-route {
  margin-bottom: 7px;
  display: grid;
  gap: 2px;
  color: rgba(60, 60, 67, 0.74);
  font-size: 12px;
}

.chat-route b {
  color: var(--text);
  font-weight: 800;
}

.chat-message-meta {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  color: rgba(60, 60, 67, 0.68);
  font-size: 11px;
}

.chat-error {
  display: block;
  margin-top: 6px;
  color: var(--red);
  overflow-wrap: anywhere;
}

.chat-compose {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.94);
}

.compose-note {
  display: grid;
  gap: 3px;
  border: 1px solid rgba(0, 113, 227, 0.14);
  border-radius: 8px;
  background: rgba(0, 113, 227, 0.06);
  padding: 10px 12px;
}

.compose-note span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.chat-compose textarea {
  min-height: 52px;
  max-height: 120px;
  resize: vertical;
}

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

.final-reply-row button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.reply-draft-status {
  margin: -2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.local-test-panel {
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

.local-test-panel summary {
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.local-test-panel[open] {
  display: grid;
  gap: 10px;
}

.local-test-panel button {
  min-width: 190px;
}

.chat-contact-empty,
.chat-empty,
.inbox-empty {
  color: var(--muted);
  line-height: 1.45;
}

.chat-contact-empty {
  display: grid;
  gap: 4px;
}

.chat-empty,
.inbox-empty {
  padding: 18px;
}

.inbox-item.inbound {
  border-left: 4px solid #34c759;
}

.dashboard-view.active {
  width: 100%;
  max-width: 1480px;
  margin: 0 auto;
  gap: 26px;
}

.dashboard-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 22px;
  align-items: stretch;
}

.dashboard-hero-copy,
.dashboard-live-panel,
.dashboard-config-panel,
.meta-panel,
.dashboard-mini-panel,
.metric-card {
  animation: dashboardRise 0.55s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.dashboard-hero-copy {
  position: relative;
  min-width: 0;
  min-height: 322px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: 30px;
  padding: 36px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.98), rgba(244, 248, 243, 0.9) 62%, rgba(230, 238, 229, 0.84)),
    var(--surface-solid);
  box-shadow: var(--shadow);
}

.dashboard-hero-copy::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.92), inset 0 -1px 0 rgba(32, 37, 34, 0.05);
}

.dashboard-hero-copy::after {
  content: "";
  position: absolute;
  right: 32px;
  bottom: 34px;
  width: 245px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(23, 107, 77, 0.42), transparent);
}

.dashboard-hero h1 {
  max-width: 720px;
  margin-top: 10px;
  font-size: 48px;
  line-height: 0.98;
  letter-spacing: 0;
  font-weight: 780;
}

.hero-lede {
  max-width: 680px;
  margin-top: 18px;
  color: #59635d;
  font-size: 17px;
  line-height: 1.58;
}

.hero-action-row {
  margin-top: 28px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.hero-note {
  color: var(--muted);
  font-size: 13px;
}

.dashboard-live-panel {
  min-width: 0;
  min-height: 322px;
  display: grid;
  align-content: space-between;
  gap: 22px;
  border: 1px solid rgba(32, 37, 34, 0.1);
  border-radius: 30px;
  padding: 28px;
  background:
    linear-gradient(180deg, rgba(31, 41, 35, 0.98), rgba(19, 26, 22, 0.98)),
    #151b17;
  color: #f8faf7;
  box-shadow: 0 26px 70px rgba(19, 26, 22, 0.18);
}

.live-panel-top {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(248, 250, 247, 0.7);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.live-pulse {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #7fd3a3;
  box-shadow: 0 0 0 0 rgba(127, 211, 163, 0.4);
  animation: livePulse 2.2s ease-out infinite;
}

.dashboard-live-panel > strong {
  display: block;
  font-size: 38px;
  line-height: 1;
  letter-spacing: 0;
}

.dashboard-live-panel p {
  color: rgba(248, 250, 247, 0.72);
  line-height: 1.48;
}

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

.live-panel-metrics div,
.mini-stat-row div {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 13px;
  background: rgba(255, 255, 255, 0.07);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.live-panel-metrics span,
.mini-stat-row span {
  display: block;
  color: rgba(248, 250, 247, 0.58);
  font-size: 12px;
}

.live-panel-metrics strong,
.mini-stat-row strong {
  display: block;
  margin-top: 6px;
  font-family: "Geist Mono", "Cascadia Mono", Consolas, monospace;
  font-size: 20px;
  letter-spacing: 0;
}

.dashboard-layout {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.42fr) minmax(360px, 0.58fr);
  gap: 22px;
  align-items: start;
}

.dashboard-main,
.dashboard-side {
  min-width: 0;
  display: grid;
  gap: 22px;
}

.premium-metrics {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.metrics.premium-metrics {
  gap: 12px;
}

.metric-card {
  min-width: 0;
  min-height: 154px;
  display: grid;
  align-content: space-between;
  grid-column: span 1;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(32, 37, 34, 0.09);
  border-radius: 22px;
  padding: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(250, 252, 249, 0.9)),
    #ffffff;
  box-shadow: var(--shadow-soft);
}

.metric-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: rgba(23, 107, 77, 0.42);
  transform: scaleX(0.54);
  transform-origin: left;
}

.metric-card span {
  color: #59635d;
  font-size: 13px;
  font-weight: 720;
}

.metric-card strong {
  margin-top: 18px;
  font-family: "Geist Mono", "Cascadia Mono", Consolas, monospace;
  font-size: 42px;
  line-height: 0.95;
  letter-spacing: 0;
}

.metric-card small {
  color: var(--muted);
  font-size: 12px;
}

.primary-metric {
  grid-column: span 2;
  min-height: 188px;
  background:
    linear-gradient(145deg, rgba(23, 107, 77, 0.96), rgba(19, 77, 55, 0.96)),
    #176b4d;
  color: #f8faf7;
}

.metrics.premium-metrics .primary-metric {
  background:
    linear-gradient(145deg, rgba(23, 107, 77, 0.96), rgba(19, 77, 55, 0.96)),
    #176b4d;
  color: #f8faf7;
}

.metrics.premium-metrics .primary-metric span,
.metrics.premium-metrics .primary-metric small {
  color: rgba(248, 250, 247, 0.72);
}

.metrics.premium-metrics .primary-metric strong {
  font-size: 58px;
  color: #f8faf7;
}

.warning-metric::before {
  background: rgba(181, 106, 0, 0.46);
}

.section-kicker {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.dashboard-config-panel {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  border-radius: 24px;
  box-shadow: var(--shadow-soft);
}

.dashboard-config-panel h2,
.meta-panel h2,
.dashboard-mini-panel h2 {
  font-size: 22px;
  letter-spacing: 0;
}

.dashboard-config-panel p {
  margin-top: 8px;
  line-height: 1.48;
}

.meta-panel,
.dashboard-mini-panel {
  border-radius: 24px;
  box-shadow: var(--shadow-soft);
}

.meta-panel .panel-header {
  align-items: start;
}

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

.meta-panel .status-card {
  min-height: 112px;
  border-color: rgba(32, 37, 34, 0.08);
  background: rgba(255, 255, 255, 0.62);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.74);
}

.meta-empty {
  grid-column: 1 / -1;
  border: 1px dashed rgba(32, 37, 34, 0.16);
  border-radius: 18px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.52);
  color: var(--muted);
}

.meta-empty strong {
  display: block;
  margin-bottom: 6px;
  color: var(--text);
}

.meta-loading {
  grid-column: 1 / -1;
  display: grid;
  gap: 10px;
}

.meta-loading span {
  height: 14px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(32, 37, 34, 0.06), rgba(255, 255, 255, 0.8), rgba(32, 37, 34, 0.06));
  background-size: 240% 100%;
  animation: loadingSweep 1.2s ease-in-out infinite;
}

.dashboard-mini-panel {
  align-content: start;
  background:
    linear-gradient(180deg, rgba(31, 41, 35, 0.98), rgba(22, 30, 25, 0.98)),
    #161e19;
  color: #f8faf7;
}

.dashboard-mini-panel .section-kicker,
.dashboard-mini-panel p {
  color: rgba(248, 250, 247, 0.62);
}

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

@keyframes dashboardRise {
  from {
    transform: translateY(16px);
  }
  to {
    transform: translateY(0);
  }
}

@keyframes livePulse {
  0% {
    box-shadow: 0 0 0 0 rgba(127, 211, 163, 0.42);
  }
  72%,
  100% {
    box-shadow: 0 0 0 12px rgba(127, 211, 163, 0);
  }
}

@keyframes loadingSweep {
  from {
    background-position: 120% 0;
  }
  to {
    background-position: -120% 0;
  }
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: 420px;
  border-radius: 8px;
  background: rgba(29, 29, 31, 0.94);
  color: white;
  padding: 13px 16px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

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

  .template-stats,
  .template-campaign-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

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

  .inbox-workspace {
    grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  }

  .chat-bubble {
    max-width: min(82%, 620px);
  }

  .phone-preview {
    position: static;
  }

  .phone-shell {
    max-width: 390px;
  }
}

@media (max-width: 860px) {
  .sidebar {
    position: static;
    width: auto;
    min-height: auto;
  }

  .app-shell {
    margin-left: 0;
    padding: 18px;
  }

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

  .metrics,
  .template-stats,
  .template-control-panel,
  .template-workspace,
  .template-campaign-list,
  .split,
  .form-grid,
  .form-grid.compact,
  .status-panel,
  .setup-grid,
  .status-grid,
  .delivery-grid {
    grid-template-columns: 1fr;
  }

  .inbox-workspace {
    min-height: auto;
    grid-template-columns: 1fr;
  }

  .inbox-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .conversation-list.rich {
    max-height: 330px;
  }

  .chat-panel {
    min-height: 620px;
  }

  .chat-contact-header {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .chat-contact-tags {
    width: 100%;
    margin-left: 66px;
    justify-content: flex-start;
  }

  .chat-messages {
    padding: 16px;
  }

  .chat-bubble {
    max-width: 92%;
  }

  .chat-input-row {
    grid-template-columns: 1fr;
  }

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

  .phone-shell {
    min-height: 520px;
  }

  .chat-body {
    min-height: 400px;
  }
}

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

  .dashboard-live-panel {
    min-height: auto;
  }

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

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

  .dashboard-side {
    grid-template-columns: minmax(0, 1fr) minmax(320px, 0.72fr);
  }
}

@media (max-width: 860px) {
  body::before {
    background-size: 30px 30px;
  }

  .dashboard-view.active {
    gap: 18px;
    max-width: 100%;
    overflow-x: hidden;
  }

  .dashboard-hero-copy,
  .dashboard-live-panel,
  .metric-card,
  .dashboard-config-panel,
  .meta-panel,
  .dashboard-mini-panel {
    border-radius: 20px;
  }

  .dashboard-hero-copy {
    min-height: auto;
    padding: 24px;
  }

  .dashboard-hero-copy::after {
    display: none;
  }

  .dashboard-hero h1 {
    font-size: 38px;
    line-height: 1.02;
  }

  .hero-lede {
    font-size: 15px;
    max-width: 100%;
  }

  .dashboard-live-panel {
    padding: 22px;
  }

  .dashboard-live-panel > strong {
    font-size: 32px;
  }

  .premium-metrics,
  .dashboard-side,
  .meta-panel .status-grid,
  .mini-stat-row,
  .live-panel-metrics {
    grid-template-columns: 1fr;
  }

  .primary-metric {
    grid-column: span 1;
  }

  .metric-card,
  .primary-metric {
    min-height: 136px;
  }

  .metrics.premium-metrics .primary-metric strong {
    font-size: 46px;
  }

  .dashboard-config-panel,
  .meta-panel .panel-header {
    grid-template-columns: 1fr;
  }

  .dashboard-config-panel {
    align-items: start;
  }

  .meta-panel .panel-header {
    display: grid;
  }

  .meta-panel .panel-header button {
    width: 100%;
  }
}

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

  .nav-button {
    padding: 0 10px;
  }

  .dashboard-hero h1 {
    font-size: 34px;
    max-width: 320px;
  }

  .hero-lede,
  .hero-action-row {
    max-width: 320px;
  }

  .dashboard-live-panel p,
  .dashboard-live-panel > strong,
  .live-panel-top,
  .live-panel-metrics {
    max-width: 320px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .dashboard-hero-copy,
  .dashboard-live-panel,
  .dashboard-config-panel,
  .meta-panel,
  .dashboard-mini-panel,
  .metric-card,
  .live-pulse,
  .meta-loading span {
    animation: none;
  }
}
