/* BeFree — design system and app styles.
   Tokens first (light + dark), then base elements, components, the app shell (sidebar on desktop,
   app bar + tab bar on phones), and each screen. Motion is subtle and turned off for people who
   ask their device for reduced motion. */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  color-scheme: light;
  /* Surfaces */
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --surface-3: #eef2f4;
  --border: #e3e8ec;
  --border-strong: #cfd7dd;
  /* Ink */
  --text: #0e1726;
  --text-2: #3c4a5c;
  --muted: #6a7788;
  /* Brand */
  --primary: #0b9467;
  --primary-hover: #087a55;
  --primary-ink: #ffffff;
  --primary-soft: #e4f6ee;
  --primary-soft-2: #c9eedd;
  --primary-text: #057049;
  --ring: rgba(11, 148, 103, .28);
  /* Status */
  --danger: #d9363e;
  --danger-soft: #fdecec;
  --warn: #a15c00;
  --warn-soft: #fff4dd;
  --info: #2a6ad9;
  --info-soft: #e8f0fd;
  --read: #1f8fe5;
  /* Chat */
  --chat-bg: #efeae2;
  --bubble-in: #ffffff;
  --bubble-out: #d9fdd3;
  --bubble-ink: #111b21;
  /* Shape & depth */
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 4px 12px rgba(16, 24, 40, .05);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .14), 0 2px 6px rgba(16, 24, 40, .06);
  /* Motion */
  --ease: cubic-bezier(.2, .8, .2, 1);
  --ease-spring: cubic-bezier(.34, 1.4, .64, 1);
  --t-fast: 140ms;
  --t: 240ms;
  --t-slow: 380ms;
  /* Layout */
  --sidebar-w: 248px;
  --appbar-h: 56px;
  --tabbar-h: 62px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  /* Legacy names (admin dashboard and older markup) */
  --panel: var(--surface);
  --line: var(--border);
  --accent: var(--primary);
  --accent-text: var(--primary-ink);
  --accent-soft: var(--primary-soft);
  --warn-bg: var(--warn-soft);
  --danger-bg: var(--danger-soft);
  --out: var(--bubble-out);
  --in: var(--bubble-in);
  --radius: var(--r);
  font-family: var(--font);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0b1014;
    --surface: #121a20;
    --surface-2: #161f26;
    --surface-3: #1c262e;
    --border: #232f38;
    --border-strong: #2f3d48;
    --text: #e9eef2;
    --text-2: #b9c4cd;
    --muted: #8796a3;
    --primary: #19b37f;
    --primary-hover: #22c78f;
    --primary-ink: #04130d;
    --primary-soft: #11291f;
    --primary-soft-2: #17392b;
    --primary-text: #4fd3a3;
    --ring: rgba(25, 179, 127, .35);
    --danger: #f0646a;
    --danger-soft: #3a1719;
    --warn: #f2b45a;
    --warn-soft: #33260f;
    --info: #6aa1ff;
    --info-soft: #14233d;
    --read: #53bdeb;
    --chat-bg: #0c1317;
    --bubble-in: #1f2c34;
    --bubble-out: #005c4b;
    --bubble-ink: #e9edef;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 1px 3px rgba(0, 0, 0, .45), 0 6px 16px rgba(0, 0, 0, .25);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, .55);
  }
}

/* ---------------------------------------------------------------- Base */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text); font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv11', 'ss01';
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, h4 { margin: 0; letter-spacing: -.015em; color: var(--text); }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 18px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 650; margin: 22px 0 10px; }
p { margin: 0 0 10px; }
a { color: var(--primary-text); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-3); padding: 2px 6px; border-radius: 6px; }
small, .small { font-size: 12px; }
.muted { color: var(--muted); }
.ok { color: var(--primary-text); font-weight: 600; }
.no { color: var(--muted); }
.bad { color: var(--danger); font-weight: 600; }
.spacer { flex: 1; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
::selection { background: var(--primary-soft-2); }

.ic { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ic.sm { width: 15px; height: 15px; }
.ic.lg { width: 22px; height: 22px; }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; border: 3px solid transparent; background-clip: padding-box; }

/* ---------------------------------------------------------------- Controls */
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--primary); color: var(--primary-ink); border: 1px solid transparent;
  border-radius: 10px; padding: 9px 16px; min-height: 38px;
  font: 600 13.5px/1 var(--font); letter-spacing: -.005em; cursor: pointer; white-space: nowrap;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast), transform var(--t-fast) var(--ease), box-shadow var(--t-fast);
  box-shadow: 0 1px 2px rgba(11, 148, 103, .25);
}
button:hover, .btn:hover { background: var(--primary-hover); text-decoration: none; }
button:active:not(:disabled), .btn:active { transform: scale(.97); }
button:focus-visible, .btn:focus-visible, a:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
button:disabled { opacity: .45; cursor: default; box-shadow: none; }
button.ghost, .btn.ghost, .btn-link {
  background: var(--surface); color: var(--text); border-color: var(--border); box-shadow: var(--shadow-sm); font-weight: 550;
}
button.ghost:hover, .btn-link:hover { background: var(--surface-2); border-color: var(--border-strong); }
button.small, .btn.small, .btn-link.small, a.small.btn-link { min-height: 32px; padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
button.danger, .btn.danger { color: var(--danger); }
button.ghost.danger:hover { background: var(--danger-soft); border-color: transparent; }
button.danger:not(.ghost) { background: var(--danger); color: #fff; }
button.icon-btn { padding: 0; width: 38px; min-height: 38px; background: transparent; color: var(--text-2); box-shadow: none; border: 0; border-radius: 10px; }
button.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.btn-link { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; border: 1px solid var(--border); border-radius: 10px; padding: 8px 14px; color: var(--text); font-weight: 550; }

input, select, textarea {
  font: 14px/1.4 var(--font); color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; width: 100%; min-height: 40px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
textarea { resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: var(--border-strong); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
input[type=checkbox] { width: 18px; height: 18px; min-height: 0; accent-color: var(--primary); }
input[type=file] { padding: 8px; background: var(--surface-2); border-style: dashed; }
input[readonly] { background: var(--surface-2); }
select { appearance: none; padding-right: 34px; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%236a7788' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m3 4.5 3 3 3-3'/%3E%3C/svg%3E") no-repeat right 12px center; }
input[type=search] { padding-left: 36px; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%236a7788' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='m14 14-3.2-3.2'/%3E%3C/svg%3E") no-repeat 12px center; }

/* Pills, badges, tags */
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 650; padding: 3px 9px; border-radius: 99px; background: var(--warn-soft); color: var(--warn); letter-spacing: .01em; }
.pill:empty { display: none; }
.pill.ok-pill { background: var(--primary-soft); color: var(--primary-text); }
.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--primary); color: var(--primary-ink); font-size: 11px; font-weight: 700; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 2px var(--surface); }
.tag { display: inline-flex; align-items: center; background: var(--surface-3); color: var(--text-2); border-radius: 99px; padding: 2px 9px; font-size: 11.5px; font-weight: 550; margin: 1px 3px 1px 0; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 650; padding: 3px 10px; border-radius: 99px; text-transform: capitalize; }
.status::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status.running { background: var(--primary-soft); color: var(--primary-text); }
.status.running::before { animation: pulse-dot 1.6s infinite; }
.status.paused { background: var(--warn-soft); color: var(--warn); }
.status.completed { background: var(--info-soft); color: var(--info); }
.status.cancelled { background: var(--surface-3); color: var(--muted); }
@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }

/* Cards, tiles, notes */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 16px 18px; margin-bottom: 12px; box-shadow: var(--shadow-sm); }
.card-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-top: 4px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 16px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden; }
.tile .label { color: var(--muted); font-size: 12.5px; font-weight: 550; }
.tile .value { font-size: 26px; font-weight: 750; margin-top: 6px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.tile .value.small-value { font-size: 17px; }
.meter { height: 6px; background: var(--surface-3); border-radius: 99px; overflow: hidden; margin: 10px 0 6px; }
.meter > div { height: 100%; background: linear-gradient(90deg, var(--primary), #33c48f); border-radius: 99px; transition: width var(--t-slow) var(--ease); }
.note { margin: 0 0 12px; padding: 12px 14px; background: var(--warn-soft); color: var(--warn); border-radius: var(--r); font-size: 13px; line-height: 1.55; border: 1px solid color-mix(in srgb, var(--warn) 18%, transparent); }
.note a { color: inherit; font-weight: 700; text-decoration: underline; }
.empty { margin: auto; color: var(--muted); text-align: center; padding: 30px; }

/* Tables */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; vertical-align: middle; }
.table th { font-size: 11.5px; color: var(--muted); font-weight: 650; text-transform: uppercase; letter-spacing: .04em; background: var(--surface-2); }
.table tbody tr { transition: background var(--t-fast); }
.table tbody tr:hover td { background: var(--surface-2); }
.table tr:last-child td { border-bottom: 0; }
.table td .ghost.small + .ghost.small { margin-left: 4px; }
.table select { width: auto; min-height: 32px; padding: 4px 30px 4px 10px; }
.pager { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
.row-actions { display: inline-flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* Forms in pages */
.settings { max-width: 760px; display: flex; flex-direction: column; gap: 14px; margin: 0 0 14px; }
fieldset { border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 14px; margin: 0; box-shadow: var(--shadow-sm); min-width: 0; }
legend { font-weight: 700; font-size: 14.5px; padding: 0 8px; margin-left: -8px; display: flex; align-items: center; gap: 8px; }
.settings label, .dlg label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 550; color: var(--text-2); }
.settings label small, .dlg label small { font-weight: 400; }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; flex-wrap: wrap; }
.actions.left { justify-content: flex-start; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { font: 12.5px ui-monospace, SFMono-Regular, Menlo, monospace; }
.reg-box { border: 1px dashed var(--border-strong); border-radius: var(--r); padding: 14px; display: flex; flex-direction: column; gap: 8px; background: var(--surface-2); }
.reg-box p { margin: 0; }
.reg-row { display: flex; gap: 8px; flex-wrap: wrap; }
.reg-row input { flex: 1 1 220px; width: auto; }
label.check { flex-direction: row !important; align-items: flex-start; gap: 10px !important; font-weight: 450 !important; color: var(--text) !important; }
label.check input { margin-top: 2px; }
.check-row { flex-direction: row !important; align-items: center; gap: 10px !important; }
.check-row input { width: auto; }

/* Dialogs (sheets on phones) */
dialog {
  border: 1px solid var(--border); border-radius: var(--r-xl); padding: 0; background: var(--surface); color: var(--text);
  width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); box-shadow: var(--shadow-lg); overflow: auto;
}
dialog[open] { animation: dialog-in var(--t) var(--ease); }
dialog::backdrop { background: rgba(10, 16, 22, .48); backdrop-filter: blur(3px); animation: fade-in var(--t) var(--ease); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }
@keyframes fade-in { from { opacity: 0; } }
.dlg { padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.dlg h3 { margin: 0; font-size: 18px; font-weight: 700; }
.dlg p { margin: 0; }
.template-body { background: var(--chat-bg); border-radius: var(--r); padding: 12px; white-space: pre-wrap; font-size: 13.5px; }
#cBody, #tBody, .camp-body { background: var(--bubble-out); color: var(--bubble-ink); border-radius: 12px 12px 12px 4px; box-shadow: var(--shadow-sm); }
.template-body:empty { display: none; }
.audience { font-weight: 650; margin: 0; padding: 10px 12px; background: var(--primary-soft); color: var(--primary-text); border-radius: var(--r); font-size: 13px; }
.audience:empty { display: none; }
.install-steps { line-height: 1.8; padding-left: 20px; margin: 0; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 80;
  display: flex; align-items: center; gap: 10px; max-width: min(520px, calc(100vw - 32px));
  background: #0f1720; color: #f2f6f8; padding: 12px 16px; border-radius: 14px; font-weight: 550; font-size: 13.5px;
  box-shadow: var(--shadow-lg); animation: toast-in var(--t) var(--ease-spring);
}
.toast::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #34d399; flex: none; }
.toast.error::before { background: #f87171; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 14px) scale(.96); } }

/* ---------------------------------------------------------------- App shell */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; height: 100dvh; }
.sidebar {
  background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column;
  padding: 16px 12px; gap: 12px; min-height: 0; z-index: 5;
}
.sb-brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 6px; font-weight: 800; font-size: 17px; letter-spacing: -.02em; }
.sb-brand img { width: 30px; height: 30px; border-radius: 9px; box-shadow: var(--shadow-sm); }
.sb-brand .pill { margin-left: auto; font-size: 10px; padding: 2px 7px; }
.ws-switch {
  justify-content: flex-start; width: 100%; background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  box-shadow: none; padding: 10px 32px 10px 12px; font-weight: 650; border-radius: 12px; overflow: hidden; text-overflow: ellipsis; position: relative; display: block; text-align: left;
}
.ws-switch:hover { background: var(--surface-3); }
.ws-switch::after {
  content: ''; position: absolute; right: 12px; top: 50%; width: 14px; height: 14px; margin-top: -7px; opacity: .6;
  background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='m7 15 5 5 5-5M7 9l5-5 5 5'/%3E%3C/svg%3E") center/contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='m7 15 5 5 5-5M7 9l5-5 5 5'/%3E%3C/svg%3E") center/contain no-repeat;
}
.ws-label { font-size: 10.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 0 8px; margin-bottom: -6px; }
.sb-nav { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.sb-nav button, .tabbar button {
  background: transparent; color: var(--text-2); box-shadow: none; border: 0; justify-content: flex-start;
  font-weight: 550; padding: 9px 12px; border-radius: 10px; position: relative; gap: 12px; font-size: 14px;
}
.sb-nav button:hover { background: var(--surface-3); color: var(--text); }
.sb-nav button.active { background: var(--primary-soft); color: var(--primary-text); font-weight: 650; }
.sb-nav button.active .ic { stroke-width: 2.3; }
.sb-nav .badge, .sb-nav .dot { margin-left: auto; }
.sb-foot { margin-top: auto; border-top: 1px solid var(--border); padding-top: 12px; }
.user-chip { width: 100%; justify-content: flex-start; background: transparent; color: var(--text); border: 0; box-shadow: none; padding: 8px; gap: 10px; border-radius: 12px; font-weight: 600; text-align: left; }
.user-chip:hover { background: var(--surface-3); }
.user-chip .u-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; flex: 1; }
.user-chip .u-text small { color: var(--muted); font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.user-chip .u-text b { overflow: hidden; text-overflow: ellipsis; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-weight: 700; font-size: 13px; color: #fff; background: var(--av, var(--primary)); letter-spacing: .02em;
}
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.avatar.lg { width: 44px; height: 44px; font-size: 15px; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
.alert, .setup, .impersonation, .announcement {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 20px; font-size: 13.5px; font-weight: 550;
  border-bottom: 1px solid var(--border); animation: slide-down var(--t) var(--ease);
}
.alert { background: var(--danger-soft); color: var(--danger); }
.setup { background: var(--warn-soft); color: var(--warn); }
.impersonation { background: #5b3cc4; color: #fff; }
.impersonation button { background: #fff; color: #5b3cc4; min-height: 30px; }
.announcement { background: var(--info-soft); color: var(--info); justify-content: space-between; }
.announcement.warning { background: var(--warn-soft); color: var(--warn); }
.announcement button { background: transparent; color: inherit; box-shadow: none; border: 0; }
.alert a, .setup a, .announcement a { color: inherit; font-weight: 700; text-decoration: underline; }
@keyframes slide-down { from { opacity: 0; transform: translateY(-6px); } }
.billing-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 20px; font-size: 13.5px; font-weight: 550;
  border-bottom: 1px solid var(--border); animation: slide-down var(--t) var(--ease); background: var(--info-soft); color: var(--info);
}
.billing-bar.warn { background: var(--warn-soft); color: var(--warn); }
.billing-bar.bad { background: var(--danger-soft); color: var(--danger); }
.billing-bar .spacer { flex: 1; }
.billing-bar button { min-height: 30px; padding: 5px 12px; font-size: 13px; }

/* ---------------------------------------------------------------- Call history */
.badge.danger { background: var(--danger); color: #fff; }
.call-card-list { padding: 0; overflow: hidden; }
.call-list { list-style: none; margin: 0; padding: 0; }
.call-list .day-sep { margin: 0; padding: 10px 18px 6px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--border); text-align: left; }
.call-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 4px 14px;
  padding: 12px 18px; border-bottom: 1px solid var(--border); animation: rise var(--t) var(--ease) both;
}
.call-row:last-child { border-bottom: 0; }
.call-row:hover { background: var(--surface-2); }
.call-row .cr-who { min-width: 0; cursor: pointer; }
.call-row .cr-name { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.call-row.missed .cr-name { color: var(--danger); }
.call-row .cr-sub { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.call-row .cr-sub .ic { width: 15px; height: 15px; flex: none; }
.call-row .cr-sub .in { color: var(--primary); } .call-row .cr-sub .out { color: var(--info); } .call-row.missed .cr-sub .ic { color: var(--danger); }
.call-row .cr-time { color: var(--muted); font-size: 12.5px; text-align: right; font-variant-numeric: tabular-nums; }
.call-row .cr-actions { display: flex; gap: 4px; }
.call-row .cr-actions .icon-btn { width: 38px; height: 38px; }
.call-row .cr-actions .call-back { color: var(--primary); }
.call-list .empty-li { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding: 48px 20px; color: var(--muted); }
.call-list .empty-li b { color: var(--text); }
@media (max-width: 900px) {
  .call-card-list { border-radius: 0; border-left: 0; border-right: 0; margin: 0 -14px; box-shadow: none; }
  .call-row { grid-template-columns: auto minmax(0, 1fr) auto; padding: 11px 16px; }
  .call-row .cr-time { grid-column: 3; grid-row: 1; align-self: end; }
  .call-row .cr-actions { grid-column: 3; grid-row: 2; justify-content: flex-end; }
  .call-row .cr-actions .chat-btn { display: none; }
  .call-row .avatar, .call-row .cr-who { grid-row: span 2; }
}

/* ---------------------------------------------------------------- Billing */
.bill-current { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 24px; padding: 22px; margin-bottom: 26px; }
.bill-current .bc-plan { display: flex; flex-direction: column; gap: 6px; }
.bill-current .bc-kicker { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.bill-current .bc-name { font-size: 30px; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; }
.bill-current .bc-sub { color: var(--text-2); font-size: 14px; }
.bill-current .bc-actions { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }
.bill-pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; text-transform: none; letter-spacing: 0; }
.bill-pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.bill-pill.active, .bill-pill.exempt { background: var(--primary-soft); color: var(--primary-text); }
.bill-pill.trial { background: var(--info-soft); color: var(--info); }
.bill-pill.grace { background: var(--warn-soft); color: var(--warn); }
.bill-pill.expired { background: var(--danger-soft); color: var(--danger); }
.meters { display: flex; flex-direction: column; gap: 14px; justify-content: center; }
.meter-row { display: grid; gap: 6px; }
.meter-row .mr-top { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.meter-row .mr-top span:first-child { color: var(--text-2); font-weight: 600; }
.meter-row .mr-top span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; }
.meter-row .bar { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.meter-row .bar i { display: block; height: 100%; border-radius: inherit; background: var(--primary); width: 0; transition: width .8s var(--ease); }
.meter-row.high .bar i { background: var(--warn); }
.meter-row.full .bar i { background: var(--danger); }
.bill-plans-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.bill-plans-head h3 { margin: 0; }
.save-tag { margin-left: 6px; padding: 1px 7px; border-radius: 99px; font-size: 11px; background: var(--primary-soft); color: var(--primary-text); font-weight: 700; }
.plans { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.plan {
  position: relative; display: flex; flex-direction: column; gap: 14px; padding: 22px; border-radius: var(--r-xl);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  transition: transform var(--t) var(--ease), box-shadow var(--t) var(--ease), border-color var(--t) var(--ease);
  animation: rise var(--t-slow) var(--ease) both;
}
.plan:nth-child(2) { animation-delay: 60ms; } .plan:nth-child(3) { animation-delay: 120ms; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
.plan:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.plan.featured { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary), var(--shadow); }
.plan.current { border-color: var(--primary-soft-2); }
.plan .p-badge { position: absolute; top: -11px; left: 22px; padding: 3px 10px; border-radius: 99px; background: var(--primary); color: var(--primary-ink); font-size: 11.5px; font-weight: 700; }
.plan .p-name { font-size: 17px; font-weight: 750; }
.plan .p-desc { color: var(--muted); font-size: 13px; margin-top: -8px; min-height: 2.6em; }
.plan .p-price { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.plan .p-price b { font-size: 30px; font-weight: 800; letter-spacing: -.03em; }
.plan .p-price span { color: var(--muted); font-size: 13px; }
.plan .p-approx { color: var(--muted); font-size: 12px; margin-top: -10px; min-height: 1.3em; }
.plan ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 9px; font-size: 13.5px; color: var(--text-2); flex: 1; }
.plan li { display: flex; gap: 9px; align-items: flex-start; }
.plan li .ic { width: 16px; height: 16px; color: var(--primary); flex: none; margin-top: 2px; }
.plan li.off { color: var(--muted); } .plan li.off .ic { color: var(--muted); opacity: .6; }
.plan button { width: 100%; min-height: 42px; }
.bill-meta { margin: 14px 0 26px; }
.pay-dlg { width: min(460px, calc(100vw - 24px)); }
.pay-sum { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px; border-radius: var(--r-lg); background: var(--surface-2); border: 1px solid var(--border); }
.pay-sum b { font-size: 20px; letter-spacing: -.02em; }
.pay-sum small { display: block; color: var(--muted); }
.pay-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pay-tabs button { background: var(--surface); color: var(--text-2); border: 1.5px solid var(--border); box-shadow: none; min-height: 52px; gap: 8px; }
.pay-tabs button.active { border-color: var(--primary); color: var(--primary-text); background: var(--primary-soft); }
.ops { display: flex; gap: 8px; flex-wrap: wrap; }
.ops label { display: block; cursor: pointer; }
.ops input { position: absolute; opacity: 0; pointer-events: none; }
.ops span { display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 12px; border: 1.5px solid var(--border); font-weight: 600; font-size: 13.5px; color: var(--text-2); transition: all var(--t-fast); }
.ops input:checked + span { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-text); }
.ops input:focus-visible + span { box-shadow: 0 0 0 3px var(--ring); }
.op-dot { width: 10px; height: 10px; border-radius: 50%; }
.phone-row { display: flex; align-items: stretch; }
.phone-row .dial { display: flex; align-items: center; padding: 0 12px; border: 1px solid var(--border); border-right: 0; border-radius: var(--r) 0 0 var(--r); background: var(--surface-2); color: var(--text-2); font-weight: 600; }
.phone-row input { border-radius: 0 var(--r) var(--r) 0; }
.pay-wait { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; padding: 18px 6px 6px; }
.pay-wait h3 { margin: 0; }
.pay-wait p { margin: 0; color: var(--text-2); max-width: 340px; }
.pay-spinner { width: 64px; height: 64px; border-radius: 50%; border: 5px solid var(--primary-soft); border-top-color: var(--primary); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.pay-done { width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; background: var(--primary); color: #fff; animation: pop-in var(--t-slow) var(--ease-spring); }
.pay-done.bad { background: var(--danger); }
.pay-done .ic { width: 36px; height: 36px; stroke-width: 2.5; }
.pay-note { font-size: 12.5px; color: var(--muted); }
@media (max-width: 1100px) { .plans { grid-template-columns: 1fr; max-width: 520px; } }
@media (max-width: 900px) { .bill-current { grid-template-columns: 1fr; padding: 18px; } .bill-current .bc-name { font-size: 26px; } .pay-dlg { width: 100%; } }

.appbar, .tabbar { display: none; }
main.content { flex: 1; min-height: 0; position: relative; }
.page { display: none; height: 100%; overflow: auto; padding: 26px 32px 40px; }
.page.active { display: block; animation: page-in var(--t) var(--ease); }
@keyframes page-in { from { opacity: 0; transform: translateY(6px); } }
.page-head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .ph-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.page-head p { margin: 0; color: var(--muted); font-size: 13.5px; max-width: 720px; }
.page-head .ph-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar input, .toolbar select { width: auto; min-width: 170px; flex: 0 1 240px; }
.toolbar h2 { margin-right: 4px; }

/* Account / team menu (popover on desktop, bottom sheet on phones) */
.user-menu { position: static; }
.pop {
  position: fixed; left: 12px; bottom: 76px; width: 300px; z-index: 50; max-height: calc(100dvh - 100px); overflow: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); padding: 8px;
  display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow-lg); animation: pop-in var(--t) var(--ease-spring);
}
.pop.from-top { bottom: auto; top: 112px; }
@keyframes pop-in { from { opacity: 0; transform: translateY(8px) scale(.97); } }
.pop-head { display: flex; flex-direction: column; padding: 10px 12px 12px; border-bottom: 1px solid var(--border); margin-bottom: 4px; overflow-wrap: anywhere; }
.pop-head b { font-size: 15px; }
.pop-section { display: flex; flex-direction: column; gap: 2px; border-bottom: 1px solid var(--border); padding: 4px 0 8px; margin-bottom: 4px; }
.pop-section > small { padding: 6px 12px 4px; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; font-size: 10.5px; }
.pop button, .pop .btn-link {
  justify-content: flex-start; background: transparent; color: var(--text); box-shadow: none; border: 0; font-weight: 550;
  padding: 9px 12px; min-height: 38px; border-radius: 10px; width: 100%; text-align: left; font-size: 13.5px; gap: 10px;
}
.pop button:hover, .pop .btn-link:hover { background: var(--surface-3); text-decoration: none; }
.pop button.danger, .pop button.danger:not(.ghost) { color: var(--danger); background: transparent; }
.pop button.danger:hover { background: var(--danger-soft); }
.pop .sheet-only { display: none; }
.lang-row { display: flex; align-items: center; gap: 10px; padding: 4px 6px 4px 12px; min-height: 42px; font-weight: 550; font-size: 13.5px; color: var(--text); }
.lang-row > span:first-of-type { flex: 1; }
.lang-select { width: auto; min-height: 34px; padding: 4px 30px 4px 10px; font-size: 13.5px; }
.team-item { display: flex; justify-content: space-between; gap: 8px; }
.team-item small { margin-left: auto; }
.team-item.current { color: var(--primary-text) !important; font-weight: 700 !important; }

/* ---------------------------------------------------------------- Inbox */
#page-inbox { padding: 0; overflow: hidden; }
.inbox { display: grid; grid-template-columns: 360px 1fr; height: 100%; }
.convs { border-right: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.convs-head { padding: 18px 16px 12px; display: flex; flex-direction: column; gap: 12px; border-bottom: 1px solid var(--border); }
.convs-title { display: flex; align-items: baseline; gap: 8px; }
.convs-title h1 { font-size: 21px; }
.convs-head .row { display: flex; gap: 8px; }
#convList { list-style: none; margin: 0; padding: 6px; overflow-y: auto; flex: 1; }
#convList li {
  display: grid; grid-template-columns: auto 1fr auto; grid-template-rows: auto auto; column-gap: 12px; row-gap: 2px; align-items: center;
  padding: 11px 10px; border-radius: 12px; cursor: pointer; transition: background var(--t-fast);
}
#convList li .avatar { grid-row: span 2; }
#convList li:hover { background: var(--surface-2); }
#convList li.sel { background: var(--primary-soft); }
#convList li.empty-li { display: flex; flex-direction: column; align-items: center; gap: 10px; cursor: default; text-align: center; padding: 48px 20px; color: var(--muted); }
#convList li.empty-li:hover { background: transparent; }
.c-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c-time { color: var(--muted); font-size: 11.5px; justify-self: end; font-variant-numeric: tabular-nums; }
.c-last { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 4px; min-width: 0; }
.c-last .ic { width: 14px; height: 14px; }
.c-last .txt { overflow: hidden; text-overflow: ellipsis; }
.c-meta { display: flex; align-items: center; gap: 6px; justify-self: end; }
li.unread .c-name { font-weight: 750; }
li.unread .c-time { color: var(--primary-text); font-weight: 650; }
li.unread .c-last { color: var(--text-2); }
.win-dot { width: 8px; height: 8px; border-radius: 50%; background: #25d366; box-shadow: 0 0 0 3px color-mix(in srgb, #25d366 22%, transparent); }
.skel { background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 37%, var(--surface-3) 63%); background-size: 400% 100%; animation: shimmer 1.3s infinite; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.skel-row { display: grid; grid-template-columns: 40px 1fr; gap: 12px; padding: 12px 10px; align-items: center; }
.skel-row .skel.circle { width: 40px; height: 40px; border-radius: 50%; }
.skel-row .lines { display: flex; flex-direction: column; gap: 8px; }
.skel-row .lines .skel { height: 10px; }

.thread { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--chat-bg); position: relative; }
.thread::before {
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background-image: radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--text) 9%, transparent) 1px, transparent 0);
  background-size: 22px 22px;
}
.thread > * { position: relative; }
.empty-state { margin: auto; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; padding: 30px; max-width: 380px; }
.empty-state .es-icon { width: 72px; height: 72px; border-radius: 22px; display: grid; place-items: center; background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }
.empty-state .es-icon .ic { width: 32px; height: 32px; stroke-width: 1.8; }
.empty-state h2 { font-size: 18px; }
.empty-state p { color: var(--muted); margin: 0; }
.t-head { display: flex; align-items: center; gap: 12px; padding: 10px 16px; min-height: 64px; background: var(--surface); border-bottom: 1px solid var(--border); }
.t-head .back { display: none; }
.t-who { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.t-title { font-weight: 700; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-sub { color: var(--muted); font-size: 12.5px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.t-window { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 99px; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.t-window.open { background: var(--primary-soft); color: var(--primary-text); }
.t-window.open::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: #25d366; }
.t-msgs { flex: 1; overflow-y: auto; padding: 18px 6% 12px; display: flex; flex-direction: column; gap: 3px; }
.day-sep { align-self: center; margin: 12px 0 8px; padding: 5px 12px; border-radius: 10px; background: var(--surface); color: var(--muted); font-size: 11px; font-weight: 650; box-shadow: var(--shadow-sm); text-transform: uppercase; letter-spacing: .05em; }
.msg {
  max-width: min(72%, 560px); padding: 7px 10px 6px; border-radius: 12px; color: var(--bubble-ink);
  box-shadow: 0 1px .5px rgba(11, 20, 26, .13); position: relative; line-height: 1.45; font-size: 14.2px;
}
.msg.in { background: var(--bubble-in); align-self: flex-start; border-top-left-radius: 4px; }
.msg.out { background: var(--bubble-out); align-self: flex-end; border-top-right-radius: 4px; }
.msg.first { margin-top: 8px; }
.msg.new { animation: msg-in var(--t) var(--ease-spring); }
.msg.out.new { transform-origin: bottom right; }
.msg.in.new { transform-origin: bottom left; }
@keyframes msg-in { from { opacity: 0; transform: translateY(8px) scale(.96); } }
.msg.template { border-left: 3px solid var(--primary); }
.msg.call .body { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.msg.call .body .ic { color: var(--primary-text); }
.msg.call.missed .body .ic { color: var(--danger); }
.msg .body { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg .meta { font-size: 11px; color: color-mix(in srgb, var(--bubble-ink) 55%, transparent); text-align: right; margin-top: 2px; display: flex; align-items: center; justify-content: flex-end; gap: 4px; }
.msg .meta .ic { width: 16px; height: 16px; }
.msg .meta .read { color: var(--read); }
.msg .meta .failed { color: var(--danger); }
.msg .err { color: var(--danger); font-size: 11.5px; margin-top: 2px; }
.msg.has-media { padding: 4px; }
.msg.has-media .body { padding: 5px 6px 0; }
.msg.has-media .meta { padding: 0 6px 2px; }
.msg .media { display: block; max-width: min(330px, 100%); max-height: 380px; border-radius: 9px; background: var(--surface-3); }
.msg .media.sticker { max-width: 150px; background: none; }
.msg audio { display: block; width: 270px; max-width: 100%; margin: 4px 0; height: 40px; }
.msg.has-media:has(audio) { width: min(290px, 78%); }
.media-note { padding: 8px 10px; color: var(--muted); font-style: italic; }
.file { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 9px; background: color-mix(in srgb, var(--bubble-ink) 6%, transparent); color: inherit; text-decoration: none; min-width: 220px; max-width: 330px; }
.file:hover { text-decoration: none; background: color-mix(in srgb, var(--bubble-ink) 10%, transparent); }
.file-info { display: flex; flex-direction: column; min-width: 0; }
.file-info b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-info small { color: var(--muted); }
.file-icon { flex: none; width: 42px; height: 42px; border-radius: 10px; background: var(--primary); color: var(--primary-ink); display: grid; place-items: center; font-size: 10px; font-weight: 800; letter-spacing: .02em; }
.closed { padding: 10px 18px; background: var(--warn-soft); color: var(--warn); font-size: 12.5px; text-align: center; border-top: 1px solid var(--border); }
.attach-preview { display: flex; gap: 8px; padding: 10px 14px 0; background: var(--surface); border-top: 1px solid var(--border); overflow-x: auto; }
.chip { display: flex; align-items: center; gap: 8px; padding: 6px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); flex: none; max-width: 260px; animation: dialog-in var(--t) var(--ease); }
.chip img { width: 42px; height: 42px; object-fit: cover; border-radius: 8px; }
.chip-name { display: flex; flex-direction: column; font-size: 12px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-name small { color: var(--muted); }
.chip-progress { font-size: 11px; color: var(--primary-text); font-weight: 700; }
.chip button { min-height: 28px; width: 28px; padding: 0; }
.composer {
  display: flex; gap: 6px; align-items: flex-end; padding: 10px 14px; background: var(--surface); border-top: 1px solid var(--border);
}
.attach-preview + .composer { border-top: 0; }
.composer .attach { width: 40px; min-height: 40px; padding: 0; border-radius: 50%; background: transparent; color: var(--text-2); box-shadow: none; border: 0; }
.composer .attach:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.composer textarea {
  flex: 1; resize: none; max-height: 140px; min-height: 42px; border-radius: 22px; padding: 10px 16px; background: var(--surface-2);
  border-color: transparent; line-height: 1.4;
}
.composer textarea:focus { background: var(--surface); }
.composer button[type=submit] { width: 42px; min-height: 42px; padding: 0; border-radius: 50%; box-shadow: var(--shadow); }
.thread.dropping::after { content: 'Drop files to attach'; position: absolute; inset: 12px; border: 2px dashed var(--primary); border-radius: var(--r-lg); display: grid; place-items: center; background: color-mix(in srgb, var(--primary-soft) 85%, transparent); color: var(--primary-text); font-weight: 700; font-size: 16px; z-index: 5; }

/* Voice recording */
.rec-bar { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--surface); border-top: 1px solid var(--border); animation: slide-up var(--t) var(--ease); }
.rec-bar #recSend { border-radius: 22px; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: pulse-dot 1s infinite; }
.rec-time { font-variant-numeric: tabular-nums; font-weight: 700; min-width: 40px; }
.rec-level { flex: 1; height: 6px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.rec-level > div { height: 100%; width: 0; background: var(--primary); transition: width .08s; border-radius: 99px; }
@keyframes slide-up { from { opacity: 0; transform: translateY(8px); } }

/* Calls */
.call-overlay { position: fixed; inset: 0; z-index: 70; background: rgba(6, 12, 10, .62); display: flex; align-items: center; justify-content: center; padding: 16px; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); animation: fade-in var(--t) var(--ease); }
.call-card { background: linear-gradient(160deg, #0f2a20, #0b1a15); color: #eaf7f1; border: 1px solid rgba(255, 255, 255, .08); border-radius: 28px; padding: 34px 26px 28px; width: min(360px, 100%); text-align: center; box-shadow: var(--shadow-lg); animation: dialog-in var(--t-slow) var(--ease-spring); }
.call-avatar { width: 96px; height: 96px; border-radius: 50%; margin: 0 auto 16px; background: rgba(255, 255, 255, .1); color: #fff; display: grid; place-items: center; font-size: 34px; font-weight: 750; }
.call-card.ringing .call-avatar { animation: ring 1.5s infinite; }
@keyframes ring { 0% { box-shadow: 0 0 0 0 rgba(37, 211, 102, .55); } 75% { box-shadow: 0 0 0 26px rgba(37, 211, 102, 0); } 100% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0); } }
.call-name { font-size: 22px; font-weight: 750; overflow-wrap: anywhere; }
.call-state { color: rgba(234, 247, 241, .65); margin: 6px 0 28px; font-variant-numeric: tabular-nums; }
.call-actions { display: flex; justify-content: center; gap: 30px; flex-wrap: wrap; }
.call-btn { width: 64px; height: 64px; border-radius: 50%; padding: 0; display: grid; place-items: center; border: 0; }
.call-btn .ic { width: 26px; height: 26px; }
.call-btn.answer { background: #25d366; color: #05200f; animation: wiggle 1.2s infinite; }
.call-btn.hangup { background: #ef4444; color: #fff; }
.call-btn.hangup .ic { transform: rotate(135deg); }
.call-btn.mute { background: rgba(255, 255, 255, .12); color: #fff; }
.call-btn.mute.on { background: #fff; color: #0b1a15; }
.call-btn-label { display: block; font-size: 12px; color: rgba(234, 247, 241, .7); margin-top: 8px; }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 10%, 30% { transform: rotate(-10deg); } 20%, 40% { transform: rotate(10deg); } 50% { transform: rotate(0); } }

/* ---------------------------------------------------------------- Contacts, campaigns, team, health */
.stats { display: flex; gap: 18px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.stats b { color: var(--text); font-size: 15px; font-weight: 700; margin-right: 3px; font-variant-numeric: tabular-nums; }
.progress { height: 8px; background: var(--surface-3); border-radius: 99px; overflow: hidden; margin: 14px 0 10px; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--primary), #33c48f); border-radius: 99px; transition: width var(--t-slow) var(--ease); }
.clickable-card { cursor: pointer; transition: border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast) var(--ease); }
.clickable-card:hover { border-color: var(--primary-soft-2); box-shadow: var(--shadow); transform: translateY(-1px); }
.camp-title { font-size: 15.5px; font-weight: 700; }
.camp-sub { flex-basis: 100%; }
.stats-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 14px; }
.tile-btn { text-align: left; font: inherit; color: var(--text); cursor: pointer; display: block; width: 100%; padding: 16px; min-height: 0; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm); white-space: normal; }
.tile-btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.tile-btn.active { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 3px var(--ring); }
.camp-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; margin-bottom: 8px; }
.camp-cols .card { margin: 0; }
.camp-cols .card > b { display: block; margin-bottom: 10px; }
.reasons td { white-space: normal; vertical-align: top; }
.reasons td.num { font-weight: 750; text-align: right; font-size: 16px; }
.table tr.clickable { cursor: pointer; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 11px; overflow: hidden; flex-wrap: wrap; background: var(--surface-2); padding: 3px; gap: 2px; }
.seg button { background: transparent; color: var(--muted); border-radius: 8px; padding: 6px 12px; min-height: 30px; font-weight: 600; font-size: 12.5px; box-shadow: none; }
.seg button:hover { color: var(--text); background: var(--surface-3); }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.rpill { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 650; padding: 3px 9px; border-radius: 99px; background: var(--surface-3); color: var(--muted); }
.rpill.st-sent { color: var(--text-2); }
.rpill.st-deliv { background: var(--primary-soft); color: var(--primary-text); }
.rpill.st-read { background: var(--info-soft); color: var(--info); }
.rpill.st-fail { background: var(--danger-soft); color: var(--danger); }
.rpill.st-skip, .rpill.st-wait { background: var(--warn-soft); color: var(--warn); }
.reason-cell { white-space: normal !important; min-width: 220px; max-width: 380px; }
.rules { line-height: 1.65; max-width: 760px; padding: 0; margin: 0; list-style: none; display: grid; gap: 10px; }
.rules li { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 14px 16px 14px 46px; position: relative; color: var(--text-2); box-shadow: var(--shadow-sm); }
.rules li::before {
  content: ''; position: absolute; left: 16px; top: 16px; width: 18px; height: 18px; background: var(--primary);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10'/%3E%3Cpath d='m9 12 2 2 4-4'/%3E%3C/svg%3E") center/contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10'/%3E%3Cpath d='m9 12 2 2 4-4'/%3E%3C/svg%3E") center/contain no-repeat;
}
.rules b { color: var(--text); }
.member-cell { display: flex; align-items: center; gap: 10px; }
.member-cell .m-text { display: flex; flex-direction: column; min-width: 0; }
.list-empty { text-align: center; padding: 46px 20px; color: var(--muted); }
.list-empty .es-icon { margin: 0 auto 12px; width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-text); }
.list-empty b { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }

/* ---------------------------------------------------------------- Sign-in & standalone pages */
.auth-page { min-height: 100dvh; display: flex; align-items: stretch; justify-content: center; background: var(--bg); }
.auth-shell { display: grid; grid-template-columns: 1.05fr 1fr; width: 100%; min-height: 100dvh; }
.auth-aside {
  position: relative; overflow: hidden; color: #eafaf3; padding: 44px 48px; display: flex; flex-direction: column; justify-content: space-between; gap: 30px;
  background: radial-gradient(1200px 600px at -10% -20%, #1fc48b 0%, transparent 55%), radial-gradient(900px 600px at 110% 120%, #0b6b4b 0%, transparent 60%), #063d2c;
}
.auth-aside .brand-row { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 20px; color: #fff; text-decoration: none; }
.auth-aside .brand-row img { width: 38px; height: 38px; border-radius: 11px; }
.auth-aside h2 { color: #fff; font-size: 34px; line-height: 1.15; letter-spacing: -.03em; max-width: 440px; margin: 0 0 14px; }
.auth-aside p { color: rgba(234, 250, 243, .78); max-width: 420px; font-size: 15px; }
.auth-points { list-style: none; padding: 0; margin: 22px 0 0; display: grid; gap: 12px; }
.auth-points li { display: flex; gap: 10px; align-items: center; color: rgba(234, 250, 243, .9); font-weight: 550; }
.auth-points .ic { color: #6ff0bd; }
.auth-bubbles { display: flex; flex-direction: column; gap: 8px; max-width: 340px; }
.auth-bubbles span { padding: 9px 13px; border-radius: 14px; font-size: 13.5px; width: fit-content; box-shadow: 0 6px 18px rgba(0, 0, 0, .18); opacity: 0; animation: bubble-pop .5s var(--ease-spring) forwards; }
.auth-bubbles .b-in { background: #fff; color: #0e1726; border-top-left-radius: 4px; }
.auth-bubbles .b-out { background: #d9fdd3; color: #0e1726; align-self: flex-end; border-top-right-radius: 4px; }
.auth-bubbles span:nth-child(2) { animation-delay: .6s; } .auth-bubbles span:nth-child(3) { animation-delay: 1.2s; }
@keyframes bubble-pop { from { opacity: 0; transform: translateY(10px) scale(.94); } to { opacity: 1; transform: none; } }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 32px 20px; position: relative; }
.auth-lang { position: absolute; top: 18px; right: 20px; z-index: 2; }
.auth-lang .lang-select { background-color: var(--surface); }
.auth-card { flex: none; width: min(420px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); padding: 32px 28px; box-shadow: var(--shadow-lg); margin: auto; animation: dialog-in var(--t-slow) var(--ease); }
.auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; margin-bottom: 22px; color: var(--text); text-decoration: none; }
.auth-brand:hover { text-decoration: none; }
.auth-brand img { width: 32px; height: 32px; border-radius: 9px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form h1 { font-size: 24px; letter-spacing: -.025em; }
.auth-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.auth-form p { margin: 0; }
.auth-form button { min-height: 44px; font-size: 14.5px; margin-top: 4px; }
.auth-links { font-size: 13px; text-align: center; color: var(--muted); }
.auth-links a { font-weight: 600; }
.auth-message { margin-top: 14px; padding: 11px 13px; border-radius: var(--r); font-size: 13px; animation: slide-down var(--t) var(--ease); }
.auth-message.error { background: var(--danger-soft); color: var(--danger); }
.auth-message.ok { background: var(--primary-soft); color: var(--primary-text); }
.suspended-card h1 { font-size: 22px; margin: 0 0 8px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 750; }
.logo { color: var(--primary); }

/* ---------------------------------------------------------------- Phones */
@media (max-width: 900px) {
  body { overscroll-behavior-y: none; }
  .app { display: block; height: 100dvh; }
  .sidebar { display: none; }
  .main { height: 100dvh; padding-top: calc(var(--appbar-h) + var(--safe-top)); padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom)); }
  .appbar {
    display: flex; align-items: center; gap: 8px; position: fixed; top: 0; left: 0; right: 0; z-index: 20;
    height: calc(var(--appbar-h) + var(--safe-top)); padding: var(--safe-top) 8px 0 16px;
    background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: saturate(1.6) blur(16px); -webkit-backdrop-filter: saturate(1.6) blur(16px);
    border-bottom: 1px solid var(--border);
  }
  .appbar h1 { font-size: 20px; font-weight: 750; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; letter-spacing: -.02em; }
  .appbar .team-chip { background: var(--surface-3); color: var(--text); box-shadow: none; border: 0; min-height: 34px; padding: 3px 12px 3px 3px; border-radius: 99px; gap: 8px; max-width: 48vw; font-weight: 650; font-size: 13px; }
  .appbar .team-chip span { overflow: hidden; text-overflow: ellipsis; }
  .appbar .pill { font-size: 9.5px; padding: 2px 6px; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
    height: calc(var(--tabbar-h) + var(--safe-bottom)); padding-bottom: var(--safe-bottom);
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: saturate(1.6) blur(16px); -webkit-backdrop-filter: saturate(1.6) blur(16px);
    border-top: 1px solid var(--border);
  }
  .tabbar button { flex-direction: column; justify-content: center; gap: 3px; font-size: 10.5px; font-weight: 600; padding: 6px 2px 4px; border-radius: 0; min-height: 0; color: var(--muted); }
  .tabbar button .ic { width: 23px; height: 23px; transition: transform var(--t) var(--ease-spring); }
  .tabbar button.active { color: var(--primary-text); background: transparent; }
  .tabbar button.active .ic { transform: translateY(-1px) scale(1.08); stroke-width: 2.3; }
  .tabbar button:hover { background: transparent; }
  .tabbar button:active:not(:disabled) { transform: none; }
  .tabbar .badge { position: absolute; top: 4px; left: calc(50% + 4px); min-width: 18px; height: 18px; font-size: 10px; }
  .tabbar .dot { position: absolute; top: 8px; left: calc(50% + 8px); }

  .page { padding: 16px 14px 28px; }
  .page-head { margin-bottom: 14px; align-items: center; }
  .page-head .ph-text h1 { display: none; } /* the app bar shows the title */
  .page-head .ph-actions { margin-left: 0; width: 100%; }
  .page-head .ph-actions > * { flex: 1; }
  .toolbar input, .toolbar select { flex: 1 1 140px; min-width: 0; }

  /* Account menu → bottom sheet */
  .pop {
    left: 0; right: 0; bottom: 0; top: auto; width: auto; max-height: 86dvh; border-radius: 22px 22px 0 0; padding: 8px 10px calc(14px + var(--safe-bottom));
    box-shadow: 0 0 0 100vmax rgba(10, 16, 22, .45), var(--shadow-lg); animation: sheet-in var(--t-slow) var(--ease);
  }
  .pop.from-top { top: auto; bottom: 0; }
  .pop::before { content: ''; display: block; width: 40px; height: 5px; border-radius: 99px; background: var(--border-strong); margin: 4px auto 6px; flex: none; }
  .pop .sheet-only { display: flex; }
  .pop button, .pop .btn-link { min-height: 46px; font-size: 15px; }

  /* Dialogs → bottom sheets */
  dialog { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 22px 22px 0 0; max-height: 92dvh; border-bottom: 0; }
  dialog[open] { animation: sheet-in var(--t-slow) var(--ease); }
  .dlg { padding: 10px 18px calc(18px + var(--safe-bottom)); }
  .dlg::before { content: ''; display: block; width: 40px; height: 5px; border-radius: 99px; background: var(--border-strong); margin: 0 auto 8px; }
  .dlg .actions > button { flex: 1; min-height: 46px; }
  .toast { bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 12px); }

  /* Inbox: list full screen; a chat slides over everything, like a native app */
  .inbox { display: block; height: 100%; }
  .convs { height: 100%; border-right: 0; background: var(--surface); }
  .convs-head { padding: 10px 12px; }
  .convs-title { display: none; }
  .hide-sm { display: none; }
  #newChat { width: 42px; padding: 0; }
  #convList li { padding: 12px 8px; border-radius: 14px; }
  .thread {
    position: fixed; inset: 0; z-index: 30; transform: translateX(100%); visibility: hidden;
    transition: transform var(--t-slow) var(--ease), visibility 0s linear var(--t-slow);
  }
  .inbox.open .thread { transform: none; visibility: visible; transition: transform var(--t-slow) var(--ease); }
  .t-head { padding: calc(6px + var(--safe-top)) 8px 6px; min-height: calc(60px + var(--safe-top)); gap: 8px; }
  .t-head .back { display: inline-flex; }
  .t-head .t-window { display: none; }
  .t-msgs { padding: 14px 10px 10px; }
  .msg { max-width: 84%; }
  .composer { padding: 8px 8px max(8px, var(--safe-bottom)); gap: 4px; }
  .rec-bar { padding-bottom: max(10px, var(--safe-bottom)); }

  /* Tables → cards */
  .table-wrap.cards { background: transparent; border: 0; box-shadow: none; overflow: visible; }
  .table-wrap.cards .table, .table-wrap.cards tbody { display: block; }
  .table-wrap.cards thead { display: none; }
  .table-wrap.cards tr { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 12px 14px; margin-bottom: 10px; box-shadow: var(--shadow-sm); }
  .table-wrap.cards td { padding: 0; border: 0; white-space: normal; background: transparent !important; min-width: 0; }
  .table-wrap.cards td[data-label]::before { content: attr(data-label); display: block; font-size: 10.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
  .table-wrap.cards td:first-child { font-weight: 650; font-size: 15px; }
  .table-wrap.cards td.cell-actions { grid-column: 1 / -1; display: flex; gap: 6px; margin-top: 6px; }
  .table-wrap.cards td.cell-actions > * { flex: 1; min-height: 38px; }
  .table-wrap.cards td.reason-cell { grid-column: 1 / -1; max-width: none; min-width: 0; }
  .camp-cols { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .seg { width: 100%; }
  .seg button { flex: 1; }
  .tile .value { font-size: 22px; }

  .auth-shell { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
  .auth-main { padding: 0; align-items: stretch; }
  .auth-card { border: 0; border-radius: 0; box-shadow: none; width: 100%; padding: calc(28px + var(--safe-top)) 22px 28px; margin: 0; min-height: 100dvh; }
  .auth-lang { top: calc(22px + var(--safe-top)); right: 16px; }
}
@keyframes sheet-in { from { transform: translateY(100%); } }

@media (min-width: 901px) and (max-width: 1180px) {
  :root { --sidebar-w: 220px; }
  .inbox { grid-template-columns: 300px 1fr; }
  .page { padding: 22px 22px 36px; }
}

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