/* ------------------------------------------------------------------
   WhatsApp Platform - UI

   One slim icon rail on the left (a bottom bar on phones) and one
   content pane. Every page shares the same vocabulary - card, btn,
   field, table, badge, alert - so a page never carries its own look.
   The inbox has its own section at the end: it is the one screen that
   fills the window edge to edge.
   ------------------------------------------------------------------ */

:root {
  --bg: #f0f2f5;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --border: #e9edef;
  --border-strong: #d1d7db;
  --text: #111b21;
  --text-muted: #54656f;
  --text-faint: #8696a0;
  --brand: #008069;
  --brand-dark: #005c4b;
  --brand-soft: #e7f8ee;
  --brand-tint: #d9fdd3;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warn: #6b4e00;
  --warn-soft: #fff8e1;
  --success: #0b5c4a;
  --success-soft: #e7f8ee;
  --info: #1e5a8a;
  --info-soft: #e3f0fa;
  --chat-bg: #efeae2;
  --bubble-in: #ffffff;
  --bubble-out: #d9fdd3;
  --tick: #8696a0;
  --tick-read: #53bdeb;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(11, 20, 26, .08);
  --rail-w: 76px;
  --accent: #1daa61;
  --accent-dark: #169c57;
  --accent-soft: #e7fce3;
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }

/* The hidden attribute must win over any display rule below, or a
   panel toggled from script shows through underneath. */
[hidden] { display: none !important; }

html { height: 100%; }

body {
  margin: 0;
  font: 15px/1.5 var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; color: var(--brand-dark); }

h1 { font-size: 1.4rem; margin: 0 0 .35rem; font-weight: 700; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; font-weight: 600; }
h3 { font-size: .9rem; margin: 0 0 .5rem; font-weight: 600; }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .875em; }
.muted { color: var(--text-muted); }
.small { font-size: .825rem; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.code-block {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .8rem;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  padding: .75rem .9rem; margin: 0; line-height: 1.5; overflow-x: auto;
}

/* ---- Shell: rail + page ------------------------------------------ */

.shell { display: flex; min-height: 100vh; min-height: 100dvh; }

/* The rail follows WhatsApp Web's light theme: white, grey icons, and a
   black rounded square for the page you are on. */
.rail {
  width: var(--rail-w); flex: 0 0 var(--rail-w);
  position: sticky; top: 0; height: 100vh; height: 100dvh;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center;
  padding: 12px 0; gap: 4px; z-index: 20;
}
.rail__brand {
  width: 44px; height: 44px; border-radius: 14px; margin-bottom: 8px;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.rail__brand:hover { text-decoration: none; background: var(--accent-dark); color: #fff; }
.rail__brand svg { width: 26px; height: 26px; }

.rail__item {
  position: relative; width: 64px; padding: 7px 0 6px; border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--text-muted); font: inherit; font-size: 10.5px; font-weight: 600; line-height: 12px;
  text-decoration: none; border: 0; background: transparent; cursor: pointer;
}
.rail__item svg { width: 24px; height: 24px; }
.rail__item:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.rail__item.is-active { background: var(--text); color: #fff; }
.rail__badge {
  position: absolute; top: 2px; right: 8px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 600;
  line-height: 14px; display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--surface);
}
.rail__item.is-active .rail__badge { border-color: var(--text); }
.rail__spacer { flex: 1; }
.rail__avatar {
  width: 36px; height: 36px; border-radius: 50%; margin: 6px 0 2px;
  background: var(--brand-tint); color: var(--brand-dark);
  font-weight: 600; font-size: 13px; display: flex; align-items: center; justify-content: center;
}
.rail form { margin: 0; display: flex; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.page { width: 100%; max-width: 1240px; margin: 0 auto; padding: 28px 32px 64px; }
.page--full { max-width: none; padding: 0; height: 100vh; height: 100dvh; overflow: hidden; display: flex; flex-direction: column; }
.page--full .flashes { padding: 12px 16px 0; }
.page--full .inbox { flex: 1; min-height: 0; }

.page-head { margin-bottom: 20px; }
.page-head h1 { font-size: 22px; font-weight: 700; color: var(--accent); margin: 0 0 4px; }
.page-head p { margin: 0; }
.page-head.flex { flex-wrap: wrap; }

.grid { display: grid; gap: 1rem; }
.grid--stats { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid--form { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 14px; }

/* ---- Cards ------------------------------------------------------- */

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px;
}
.card__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; margin-bottom: .9rem; flex-wrap: wrap;
}
.card__head h2 { margin: 0; }

.stat__label { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); font-weight: 600; }
.stat__value { font-size: 1.8rem; font-weight: 600; line-height: 1.2; margin-top: .2rem; letter-spacing: -.02em; }

/* ---- Buttons ----------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  height: 38px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s, opacity .12s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
.btn--danger { color: var(--danger); border-color: #f5b8b1; background: var(--danger-soft); }
.btn--danger:hover { background: #fbd9d4; }
.btn--sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn--lg { height: 46px; padding: 0 24px; font-size: 15px; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 0; padding: 0;
  background: transparent; color: var(--text-muted); font: inherit; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
}
.icon-btn svg { width: 24px; height: 24px; }
.icon-btn:hover { background: #e4e7ea; color: var(--text); }
.icon-btn:disabled { opacity: .4; cursor: not-allowed; background: transparent; }
.icon-btn--primary { background: var(--accent); color: #fff; }
.icon-btn--primary:hover { background: var(--accent-dark); color: #fff; }

/* ---- Forms ------------------------------------------------------- */

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.input, .select, .textarea {
  width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--border-strong);
  border-radius: 8px; font: inherit; font-size: 14px; background: var(--surface); color: var(--text);
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}
.textarea { height: auto; min-height: 90px; padding: 10px 12px; resize: vertical; }
.hint { font-size: .8rem; color: var(--text-muted); margin-top: .3rem; }

/* ---- Tables ------------------------------------------------------ */

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--border);
}
.table td { padding: 11px 10px; border-bottom: 1px solid #f0f2f5; vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }

/* ---- Badges ------------------------------------------------------ */

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 6px;
  font-size: 11.5px; font-weight: 600; line-height: 16px; letter-spacing: .01em;
  background: #f0f2f5; color: var(--text-muted);
}
.badge--ok { background: var(--success-soft); color: var(--success); }
.badge--warn { background: #fff3cd; color: var(--warn); }
.badge--danger { background: var(--danger-soft); color: #8a1c12; }
.badge--info { background: var(--info-soft); color: var(--info); }

/* ---- Alerts ------------------------------------------------------ */

.alert {
  padding: 12px 16px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); margin-bottom: 16px; font-size: 14px;
}
.alert ul { margin: .4rem 0 0; padding-left: 1.1rem; }
.alert--success { background: var(--success-soft); border-color: #bfe8cf; color: var(--success); }
.alert--warn { background: var(--warn-soft); border-color: #f3e2a3; color: var(--warn); }
.alert--error { background: var(--danger-soft); border-color: #f5b8b1; color: var(--danger); }
.alert--info { background: var(--info-soft); border-color: #bcd7ee; color: var(--info); }

/* ---- Dialogs ----------------------------------------------------- */

dialog {
  border: 1px solid var(--border); border-radius: 16px; padding: 24px;
  box-shadow: 0 12px 40px rgba(11, 20, 26, .25); color: var(--text);
  max-width: 34rem; width: 92%; font: inherit;
}
dialog::backdrop { background: rgba(17, 27, 33, .45); }
dialog h2 { font-size: 18px; margin: 0 0 6px; }
.dialog__actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

/* ---- Embedded signup --------------------------------------------- */

.es-hero { text-align: center; padding: 2rem 1.5rem; }
.es-status { margin: 1rem 0; font-size: .9rem; font-weight: 500; }
.es-status--idle { color: var(--text-muted); }
.es-status--busy { color: var(--brand-dark); }
.es-status--success { color: var(--success); }
.es-status--warn { color: var(--warn); }
.es-status--error { color: var(--danger); }

.es-steps { list-style: none; padding: 0; margin: 1rem auto; max-width: 26rem; text-align: left; }
.es-step {
  padding: .4rem 0 .4rem 1.6rem; position: relative; font-size: .875rem; color: var(--text-muted);
}
.es-step--done::before {
  content: "\2713"; position: absolute; left: 0; color: var(--success); font-weight: 700;
}
.es-numbers { list-style: none; padding: 0; margin: .75rem 0; }
.es-numbers li { padding: .4rem 0; border-bottom: 1px solid var(--border); font-size: .9rem; }

/* ---- Auth -------------------------------------------------------- */

.auth-shell {
  min-height: 100vh;
  background: linear-gradient(var(--brand) 0, var(--brand) 222px, var(--bg) 222px);
  display: flex; flex-direction: column; align-items: center; padding: 48px 16px 40px;
}
.auth-brand {
  display: flex; align-items: center; gap: 10px; margin-bottom: 28px;
  color: #fff; font-weight: 600; font-size: 15px; letter-spacing: .08em; text-transform: uppercase;
}
.auth-brand:hover { color: #fff; text-decoration: none; }
.auth-brand svg { width: 30px; height: 30px; }
/* The logo file has a white background; multiply blends it into the page. */
.auth-logo { display: block; margin-bottom: 6px; }
.auth-logo img { display: block; width: 124px; height: 34px; object-fit: cover; object-position: center; mix-blend-mode: multiply; }
.auth-footer { margin-top: 28px; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.auth-meta { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); }
.auth-meta img { display: block; width: 72px; height: 30px; object-fit: cover; mix-blend-mode: darken; }
.auth-copy { margin: 0; font-size: 12px; color: var(--text-muted); }
.auth-card { width: 100%; max-width: 27rem; }
.auth-card .card { padding: 32px 36px; border: 0; box-shadow: 0 6px 24px rgba(11, 20, 26, .14); }
.auth-card h1 { font-size: 24px; font-weight: 400; margin: 0 0 6px; }
.auth-form { margin-top: 20px; }
.auth-form .btn { width: 100%; }
.auth-foot { text-align: center; font-size: 13px; color: var(--text-muted); margin: 18px 0 0; }

/* ---- Misc -------------------------------------------------------- */

.empty { text-align: center; padding: 2.5rem 1rem; color: var(--text-muted); }
.empty.small { padding: 1.5rem 1rem; }
.flex { display: flex; gap: .5rem; align-items: center; }
.flex--between { justify-content: space-between; }
.stack > * + * { margin-top: 1rem; }
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li {
  display: flex; gap: .6rem; align-items: flex-start;
  padding: .55rem 0; border-bottom: 1px solid var(--border); font-size: .875rem;
}
.checklist li:last-child { border-bottom: none; }
.check-icon { flex: none; font-weight: 700; }
.check-icon--ok { color: var(--success); }
.check-icon--bad { color: var(--danger); }

.text-danger { color: var(--danger); }
.text-warn   { color: var(--warn); }

.filters { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; margin-bottom: 1rem; }
.filters .field { margin: 0; }
.filters .field label { display: block; font-size: .75rem; color: var(--text-muted); margin-bottom: .2rem; }
.filters .input, .filters .select { min-width: 9rem; }
.filters .input--search { min-width: 15rem; }

.ticks { display: inline-flex; color: var(--tick); flex: 0 0 auto; }
.ticks svg { width: 18px; height: 18px; }
.ticks.is-read { color: var(--tick-read); }
.ticks.is-failed { color: var(--danger); }

/* ---- Inbox ------------------------------------------------------- */

.inbox { display: flex; height: 100%; background: var(--surface); overflow: hidden; }

.inbox__list {
  width: 420px; flex: 0 0 420px; min-width: 0;
  display: flex; flex-direction: column; border-right: 1px solid var(--border); background: var(--surface);
}
.inbox__chat { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--chat-bg); }

.list__head { display: flex; align-items: center; justify-content: space-between; padding: 14px 12px 8px 20px; }
.list__head h1 { margin: 0; font-size: 22px; font-weight: 700; color: var(--accent); }
.list__actions { display: flex; align-items: center; gap: 4px; }

.search {
  margin: 4px 16px 8px; display: flex; align-items: center; gap: 12px;
  background: var(--bg); border-radius: 999px; padding: 0 14px; height: 38px;
}
.search svg { width: 20px; height: 20px; color: var(--text-muted); flex: 0 0 auto; }
.search input {
  flex: 1; min-width: 0; border: 0; background: transparent; font: inherit; font-size: 14px;
  color: var(--text); outline: none;
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 16px 10px; }
.chip {
  height: 32px; padding: 0 12px; border-radius: 999px; font: inherit; font-size: 14px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-muted);
}
.chip:hover { background: var(--surface-2); }
.chip.is-active { background: var(--accent-soft); border-color: var(--accent-soft); color: var(--brand); font-weight: 600; }
select.chip { max-width: 11rem; }

.threads { flex: 1; min-height: 0; overflow-y: auto; border-top: 1px solid #f0f2f5; }
.thread {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 0 0 0 14px;
  border: 0; background: transparent; text-align: left; font: inherit; color: var(--text); cursor: pointer;
}
.thread:hover { background: var(--surface-2); }
.thread.is-active { background: var(--bg); }
.thread__body {
  flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px;
  padding: 13px 16px 13px 0; border-bottom: 1px solid #f0f2f5;
}
.thread__top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.thread__name { font-size: 16px; font-weight: 500; line-height: 21px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread__time { font-size: 12px; line-height: 16px; color: var(--text-muted); flex: 0 0 auto; }
.thread.is-unread .thread__time { color: var(--accent); }
.thread__bottom { display: flex; align-items: center; gap: 8px; }
.thread__preview {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 4px;
  font-size: 14px; line-height: 20px; color: var(--text-muted);
}
.thread__preview > span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread__preview > svg { width: 16px; height: 16px; flex: 0 0 auto; }
.thread__clock { display: inline-flex; color: var(--text-faint); flex: 0 0 auto; }
.thread__clock svg { width: 16px; height: 16px; }
.thread__unread {
  flex: 0 0 auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--accent); color: #fff; font-size: 12px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.tag {
  flex: 0 0 auto; font-size: 11px; font-weight: 600; line-height: 16px;
  border-radius: 6px; padding: 1px 6px; background: var(--info-soft); color: var(--info);
}

.avatar {
  width: 49px; height: 49px; border-radius: 50%; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 16px; background: #d5f1e8; color: #0b5c4a;
}
.avatar--sm { width: 40px; height: 40px; font-size: 14px; }

.chat__empty {
  flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center;
  padding: 24px; gap: 28px; background: var(--bg); overflow-y: auto;
}
/* Centred with auto margins rather than justify-content, so a short
   window scrolls from the top instead of clipping the card. */
.chat__welcome {
  margin-top: auto; flex: 0 0 auto;
  background: var(--surface); border-radius: 16px; padding: 36px 40px 32px;
  max-width: 440px; width: 100%; text-align: center; box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.chat__empty .quick { margin-bottom: auto; flex: 0 0 auto; }
.chat__welcome h2 { margin: 6px 0 0; font-size: 24px; font-weight: 500; line-height: 30px; }
.chat__welcome p { margin: 0; color: var(--text-muted); font-size: 14px; }
.quick { display: flex; flex-wrap: wrap; justify-content: center; gap: 28px; }
.quick__item {
  display: flex; flex-direction: column; align-items: center; gap: 8px; width: 96px;
  border: 0; background: transparent; padding: 0; cursor: pointer; color: var(--text-muted);
  font: inherit; font-size: 12px; line-height: 16px; text-align: center; text-decoration: none;
}
.quick__item > span {
  width: 56px; height: 56px; border-radius: 50%; background: var(--surface); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
}
.quick__item svg { width: 24px; height: 24px; }
.quick__item:hover { text-decoration: none; color: var(--text); }

.chat__panel { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.chat__head {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px; min-height: 60px;
  background: var(--surface); border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.chat__back { display: none; }
.chat__who { flex: 1; min-width: 180px; display: flex; flex-direction: column; gap: 2px; }
.chat__name { font-size: 16px; font-weight: 500; line-height: 21px; }
.chat__meta { font-size: 13px; line-height: 17px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.pill {
  display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600;
  padding: 1px 8px; border-radius: 6px; background: var(--danger-soft); color: #8a1c12;
}
.pill svg { width: 13px; height: 13px; }
.pill--ok { background: var(--success-soft); color: var(--success); }
a.pill:hover { text-decoration: underline; }

.bot-pill {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px 0 10px;
  border-radius: 999px; border: 0; cursor: pointer; font: inherit; font-size: 13px;
  background: #fff3cd; color: var(--warn);
}
.bot-pill::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: #c98a00; }
.bot-pill strong { font-weight: 600; }
.bot-pill span { opacity: .85; }
.bot-pill.is-on { background: var(--brand-tint); color: var(--brand-dark); }
.bot-pill.is-on::before { background: #1dab61; }
.bot-pill:disabled { opacity: .6; cursor: default; }

.chat__body {
  flex: 1; min-height: 0; overflow-y: auto; padding: 12px 8% 8px;
  display: flex; flex-direction: column; gap: 4px;
}
.chat__pill {
  align-self: center; background: var(--surface); color: var(--text-muted);
  font-size: 12.5px; line-height: 16px; padding: 5px 12px; border-radius: 8px;
  box-shadow: 0 1px .5px rgba(11, 20, 26, .13); margin: 8px 0; text-align: center;
}
.chat__pill--lead { display: flex; align-items: center; gap: 8px; background: var(--success-soft); color: var(--success); }
.chat__pill--lead svg { width: 16px; height: 16px; flex: 0 0 auto; }
.chat__pill--lead a { color: inherit; text-decoration: underline; }

.bubble {
  position: relative; max-width: 65%; padding: 6px 9px 7px; border-radius: 8px;
  box-shadow: 0 1px .5px rgba(11, 20, 26, .13); font-size: 14.2px; line-height: 19px;
  word-wrap: break-word; overflow-wrap: anywhere;
}
.bubble--in { align-self: flex-start; background: var(--bubble-in); border-top-left-radius: 0; }
.bubble--out { align-self: flex-end; background: var(--bubble-out); border-top-right-radius: 0; }
.bubble--failed { background: var(--danger-soft); }
.bubble__sender { display: block; font-size: 12px; font-weight: 600; line-height: 16px; color: var(--info); margin-bottom: 2px; }
.bubble__sender--you { color: #7a2e6b; }
.bubble__text { display: block; white-space: pre-wrap; }
.bubble__template { display: block; font-size: 12px; font-weight: 600; line-height: 16px; color: var(--text-muted); margin-bottom: 2px; }
.bubble__meta {
  display: flex; justify-content: flex-end; align-items: center; gap: 4px;
  font-size: 11px; line-height: 15px; color: #3b4a54; margin-top: 3px;
}
.bubble__meta .ticks svg { width: 16px; height: 16px; }
.bubble__error { display: block; font-size: 11px; line-height: 15px; color: var(--danger); margin-top: 2px; text-align: right; }
.bubble__quote {
  display: block; background: #f5f6f6; border-left: 4px solid #06cf9c; border-radius: 6px;
  padding: 5px 10px; font-size: 13px; line-height: 17px; color: var(--text-muted); margin-bottom: 5px;
}
.bubble--out .bubble__quote { background: rgba(255, 255, 255, .55); }
.bubble__actions { display: block; margin: 6px -9px -7px; }
.bubble__action {
  display: flex; align-items: center; justify-content: center; gap: 6px; padding: 10px;
  border-top: 1px solid rgba(11, 20, 26, .09); color: #075e8c; font-weight: 500;
}
.bubble__action svg { width: 18px; height: 18px; }
.bubble__file {
  display: flex; align-items: center; gap: 12px; background: #f5f6f6; border-radius: 6px;
  padding: 10px 12px; min-width: 240px; max-width: 100%; color: inherit; margin-bottom: 4px;
}
.bubble--out .bubble__file { background: rgba(255, 255, 255, .55); }
.bubble__file > svg { width: 30px; height: 30px; color: var(--text-muted); flex: 0 0 auto; }
.bubble__file-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.bubble__file-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bubble__file-meta { font-size: 12px; line-height: 16px; color: var(--text-muted); }
.bubble__file a {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border-strong);
  display: flex; align-items: center; justify-content: center; color: var(--text-muted); flex: 0 0 auto;
}
.bubble__file a svg { width: 18px; height: 18px; }
a.bubble__file:hover { text-decoration: none; }
.bubble img, .bubble video { max-width: 100%; max-height: 360px; border-radius: 6px; display: block; margin-bottom: 4px; }
.bubble audio { max-width: 100%; display: block; margin-bottom: 4px; }

.chat__banner {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 12px 16px;
  background: var(--warn-soft); border-top: 1px solid #f3e2a3; color: var(--warn); font-size: 14px; line-height: 20px;
}
.chat__banner > svg { width: 20px; height: 20px; flex: 0 0 auto; }
.chat__banner > span { flex: 1; min-width: 240px; }

.chat__foot {
  display: flex; align-items: flex-end; gap: 6px; padding: 10px 16px;
  background: var(--surface); border-top: 1px solid var(--border); margin: 0;
}
.chat__foot .icon-btn { width: 44px; height: 44px; }
.composer-input {
  flex: 1; min-width: 0; resize: none; border: 1px solid var(--border); border-radius: 24px; padding: 11px 16px;
  font: inherit; font-size: 15px; line-height: 20px; background: var(--surface); color: var(--text);
  outline: none; min-height: 44px; max-height: 140px;
}
.composer-input:focus { border-color: var(--border-strong); }
.composer-input:disabled { background: var(--surface-2); color: var(--text-muted); }
.chat__foot .send { background: var(--accent); color: #fff; }
.chat__foot .send:hover { background: var(--accent-dark); color: #fff; }
.chat__foot .send:disabled { background: #aebac1; opacity: 1; }

.tpl-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; max-height: 240px; overflow-y: auto; }
.tpl-option {
  display: flex; flex-direction: column; gap: 4px; text-align: left; padding: 12px 14px;
  border-radius: 12px; cursor: pointer; font: inherit; background: var(--surface); border: 2px solid var(--border);
}
.tpl-option:hover { background: var(--surface-2); }
.tpl-option.is-active { background: #f0fbf6; border-color: var(--brand); }
.tpl-option__name { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; flex-wrap: wrap; }
.tpl-option__body { font-size: 13px; line-height: 18px; color: var(--text-muted); }
.tpl-preview { background: var(--chat-bg); border-radius: 12px; padding: 14px 16px; display: flex; }
.tpl-preview:empty { display: none; }
.tpl-preview .bubble { margin-left: auto; max-width: 85%; }

/* ---- Dashboard: lead section ------------------------------------ */

.crm-line {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin-bottom: 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 18px; box-shadow: var(--shadow); font-size: 14px;
}
.crm-line__state { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; color: var(--success); }
.crm-line__state svg { width: 18px; height: 18px; }
.crm-line__state--off { color: var(--warn); }
.crm-line__spacer { flex: 1; }
.crm-line a { font-weight: 600; }

.grid--leads { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin-bottom: 16px; }
.grid--split { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); margin-bottom: 16px; }
.grid--compact .card { padding: 14px 16px; }
.grid--compact .stat__value { font-size: 1.4rem; }

.tile { display: flex; flex-direction: column; gap: 4px; color: inherit; }
a.tile:hover { text-decoration: none; color: inherit; border-color: var(--border-strong); }
.stat__value--lg { font-size: 30px; }
.stat__row { display: flex; align-items: center; gap: 10px; }
.stat__delta { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 600; color: var(--success); }
.stat__delta svg { width: 14px; height: 14px; }
.stat__delta--down { color: var(--danger); }
.stat__delta--flat { color: var(--text-muted); font-weight: 400; }
.stat__note { font-size: 13px; line-height: 18px; color: var(--text-muted); }
.tile-tag {
  display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600;
  padding: 2px 8px; border-radius: 6px; background: #fff3cd; color: var(--warn);
}
.tile-tag svg { width: 12px; height: 12px; }

.card--col { display: flex; flex-direction: column; }
.card__sub { display: block; font-size: 13px; color: var(--text-muted); }
.card__head .card__sub strong { color: var(--text); font-weight: 600; }
.card__foot { font-size: 12px; color: var(--text-muted); margin-top: auto; padding-top: 12px; }

.chart { position: relative; height: 160px; margin-top: 18px; }
.chart__line { position: absolute; left: 0; right: 0; border-top: 1px solid #f0f2f5; }
.chart__line--base { border-top-color: var(--border-strong); }
.chart__bars { position: absolute; inset: 0; display: flex; justify-content: space-between; align-items: flex-end; padding: 0 6px; }
.chart__bar { position: relative; width: 22px; max-width: 6%; background: var(--brand); border-radius: 4px 4px 0 0; }
.chart__bar--today { background: #1dab61; }
.chart__bar--zero { height: 2px !important; background: var(--border-strong); border-radius: 0; }
.chart__value { position: absolute; top: -20px; left: 50%; transform: translateX(-50%); font-size: 12px; font-weight: 600; color: var(--text); }
.chart__axis { display: flex; justify-content: space-between; padding: 0 6px; margin-top: 6px; font-size: 11px; color: var(--text-muted); }
.chart__axis span { width: 22px; max-width: 6%; text-align: center; }
.chart__axis span.is-today { color: var(--brand); font-weight: 600; }

.bar-list { display: flex; flex-direction: column; gap: 12px; }
.bar-list__row { display: grid; grid-template-columns: minmax(0, 1fr) 36px; gap: 4px 12px; align-items: center; }
.bar-list__label { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-list__label--muted { color: var(--text-muted); }
.bar-list__n { font-size: 13px; font-weight: 600; text-align: right; }
.bar-list__track { grid-column: 1 / -1; height: 10px; background: var(--bg); border-radius: 0 4px 4px 0; }
.bar-list__fill { height: 100%; background: var(--brand); border-radius: 0 4px 4px 0; }
.bar-list__fill--muted { background: var(--text-faint); }

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

/* ---- Phones ------------------------------------------------------ */

@media (max-width: 1100px) {
  .chat__body { padding: 12px 24px 8px; }
}

@media (max-width: 860px) {
  .inbox__list { width: 100%; flex: 1 1 auto; border-right: 0; }
  .inbox__chat { display: none; }
  .inbox.is-open .inbox__list { display: none; }
  .inbox.is-open .inbox__chat { display: flex; }
  .chat__back { display: inline-flex; }
  .chat__who { min-width: 0; }
  .chat__head { gap: 8px; padding: 8px 8px 8px 4px; min-height: 56px; }
  .chat__name, .chat__meta { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .chat__head .pill--ok { display: none; }
  .bot-pill { height: 32px; padding: 0 10px 0 8px; font-size: 12px; }
  .bot-pill span { display: none; }
  .bubble { max-width: 85%; }
  .chat__body { padding: 10px 12px 8px; }
}

@media (max-width: 820px) {
  .shell { flex-direction: column; }
  .rail {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: auto;
    height: calc(64px + env(safe-area-inset-bottom, 0px));
    flex-direction: row; justify-content: flex-start; overflow-x: auto; overflow-y: hidden;
    padding: 4px 6px calc(4px + env(safe-area-inset-bottom, 0px)); gap: 2px;
    border-right: 0; border-top: 1px solid var(--border);
  }
  .rail__brand, .rail__spacer, .rail__avatar { display: none; }
  .rail__item { flex: 0 0 auto; width: 68px; padding: 6px 0 5px; }
  .page { padding: 20px 16px calc(96px + env(safe-area-inset-bottom, 0px)); }
  .page--full {
    height: calc(100vh - 64px);
    height: calc(100dvh - 64px - env(safe-area-inset-bottom, 0px));
    padding: 0;
  }
}

@media print {
  .rail, .no-print { display: none !important; }
  .page { padding: 0; max-width: none; }
  body { background: #fff; }
}
