/* Theme tokens. Three modes:
   Light: neutral and restrained, for all-day operational use.
   Dark: Terance's colours with translucent cards, but no blur or animation.
   Terance: the sign-in look, translucent glass panels over the animated fluid. */
:root,
:root[data-theme="light"] {
  --primary: #4C1D95;
  --primary-fg: #FFFFFF;
  --primary-soft: #F3EFFB;
  --bg: #F5F6F8;
  --surface: #FFFFFF;
  --surface-2: #F9FAFB;
  --text: #111827;
  --muted: #5B6474;
  --border: #E3E6EB;
  --row-border: #EEF0F3;
  --node-bg: #F3F4F6;
  --spark: #FF6B4A;

  --ok-bg: #E7F6EC;   --ok-fg: #137333;
  --warn-bg: #FEF4DC; --warn-fg: #8A5300;
  --bad-bg: #FDECEC;  --bad-fg: #B42318;
  --info-bg: #EAF1FE; --info-fg: #1D4ED8;

  --whatsapp: #22C55E;
  --rcs: #2563EB;
  --voice: #F59E0B;
  --sms: #64748B;
  --telegram: #0EA5E9;

  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-pop: 0 12px 32px rgba(16, 24, 40, 0.14), 0 2px 6px rgba(16, 24, 40, 0.06);

  --maroon: #9F1239;
  --accent-bar: linear-gradient(180deg, #4C1D95, #9F1239);
  --field: #FFFFFF;
  --canvas-bg: #F7F8FA;
  --drawer-bg: #FFFFFF;
  --sidebar-bg: #FFFFFF;
  --topbar-bg: rgba(255, 255, 255, 0.88);
  --pop-bg: #FFFFFF;
  --btn-bg: #4C1D95;
  --btn-fg: #FFFFFF;
  --app-bg: #F5F6F8;
  --glass: none;
  --nav-w: 232px;
  color-scheme: light;
}

:root[data-theme="terance"],
:root[data-theme="dark"] {
  --primary: #C4B5FD;
  --primary-fg: #1E0B3A;
  --primary-soft: rgba(196, 181, 253, 0.14);
  --bg: #07040D;
  --surface: rgba(16, 8, 28, 0.46);
  --surface-2: rgba(255, 255, 255, 0.03);
  --text: #F5F2FB;
  --muted: rgba(255, 255, 255, 0.66);
  --border: rgba(255, 255, 255, 0.14);
  --row-border: rgba(255, 255, 255, 0.07);
  --node-bg: rgba(255, 255, 255, 0.06);
  --spark: #FF6B4A;

  --ok-bg: rgba(34, 197, 94, 0.16);  --ok-fg: #4ADE80;
  --warn-bg: rgba(250, 204, 21, 0.14); --warn-fg: #FACC15;
  --bad-bg: rgba(248, 113, 113, 0.16); --bad-fg: #FCA5A5;
  --info-bg: rgba(96, 165, 250, 0.16); --info-fg: #93C5FD;

  --shadow: 0 24px 60px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  --shadow-pop: 0 24px 70px rgba(0, 0, 0, 0.5);

  --maroon: #F0577F;
  --accent-bar: linear-gradient(180deg, #C4B5FD, #F0577F);
  --field: rgba(0, 0, 0, 0.3);
  --canvas-bg: rgba(5, 3, 9, 0.35);
  --drawer-bg: #0B0614;
  --sidebar-bg: rgba(10, 5, 18, 0.5);
  --topbar-bg: rgba(10, 5, 18, 0.42);
  --pop-bg: rgba(18, 9, 32, 0.9);
  --btn-bg: #FFFFFF;
  --btn-fg: #2E1065;
  --app-bg: #050309;
  /* The sign-in card's glass. */
  --glass: blur(22px) saturate(150%);
  color-scheme: dark;
}

/* Dark: Terance's colours and translucent cards, but no blur and no animation.
   Cards are tinted over a still gradient; bars and popovers are near-opaque
   so they stay readable without a blur behind them. */
:root[data-theme="dark"] {
  --surface: rgba(255, 255, 255, 0.045);
  --surface-2: rgba(255, 255, 255, 0.03);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  --shadow-pop: 0 18px 48px rgba(0, 0, 0, 0.55);
  --canvas-bg: rgba(0, 0, 0, 0.22);
  --sidebar-bg: rgba(255, 255, 255, 0.025);
  --topbar-bg: rgba(12, 8, 20, 0.94);
  --pop-bg: #150D24;
  --app-bg: #0B0713;
  --glass: none;
}

:root[data-theme="dark"] body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(70% 60% at 10% 0%, rgba(76, 29, 149, 0.32), transparent 70%),
    radial-gradient(60% 55% at 100% 100%, rgba(159, 18, 57, 0.2), transparent 70%);
}

:root.nav-collapsed { --nav-w: 68px; }

*,
*::before,
*::after { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--app-bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }

.icon { width: 18px; height: 18px; flex: none; }

/* Shell: sidebar + main column (sticky top bar, then the page) */
.shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--nav-w) minmax(0, 1fr);
  min-height: 100vh;
  transition: grid-template-columns 0.2s ease;
}

/* Dimmed fluid behind the app in Terance mode. The shade keeps text readable. */
.backdrop { position: fixed; inset: 0; z-index: 0; display: none; pointer-events: none; }
.backdrop canvas { width: 100%; height: 100%; display: block; }
.backdrop.no-webgl canvas { display: none; }
.backdrop.no-webgl .fluid-fallback { display: block; }

.backdrop::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 90% at 60% 30%, rgba(5, 3, 9, 0.12), rgba(5, 3, 9, 0.5)),
    rgba(5, 3, 9, 0.08);
}

:root[data-theme="terance"]:not(.locked) .backdrop { display: block; }

.sidebar {
  position: sticky;
  top: 0;
  z-index: 5;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 12px 10px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  -webkit-backdrop-filter: var(--glass);
  backdrop-filter: var(--glass);
  overflow: hidden;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 0 10px;
  margin-bottom: 8px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.brand-mark { width: 24px; height: 24px; color: var(--primary); flex: none; }

.nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin: 0 -4px;
  padding: 0 4px 8px;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}

.nav:hover { scrollbar-color: var(--border) transparent; }

.nav-label {
  margin: 12px 10px 3px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.nav a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.nav-icon { width: 18px; height: 18px; flex: none; }
.nav a:hover { color: var(--text); background: var(--node-bg); }

.nav a.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

/* Purple-to-maroon marker, borrowed from the sign-in fluid. */
.nav a.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent-bar);
}

:root:is([data-theme="terance"], [data-theme="dark"]) .nav a.active { color: var(--text); }

.sidebar-foot {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--row-border);
}

.org-chip { display: flex; align-items: center; gap: 10px; padding: 4px 6px; min-width: 0; }

.org-avatar {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 8px;
  background: var(--accent-bar);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

:root:is([data-theme="terance"], [data-theme="dark"]) .org-avatar { color: #1E0B3A; }
.org-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.org-text b, .org-text small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.org-text b { font-size: 13px; }
.org-text small { font-size: 12px; color: var(--muted); }

.company {
  padding: 0 8px;
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Collapsed rail: icons only. Labels show as tooltips (see .nav-tip). */
@media (min-width: 821px) {
  .nav-collapsed .brand-text,
  .nav-collapsed .nav-text,
  .nav-collapsed .org-text,
  .nav-collapsed .company { display: none; }
  .nav-collapsed .brand { justify-content: center; padding: 0; }
  .nav-collapsed .nav a { justify-content: center; padding: 0; }
  .nav-collapsed .nav-label { height: 1px; margin: 10px 10px; overflow: hidden; font-size: 0; background: var(--row-border); }
  .nav-collapsed .org-chip { justify-content: center; padding: 4px 0; }
}

.nav-tip {
  position: fixed;
  z-index: 60;
  padding: 5px 9px;
  border-radius: 7px;
  background: #111827;
  color: #fff;
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
  transform: translateY(-50%);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 56px;
  padding: 0 20px 0 12px;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  -webkit-backdrop-filter: blur(14px) saturate(150%);
  backdrop-filter: blur(14px) saturate(150%);
}

.crumbs {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 4px;
  font-size: 13.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
}

.crumbs a:hover { color: var(--text); }
.crumbs [aria-current] { color: var(--text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.crumb-sep { display: inline-flex; opacity: 0.5; }
.crumb-sep .icon { width: 14px; height: 14px; }

.search-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 260px;
  height: 34px;
  padding: 0 6px 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--field);
  color: var(--muted);
  font-size: 13.5px;
  cursor: pointer;
}

.search-btn:hover { border-color: var(--primary); }
.search-btn .icon { width: 16px; height: 16px; }
.search-btn span { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

kbd {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 22px;
  padding: 0 6px;
  border-radius: 6px;
  background: var(--node-bg);
  border: 1px solid var(--border);
  font: 600 11px Inter, system-ui, sans-serif;
  color: var(--muted);
  white-space: nowrap;
}

.mode-switch {
  display: inline-flex;
  flex: none;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--node-bg);
}

.mode-switch button {
  height: 28px;
  padding: 0 10px;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.mode-switch button[aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(16, 24, 40, 0.12); }
:root:is([data-theme="terance"], [data-theme="dark"]) .mode-switch button[aria-checked="true"] { background: rgba(255, 255, 255, 0.16); box-shadow: none; }
.mode-switch button:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.mode-switch.small button { height: 26px; padding: 0 8px; font-size: 12px; }

.page { padding: 24px 28px 48px; min-width: 0; }
.page.wide { padding-right: 20px; }

.page-head {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 20px;
}

.titles { flex: 1; min-width: 0; }

.titles h1 {
  font-size: 23px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.titles p { color: var(--muted); font-size: 14px; margin-top: 3px; }
.titles p:empty { display: none; }

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

/* Buttons */
.btn {
  height: 36px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: filter 0.15s, background 0.15s;
}

.btn-primary { background: var(--btn-bg); color: var(--btn-fg); font-weight: 600; }
.btn-primary:hover { filter: brightness(1.1); }
:root:is([data-theme="terance"], [data-theme="dark"]) .btn-primary:hover { filter: none; background: #EDE7F9; }

.btn-secondary { background: var(--surface); border-color: var(--border); }
.btn-secondary:hover { background: var(--primary-soft); }

.btn:focus-visible,
.nav a:focus-visible,
.menu-btn:focus-visible,
.chip:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  padding: 16px 16px 12px;
}

.card-pad { padding: 16px; }

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

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

.stat { padding: 16px; }
.stat-label { color: var(--muted); font-size: 13px; }

.stat-value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.3;
  margin: 2px 0;
  font-variant-numeric: tabular-nums;
}

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

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

/* Tables */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }

th {
  text-align: left;
  font-weight: 500;
  color: var(--muted);
  font-size: 12.5px;
  padding: 10px 16px;
  border-top: 1px solid var(--row-border);
  border-bottom: 1px solid var(--row-border);
  white-space: nowrap;
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--row-border);
  white-space: nowrap;
}

tbody tr:last-child td { border-bottom: 0; }
td.name { font-weight: 500; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.channel { display: inline-flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--sms); }
.dot.whatsapp { background: var(--whatsapp); }
.dot.rcs { background: var(--rcs); }
.dot.voice { background: var(--voice); }
.dot.sms { background: var(--sms); }
.dot.telegram { background: var(--telegram); }
.dot.spark { background: var(--spark); }

.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  background: var(--node-bg);
  color: var(--muted);
}

.pill.ok { background: var(--ok-bg); color: var(--ok-fg); }
.pill.warn { background: var(--warn-bg); color: var(--warn-fg); }
.pill.bad { background: var(--bad-bg); color: var(--bad-fg); }
.pill.info { background: var(--info-bg); color: var(--info-fg); }

/* Flow diagram */
.flow { position: relative; height: 170px; margin: 4px 16px 0; }
.flow svg.links { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.flow svg.links path { stroke: var(--primary); stroke-width: 1.6; fill: none; }

.node {
  position: absolute;
  width: 34%;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  border-radius: 8px;
  background: var(--node-bg);
  border: 1px solid var(--border);
  font-size: 12.5px;
  white-space: nowrap;
}

.node.focus { border-color: var(--primary); border-width: 1.5px; }

.node .pulse {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--spark);
  box-shadow: 0 0 0 3px var(--surface);
}

.live {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px 18px;
  color: var(--muted);
  font-size: 13.5px;
}

.live .dot { animation: blink 1.6s ease-in-out infinite; }

@keyframes blink { 50% { opacity: 0.35; } }

/* Chips (filters) */
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }

.chip {
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.chip.active { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
:root:is([data-theme="terance"], [data-theme="dark"]) .chip.active { color: var(--text); }

/* Generic item cards (flows, agents) */
.item { display: flex; flex-direction: column; gap: 10px; padding: 16px; }
.item-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.item-title { font-weight: 600; }
.item-meta { color: var(--muted); font-size: 13px; }

.steps { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12.5px; }
.steps span { padding: 3px 8px; border-radius: 6px; background: var(--node-bg); border: 1px solid var(--border); }
.steps i { color: var(--muted); font-style: normal; }

.kv { display: flex; gap: 18px; font-size: 13px; color: var(--muted); }
.kv b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

/* Inbox */
.inbox {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 460px;
  overflow: hidden;
}

.threads { border-right: 1px solid var(--border); }

.thread {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--row-border);
  cursor: pointer;
}

.thread.active { background: var(--primary-soft); }
.thread-top { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; font-weight: 600; }
.thread-top time { color: var(--muted); font-weight: 400; font-size: 12px; }
.thread p { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.convo { display: flex; flex-direction: column; }

.convo-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.messages { flex: 1; display: flex; flex-direction: column; gap: 8px; padding: 16px; }

.msg {
  max-width: 70%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 14px;
  background: var(--node-bg);
  align-self: flex-start;
}

.msg.out { align-self: flex-end; background: var(--primary); color: var(--primary-fg); }
.msg small { display: block; font-size: 11px; opacity: 0.7; margin-top: 2px; }

.composer {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.composer input {
  flex: 1;
  min-width: 0;
  height: 36px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--field);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}

/* Reports bars */
.bars { display: flex; flex-direction: column; gap: 12px; padding: 4px 16px 18px; }
.bar-row { display: grid; grid-template-columns: 90px minmax(0, 1fr) 64px; align-items: center; gap: 12px; font-size: 13.5px; }
.bar-track { height: 8px; border-radius: 999px; background: var(--node-bg); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--primary); }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

.section-gap { margin-top: 12px; }

/* Shared bits */
.nav-label {
  margin: 14px 10px 2px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0.8;
}

.route-actions { display: contents; }
a.btn { display: inline-flex; align-items: center; justify-content: center; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.danger { color: var(--bad-fg); margin-top: 6px; }

.icon-btn {
  width: 32px;
  height: 32px;
  flex: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}

.icon-btn:hover { color: var(--bad-fg); }

.muted { color: var(--muted); }
.block { display: block; }
.mono { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: 13px; }
.link { color: var(--primary); font-size: 13.5px; font-weight: 500; }
.link:hover { text-decoration: underline; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 6px;
  background: var(--node-bg);
  border: 1px solid var(--border);
  font-size: 12px;
}

tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--primary-soft); }
td a:hover { color: var(--primary); }

a.card.item { transition: border-color 0.15s; }
a.card.item:hover { border-color: var(--primary); }

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.toolbar .chips { margin-bottom: 0; }
.toolbar .search { max-width: 280px; }

.quick {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.quick-item { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; transition: border-color 0.15s; }
.quick-item:hover { border-color: var(--primary); }
.quick-item b { font-weight: 600; font-size: 14px; }
.quick-item span { color: var(--muted); font-size: 13px; }

/* Forms */
.form-card { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.form-card + .form-card { margin-top: 12px; }
.form-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.form-card-head h2 { font-size: 15px; font-weight: 600; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.label { font-size: 13px; font-weight: 500; }
.hint { color: var(--muted); font-size: 12.5px; }
.hint.between { display: flex; justify-content: space-between; gap: 8px; }

.input {
  width: 100%;
  min-height: 36px;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--field);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}

textarea.input { resize: vertical; line-height: 1.5; }
select.input { padding-right: 28px; }
.input:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: transparent; }
.input::placeholder { color: var(--muted); opacity: 0.8; }

.row-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.row-2.narrow-first { grid-template-columns: 100px minmax(0, 1fr); }

.seg {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 3px;
  border-radius: 10px;
  background: var(--node-bg);
  border: 1px solid var(--border);
  align-self: flex-start;
  max-width: 100%;
}

.seg button {
  padding: 5px 12px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.seg button[aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(23, 16, 43, 0.1); }
:root:is([data-theme="terance"], [data-theme="dark"]) .seg button[aria-checked="true"] { background: var(--primary-soft); }
.seg button:focus-visible { outline: 2px solid var(--primary); }

.toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  cursor: pointer;
}

.toggle > span:first-child { display: flex; flex-direction: column; }
.toggle-label { font-size: 14px; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }

.switch {
  position: relative;
  width: 36px;
  height: 20px;
  flex: none;
  border-radius: 999px;
  background: var(--border);
  transition: background 0.15s;
}

.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s;
}

.toggle input:checked + .switch { background: var(--primary); }
.toggle input:checked + .switch::after { transform: translateX(16px); }
.toggle input:focus-visible + .switch { outline: 2px solid var(--primary); outline-offset: 2px; }

.check-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.check { display: flex; align-items: center; gap: 10px; padding: 10px 12px; font-size: 14px; cursor: pointer; }
.check + .check { border-top: 1px solid var(--row-border); }
.check span:nth-child(2) { flex: 1; }
.check input { accent-color: var(--primary); width: 16px; height: 16px; }

.form-foot { display: flex; justify-content: space-between; gap: 8px; padding-top: 4px; }

.drop {
  padding: 18px;
  border: 1.5px dashed var(--border);
  border-radius: 10px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
  cursor: pointer;
}

.drop:hover { border-color: var(--primary); color: var(--text); }

.sample-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.sample { display: flex; align-items: center; gap: 8px; }
.sample span { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; color: var(--muted); flex: none; }

.btn-rows { display: flex; flex-direction: column; gap: 8px; }
.btn-row { display: grid; grid-template-columns: 170px minmax(0, 1fr) minmax(0, 1fr) 32px; gap: 8px; align-items: center; }
.btn-row.two { grid-template-columns: minmax(0, 1fr) 32px; }
.btn-row.ivr { grid-template-columns: 70px minmax(0, 1fr) 32px; }
.form-card > .btn-sm { align-self: flex-start; }

.range { width: 100%; accent-color: var(--primary); margin: 8px 0; }

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

.choice {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
}

.choice[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-soft); }
.choice:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: 10px; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; }
.list li + li { border-top: 1px solid var(--row-border); }
.list b { display: block; font-weight: 500; font-size: 14px; }
.list small { color: var(--muted); font-size: 12.5px; }
.list-end { display: flex; align-items: center; gap: 8px; flex: none; }

/* Builders: form on the left, preview or summary on the right */
.page.wide .builder { max-width: none; }

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

.sticky { position: sticky; top: 16px; }

.stepper {
  display: flex;
  gap: 4px;
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  overflow-x: auto;
}

.stepper li { flex: 1; min-width: 110px; }

.stepper button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-bottom: 2px solid var(--border);
  background: none;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
}

.stepper span {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--node-bg);
  border: 1px solid var(--border);
  font-size: 12px;
}

.stepper .current button { color: var(--text); border-color: var(--primary); }
.stepper .current span, .stepper .done span { background: var(--primary); color: var(--primary-fg); border-color: transparent; }

.review { margin: 0; display: flex; flex-direction: column; }
.review div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--row-border); font-size: 14px; }
.review div:last-child { border-bottom: 0; }
.review dt { color: var(--muted); }
.review dd { margin: 0; font-weight: 500; text-align: right; }
.review.compact div { padding: 7px 0; }

/* Phone preview */
.preview-label { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 13px; font-weight: 500; color: var(--muted); }

.phone {
  border: 1px solid var(--border);
  border-radius: 24px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.phone-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  border-top: 3px solid var(--sms);
}

.phone-head.wa { border-top-color: var(--whatsapp); }
.phone-head.rcs { border-top-color: var(--rcs); }
.phone-head.telegram { border-top-color: var(--telegram); }
.phone-head.voice { border-top-color: var(--voice); }
.phone-head b { display: block; font-size: 14px; }
.phone-head small { color: var(--muted); font-size: 12px; }

.avatar, .agent-avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 50%;
  background: var(--primary);
  color: var(--primary-fg);
  font-weight: 600;
  font-size: 14px;
}

.phone-body {
  min-height: 380px;
  padding: 16px 14px 20px;
  background: var(--node-bg);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bubble {
  position: relative;
  max-width: 88%;
  padding: 8px 10px 18px;
  border-radius: 4px 12px 12px 12px;
  background: var(--surface);
  font-size: 14px;
  line-height: 1.45;
  box-shadow: var(--shadow);
  overflow-wrap: anywhere;
}

.bubble.grey { background: var(--surface); }
.bubble-title { display: block; margin-bottom: 4px; }
.bubble-foot { display: block; margin-top: 6px; color: var(--muted); font-size: 12px; }
.ts { position: absolute; right: 8px; bottom: 3px; font-size: 10.5px; color: var(--muted); }

.bubble mark, .quote mark, .rich-body mark {
  background: var(--primary-soft);
  color: inherit;
  border-radius: 3px;
  padding: 0 2px;
}

.media {
  display: grid;
  place-items: center;
  height: 120px;
  margin: -2px -4px 8px;
  border-radius: 8px;
  background: repeating-linear-gradient(45deg, var(--node-bg) 0 8px, var(--border) 8px 16px);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.media.tall { height: 130px; margin: 0; border-radius: 0; }

.bubble-buttons { display: flex; flex-direction: column; gap: 4px; max-width: 88%; }

.bubble-buttons span {
  padding: 8px;
  border-radius: 8px;
  background: var(--surface);
  color: var(--rcs);
  text-align: center;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow);
}

:root:is([data-theme="terance"], [data-theme="dark"]) .bubble-buttons span { color: var(--info-fg); }

.carousel { display: flex; gap: 8px; overflow-x: auto; margin-right: -14px; padding-right: 14px; }
.carousel .rich-card { flex: 0 0 78%; }

.rich-card { max-width: 92%; border-radius: 14px; overflow: hidden; background: var(--surface); box-shadow: var(--shadow); }
.rich-body { padding: 10px 12px 12px; font-size: 13.5px; }
.rich-body b { display: block; margin-bottom: 4px; }
.rich-body p { color: var(--muted); }

.suggestions, .inline-kb { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }

.suggestions span {
  padding: 6px 12px;
  border: 1px solid var(--rcs);
  border-radius: 999px;
  color: var(--rcs);
  font-size: 13px;
  font-weight: 500;
}

:root:is([data-theme="terance"], [data-theme="dark"]) .suggestions span { color: var(--info-fg); border-color: var(--info-fg); }

.inline-kb { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 88%; gap: 4px; }
.inline-kb span { padding: 7px; border-radius: 8px; background: color-mix(in srgb, var(--surface) 70%, transparent); text-align: center; font-size: 13px; font-weight: 500; }

.meta-line { color: var(--muted); font-size: 12px; }

.call-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.call-steps > li { position: relative; display: flex; gap: 12px; padding-bottom: 16px; }
.call-steps > li:not(:last-child)::before { content: ""; position: absolute; left: 5px; top: 14px; bottom: 0; width: 2px; background: var(--border); }
.call-steps > li > div { flex: 1; min-width: 0; }
.call-steps b { display: block; font-size: 14px; }
.call-steps small { color: var(--muted); font-size: 12.5px; }
.step-dot { width: 12px; height: 12px; margin-top: 4px; flex: none; border-radius: 50%; background: var(--primary); }
.step-dot.spark { background: var(--spark); }
.quote { margin-top: 6px; padding: 8px 10px; border-radius: 8px; background: var(--surface); font-size: 13.5px; }

.wave { display: flex; align-items: center; gap: 2px; height: 40px; margin-top: 8px; }
.wave i { flex: 1; border-radius: 2px; background: var(--primary); opacity: 0.7; }

.keys { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 13.5px; }
.keys li { display: flex; align-items: center; gap: 8px; }

kbd {
  display: grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  font: 600 12.5px Inter, system-ui, sans-serif;
}

/* Flow builder */
.page.wide { padding-right: 20px; }

.fb {
  display: grid;
  grid-template-columns: 172px minmax(0, 1fr) 270px;
  height: calc(100vh - 120px);
  min-height: 520px;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
}

.palette, .inspector { overflow-y: auto; padding: 12px; background: var(--surface); }
.palette { border-right: 1px solid var(--border); display: flex; flex-direction: column; gap: 14px; }
.inspector { border-left: 1px solid var(--border); display: flex; flex-direction: column; gap: 14px; }
.pal-group { display: flex; flex-direction: column; gap: 4px; }
.pal-group .label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 2px; }

.pal-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: none;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.pal-item:hover { background: var(--node-bg); border-color: var(--border); }
.pal-item:focus-visible { outline: 2px solid var(--primary); }

.ficon {
  --c: var(--primary);
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex: none;
  border-radius: 6px;
  background: color-mix(in srgb, var(--c) 16%, transparent);
  color: var(--c);
  font-size: 12px;
}

.t-start .ficon { --c: var(--spark); }
.t-condition .ficon, .t-delay .ficon, .t-api .ficon { --c: var(--rcs); }
.t-agent .ficon, .t-handoff .ficon { --c: var(--whatsapp); }
.t-voice .ficon { --c: var(--voice); }
.t-end .ficon { --c: var(--sms); }
:root:is([data-theme="terance"], [data-theme="dark"]) .t-condition .ficon, :root:is([data-theme="terance"], [data-theme="dark"]) .t-delay .ficon, :root:is([data-theme="terance"], [data-theme="dark"]) .t-api .ficon { --c: var(--info-fg); }

.canvas-wrap {
  overflow: auto;
  background-color: var(--canvas-bg);
  background-image: radial-gradient(var(--border) 1px, transparent 1px);
  background-size: 18px 18px;
}

.canvas-area { position: relative; min-width: 0; min-height: 0; display: flex; }
.canvas-area .canvas-wrap { flex: 1; }
.canvas-sizer { position: relative; }
.canvas { position: relative; width: 1680px; height: 680px; transform-origin: 0 0; }

.zoom {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 12.5px;
}

.zoom button {
  min-width: 28px;
  height: 26px;
  border: 0;
  border-radius: 7px;
  background: none;
  cursor: pointer;
  font-size: 13px;
}

.zoom button:hover { background: var(--node-bg); }
.zoom span { min-width: 40px; text-align: center; color: var(--muted); font-variant-numeric: tabular-nums; }

svg.edges { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
svg.edges path { fill: none; stroke: var(--primary); stroke-width: 1.6; }
svg.edges path.fallback { stroke: var(--spark); stroke-dasharray: 5 4; }

.fnode {
  position: absolute;
  width: 210px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(23, 16, 43, 0.06);
  font-size: 13px;
  user-select: none;
}

.fnode.selected { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

.fnode-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; cursor: grab; touch-action: none; }
.fnode-head:active { cursor: grabbing; }
.fnode-head b { display: block; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 150px; }
.fnode-head small { color: var(--muted); font-size: 11.5px; }
.fnode-detail { padding: 0 10px 8px; color: var(--muted); font-size: 12px; }

.fouts { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--row-border); }
.fouts li { position: relative; padding: 5px 10px; font-size: 12px; text-align: right; color: var(--muted); }
.fouts li + li { border-top: 1px solid var(--row-border); }
.fouts li.fallback { color: var(--spark); }

.handle {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--primary);
}

.handle.in { left: -6px; top: 16px; }
.handle.out { right: -6px; top: calc(50% - 5px); }
.fouts li.fallback .handle { border-color: var(--spark); }

.insp-title { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; }
.checks { display: flex; flex-direction: column; gap: 4px; }
.check-item { font-size: 13px; }
.check-item.ok::before { content: "✓"; color: var(--ok-fg); font-weight: 700; margin-right: 6px; }

/* Agents */
.agent-name { display: flex; align-items: center; gap: 10px; }
.agent-avatar { width: 36px; height: 36px; }
.channel-list { display: flex; flex-wrap: wrap; gap: 12px; font-size: 13.5px; }
.add-card { align-items: center; justify-content: center; text-align: center; border-style: dashed; min-height: 150px; }
.add-card .plus { font-size: 24px; color: var(--primary); line-height: 1; }

.test-chat { display: flex; flex-direction: column; height: calc(100vh - 120px); max-height: 640px; overflow: hidden; }
.test-chat .convo-head { justify-content: flex-start; gap: 10px; }
.test-chat .messages { overflow-y: auto; }

/* Channels */
.channel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 12px; align-items: start; }
.channel-card { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.channel-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.channel-card-head h2 { font-size: 16px; font-weight: 600; margin-bottom: 2px; }
.connect { display: flex; flex-direction: column; gap: 12px; padding: 12px; border-radius: 10px; background: var(--node-bg); }
.providers { color: var(--muted); font-size: 12.5px; }

/* Sign-in */
html.locked .shell { display: none; }
html:not(.locked) .auth:not(.exit) { display: none; }
html.locked body { overflow: hidden; }

.auth {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  overflow-y: auto;
  padding: 32px 16px;
  background: #050309;
  color: #fff;
  color-scheme: dark;
}

.fluid { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

.fluid-fallback { position: fixed; inset: 0; display: none; overflow: hidden; filter: blur(60px); }
.auth.no-webgl .fluid { display: none; }
.auth.no-webgl .fluid-fallback { display: block; }

.fluid-fallback i {
  position: absolute;
  width: 60vmax;
  height: 60vmax;
  border-radius: 50%;
  opacity: 0.75;
  animation: drift 26s ease-in-out infinite alternate;
}

.fluid-fallback i:nth-child(1) { background: #4C1D95; left: -15vmax; top: -20vmax; }
.fluid-fallback i:nth-child(2) { background: #6B0A26; right: -20vmax; top: 10vmax; animation-duration: 32s; }
.fluid-fallback i:nth-child(3) { background: #2E1065; left: 10vmax; bottom: -30vmax; animation-duration: 38s; }
.fluid-fallback i:nth-child(4) { background: #EDE7F9; width: 18vmax; height: 18vmax; left: 45vw; top: 35vh; opacity: 0.25; animation-duration: 22s; }

@keyframes drift {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(8vmax, 6vmax) scale(1.15); }
  100% { transform: translate(-6vmax, 10vmax) scale(0.9); }
}

.auth-inner {
  position: relative;
  z-index: 1;
  width: min(400px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
}

.auth-brand { display: flex; flex-direction: column; align-items: center; text-align: center; }
.auth-mark { width: 44px; height: 44px; margin-bottom: 12px; filter: drop-shadow(0 4px 16px rgba(0, 0, 0, 0.35)); }

.auth-brand h1 {
  font-size: 46px;
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.05;
  text-shadow: 0 4px 30px rgba(0, 0, 0, 0.35);
}

.auth-brand p { margin-top: 6px; font-size: 15px; letter-spacing: 0.02em; color: rgba(255, 255, 255, 0.78); }

.auth-stage { display: grid; width: 100%; }
.auth-stage > .auth-card { grid-area: 1 / 1; }

.auth-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  padding: 28px 24px 24px;
  border-radius: 20px;
  background: rgba(16, 8, 28, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  backdrop-filter: blur(22px) saturate(150%);
}

.auth-card[hidden] { display: none; }
.auth-card h2 { font-size: 19px; font-weight: 600; letter-spacing: -0.01em; }
.auth-sub { margin-top: -10px; font-size: 13.5px; color: rgba(255, 255, 255, 0.7); overflow-wrap: anywhere; }

.auth-field { display: flex; flex-direction: column; gap: 6px; }
.auth-field > span:first-child { font-size: 13px; font-weight: 500; color: rgba(255, 255, 255, 0.85); }

.auth-field input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border-radius: 11px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.3);
  color: #fff;
  font: inherit;
  font-size: 15px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.auth-field input::placeholder { color: rgba(255, 255, 255, 0.42); }
.auth-field input:focus { outline: none; border-color: rgba(255, 255, 255, 0.85); box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.45); }
.auth-field input[aria-invalid="true"] { border-color: #FF9B8A; box-shadow: 0 0 0 3px rgba(255, 107, 74, 0.25); }

.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 64px; }

.pw-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
}

.pw-toggle:hover { background: rgba(255, 255, 255, 0.18); }

.auth-error { font-size: 13px; color: #FFB4A6; margin-top: -4px; }
.auth-error:empty { display: none; }

.auth-btn {
  height: 48px;
  margin-top: 4px;
  border: 0;
  border-radius: 11px;
  background: #fff;
  color: #2E1065;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}

.auth-btn:hover { background: #EDE7F9; }
.auth-btn:active { transform: scale(0.985); }

.auth-btn:focus-visible,
.pw-toggle:focus-visible,
.auth-back:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }

.auth-note { font-size: 12.5px; text-align: center; color: rgba(255, 255, 255, 0.62); }

.auth-back {
  align-self: center;
  border: 0;
  background: none;
  color: rgba(255, 255, 255, 0.75);
  font: inherit;
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.auth-back:hover { color: #fff; }

/* The current card drifts up and dissolves; the next one rises in. */
.auth-card.leaving { animation: flow-away 0.7s cubic-bezier(0.5, 0, 0.75, 0) forwards; pointer-events: none; }
.auth-card.entering { animation: flow-in 0.75s cubic-bezier(0.16, 1, 0.3, 1); }
.auth-card.shake { animation: shake 0.4s ease; }

@keyframes flow-away {
  0% { opacity: 1; transform: none; filter: blur(0); border-radius: 20px; }
  45% { border-radius: 40% 30% 45% 25% / 30% 45% 25% 40%; }
  100% { opacity: 0; transform: translate(-36px, -70px) rotate(-4deg) scale(0.9); filter: blur(14px); border-radius: 50% 40% 55% 35% / 40% 55% 35% 50%; }
}

@keyframes flow-in {
  0% { opacity: 0; transform: translate(30px, 60px) rotate(3deg) scale(0.94); filter: blur(12px); border-radius: 45% 35% 40% 30% / 35% 40% 30% 45%; }
  100% { opacity: 1; transform: none; filter: blur(0); border-radius: 20px; }
}

@keyframes shake {
  20%, 60% { transform: translateX(-7px); }
  40%, 80% { transform: translateX(7px); }
}

.auth.exit { animation: auth-exit 1s cubic-bezier(0.65, 0, 0.35, 1) forwards; pointer-events: none; }
.auth.exit .auth-inner { animation: flow-away 0.7s cubic-bezier(0.5, 0, 0.75, 0) forwards; }

@keyframes auth-exit {
  0%, 35% { opacity: 1; transform: none; }
  100% { opacity: 0; transform: scale(1.08); filter: blur(8px); }
}

.shell.app-enter { animation: app-enter 0.8s 0.35s cubic-bezier(0.16, 1, 0.3, 1) both; }

@keyframes app-enter {
  from { opacity: 0; transform: scale(0.985); }
  to { opacity: 1; transform: none; }
}

/* ------------------------------------------------------------------
   Shell components
   ------------------------------------------------------------------ */

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn .icon { width: 16px; height: 16px; }

.icon-btn.ghost {
  position: relative;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border: 1px solid transparent;
  background: none;
  color: var(--muted);
}

.icon-btn.ghost:hover { background: var(--node-bg); color: var(--text); }
.icon-btn.ghost:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }

.badge {
  position: absolute;
  top: 2px;
  right: 2px;
  display: grid;
  place-items: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--spark);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1;
}

.badge[hidden] { display: none; }

.pop-anchor { position: relative; flex: none; }

.popover {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 30;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--pop-bg);
  box-shadow: var(--shadow-pop);
  -webkit-backdrop-filter: var(--glass);
  backdrop-filter: var(--glass);
  overflow: hidden;
}

.popover[hidden] { display: none; }
.notif-pop { width: 360px; }
.account-pop { width: 270px; padding: 6px; }

.pop-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--row-border);
}

.pop-foot {
  display: block;
  padding: 10px;
  border-top: 1px solid var(--row-border);
  text-align: center;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--primary);
}

.pop-foot:hover { background: var(--node-bg); }

.link-btn {
  border: 0;
  background: none;
  padding: 0;
  color: var(--primary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.link-btn:hover { text-decoration: underline; }

.notif-list { list-style: none; margin: 0; padding: 0; }

.notif-list li {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--row-border);
}

.notif-list li:last-child { border-bottom: 0; }
.notif-list li.unread { background: var(--primary-soft); }
.notif-list li > div { flex: 1; min-width: 0; }
.notif-list b { font-size: 13.5px; font-weight: 600; }
.notif-list p { color: var(--muted); font-size: 13px; margin-top: 1px; }
.notif-list small { color: var(--muted); font-size: 12px; white-space: nowrap; }
.notif-list.full li { padding: 14px 18px; align-items: flex-start; }

.notif-dot { width: 8px; height: 8px; margin-top: 6px; flex: none; border-radius: 50%; background: var(--sms); }
.notif-dot.ok { background: #22C55E; }
.notif-dot.warn { background: #F59E0B; }
.notif-dot.bad { background: #EF4444; }
.notif-dot.info { background: #3B82F6; }

.avatar-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  margin-left: 4px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--accent-bar);
  color: #fff;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
}

.avatar-btn:hover { filter: brightness(1.08); }
.avatar-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
:root:is([data-theme="terance"], [data-theme="dark"]) .avatar-btn { color: #1E0B3A; }

.account-pop-head {
  display: flex;
  flex-direction: column;
  padding: 8px 10px 10px;
  border-bottom: 1px solid var(--row-border);
  margin-bottom: 4px;
}

.account-pop-head b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-pop-head span { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.account-pop-mode {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px 10px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--row-border);
  font-size: 13px;
  color: var(--muted);
}

.account-pop-item {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: none;
  text-align: left;
  font-size: 14px;
  cursor: pointer;
}

.account-pop-item:hover,
.account-pop-item:focus-visible { background: var(--node-bg); outline: none; }
.account-pop-item.danger:hover,
.account-pop-item.danger:focus-visible { color: var(--bad-fg); }

/* Command palette */
.palette-wrap { position: fixed; inset: 0; z-index: 200; }
.palette-wrap[hidden] { display: none; }
.palette-scrim { position: absolute; inset: 0; background: rgba(16, 24, 40, 0.35); }
:root:is([data-theme="terance"], [data-theme="dark"]) .palette-scrim { background: rgba(3, 1, 8, 0.55); }

.palette-box {
  position: relative;
  width: min(560px, calc(100% - 32px));
  margin: 12vh auto 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--pop-bg);
  box-shadow: var(--shadow-pop);
  -webkit-backdrop-filter: var(--glass);
  backdrop-filter: var(--glass);
  overflow: hidden;
}

.palette-input { display: flex; align-items: center; gap: 10px; padding: 0 14px; border-bottom: 1px solid var(--row-border); color: var(--muted); }

.palette-input input {
  flex: 1;
  height: 52px;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 15.5px;
  outline: none;
}

.palette-list { list-style: none; margin: 0; padding: 6px; max-height: min(420px, 55vh); overflow-y: auto; }

.palette-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
}

.palette-list li .icon { width: 16px; height: 16px; color: var(--muted); }
.palette-list li span { flex: 1; }
.palette-list li small { color: var(--muted); font-size: 12px; }
.palette-list li[aria-selected="true"] { background: var(--primary-soft); }
.palette-list .palette-empty { color: var(--muted); cursor: default; }

/* ------------------------------------------------------------------
   Page components
   ------------------------------------------------------------------ */

.stat-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.trend {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 1px 7px 1px 4px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.trend .icon { width: 14px; height: 14px; stroke-width: 2.4; }
.trend.good { background: var(--ok-bg); color: var(--ok-fg); }
.trend.bad { background: var(--bad-bg); color: var(--bad-fg); }

.panel { overflow: hidden; }
.panel + .panel { margin-top: 12px; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--row-border);
}

.panel-head h2 { font-size: 15px; font-weight: 600; }
.panel-head p { color: var(--muted); font-size: 13px; margin-top: 1px; }
.panel-actions { display: flex; gap: 8px; flex: none; }
.panel-body { padding: 16px; }

.panel-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid var(--row-border);
  font-size: 13px;
}

.panel-foot.end { justify-content: flex-end; }

.tabs {
  display: flex;
  gap: 4px;
  padding: 0 12px;
  border-bottom: 1px solid var(--row-border);
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs [role="tab"] {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 46px;
  padding: 0 10px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}

.tabs [role="tab"]:hover { color: var(--text); }
.tabs [role="tab"][aria-selected="true"] { color: var(--text); border-bottom-color: var(--primary); font-weight: 600; }
.tabs [role="tab"]:focus-visible { outline: 2px solid var(--primary); outline-offset: -4px; border-radius: 6px; }

.tab-count {
  padding: 0 6px;
  border-radius: 999px;
  background: var(--node-bg);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 18px;
}

[role="tabpanel"] > .table-wrap table th:first-child,
[role="tabpanel"] > .table-wrap table td:first-child { padding-left: 16px; }

.table-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-top: 1px solid var(--row-border);
  color: var(--muted);
  font-size: 13px;
}

.pager { display: flex; gap: 6px; }
.table-note { padding: 10px 16px 14px; color: var(--muted); font-size: 12.5px; }
small.sub { display: block; color: var(--muted); font-size: 12px; font-weight: 400; }
td.neg { color: var(--bad-fg); }
td.pos { color: var(--ok-fg); }
td.arrow { width: 24px; text-align: center; }
.center { text-align: center; }

.notice {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  -webkit-backdrop-filter: var(--glass);
  backdrop-filter: var(--glass);
}

.notice > .icon { color: var(--ok-fg); }
.notice > div { flex: 1; display: flex; flex-direction: column; }
.notice b { font-size: 14px; }
.notice span { color: var(--muted); font-size: 13px; }
.notice.ok { border-left: 3px solid var(--ok-fg); }

.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; padding: 16px; }

.media-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  overflow: hidden;
  text-align: left;
}

.media-thumb {
  position: relative;
  display: grid;
  place-items: center;
  height: 110px;
  background: repeating-linear-gradient(45deg, var(--node-bg) 0 8px, var(--border) 8px 16px);
  color: var(--muted);
}

.media-thumb span { position: absolute; left: 8px; bottom: 8px; padding: 1px 6px; border-radius: 5px; background: var(--surface); font-size: 11.5px; font-weight: 600; }
.media-thumb .icon { width: 28px; height: 28px; }
.media-thumb.video { background: linear-gradient(135deg, #2E1065, #6B0A26); color: #fff; }
.media-thumb.audio { background: linear-gradient(135deg, #1E3A8A, #2E1065); }
.media-meta { display: flex; flex-direction: column; gap: 1px; padding: 10px 12px; min-width: 0; }
.media-meta b { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-meta small { font-size: 12.5px; }

.media-card.add {
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 160px;
  border-style: dashed;
  background: none;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
}

.media-card.add:hover { color: var(--primary); border-color: var(--primary); }

.grid-cards.wide { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.grid-2.even { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.item-actions { display: flex; gap: 8px; margin-top: auto; padding-top: 4px; }
.logo-row { display: flex; align-items: center; gap: 10px; }

.logo-tile {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--sms);
  color: #fff;
  font-weight: 700;
}

.logo-tile.hubspot { background: #FF7A59; }
.logo-tile.salesforce { background: #00A1E0; }
.logo-tile.meta { background: #0866FF; }

.person { display: flex; align-items: center; gap: 10px; }

.person-avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12.5px;
  font-weight: 700;
}

.person b { display: block; font-weight: 600; }
.person small { color: var(--muted); font-size: 12.5px; }

.role-tag { display: inline-block; padding: 3px 10px; border-radius: 7px; background: var(--node-bg); font-size: 13px; font-weight: 600; }
.input.input-sm { width: auto; min-height: 30px; padding: 4px 28px 4px 8px; font-size: 13px; }
.matrix td, .matrix th { white-space: nowrap; }
.perm { font-weight: 500; }
.check-yes { color: var(--ok-fg); font-weight: 700; }
.check-no { color: var(--muted); opacity: 0.6; }

.score {
  display: inline-block;
  min-width: 36px;
  padding: 1px 6px;
  border-radius: 6px;
  text-align: center;
  font-weight: 600;
  font-size: 12.5px;
}

.score.ok { background: var(--ok-bg); color: var(--ok-fg); }
.score.warn { background: var(--warn-bg); color: var(--warn-fg); }
.score.bad { background: var(--bad-bg); color: var(--bad-fg); }

.billing-top { align-items: stretch; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack > .panel + .panel, .stack > * + .panel { margin-top: 0; }
.wallet { padding: 20px; display: flex; flex-direction: column; gap: 6px; }
.wallet-head { display: flex; align-items: center; justify-content: space-between; }
.wallet-value { font-size: 34px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.recharge { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; padding-top: 14px; border-top: 1px solid var(--row-border); }
.recharge-row { display: flex; gap: 8px; }
.recharge-row .input { max-width: 180px; }

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 44px 16px;
  text-align: center;
  color: var(--muted);
}

.empty .icon { width: 30px; height: 30px; margin-bottom: 6px; }
.empty b { color: var(--text); font-weight: 600; }

.lead-text { color: var(--muted); margin-bottom: 12px; }
.tool-list { list-style: none; margin: 0 0 16px; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.tool-list li { display: flex; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.tool-list li .icon { color: var(--primary); margin-top: 2px; }
.tool-list b { display: block; font-size: 14px; }
.tool-list span { color: var(--muted); font-size: 13px; }

.code-block { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.code-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; background: var(--surface-2); border-bottom: 1px solid var(--row-border); font-size: 13px; color: var(--muted); }

.code-block pre {
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
  background: #0F0A1A;
  color: #E9E3F7;
  font: 12.5px/1.6 ui-monospace, "SFMono-Regular", Consolas, monospace;
}

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.span-2 { grid-column: 1 / -1; }
.stack-form { display: flex; flex-direction: column; gap: 14px; }
.color-row { display: flex; gap: 8px; }
.color-row input[type="color"] { width: 44px; height: 36px; padding: 2px; border: 1px solid var(--border); border-radius: 8px; background: var(--field); }

.uptime { display: flex; gap: 3px; height: 36px; }
.uptime span { flex: 1; border-radius: 3px; background: #22C55E; }
.uptime span.warn { background: #F59E0B; }
.uptime span.bad { background: #EF4444; }
.uptime-legend { display: flex; justify-content: space-between; margin-top: 8px; color: var(--muted); font-size: 12.5px; }

/* Refinements: denser, quieter tables and cards. */
.card { border-radius: 10px; }
th { background: var(--surface-2); text-transform: uppercase; letter-spacing: 0.04em; font-size: 11.5px; font-weight: 600; }
tbody tr:hover td { background: var(--surface-2); }
.card-title { font-size: 15px; }

/* Builders sit under a 56px sticky top bar now. */
.sticky { top: 72px; }
.fb { height: calc(100vh - 190px); }
.test-chat { height: calc(100vh - 190px); }

/* Terance mode: glass panels like the sign-in card (--glass is none in Dark). */
:root:is([data-theme="terance"], [data-theme="dark"]) .card,
:root:is([data-theme="terance"], [data-theme="dark"]) .fb,
:root:is([data-theme="terance"], [data-theme="dark"]) .phone {
  -webkit-backdrop-filter: var(--glass);
  backdrop-filter: var(--glass);
}

:root:is([data-theme="terance"], [data-theme="dark"]) .card { border-radius: 16px; }
:root:is([data-theme="terance"], [data-theme="dark"]) .fb .palette,
:root:is([data-theme="terance"], [data-theme="dark"]) .fb .inspector { background: transparent; }
:root:is([data-theme="terance"], [data-theme="dark"]) th { background: rgba(255, 255, 255, 0.025); }
:root:is([data-theme="terance"], [data-theme="dark"]) .input,
:root:is([data-theme="terance"], [data-theme="dark"]) .composer input { border-color: rgba(255, 255, 255, 0.16); }

/* ------------------------------------------------------------------
   Responsive
   ------------------------------------------------------------------ */
@media (max-width: 1100px) {
  .grid-2, .grid-2.even { grid-template-columns: minmax(0, 1fr); }
  .stats.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quick { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .builder { grid-template-columns: minmax(0, 1fr); }
  .sticky { position: static; }
  .test-chat { height: 460px; }
  .fb { grid-template-columns: 170px minmax(0, 1fr); }
  .fb .inspector { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--border); }
  .fb { height: auto; grid-template-rows: 560px auto; }
  .search-btn { width: 200px; }
}

@media (max-width: 980px) {
  .search-btn { width: 34px; padding: 0; justify-content: center; }
  .search-btn span, .search-btn kbd { display: none; }
  .topbar > .mode-switch { display: none; }
}

@media (max-width: 820px) {
  .shell { grid-template-columns: minmax(0, 1fr); }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 264px;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    background: var(--drawer-bg);
  }

  .sidebar.open { transform: none; }

  .scrim {
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(14, 10, 26, 0.5);
  }

  .topbar { padding: 0 12px; }
  .crumbs > :not(:last-child) { display: none; }
  .page { padding: 16px 16px 40px; }
  .page-head { flex-direction: column; align-items: stretch; gap: 12px; margin-bottom: 16px; }
  .actions .btn { flex: 1; }
  .popover { position: fixed; top: 60px; left: 12px; right: 12px; width: auto; }
  .stats { grid-template-columns: minmax(0, 1fr); }
  .inbox { grid-template-columns: minmax(0, 1fr); }
  .threads { border-right: 0; border-bottom: 1px solid var(--border); }
  .msg { max-width: 85%; }
  .row-2 { grid-template-columns: minmax(0, 1fr); }
  .row-2.narrow-first { grid-template-columns: 90px minmax(0, 1fr); }
  .btn-row { grid-template-columns: minmax(0, 1fr) 32px; }
  .btn-row:not(.two):not(.ivr) > select { grid-row: 1; grid-column: 1; }
  .btn-row:not(.two):not(.ivr) > .icon-btn { grid-row: 1; grid-column: 2; }
  .btn-row:not(.two):not(.ivr) > input { grid-column: 1 / -1; }
  .btn-row > span:empty { display: none; }
  .btn-row.ivr { grid-template-columns: 64px minmax(0, 1fr) 32px; }
  .channel-grid { grid-template-columns: minmax(0, 1fr); }
  .toolbar .search { max-width: none; }
  .fb { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 460px auto; }
  .fb .palette { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--border); gap: 12px; }
  .fb .pal-group { flex: none; }
  .fb .pal-group > div, .fb .pal-group { flex-direction: row; flex-wrap: nowrap; align-items: center; }
  .fb .pal-group .label { margin: 0 4px 0 0; }
  .pal-item { white-space: nowrap; }
  .form-grid, .tool-list { grid-template-columns: minmax(0, 1fr); }
  .table-foot { flex-wrap: wrap; }
  .recharge-row { flex-wrap: wrap; }
  .recharge-row .input { max-width: none; flex: 1; }
}

@media (max-width: 480px) {
  .stats.four { grid-template-columns: minmax(0, 1fr); }
  .quick { grid-template-columns: minmax(0, 1fr); }
  .actions .btn { flex: 1 1 auto; padding: 0 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
