/* متابعة واتساب: أخضر مزرق. شريط جانبي داكن، مساحة عمل فاتحة، خط Readex Pro، أيقونات خطية (Lucide). */

@font-face {
  font-family: "Readex Pro";
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/readex-pro-arabic-400.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
  font-family: "Readex Pro";
  font-weight: 500;
  font-display: swap;
  src: url("/static/fonts/readex-pro-arabic-500.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
  font-family: "Readex Pro";
  font-weight: 600;
  font-display: swap;
  src: url("/static/fonts/readex-pro-arabic-600.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
  font-family: "Readex Pro";
  font-weight: 700;
  font-display: swap;
  src: url("/static/fonts/readex-pro-arabic-700.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
  font-family: "Readex Pro";
  font-weight: 400 500;
  font-display: swap;
  src: url("/static/fonts/readex-pro-latin-400.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215;
}
@font-face {
  font-family: "Readex Pro";
  font-weight: 600 700;
  font-display: swap;
  src: url("/static/fonts/readex-pro-latin-600.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215;
}

:root {
  --bg: #f2f5f3;
  --surface: #ffffff;
  --surface-2: #f7faf8;
  --border: #e1e8e4;
  --hair: #edf2ef;
  --text: #10201b;
  --muted: #5f6f69;
  --faint: #66786f;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --accent-soft: #e6f4f1;
  --accent-ring: rgb(15 118 110 / 22%);
  --mint: #34d399;
  --rail: #0f3b35;
  --rail-text: #d5e7e2;
  --rail-muted: #8fb5ab;
  --rail-active: rgb(255 255 255 / 10%);
  --rail-line: rgb(255 255 255 / 9%);
  --live: #22c55e;
  --warn: #c2410c;
  --warn-soft: #fff1e8;
  --bad: #b91c1c;
  --bad-soft: #fdeceb;
  --ok: #15803d;
  --ok-soft: #e7f6ec;
  --amber-soft: #fff8e6;
  --amber-line: #f2cf74;
  --amber-text: #7a4300;
  --chat-bg: #e7eee9;
  --bubble-out: #d7f0e8;
  --kpi-1: #0f766e;
  --kpi-2: #6d28d9;
  --kpi-3: #0369a1;
  --kpi-4: #c2410c;
  --kpi-5: #b91c1c;
  --kpi-6: #3f4f49;
  --tint: 11%;
  --radius: 16px;
  --shadow-sm: 0 1px 2px rgb(16 32 27 / 6%);
  --shadow: 0 1px 2px rgb(16 32 27 / 6%), 0 8px 24px rgb(16 32 27 / 5%);
  --font: "Readex Pro", system-ui, "Segoe UI", Tahoma, Arial, sans-serif;
  --rail-w: 76px;
  --list-w: 340px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }
/* Elements that set their own display (badges, form rows) must still disappear when hidden. */
[hidden] { display: none !important; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
[dir="ltr"], .ltr { direction: ltr; unicode-bidi: isolate; }
.num, .conv-time, .kpi .v, td, .badge, .pill { font-variant-numeric: tabular-nums; }

/* Line icons from the sprite at the top of the page. */
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
svg.i {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}

/* ---------------------------------------------------------------- sign-in pages */

.auth-body {
  min-height: 100dvh;
  background:
    radial-gradient(900px 420px at 85% -8%, rgb(52 211 153 / 22%), transparent 65%),
    linear-gradient(180deg, var(--rail) 0 42%, var(--bg) 42%);
}
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 28px 16px; }
.auth-card {
  width: min(410px, 100%);
  background: var(--surface);
  border-radius: 20px;
  box-shadow: 0 1px 2px rgb(16 32 27 / 8%), 0 24px 60px rgb(8 35 31 / 22%);
  padding: 30px 26px;
  display: grid;
  gap: 15px;
}
.auth-card-wide { width: min(470px, 100%); }
.auth-brand { display: flex; align-items: center; gap: 12px; }
.auth-brand img { border-radius: 11px; }
.auth-brand div { display: grid; }
.auth-brand strong { font-size: 17px; font-weight: 700; }
.auth-brand span { color: var(--muted); font-size: 13px; }
.auth-card h1 { font-size: 21px; font-weight: 700; margin: 8px 0 0; }
.auth-card p { margin: 0; }
.auth-card label { display: grid; gap: 6px; font-weight: 500; font-size: 14px; }
.auth-card small { color: var(--muted); font-weight: 400; font-size: 12.5px; }
.auth-card input {
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 11px 13px;
  font-size: 16px;
  background: var(--surface-2);
  transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}
.auth-card input:hover { border-color: #c9d6cf; }
.auth-card input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-ring); background: var(--surface); }
.auth-error { margin: 0; background: var(--bad-soft); color: var(--bad); border-radius: 11px; padding: 10px 12px; font-size: 14px; }
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 46px; border: 0; border-radius: 11px; padding: 12px 16px;
  background: var(--accent); color: #fff; font-weight: 600; font-size: 16px; text-decoration: none;
  transition: background-color 0.15s;
}
.btn-primary:hover { background: var(--accent-strong); }
.btn-outline {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; border: 1px solid var(--border); border-radius: 11px; padding: 11px 16px;
  background: var(--surface); color: var(--accent); font-weight: 600; font-size: 15px; text-decoration: none; text-align: center;
  transition: border-color 0.15s, background-color 0.15s;
}
.btn-outline:hover { border-color: var(--accent); background: var(--accent-soft); }
.btn-outline svg { flex: none; }
.steps { margin: 0; padding-inline-start: 20px; display: grid; gap: 6px; font-size: 14px; }
.qr { display: grid; place-items: center; padding: 10px; border: 1px solid var(--border); border-radius: 14px; justify-self: center; background: #fff; }
.qr svg { width: 210px; height: 210px; display: block; }
.manual summary { cursor: pointer; color: var(--accent); font-size: 14px; }
.manual code {
  display: block; margin-top: 8px; padding: 10px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--hair);
  font-size: 15px; letter-spacing: 1px; word-break: break-all; text-align: center;
}

/* ---------------------------------------------------------------- app frame (phones first) */

.app-body {
  height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  /* Named areas keep the main area in the tall row even when a bar above or below it is hidden. */
  grid-template-areas: "top" "lhead" "main" "nav";
  overflow: hidden;
}
.rail { display: none; }
.topbar { grid-area: top; }
.list-head { grid-area: lhead; }
.app { grid-area: main; display: grid; min-height: 0; min-width: 0; }
.bottom-nav { grid-area: nav; }

/* brand mark shared by the rail and the phone bar */
.logo {
  width: 38px; height: 38px; border-radius: 11px; flex: none;
  display: grid; place-items: center;
  background: var(--mint); color: var(--rail);
}
.logo svg.i { width: 21px; height: 21px; stroke-width: 2; }

.live { display: flex; align-items: center; gap: 8px; font-size: 12.5px; white-space: nowrap; }
.live .dot { width: 8px; height: 8px; border-radius: 50%; background: #9fb3ac; flex: none; }
.live.on .dot { background: var(--live); animation: pulse 2.2s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgb(34 197 94 / 55%); }
  70% { box-shadow: 0 0 0 7px rgb(34 197 94 / 0%); }
  100% { box-shadow: 0 0 0 0 rgb(34 197 94 / 0%); }
}
.logout { margin: 0; display: flex; }
.logout button {
  width: 40px; height: 40px; display: grid; place-items: center;
  border: 0; border-radius: 10px; background: transparent; color: var(--rail-muted);
  transition: background-color 0.15s, color 0.15s;
}
.logout button:hover { background: var(--rail-active); color: #fff; }
.logout svg.i { width: 19px; height: 19px; }

/* phone bar */
.topbar {
  background: var(--rail);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px 9px 8px;
  padding-top: max(9px, env(safe-area-inset-top));
}
.topbar :focus-visible, .rail :focus-visible { outline-color: var(--mint); }
.topbar-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-brand .logo { width: 34px; height: 34px; border-radius: 10px; }
.topbar-brand div { display: grid; min-width: 0; line-height: 1.3; }
.topbar-brand strong { font-size: 15.5px; font-weight: 700; }
.topbar-brand span { font-size: 12px; color: var(--rail-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .live { margin-inline-start: auto; color: var(--rail-text); font-size: 12px; }
.topbar .logout button { color: var(--rail-text); }

/* side rail (wide screens) */
.rail {
  grid-area: rail;
  background: var(--rail);
  color: var(--rail-text);
  flex-direction: column;
  gap: 22px;
  padding: 18px 12px;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: none;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 0 6px; }
.brand div { display: grid; line-height: 1.35; min-width: 0; }
.brand b { font-size: 15.5px; font-weight: 700; color: #fff; }
.brand span { font-size: 12px; color: var(--rail-muted); }
.rail-nav { display: grid; gap: 3px; }
.nav-label { font-size: 11.5px; color: var(--rail-muted); padding: 0 12px; margin: 10px 0 4px; letter-spacing: 0.2px; }
.nav-label:first-child { margin-top: 0; }
.rail-nav a {
  display: flex; align-items: center; gap: 11px;
  min-height: 44px; padding: 9px 12px; border-radius: 11px;
  color: inherit; text-decoration: none; font-weight: 500; position: relative;
  transition: background-color 0.15s, color 0.15s;
}
.rail-nav a:hover { background: var(--rail-active); color: #fff; }
.rail-nav a[aria-current] { background: var(--rail-active); color: #fff; font-weight: 600; }
.rail-nav a[aria-current]::before {
  content: ""; position: absolute; inset-inline-start: -12px; top: 11px; bottom: 11px;
  width: 3px; border-radius: 3px; background: var(--mint);
}
.rail-nav a[aria-current] svg.i { color: var(--mint); }
.rail-nav .badge { margin-inline-start: auto; }
.rail-foot { margin-top: auto; display: grid; gap: 10px; }
.rail .live { color: var(--rail-muted); padding: 0 12px; }
.me { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 13px; background: var(--rail-active); }
.me div { display: grid; min-width: 0; line-height: 1.35; }
.me b { font-size: 13.5px; font-weight: 600; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me span { font-size: 11.5px; color: var(--rail-muted); }
.me .logout { margin-inline-start: auto; }
.me-av.avatar { width: 34px; height: 34px; font-size: 13.5px; background: var(--mint); color: var(--rail); }

/* the list header: title, the two list tabs, agent and page filters */
.list-head { background: var(--surface); display: grid; gap: 12px; }
.list-title { margin: 0; font-size: 18px; font-weight: 700; }
.tabs {
  display: grid; grid-template-columns: 1fr 1fr;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 3px;
}
.tab {
  display: inline-flex; justify-content: center; align-items: center; gap: 7px;
  min-height: 36px; padding: 6px; border-radius: 9px;
  text-decoration: none; color: var(--muted); font-weight: 500;
  transition: background-color 0.15s, color 0.15s;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgb(16 32 27 / 8%), 0 0 0 1px var(--border); }

.pages { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.pages::-webkit-scrollbar { display: none; }
.pages:empty { display: none; }
.chip {
  flex: none;
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 34px; padding: 5px 13px;
  border: 1px solid var(--border); background: var(--surface); border-radius: 999px;
  font-size: 13.5px; color: var(--muted); white-space: nowrap;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.chip:hover { border-color: #c4d6ce; color: var(--text); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.chip[aria-pressed="true"] .badge { background: #fff; color: var(--accent); }
.agent-chip { color: var(--text); font-weight: 600; }
.chip-sep { flex: none; width: 1px; align-self: stretch; margin: 6px 3px; background: var(--border); }

.badge {
  display: inline-grid; place-items: center;
  min-width: 21px; height: 20px; padding: 0 6px;
  border-radius: 999px; background: var(--warn); color: #fff;
  font-size: 11.5px; font-weight: 600; line-height: 1;
}

.sidebar { background: var(--surface); display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.content { min-height: 0; min-width: 0; overflow-y: auto; container-type: inline-size; }
.conv-list, .content, .messages { scrollbar-width: thin; scrollbar-color: #cfdcd5 transparent; }

/* ---------------------------------------------------------------- conversation list */

.conv-list { list-style: none; margin: 0; padding: 6px 8px; overflow-y: auto; flex: 1; }
.conv {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 11px;
  padding: 10px;
  border-radius: 13px;
  text-decoration: none;
  color: inherit;
  position: relative;
  transition: background-color 0.15s;
}
.conv:hover { background: var(--surface-2); }
.conv[aria-current="true"] { background: var(--accent-soft); }
.conv.wait::after, .conv.late::after {
  content: ""; position: absolute; inset-inline-start: 0; top: 14px; bottom: 14px;
  width: 3px; border-radius: 3px; background: var(--warn);
}
.conv.late::after { background: var(--bad); }
.conv.flash { animation: flash 2.2s ease-out; }
@keyframes flash { 0% { background: #fdf3cf; } 100% { background: transparent; } }
.avatar {
  width: 44px; height: 44px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  font-weight: 600; font-size: 16.5px;
  background: var(--accent-soft);
  background: color-mix(in srgb, var(--c, var(--accent)) var(--tint), var(--surface));
  color: var(--c, var(--accent));
}
.avatar svg.i { width: 21px; height: 21px; }
.conv-main { min-width: 0; display: grid; gap: 1px; align-content: center; }
.conv-top { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.conv-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-time { margin-inline-start: auto; color: var(--faint); font-size: 12px; flex: none; }
.conv-preview { color: var(--muted); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-preview .who { color: var(--accent); font-weight: 500; }
.conv-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 5px; align-items: center; }
.conv-tags:empty { display: none; }
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; line-height: 1.6; border-radius: 6px; padding: 1px 8px;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--hair);
}
.tag svg.i { width: 12px; height: 12px; stroke-width: 2.2; }
.tag.wait { background: var(--warn-soft); color: var(--warn); border-color: transparent; font-weight: 600; }
.tag.late { background: var(--bad-soft); color: var(--bad); border-color: transparent; font-weight: 600; }
.tag.new { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.tag.agent { background: var(--accent-soft); color: var(--accent-strong); border-color: transparent; }
.empty { padding: 44px 20px; text-align: center; color: var(--muted); margin: 0; }
.more {
  margin: 8px 14px 14px; min-height: 40px; border: 1px solid var(--border); background: var(--surface);
  border-radius: 11px; padding: 8px; color: var(--accent); font-weight: 500;
  transition: background-color 0.15s;
}
.more:hover { background: var(--accent-soft); }

/* An agent's numbers, one per row, before their chats (the owner after choosing an agent; an agent with several numbers). */
.list-note { padding: 8px 10px 4px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.numrow {
  width: 100%; border: 0; background: transparent; font: inherit; text-align: start; cursor: pointer;
  grid-template-columns: 44px minmax(0, 1fr) auto; align-items: center;
}
.numrow:focus-visible { outline: 2px solid var(--accent-ring); outline-offset: -2px; }
.num-phone { text-align: end; }
.num-go { display: grid; place-items: center; color: var(--faint); }
.num-go svg.i { width: 18px; height: 18px; }
.all-chats { display: block; width: calc(100% - 12px); margin: 8px 6px 14px; }
.list-back {
  position: sticky; top: -6px; z-index: 1;
  display: flex; align-items: center; gap: 10px;
  margin: -6px -8px 4px; padding: 10px 14px;
  background: var(--surface); border-bottom: 1px solid var(--hair);
}
.back-row {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px; padding: 6px 12px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  color: var(--accent); font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer;
  transition: background-color 0.15s;
}
.back-row:hover { background: var(--accent-soft); }
.back-row svg.i { width: 16px; height: 16px; }
.list-back-title { min-width: 0; display: grid; line-height: 1.35; }
.list-back-title b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-back-title span { font-size: 12px; color: var(--muted); text-align: end; }

/* ---------------------------------------------------------------- content pages */

.panel { padding: 18px 14px 28px; max-width: 1160px; margin: 0 auto; display: grid; gap: 16px; }
.panel-head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.panel-head:has(> .back) { align-items: center; }
.panel-head h2 { margin: 0; font-size: 21px; font-weight: 700; letter-spacing: -0.2px; line-height: 1.35; }
.panel-head p { margin: 3px 0 0; font-size: 13.5px; }

.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.kpi {
  --k: var(--kpi-1);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 13px 14px;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; align-items: start;
}
.kpi .l { color: var(--muted); font-size: 13px; font-weight: 500; line-height: 1.4; }
.kpi .v { grid-column: 1; font-size: 25px; font-weight: 700; line-height: 1.15; letter-spacing: -0.4px; }
.kpi .ic {
  grid-row: 1 / span 2; grid-column: 2;
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  color: var(--k); background: var(--accent-soft); background: color-mix(in srgb, var(--k) var(--tint), var(--surface));
}
.kpi .ic svg.i { width: 19px; height: 19px; }
.kpi.warn .v { color: var(--warn); }
.kpi.bad .v { color: var(--bad); }
.k-1 { --k: var(--kpi-1); } .k-2 { --k: var(--kpi-2); } .k-3 { --k: var(--kpi-3); }
.k-4 { --k: var(--kpi-4); } .k-5 { --k: var(--kpi-5); } .k-6 { --k: var(--kpi-6); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 13px 16px; border-bottom: 1px solid var(--hair); }
.card-head h3, .card > h3 { margin: 0; font-size: 15px; font-weight: 600; }
.card > h3 { padding: 13px 16px; border-bottom: 1px solid var(--hair); }
.card-head span { color: var(--faint); font-size: 12.5px; margin-inline-start: auto; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th, td { padding: 11px 14px; text-align: start; white-space: nowrap; border-bottom: 1px solid var(--hair); }
tr:last-child td { border-bottom: 0; }
th { color: var(--faint); font-weight: 500; font-size: 12px; background: var(--surface-2); }
tbody tr { transition: background-color 0.15s; }
tbody tr:hover td { background: var(--surface-2); }
td.num, th.num { text-align: center; }
.pill { display: inline-grid; place-items: center; min-width: 28px; padding: 1px 8px; border-radius: 999px; font-weight: 600; font-size: 12.5px; }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.zero { color: var(--faint); font-weight: 500; }
.note { color: var(--muted); font-size: 12.5px; margin: 0; display: flex; gap: 8px; align-items: flex-start; line-height: 1.6; }
.note svg.i { width: 16px; height: 16px; margin-top: 2px; color: var(--faint); }
.linkish {
  border: 0; background: none; padding: 0; color: var(--accent); font-weight: 600;
  text-decoration: underline; text-decoration-color: var(--accent-ring); text-underline-offset: 4px;
}
.linkish:hover { text-decoration-color: currentColor; }
.linkish[aria-pressed="true"] { text-decoration: none; background: var(--accent-soft); border-radius: 6px; padding: 1px 7px; }

.report-list { list-style: none; margin: 0; padding: 0; }
.report-list li + li a { border-top: 1px solid var(--hair); }
.report-list a {
  display: flex; gap: 12px; align-items: center; padding: 14px 16px; min-height: 52px;
  text-decoration: none; color: inherit; transition: background-color 0.15s;
}
.report-list a:hover { background: var(--surface-2); }
.report-list .date { font-weight: 600; min-width: 96px; }
.report-list .sub { color: var(--muted); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.report-list .who { font-size: 11.5px; border-radius: 6px; padding: 1px 8px; background: var(--accent-soft); color: var(--accent-strong); flex: none; }
.report-list .who.all { background: var(--surface-2); color: var(--muted); border: 1px solid var(--hair); }
.report-frame { width: 100%; border: 1px solid var(--border); background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); min-height: 75dvh; }

.back {
  width: 40px; height: 40px; flex: none; display: inline-grid; place-items: center;
  border: 0; background: transparent; border-radius: 10px; color: var(--accent); text-decoration: none;
  transition: background-color 0.15s;
}
.back:hover { background: var(--accent-soft); }

/* ---------------------------------------------------------------- the owner's agents and phones page */

.card-body { padding: 14px 16px; display: grid; gap: 12px; }
.form-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin: 0; }
.form-row label { display: grid; gap: 5px; font-size: 13px; color: var(--muted); flex: 1 1 180px; }
.form-row label.check { display: flex; align-items: center; gap: 9px; flex-basis: 100%; font-size: 14px; color: var(--text); }
.form-row label.check input { width: 18px; height: 18px; margin: 0; padding: 0; accent-color: var(--accent); }
.form-row input, .form-row select, td select, .num-row select {
  font: inherit; font-size: 14.5px; color: var(--text); min-width: 0; max-width: 100%; min-height: 40px;
  border: 1px solid var(--border); border-radius: 10px; padding: 8px 11px; background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-row input:hover, .form-row select:hover, .num-row select:hover { border-color: #c4d6ce; }
.form-row input:focus, .form-row select:focus, td select:focus, .num-row select:focus {
  border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-ring);
}
td select { min-height: 34px; padding: 5px 8px; font-size: 13.5px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 40px; border: 1px solid var(--border); background: var(--surface); border-radius: 10px;
  padding: 8px 15px; font-size: 14px; font-weight: 500; color: var(--text);
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover { background: var(--surface-2); border-color: #c4d6ce; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.small { min-height: 34px; padding: 5px 11px; font-size: 13px; }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); border-color: #f3c9c5; }
.btn:disabled { opacity: 0.5; cursor: default; }
.agent-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 13px 16px; border-bottom: 1px solid var(--hair); }
.agent-head h3 { margin: 0; font-size: 16px; font-weight: 600; }
.agent-head .muted { font-size: 13px; }
.agent-head .actions { margin-inline-start: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.budget-list { display: grid; gap: 10px; }
.budget-row { display: grid; gap: 8px; padding: 10px 12px; border: 1px solid var(--hair); border-radius: 10px; }
.budget-head { display: flex; align-items: center; gap: 6px 10px; flex-wrap: wrap; }
.budget-head .muted { font-size: 13px; }
.budget-head .btn { margin-inline-start: auto; }
.budget-items { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.budget-items li { display: flex; align-items: center; gap: 6px 12px; flex-wrap: wrap; font-size: 13.5px; }
.budget-items li .muted { font-size: 12.5px; }
.budget-items li .btn { margin-inline-start: auto; }
.num-row { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--hair); }
.num-row:last-child { border-bottom: 0; }
.num-row .label { font-weight: 600; }
.num-row .phone { color: var(--muted); font-size: 13px; }
.num-row .controls { margin-inline-start: auto; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.num-row select { min-height: 34px; padding: 5px 9px; font-size: 13.5px; }
.num-row form { flex: 1 1 100%; }
.user-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 9px 0; border-bottom: 1px solid var(--hair); }
.user-row:last-child { border-bottom: 0; }
.user-row .name { font-weight: 600; direction: ltr; unicode-bidi: isolate; }
.user-row .actions { margin-inline-start: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.status { font-size: 12px; font-weight: 500; border-radius: 999px; padding: 1px 9px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--hair); }
.status.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.status.wait { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.status.off { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.secret {
  background: var(--amber-soft); border: 1px solid var(--amber-line); color: var(--amber-text);
  border-radius: 12px; padding: 13px 15px; display: grid; gap: 8px; font-size: 14px;
}
.secret code {
  font-size: 18px; letter-spacing: 1px; direction: ltr; unicode-bidi: isolate; color: var(--text);
  background: #fff; border: 1px solid var(--amber-line); border-radius: 9px; padding: 6px 11px; justify-self: start; user-select: all;
}
.form-error { margin: 0; background: var(--bad-soft); color: var(--bad); border-radius: 10px; padding: 9px 13px; font-size: 14px; }

/* page phones: pairing code, app download, phone rows */
.pair-grid { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.pair-code { display: grid; gap: 6px; min-width: 0; flex: 1 1 220px; }
.pair-code a { overflow-wrap: anywhere; font-size: 13px; }
.qr-img { width: 190px; height: 190px; background: #fff; border-radius: 12px; padding: 7px; border: 1px solid var(--border); }
.qr-img.small { width: 130px; height: 130px; }
.secret.pairing code { font-size: 26px; letter-spacing: 3px; }
.secret .steps { margin: 0; padding-inline-start: 20px; display: grid; gap: 4px; }
.secret .note { color: var(--amber-text); }
.device-row .device-details { flex: 1 1 100%; color: var(--muted); font-size: 12.5px; }
.card .conv-list.group-list { overflow: visible; padding: 6px 8px; }
.bubble .sender { font-size: 12.5px; font-weight: 600; margin-bottom: 1px; }

/* ---------------------------------------------------------------- conversation */

.chat {
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto; height: 100%; min-height: 0;
  background-color: var(--chat-bg);
  background-image: radial-gradient(rgb(15 59 53 / 7%) 1px, transparent 1.2px);
  background-size: 18px 18px;
}
.chat-head {
  background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; min-height: 62px;
}
.chat-head .avatar { width: 40px; height: 40px; font-size: 15.5px; }
.chat-title { min-width: 0; display: grid; line-height: 1.4; }
.chat-title strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-title span { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-head .tags { margin-inline-start: auto; display: flex; gap: 6px; flex-wrap: wrap; justify-content: end; }
.messages { overflow-y: auto; padding: 16px 12px 20px; display: flex; flex-direction: column; gap: 4px; }
.older {
  align-self: center; margin-bottom: 8px; min-height: 34px; border: 1px solid var(--border); background: var(--surface);
  border-radius: 999px; padding: 5px 15px; font-size: 13px; color: var(--accent); box-shadow: var(--shadow-sm);
}
.older:hover { background: var(--accent-soft); }
.day-sep {
  align-self: center; margin: 12px 0 6px; background: var(--surface); color: var(--muted);
  font-size: 12px; font-weight: 500; padding: 3px 12px; border-radius: 999px; box-shadow: var(--shadow-sm);
}
.ad-banner {
  align-self: center; margin: 6px 0; background: var(--amber-soft); color: var(--amber-text); border: 1px solid var(--amber-line);
  border-radius: 10px; padding: 6px 12px; font-size: 13px; max-width: 90%; text-align: center;
}
.bubble {
  max-width: min(80%, 560px);
  padding: 7px 11px 5px;
  border-radius: 12px;
  box-shadow: 0 1px 1px rgb(16 32 27 / 9%);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  position: relative;
  font-size: 14.5px;
}
.bubble.in { align-self: flex-start; background: var(--surface); border-start-start-radius: 4px; }
.bubble.out { align-self: flex-end; background: var(--bubble-out); border-start-end-radius: 4px; }
.bubble.auto { background: #f3f6f4; border: 1px dashed #b9cac2; color: var(--muted); box-shadow: none; }
.bubble .media { color: var(--text); font-weight: 500; }
.bubble .revoked { color: var(--muted); font-style: italic; display: inline-flex; align-items: center; gap: 6px; }
.bubble .revoked svg.i { width: 15px; height: 15px; }
.bubble .meta { display: flex; gap: 6px; justify-content: end; font-size: 11px; color: var(--faint); margin-top: 2px; }
.bubble .label { color: var(--accent); font-weight: 500; }
.reactions { position: absolute; bottom: -12px; inset-inline-end: 8px; background: var(--surface); border-radius: 999px; padding: 0 6px; font-size: 13px; box-shadow: var(--shadow-sm); border: 1px solid var(--hair); }
.bubble.has-reactions { margin-bottom: 12px; }
.chat-foot {
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 10px 14px; padding-bottom: max(10px, env(safe-area-inset-bottom));
  font-size: 12.5px; color: var(--muted); text-align: center;
}
/* The reply box (REPLIES=on). */
.composer { text-align: start; padding: 8px 12px; padding-bottom: max(8px, env(safe-area-inset-bottom)); display: grid; gap: 6px; }
.reply-status { font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.reply-status:empty { display: none; }
.reply-status.warn { color: var(--warn); font-weight: 500; }
.reply-status.bad { color: var(--bad); font-weight: 500; }
.composer[data-mode="off"] .reply-status, .composer[data-mode="closed"] .reply-status { text-align: center; }
.reply-row { display: flex; align-items: flex-end; gap: 8px; }
.reply-row[hidden] { display: none; }
.reply-text {
  flex: 1; min-width: 0; resize: none; font: inherit; font-size: 15px; line-height: 1.5; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 20px; padding: 9px 14px;
  max-height: 168px; overflow-y: auto;
}
.reply-text:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); background: var(--surface); }
.reply-text:disabled { opacity: 0.6; cursor: not-allowed; }
.reply-send {
  flex: none; width: 44px; height: 44px; border-radius: 50%; border: 0; display: grid; place-items: center;
  background: var(--accent); color: #fff; cursor: pointer; transition: background-color 0.15s ease, opacity 0.15s ease;
}
.reply-send:hover { background: var(--accent-strong); }
.reply-send:focus-visible { outline: 3px solid var(--accent-ring); outline-offset: 2px; }
.reply-send:disabled { opacity: 0.45; cursor: default; }
.reply-send svg.i { width: 20px; height: 20px; }
/* The arrow points the way the text runs. */
[dir="rtl"] .reply-send svg.i { transform: scaleX(-1); }
.composer[data-sending="1"] .reply-send { opacity: 0.6; }

/* Files in the chat. */
.bubble.has-media { padding: 4px 4px 4px; }
.bubble.has-media .meta, .bubble.has-media .caption { padding: 0 7px; }
.bubble .caption { margin-top: 4px; }
.media-open { display: block; padding: 0; border: 0; background: none; cursor: zoom-in; border-radius: 9px; overflow: hidden; }
.media-open img { display: block; max-width: min(280px, 100%); max-height: 340px; min-width: 120px; min-height: 90px; object-fit: cover; background: var(--hair); }
.media-open.sticker { background: none; }
.media-open.sticker img { max-width: 140px; max-height: 140px; min-width: 0; min-height: 0; background: none; object-fit: contain; }
.media-open:focus-visible { outline: 3px solid var(--accent-ring); outline-offset: 2px; }
.media-audio { display: grid; gap: 2px; padding: 4px 4px 0; }
.media-audio audio { width: min(280px, 64vw); height: 40px; }
.media-dl { font-size: 12px; color: var(--accent); justify-self: start; padding: 0 6px; }
.media-video { display: block; max-width: min(320px, 100%); max-height: 360px; border-radius: 9px; background: #000; }
.media-file {
  display: flex; align-items: center; gap: 9px; padding: 9px 11px; border-radius: 9px; min-height: 44px;
  background: rgb(15 59 53 / 6%); color: var(--text); text-decoration: none; max-width: 300px;
}
.media-file:hover { background: rgb(15 59 53 / 10%); }
.media-file .name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.media-file .size { margin-inline-start: auto; color: var(--muted); font-size: 12px; flex: none; }
.media-file svg.i { flex: none; width: 18px; height: 18px; color: var(--accent); }
.media-note { font-size: 12px; color: var(--muted); }
.media-note.pending { color: var(--accent); }
.bubble .meta .by { color: var(--accent); font-weight: 500; }
.tick { display: inline-flex; align-items: center; color: var(--faint); }
.tick svg.i { width: 15px; height: 15px; }
.tick.read { color: #0ea5e9; }
.tick.failed { color: var(--bad); font-weight: 500; }
.viewer {
  position: fixed; inset: 0; z-index: 50; background: rgb(6 20 17 / 88%);
  display: grid; grid-template-rows: minmax(0, 1fr) auto; place-items: center; padding: 16px; gap: 12px;
}
.viewer img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; }
.viewer-bar { display: flex; gap: 10px; padding-bottom: env(safe-area-inset-bottom); }

.wait-banner { background: var(--warn-soft); color: var(--warn); text-align: center; font-size: 13.5px; padding: 6px 10px; font-weight: 500; border-bottom: 1px solid rgb(194 65 12 / 12%); }
.wait-banner.late { background: var(--bad-soft); color: var(--bad); border-bottom-color: rgb(185 28 28 / 12%); }

/* ---------------------------------------------------------------- bottom navigation (phones) */

.bottom-nav {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 4px 2px env(safe-area-inset-bottom);
}
.bottom-nav a {
  display: grid; justify-items: center; align-content: center; gap: 2px; min-height: 56px; padding: 5px 2px 6px;
  text-decoration: none; color: var(--muted); font-size: 11.5px; position: relative; white-space: nowrap;
}
.bottom-nav a span:not(.badge) { overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.bottom-nav svg.i { width: 22px; height: 22px; padding: 4px 14px; box-sizing: content-box; border-radius: 999px; transition: background-color 0.15s, color 0.15s; }
.bottom-nav a[aria-current="page"] { color: var(--accent-strong); font-weight: 600; }
.bottom-nav a[aria-current="page"] svg.i { background: var(--accent-soft); color: var(--accent); }
.bottom-nav .badge { position: absolute; top: 2px; inset-inline-start: calc(50% + 7px); min-width: 19px; height: 18px; font-size: 11px; box-shadow: 0 0 0 2px var(--surface); }

/* Phones: one column. The list views show the list, everything else shows the content area. */
@media (max-width: 959px) {
  .list-head { padding: 0; border-bottom: 1px solid var(--border); }
  .list-title, .tabs { display: none; }
  .pages { padding: 9px 12px; }
  body[data-view="live"] .content, body[data-view="waiting"] .content { display: none; }
  body:not([data-view="live"]):not([data-view="waiting"]) .sidebar { display: none; }
  body[data-view="c"] .bottom-nav, body[data-view="r"] .bottom-nav, body[data-view="g"] .bottom-nav { display: none; }
  body[data-view="c"] .list-head, body[data-view="r"] .list-head, body[data-view="g"] .list-head { display: none; }
  body[data-view="c"] .topbar, body[data-view="g"] .topbar { display: none; }
  body[data-view="c"] .chat-head, body[data-view="g"] .chat-head { padding-top: max(9px, env(safe-area-inset-top)); }
  body[data-view="c"] .content, body[data-view="g"] .content { overflow: hidden; }
  .conv-list { padding: 4px 6px; }
}
@media (max-width: 359px) {
  .topbar .live-text { display: none; }
}

/* Wide screens: side rail, the list beside it, the details in the rest. */
@media (min-width: 960px) {
  .app-body {
    grid-template-columns: var(--rail-w) var(--list-w) minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: "rail lhead main" "rail side main";
  }
  .topbar, .bottom-nav { display: none; }
  .rail { display: flex; }
  .app { display: contents; }
  .sidebar { grid-area: side; border-inline-end: 1px solid var(--border); }
  .content { grid-area: main; }
  .list-head { padding: 18px 16px 12px; border-inline-end: 1px solid var(--border); border-bottom: 1px solid var(--hair); }
  .content.chat-open { overflow: hidden; }
  .back.mobile-only { display: none; }
  .panel { padding: 26px 28px 40px; gap: 20px; }
  .panel-head h2 { font-size: 24px; }
  .chat-head { padding: 10px 18px; }
  .messages { padding: 18px 22px 24px; }

  /* Narrow desktops: the rail shows icons only, with the names kept for screen readers and as tooltips. */
  .rail { align-items: stretch; padding: 16px 10px; }
  .brand { justify-content: center; padding: 0; }
  .brand div, .rail .live-text, .me div { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .nav-label { font-size: 0; height: 1px; padding: 0; margin: 8px 12px; background: var(--rail-line); }
  .nav-label:first-child { display: none; }
  .rail-nav a { justify-content: center; padding: 10px; }
  .rail-nav a > span:not(.badge) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .rail-nav a[aria-current]::before { inset-inline-start: -10px; }
  .rail-nav .badge { position: absolute; top: 3px; inset-inline-start: 50%; margin: 0; min-width: 19px; height: 18px; font-size: 11px; box-shadow: 0 0 0 2px var(--rail); }
  .rail .live { justify-content: center; padding: 0; }
  .me { flex-direction: column; background: transparent; padding: 0; gap: 6px; }
  .me .logout { margin: 0; }
}
@media (min-width: 1280px) {
  :root { --rail-w: 244px; --list-w: 370px; }
  .rail { padding: 18px 12px; }
  .brand { justify-content: flex-start; padding: 0 6px; }
  .brand div, .rail .live-text, .me div, .rail-nav a > span:not(.badge) { position: static; width: auto; height: auto; overflow: visible; clip: auto; }
  .me div { overflow: hidden; }
  .nav-label { font-size: 11.5px; height: auto; padding: 0 12px; margin: 10px 0 4px; background: none; }
  .nav-label:first-child { display: block; margin-top: 0; }
  .rail-nav a { justify-content: flex-start; padding: 9px 12px; }
  .rail-nav a[aria-current]::before { inset-inline-start: -12px; }
  .rail-nav .badge { position: static; margin-inline-start: auto; min-width: 21px; height: 20px; font-size: 11.5px; box-shadow: none; }
  .rail .live { justify-content: flex-start; padding: 0 12px; }
  .me { flex-direction: row; background: var(--rail-active); padding: 9px 10px; gap: 10px; }
  .me .logout { margin-inline-start: auto; }
}
@media (min-width: 1600px) {
  :root { --list-w: 390px; }
}

/* KPI columns follow the width of the content area, not the window. */
@container (min-width: 600px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
  .kpi { padding: 16px 18px; gap: 6px 12px; }
  .kpi .v { font-size: 30px; }
  .kpi .ic { width: 42px; height: 42px; border-radius: 12px; }
  .kpi .ic svg.i { width: 20px; height: 20px; }
  .card-head, .card > h3, .card-body, .agent-head, .num-row, .report-list a { padding-inline: 18px; }
}
@container (min-width: 1120px) {
  .kpis { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

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