/* J2workers: one stylesheet, no build step. Every color is a variable, so the
   light and dark themes only differ in the two token blocks below. */

:root {
  color-scheme: light;

  --brand-50: #eef1ff;
  --brand-100: #e0e5ff;
  --brand-200: #c5cdff;
  --brand-300: #a1adff;
  --brand-500: #5a66f8;
  --brand-600: #4353f6;
  --brand-700: #3542d8;
  --brand-800: #2c36ae;
  --brand-hover: #3542d8;
  --brand-text: #4353f6;
  --violet: #7c3aed;

  --ink: #0b1220;
  --ink-2: #1e293b;
  --ink-3: #475569;
  --muted: #64748b;
  --faint: #94a3b8;
  --line: #e4e8f0;
  --line-2: #eef1f6;
  --line-strong: #d3d9e4;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #ffffff;
  --subtle: #f1f4f9;
  --input-bg: #ffffff;
  --chat-bg: #f6f7fb;
  --bubble-theirs: #ffffff;
  --tab-active: #ffffff;

  --green: #15803d;
  --green-dot: #22c55e;
  --green-50: #ecfdf3;
  --red: #dc2626;
  --red-50: #fef2f2;
  --red-200: #fecaca;
  --amber: #b45309;
  --amber-50: #fffbeb;
  --amber-200: #fde68a;
  --danger-text: #991b1b;
  --success-text: #166534;
  --success-border: #bbf7d0;

  --toast-bg: #0b1220;
  --toast-fg: #ffffff;
  --presence-off: #cbd5e1;
  --skeleton-hi: #e7ebf3;
  --header-glass: rgb(245 247 251 / 0.78);
  --glow-1: rgb(124 58 237 / 0.1);
  --glow-2: rgb(67 83 246 / 0.13);
  --auth-glow: rgb(67 83 246 / 0.14);
  --backdrop: rgb(11 18 32 / 0.35);
  --read-tick: #a7f3d0;
  --weekend-bg: #f8f9fc;
  --today-bg: #f3f5ff;

  /* Chart series (checked for color-blind separation and 3:1 contrast on --surface) */
  --series-1: #4353f6;
  --series-2: #e8641f;

  --shadow-xs: 0 1px 2px rgb(16 24 40 / 0.05);
  --shadow-sm: 0 1px 3px rgb(16 24 40 / 0.08), 0 1px 2px rgb(16 24 40 / 0.04);
  --shadow: 0 4px 16px rgb(16 24 40 / 0.08), 0 1px 3px rgb(16 24 40 / 0.05);
  --shadow-lg: 0 24px 48px -12px rgb(16 24 40 / 0.2);
  --ring: 0 0 0 4px rgb(67 83 246 / 0.16);

  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --brand-50: rgb(99 112 255 / 0.14);
  --brand-100: rgb(99 112 255 / 0.26);
  --brand-200: rgb(99 112 255 / 0.4);
  --brand-300: #a9b2ff;
  --brand-500: #6f7bff;
  --brand-600: #4f5ef7;
  --brand-700: #b4bcff;
  --brand-800: #c9cfff;
  --brand-hover: #6170ff;
  --brand-text: #98a3ff;
  --violet: #8b5cf6;

  --ink: #f1f5f9;
  --ink-2: #d5dde9;
  --ink-3: #a5b2c5;
  --muted: #8391a7;
  --faint: #6b7a92;
  --line: #242e44;
  --line-2: #1c2538;
  --line-strong: #34405a;
  --bg: #0a0e18;
  --surface: #111725;
  --surface-2: #161e2f;
  --subtle: #1a2234;
  --input-bg: #0d1320;
  --chat-bg: #0c111c;
  --bubble-theirs: #1a2234;
  --tab-active: #263049;

  --green: #4ade80;
  --green-50: rgb(34 197 94 / 0.12);
  --red: #f87171;
  --red-50: rgb(239 68 68 / 0.12);
  --red-200: rgb(239 68 68 / 0.32);
  --amber: #fbbf24;
  --amber-50: rgb(245 158 11 / 0.1);
  --amber-200: rgb(245 158 11 / 0.3);
  --danger-text: #fca5a5;
  --success-text: #86efac;
  --success-border: rgb(34 197 94 / 0.3);

  --toast-bg: #1f2940;
  --toast-fg: #f8fafc;
  --presence-off: #4b5568;
  --skeleton-hi: #232d43;
  --header-glass: rgb(10 14 24 / 0.75);
  --glow-1: rgb(139 92 246 / 0.16);
  --glow-2: rgb(79 94 247 / 0.22);
  --auth-glow: rgb(79 94 247 / 0.2);
  --backdrop: rgb(0 0 0 / 0.55);
  --weekend-bg: #0d1220;
  --today-bg: #141b33;
  --series-1: #6f7bff;
  --series-2: #e76624;

  --shadow-xs: 0 1px 2px rgb(0 0 0 / 0.35);
  --shadow-sm: 0 1px 3px rgb(0 0 0 / 0.4), 0 1px 2px rgb(0 0 0 / 0.3);
  --shadow: 0 8px 24px rgb(0 0 0 / 0.4), 0 1px 3px rgb(0 0 0 / 0.3);
  --shadow-lg: 0 24px 48px -12px rgb(0 0 0 / 0.65);
  --ring: 0 0 0 4px rgb(99 112 255 / 0.3);
}

/* Short color fade while switching themes (the class is added for ~350ms). */
.theme-anim, .theme-anim *, .theme-anim *::before, .theme-anim *::after {
  transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease, fill 0.3s ease !important;
}

/* ------------------------------------------------------------------ base */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink-2);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4 { margin: 0; color: var(--ink); line-height: 1.2; letter-spacing: -0.015em; }
p { margin: 0; }
a { color: var(--brand-text); text-decoration: none; }
a:hover { text-decoration: underline; }
img { display: block; max-width: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 2px; }
::selection { background: var(--brand-100); }
.muted { color: var(--muted); }
.icon { display: block; flex-shrink: 0; }
strong { color: var(--ink); font-weight: 650; }

/* --------------------------------------------------------------- buttons */

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none !important;
  user-select: none;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s, transform 0.05s;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn-primary {
  background: var(--brand-600);
  color: #fff;
  box-shadow: 0 1px 2px rgb(16 24 40 / 0.12), inset 0 1px 0 rgb(255 255 255 / 0.14);
}
.btn-primary:hover:not(:disabled) { background: var(--brand-hover); }
.btn-secondary { background: var(--surface); color: var(--ink-2); border-color: var(--line); box-shadow: var(--shadow-xs); }
.btn-secondary:hover:not(:disabled) { background: var(--subtle); border-color: var(--line-strong); }
.btn-ghost { background: transparent; color: var(--ink-3); }
.btn-ghost:hover:not(:disabled) { background: var(--subtle); color: var(--ink); }
.btn-sm { height: 34px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn-lg { height: 50px; padding: 0 22px; font-size: 16px; border-radius: 14px; }
.btn-block { width: 100%; }
.btn.is-busy { color: transparent !important; pointer-events: none; opacity: 1; }
.btn.is-busy > * { visibility: hidden; }
.btn.is-busy::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgb(255 255 255 / 0.45);
  border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}
.btn-secondary.is-busy::after, .btn-ghost.is-busy::after { border-color: var(--brand-100); border-top-color: var(--brand-600); }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-3);
  transition: background-color 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--subtle); color: var(--ink); }
.icon-btn.active { background: var(--brand-50); color: var(--brand-700); }

.theme-toggle { width: 40px; height: 40px; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow-xs); }
.theme-toggle:hover { border-color: var(--line-strong); }
.corner-toggle { position: fixed; top: 16px; right: 16px; z-index: 5; }

.link-btn { padding: 0; border: 0; background: none; color: var(--brand-text); font-weight: 600; }
.link-btn:hover:not(:disabled) { text-decoration: underline; }
.link-btn:disabled { color: var(--muted); font-weight: 500; cursor: default; }

.inline-link { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }

/* ----------------------------------------------------------------- forms */

.form-stack { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.field-label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.field-link { font-size: 13.5px; font-weight: 600; }
.field-hint { font-size: 13px; color: var(--muted); }
.field-error { font-size: 13px; font-weight: 500; color: var(--red); }
.field-error:empty { display: none; }

.input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--input-bg);
  color: var(--ink);
  font-size: 16px;
  box-shadow: var(--shadow-xs);
  transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}
.input::placeholder { color: var(--faint); }
.input:hover { border-color: var(--line-strong); }
.input:focus { outline: none; border-color: var(--brand-500); box-shadow: var(--ring); }
.input[readonly] { background: var(--subtle); color: var(--ink-3); cursor: default; }
.has-error .input { border-color: var(--red); }
.has-error .input:focus { box-shadow: 0 0 0 4px rgb(220 38 38 / 0.15); }

.select-wrap { position: relative; min-width: 0; }
.select-wrap .icon { position: absolute; top: 50%; right: 12px; color: var(--muted); pointer-events: none; transform: translateY(-50%); }
select.input { padding-right: 38px; appearance: none; -webkit-appearance: none; text-overflow: ellipsis; cursor: pointer; }
select.input:invalid { color: var(--faint); }
select.input option, select.input optgroup { background: var(--surface); color: var(--ink); }
.field-row { display: grid; gap: 10px; }
.field-row.two { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.money-input { position: relative; }
.money-input .input { padding-right: 92px; padding-left: 30px; -moz-appearance: textfield; appearance: textfield; }
.money-input .input::-webkit-outer-spin-button, .money-input .input::-webkit-inner-spin-button { margin: 0; -webkit-appearance: none; }
.money-suffix { position: absolute; top: 50%; right: 14px; color: var(--muted); font-size: 14px; pointer-events: none; transform: translateY(-50%); }
.money-prefix { position: absolute; top: 50%; left: 14px; color: var(--ink-3); font-weight: 650; pointer-events: none; transform: translateY(-50%); }

.check { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-3); font-size: 13.5px; font-weight: 500; cursor: pointer; user-select: none; }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--brand-600); cursor: pointer; }

.input-wrap { position: relative; }
.input-wrap .input { padding-right: 48px; }
.input-action {
  position: absolute;
  top: 4px;
  right: 4px;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--muted);
}
.input-action:hover { background: var(--subtle); color: var(--ink); }

.input-group {
  display: flex;
  align-items: stretch;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--input-bg);
  box-shadow: var(--shadow-xs);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input-group:focus-within { border-color: var(--brand-500); box-shadow: var(--ring); }
.has-error .input-group { border-color: var(--red); }
.input-group .input { border: 0; border-radius: 0; box-shadow: none; padding-left: 2px; }
.input-group .input:focus { box-shadow: none; }
.input-prefix { display: grid; place-items: center; padding: 0 2px 0 14px; color: var(--muted); font-size: 16px; font-weight: 600; }

.code-input { display: flex; justify-content: center; gap: 10px; }
.code-box {
  width: 52px;
  height: 60px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--input-bg);
  color: var(--ink);
  font-size: 26px;
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
  caret-color: var(--brand-600);
  box-shadow: var(--shadow-xs);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.code-box:focus { outline: none; border-color: var(--brand-500); box-shadow: var(--ring); }
.code-box:disabled { background: var(--subtle); }
.shake { animation: shake 0.4s; }

.divider { display: flex; align-items: center; gap: 12px; margin: 22px 0; color: var(--faint); font-size: 13px; font-weight: 500; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ------------------------------------------------- alerts, badges, toasts */

.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.45;
}
.alert .icon { margin-top: 1px; }
.alert-error { background: var(--red-50); border-color: var(--red-200); color: var(--danger-text); }
.alert-success { background: var(--green-50); border-color: var(--success-border); color: var(--success-text); }
.alert-info { background: var(--brand-50); border-color: var(--brand-100); color: var(--brand-800); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.badge-brand { background: var(--brand-50); color: var(--brand-700); border: 1px solid var(--brand-100); }
.badge-warn { background: var(--amber-50); color: var(--amber); border: 1px solid var(--amber-200); }

.toasts {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(420px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border: 1px solid rgb(255 255 255 / 0.06);
  border-radius: 12px;
  background: var(--toast-bg);
  color: var(--toast-fg);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: auto;
  cursor: pointer;
}
.toast.show { opacity: 1; transform: none; }
.toast .icon { margin-top: 1px; }
.toast-success .icon { color: #4ade80; }
.toast-error .icon { color: #f87171; }
.toast-info .icon { color: #a1adff; }

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--brand-100);
  border-top-color: var(--brand-600);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.spinner-sm { width: 14px; height: 14px; }
.spinner-lg { width: 32px; height: 32px; border-width: 3px; }
.boot { display: grid; place-items: center; min-height: 100vh; }

.empty { margin: auto; padding: 32px 16px; max-width: 380px; text-align: center; color: var(--ink-3); }
.empty-icon {
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  margin: 0 auto 16px;
  border-radius: 18px;
  background: var(--brand-50);
  color: var(--brand-text);
}
.empty h3 { margin-bottom: 6px; font-size: 17px; }
.empty p { font-size: 14.5px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow-sm); }

/* ------------------------------------------------------------------ logo */

.logo { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 800; letter-spacing: -0.02em; text-decoration: none !important; }
.logo-mark {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand-600), var(--violet));
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.02em;
  box-shadow: 0 4px 12px -2px rgb(67 83 246 / 0.45);
}
.logo-word { font-size: 19px; color: var(--ink); }
.logo-word b { color: var(--brand-text); font-weight: 800; }
.logo-sm .logo-mark { width: 30px; height: 30px; border-radius: 9px; font-size: 12.5px; }
.logo-sm .logo-word { font-size: 17px; }
.logo-lg .logo-mark { width: 44px; height: 44px; border-radius: 12px; font-size: 17px; }
.logo-lg .logo-word { font-size: 24px; }

/* --------------------------------------------------------------- avatars */

.avatar {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  border-radius: 50%;
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.01em;
  user-select: none;
}
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; background: var(--subtle); }
.avatar-slot, .chat-avatar { display: inline-flex; }
.presence {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 28%;
  height: 28%;
  min-width: 10px;
  min-height: 10px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--presence-off);
}
.presence.on { background: var(--green-dot); }

.peer-mark {
  position: relative;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background: linear-gradient(135deg, var(--brand-600), var(--violet));
  color: #fff;
  font-size: 15px;
  font-weight: 800;
}
.peer-mark .presence { right: -3px; bottom: -3px; width: 14px; height: 14px; min-width: 0; min-height: 0; }

/* --------------------------------------------------------------- landing */

.landing {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background:
    radial-gradient(1000px 560px at 85% -10%, var(--glow-1), transparent 60%),
    radial-gradient(900px 520px at 10% -5%, var(--glow-2), transparent 60%),
    var(--bg);
}
.container { width: 100%; max-width: 1160px; margin: 0 auto; padding: 0 24px; }
.land-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--header-glass);
  border-bottom: 1px solid var(--line);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
}
.land-header-inner { display: flex; align-items: center; justify-content: space-between; height: 68px; }
.land-nav { display: flex; align-items: center; gap: 8px; }

.hero { display: flex; flex-direction: column; align-items: center; padding: 104px 24px 80px; text-align: center; }
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 14px 0 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-3);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-xs);
}
.eyebrow-dot { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--brand-50); color: var(--brand-text); }
.hero-title { margin: 24px 0 20px; font-size: clamp(42px, 7vw, 76px); font-weight: 800; line-height: 1.03; letter-spacing: -0.04em; }
.grad {
  background: linear-gradient(120deg, var(--brand-600) 10%, var(--violet) 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
:root[data-theme="dark"] .grad { background-image: linear-gradient(120deg, #8f9bff 10%, #c084fc 90%); }
/* Gradient text has a transparent color, so give selected text a real one. */
.grad::selection, .nf-code::selection { color: var(--brand-text); -webkit-text-fill-color: var(--brand-text); background: var(--brand-100); }
.hero-sub { max-width: 600px; font-size: 18.5px; line-height: 1.6; color: var(--ink-3); }
.hero-cta { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 36px; }
.hero-note { display: flex; flex-wrap: wrap; justify-content: center; gap: 20px; margin-top: 28px; font-size: 14px; color: var(--muted); }
.hero-note span { display: inline-flex; align-items: center; gap: 6px; }
.hero-note .icon { color: var(--green); }

.steps-section { padding: 16px 24px 96px; }
.section-title { text-align: center; font-size: 30px; letter-spacing: -0.025em; }
.section-sub { max-width: 520px; margin: 10px auto 40px; text-align: center; font-size: 16px; color: var(--ink-3); }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.step {
  position: relative;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s, box-shadow 0.2s;
}
.step:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.step-icon { display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: 18px; border-radius: 14px; background: var(--brand-50); color: var(--brand-text); }
.step-num { position: absolute; top: 24px; right: 24px; color: var(--faint); font-size: 13px; font-weight: 700; }
.step h3 { margin-bottom: 8px; font-size: 18px; }
.step p { font-size: 15px; line-height: 1.6; color: var(--ink-3); }

.land-footer { margin-top: auto; padding: 24px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.land-footer .container { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.land-footer-links { display: flex; gap: 18px; }
.land-footer-links a { color: var(--ink-3); font-weight: 500; }

/* ------------------------------------------------------------ auth pages */

.auth-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: radial-gradient(900px 480px at 50% -12%, var(--auth-glow), transparent 70%), var(--bg);
}
.auth-top { position: relative; display: flex; justify-content: center; padding: 24px; }
.auth-top .theme-toggle { position: absolute; top: 50%; right: 20px; transform: translateY(-50%); }
.auth-main { flex: 1; display: flex; align-items: flex-start; justify-content: center; padding: 16px 16px 40px; }
.auth-card {
  width: 100%;
  max-width: 440px;
  padding: 36px 36px 32px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.auth-card-wide { max-width: 540px; }
.auth-head { margin-bottom: 24px; }
.auth-head.center { text-align: center; }
.auth-title { font-size: 26px; letter-spacing: -0.025em; }
.auth-sub { margin-top: 8px; font-size: 15px; color: var(--ink-3); }
.auth-icon { display: grid; place-items: center; width: 56px; height: 56px; margin: 0 auto 18px; border-radius: 16px; background: var(--brand-50); color: var(--brand-text); }
.auth-switch { margin-top: 20px; text-align: center; font-size: 14.5px; color: var(--ink-3); }
.auth-switch a { font-weight: 600; }
.auth-foot { padding: 24px; text-align: center; font-size: 13px; color: var(--faint); }
.google-slot { display: flex; justify-content: center; min-height: 44px; transition: opacity 0.15s; }
.google-slot.is-loading { opacity: 0.5; pointer-events: none; }
.fine-print { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 13px; color: var(--muted); text-align: center; }

.stepper { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; font-size: 13px; font-weight: 600; color: var(--muted); }
.st { display: inline-flex; align-items: center; gap: 8px; }
.st-dot { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--subtle); color: var(--muted); font-size: 12px; }
.st.done .st-dot { background: var(--green-50); color: var(--green); }
.st.current { color: var(--ink); }
.st.current .st-dot { background: var(--brand-600); color: #fff; }
.st-line { flex: 1; max-width: 48px; height: 2px; border-radius: 2px; background: var(--line); }

/* ------------------------------------------------------------- app shell */

/* Signed-in layout: left bar + page. Phones get a top bar and bottom tabs instead. */
.shell {
  display: grid;
  grid-template-areas: "side main";
  grid-template-columns: 248px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}
.side-nav {
  grid-area: side;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
  padding: 18px 12px 14px;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--surface);
}
.side-logo { display: flex; align-items: center; gap: 10px; padding: 0 8px 20px; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 44px;
  padding: 0 12px;
  border-radius: 12px;
  color: var(--ink-3);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none !important;
  transition: background-color 0.15s, color 0.15s;
}
.nav-item:hover { background: var(--subtle); color: var(--ink); }
.nav-item.active { background: var(--brand-50); color: var(--brand-text); }
.nav-icon { position: relative; display: inline-flex; }
.nav-badge {
  position: absolute;
  top: -7px;
  right: -10px;
  display: grid;
  place-items: center;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border: 2px solid var(--surface);
  border-radius: 999px;
  background: var(--brand-600);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1;
}
.side-bottom { display: flex; align-items: center; gap: 8px; margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line-2); }
.side-bottom .user-menu { flex: 1; min-width: 0; }
.shell-main { grid-area: main; display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; }
.mobile-top { grid-area: top; display: none; }
.tabbar { grid-area: tabs; display: none; }
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 10px; }
.user-menu { position: relative; }
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 260px;
  padding: 4px 10px 4px 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 600;
  transition: background-color 0.15s;
}
.user-chip:hover { background: var(--subtle); }
.user-chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip.wide { width: 100%; max-width: none; padding: 6px 8px 6px 6px; border-radius: 12px; }
.user-chip.wide > .icon { color: var(--muted); }
.user-chip-text { display: flex; flex: 1; flex-direction: column; min-width: 0; line-height: 1.25; text-align: left; }
.user-chip-email { overflow: hidden; color: var(--muted); font-size: 12px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.user-menu.up .menu { top: auto; right: auto; bottom: calc(100% + 8px); left: 0; }
.menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 50;
  width: 250px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
  box-shadow: var(--shadow-lg);
  animation: pop 0.14s ease-out;
}
.menu-head { margin-bottom: 6px; padding: 10px 12px 12px; border-bottom: 1px solid var(--line-2); }
.menu-name, .menu-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-name { color: var(--ink); font-weight: 700; }
.menu-email { color: var(--muted); font-size: 13px; }
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--ink-2);
  font-size: 14.5px;
  font-weight: 500;
  text-align: left;
  text-decoration: none !important;
}
.menu-item:hover { background: var(--subtle); }
.menu-item .icon { color: var(--muted); }
.menu-item.danger, .menu-item.danger .icon { color: var(--red); }
.conn-banner {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--amber-200);
  background: var(--amber-50);
  color: var(--amber);
  font-size: 13.5px;
  font-weight: 600;
}
.conn-banner .spinner { border-color: var(--amber-200); border-top-color: var(--amber); }

/* ------------------------------------------------------------------ chat */

.chat { display: flex; flex-direction: column; height: 100%; min-height: 0; background: var(--surface); }
.chat-head-wrap { flex-shrink: 0; }
.chat-head {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 12px;
  min-height: 68px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.chat-peer { display: flex; flex: 1; align-items: center; gap: 12px; min-width: 0; }
.chat-peer-text { min-width: 0; }
.chat-title { overflow: hidden; color: var(--ink); font-size: 16px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.chat-status { overflow: hidden; color: var(--muted); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.chat-status.online { color: var(--green); font-weight: 600; }
.chat-actions { display: flex; gap: 4px; }
.chat-notice {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-bottom: 1px solid var(--amber-200);
  background: var(--amber-50);
  color: var(--amber);
  font-size: 13px;
  font-weight: 500;
}
.chat-body { position: relative; display: flex; flex: 1; min-height: 0; }
.chat-scroll {
  --chat-pad: 20px;
  display: flex;
  flex: 1;
  flex-direction: column;
  overflow-y: auto;
  padding: 16px var(--chat-pad) 12px;
  background: var(--chat-bg);
  overscroll-behavior: contain;
}
.older { display: flex; justify-content: center; margin-bottom: 8px; }
.messages { display: flex; flex: 1 0 auto; flex-direction: column; justify-content: flex-end; width: 100%; }
/* Each message's line spans the whole chat (the click and highlight area, like
   Telegram); the bubbles themselves stay in a centred 860px column. */
.msg { margin-inline: calc(-1 * var(--chat-pad)); padding-inline: max(var(--chat-pad), calc((100% - 860px) / 2 + var(--chat-pad))); }
.chat-loading, .chat-error { display: flex; flex-direction: column; align-items: center; gap: 12px; margin: auto; padding: 40px; color: var(--ink-3); text-align: center; }
.day-sep { display: flex; justify-content: center; margin: 18px 0 8px; }
.day-sep span { padding: 3px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--muted); font-size: 12px; font-weight: 600; }
.msg { display: flex; flex-direction: column; margin-top: 10px; }
.msg.grouped { margin-top: 3px; }
.msg.mine { align-items: flex-end; }
.msg.theirs { align-items: flex-start; }
.bubble { max-width: min(78%, 620px); padding: 8px 12px 6px; border-radius: 18px; box-shadow: var(--shadow-xs); }
.mine .bubble { border-bottom-right-radius: 6px; background: var(--brand-600); color: #fff; }
.theirs .bubble { border: 1px solid var(--line); border-bottom-left-radius: 6px; background: var(--bubble-theirs); color: var(--ink-2); }
.mine.grouped .bubble { border-top-right-radius: 6px; }
.theirs.grouped .bubble { border-top-left-radius: 6px; }
.msg-text { font-size: 15px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.mine .msg-text a { color: #fff; text-decoration: underline; }
.theirs .msg-text a { color: var(--brand-text); text-decoration: underline; }
.msg-meta { display: flex; align-items: center; justify-content: flex-end; gap: 4px; margin-top: 3px; font-size: 11.5px; line-height: 1; white-space: nowrap; }
.mine .msg-meta { color: rgb(255 255 255 / 0.78); }
.theirs .msg-meta { color: var(--faint); }
.msg-sender { margin-right: 4px; font-weight: 700; }
.msg-status { display: inline-flex; }
.msg-status.read { color: var(--read-tick); }
.msg.pending .bubble { opacity: 0.7; }
.msg.failed .bubble { border: 1px solid var(--red-200); background: var(--red-50); color: var(--danger-text); }
.msg.failed .msg-meta { color: var(--red); }
.bubble { position: relative; }
.msg { position: relative; }
.msg-menu-btn {
  position: absolute;
  top: 3px;
  right: 4px;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 26px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}
.mine .msg-menu-btn { background: rgb(255 255 255 / 0.18); color: #fff; }
.theirs .msg-menu-btn { background: var(--subtle); color: var(--muted); }
.msg.has-image .msg-menu-btn { top: 8px; right: 8px; background: rgb(0 0 0 / 0.5); color: #fff; }
/* Computers show the ⌄ on hover: keep a little room for it at the end of the
   first line, so it never covers any text (and nothing moves on hover). */
@media (hover: hover) and (pointer: fine) {
  .msg:not(.deleted) .msg-text::before { content: ''; float: right; width: 24px; height: 18px; }
  .msg-quote { padding-right: 30px; }
  .msg.has-file .msg-file { padding-right: 34px; }
}
.msg:hover .msg-menu-btn, .msg-menu-btn:focus-visible, .msg.menu-open .msg-menu-btn { opacity: 1; pointer-events: auto; }
.msg.menu-open { background: color-mix(in srgb, var(--brand-500) 12%, transparent); }
.msg-menu {
  position: fixed;
  z-index: 60;
  width: 236px;
  max-width: calc(100vw - 16px);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: menu-in 0.12s ease;
}
@keyframes menu-in { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: none; } }
.react-pill {
  position: fixed;
  z-index: 61;
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  box-shadow: var(--shadow-lg);
  animation: menu-in 0.12s ease;
}
.react-pill.expanded { width: 344px; max-width: calc(100vw - 16px); padding: 0; border-radius: 16px; overflow: hidden; }
.react-pill .react-pick { width: 34px; height: 34px; font-size: 20px; }
.react-pill .react-pick.more { width: 30px; color: var(--muted); }
.menu-foot { display: flex; align-items: center; gap: 8px; padding: 9px 14px 10px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.msg-menu-items { display: flex; flex-direction: column; padding: 5px; }
.msg-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--ink-2);
  font-size: 14.5px;
  font-weight: 500;
  text-align: left;
}
.msg-menu-item .icon { color: var(--muted); }
.msg-menu-item:hover, .msg-menu-item:focus-visible { background: var(--subtle); outline: none; }
.msg-menu-item.danger, .msg-menu-item.danger .icon { color: var(--red); }
.msg-menu-item.danger:hover { background: var(--red-50); }
.msg-quote {
  display: flex;
  flex-direction: column;
  gap: 1px;
  width: 100%;
  min-width: 140px;
  margin-bottom: 6px;
  padding: 5px 10px 5px 9px;
  border: 0;
  border-left: 3px solid var(--brand-500);
  border-radius: 8px;
  background: var(--subtle);
  color: inherit;
  text-align: left;
  font-size: 13px;
  line-height: 1.35;
}
.mine .msg-quote { border-left-color: rgb(255 255 255 / 0.85); background: rgb(255 255 255 / 0.15); }
.msg-quote:hover { filter: brightness(1.06); }
.msg-quote-name { color: var(--brand-text); font-weight: 700; }
.mine .msg-quote-name { color: #fff; }
.msg-quote-text { display: -webkit-box; overflow: hidden; opacity: 0.85; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.msg.has-image .msg-quote { margin: 2px 2px 6px; width: auto; }
.msg.flash .bubble { animation: msg-flash 1.5s ease; }
@keyframes msg-flash { 0%, 30% { box-shadow: 0 0 0 3px var(--brand-300); } 100% { box-shadow: 0 0 0 3px transparent; } }
.reply-bar { display: flex; flex-shrink: 0; align-items: center; gap: 10px; padding: 8px 12px 0 16px; border-top: 1px solid var(--line); background: var(--surface); }
.reply-bar + .attach-bar, .reply-bar ~ .composer { border-top: 0; }
.reply-bar-icon { color: var(--brand-text); }
.reply-bar-main { flex: 1; min-width: 0; padding-left: 10px; border-left: 3px solid var(--brand-500); }
.reply-bar-title { color: var(--brand-text); font-size: 13px; font-weight: 700; }
.reply-bar-text { overflow: hidden; color: var(--ink-3); font-size: 13.5px; text-overflow: ellipsis; white-space: nowrap; }
.pinned-bar { display: flex; flex-shrink: 0; align-items: center; gap: 4px; padding: 0 8px 0 0; border-bottom: 1px solid var(--line); background: var(--surface); }
.pinned-main { display: flex; flex: 1; align-items: center; gap: 10px; min-width: 0; padding: 7px 8px 7px 16px; border: 0; background: none; color: inherit; text-align: left; }
.pinned-main:hover { background: var(--subtle); }
.pinned-icon { color: var(--brand-text); }
.pinned-body { min-width: 0; padding-left: 10px; border-left: 3px solid var(--brand-500); }
.pinned-title { color: var(--brand-text); font-size: 12.5px; font-weight: 700; }
.pinned-text { overflow: hidden; color: var(--ink-3); font-size: 13.5px; text-overflow: ellipsis; white-space: nowrap; }
.ctx-divider { height: 1px; margin: 4px 8px; background: var(--line); }
.cand-mark { display: inline-flex; flex-shrink: 0; margin-left: -4px; color: var(--faint); }
.copy-scratch { position: fixed; top: -1000px; left: -1000px; opacity: 0; }
@media (pointer: coarse) {
  .msg-menu-btn { display: none; } /* phones: tap the message instead */
  .bubble { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
}
.msg-edited { font-style: italic; }
.msg.deleted .bubble { border: 1px dashed var(--line-strong); background: transparent; box-shadow: none; color: var(--muted); }
.msg-deleted-text { display: flex; align-items: center; gap: 6px; font-size: 14px; font-style: italic; }
.mine.deleted .msg-meta, .theirs.deleted .msg-meta { color: var(--faint); }
.msg-reactions { display: flex; flex-wrap: wrap; gap: 4px; max-width: min(78%, 620px); margin-top: 4px; }
.mine .msg-reactions { justify-content: flex-end; }
.reaction {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 26px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-3);
  font-size: 12.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.reaction:hover { border-color: var(--brand-200); }
.reaction.mine { border-color: var(--brand-300); background: var(--brand-50); color: var(--brand-text); }
.reaction-emoji { font-size: 15px; line-height: 1; }
.react-pick { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 999px; background: none; color: var(--muted); font-size: 21px; line-height: 1; transition: transform 0.1s ease; }
.react-pick:hover { background: var(--subtle); transform: scale(1.15); }
.react-pick[aria-pressed="true"], .react-pick.active { background: var(--brand-50); }
.react-pick.more { font-size: 0; }
.deleted-preview { display: inline-flex; align-items: center; gap: 4px; color: var(--faint); font-style: italic; }
.deleted-preview .icon { flex-shrink: 0; }
.composer { position: relative; }
.attach-toggle { display: grid; flex-shrink: 0; place-items: center; width: 38px; height: 46px; padding: 0; border: 0; border-radius: 12px; background: none; color: var(--muted); }
.attach-toggle:hover { background: var(--subtle); color: var(--brand-text); }
.attach-bar { display: flex; flex-shrink: 0; align-items: center; gap: 12px; padding: 10px 12px 0 16px; border-top: 1px solid var(--line); background: var(--surface); }
.attach-bar + .composer { border-top: 0; }
.attach-thumb { width: 46px; height: 46px; border-radius: 10px; object-fit: cover; }
.attach-icon { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 10px; background: var(--brand-50); color: var(--brand-text); }
.attach-text { flex: 1; min-width: 0; }
.attach-name { overflow: hidden; color: var(--ink); font-size: 14px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.attach-size { overflow: hidden; color: var(--muted); font-size: 12.5px; text-overflow: ellipsis; white-space: nowrap; }
.msg-media { display: flex; flex-direction: column; gap: 6px; }
.msg.has-image .bubble { padding: 4px 4px 6px; }
.msg.has-image .msg-text, .msg.has-image .msg-meta { padding: 0 8px; }
.msg.has-image .msg-text { margin-top: 4px; }
.msg-image-btn { display: block; padding: 0; border: 0; border-radius: 14px; background: none; cursor: zoom-in; overflow: hidden; }
.msg-image { display: block; width: auto; max-width: min(300px, 100%); height: auto; max-height: 340px; border-radius: 14px; object-fit: cover; background: var(--subtle); }
.msg-file { display: flex; align-items: center; gap: 10px; min-width: 220px; max-width: 320px; padding: 8px 10px; border-radius: 12px; color: inherit; text-decoration: none !important; }
.mine .msg-file { background: rgb(255 255 255 / 0.14); color: #fff; }
.theirs .msg-file { background: var(--subtle); color: var(--ink-2); }
.msg.has-file .msg-text { margin-top: 6px; }
.msg-file-icon { position: relative; display: grid; flex-shrink: 0; place-items: center; width: 40px; height: 44px; }
.msg-file-ext { position: absolute; bottom: 7px; left: 50%; padding: 0 3px; border-radius: 3px; background: var(--brand-600); color: #fff; font-size: 8.5px; font-weight: 800; letter-spacing: 0.02em; transform: translateX(-50%); }
.mine .msg-file-ext { background: #fff; color: var(--brand-700); }
.msg-file-text { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.msg-file-name { overflow: hidden; font-size: 14px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.msg-file-size { font-size: 12px; opacity: 0.75; }
.msg-file-get { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 999px; background: rgb(0 0 0 / 0.08); }
.mine .msg-file-get { background: rgb(255 255 255 / 0.18); }
a.msg-file:hover .msg-file-get { background: var(--brand-500); color: #fff; }
.upload-state { display: flex; flex-direction: column; gap: 4px; padding: 0 6px; font-size: 12px; opacity: 0.85; }
.upload-progress { height: 4px; border-radius: 999px; background: rgb(127 127 127 / 0.3); overflow: hidden; }
.upload-progress span { display: block; height: 100%; border-radius: 999px; background: currentColor; transition: width 0.2s ease; }
.lightbox { position: fixed; inset: 0; z-index: 80; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px; background: rgb(6 9 16 / 0.88); }
.lightbox-img { max-width: min(1100px, 100%); max-height: calc(100vh - 120px); border-radius: 10px; object-fit: contain; box-shadow: var(--shadow-lg); }
.lightbox-bar { display: flex; align-items: center; gap: 10px; max-width: 100%; }
.lightbox-name { overflow: hidden; color: #e2e8f0; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.lightbox-close { color: #e2e8f0; }
.lightbox-close:hover { background: rgb(255 255 255 / 0.1); }
.chat-body { position: relative; }
.drop-hint {
  position: absolute;
  inset: 10px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 2px dashed var(--brand-300);
  border-radius: 18px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  color: var(--brand-text);
  font-size: 16px;
  font-weight: 700;
  pointer-events: none;
}
.emoji-toggle { display: grid; flex-shrink: 0; place-items: center; width: 40px; height: 46px; padding: 0; border: 0; border-radius: 12px; background: none; color: var(--muted); }
.emoji-toggle:hover, .emoji-toggle[aria-expanded="true"] { background: var(--subtle); color: var(--brand-text); }
.emoji-panel {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 12px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  width: min(352px, calc(100% - 24px));
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-2);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.emoji-panel.inline { position: static; width: 100%; border: 0; border-radius: 0; box-shadow: none; }
.emoji-tabs { display: flex; gap: 2px; padding: 6px; border-bottom: 1px solid var(--line); }
.emoji-tab { flex: 1; height: 34px; padding: 0; border: 0; border-radius: 8px; background: none; font-size: 18px; line-height: 1; opacity: 0.6; }
.emoji-tab:hover { background: var(--subtle); opacity: 1; }
.emoji-tab.active { background: var(--brand-50); opacity: 1; }
.emoji-title { padding: 8px 12px 2px; color: var(--muted); font-size: 12px; font-weight: 700; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 2px; max-height: 236px; padding: 4px 8px 10px; overflow-y: auto; }
.emoji-btn { display: grid; place-items: center; height: 38px; padding: 0; border: 0; border-radius: 8px; background: none; font-size: 23px; line-height: 1; }
.emoji-btn:hover { background: var(--subtle); }
@media (max-width: 560px) {
  .emoji-panel { left: 8px; width: calc(100% - 16px); }
  .emoji-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .composer { gap: 6px; padding-left: 8px; }
}
.msg.editing .bubble { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--brand-300); }
.edit-bar { display: flex; flex-shrink: 0; align-items: center; gap: 10px; padding: 8px 12px 0 16px; border-top: 1px solid var(--line); background: var(--surface); }
.edit-bar-icon { color: var(--brand-text); }
.edit-bar-main { flex: 1; min-width: 0; padding-left: 10px; border-left: 3px solid var(--brand-500); }
.edit-bar-title { color: var(--brand-text); font-size: 12.5px; font-weight: 700; }
.edit-bar-text { overflow: hidden; color: var(--muted); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.composer.is-editing { border-top: 0; }
.msg-retry { margin-top: 4px; padding: 0; border: 0; background: none; color: var(--red); font-size: 12.5px; font-weight: 600; }
.typing { display: flex; align-items: center; gap: 8px; width: 100%; max-width: 860px; margin: 10px auto 0; color: var(--muted); font-size: 13px; }
.dots { display: inline-flex; gap: 3px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 14px; border-bottom-left-radius: 5px; background: var(--bubble-theirs); }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); animation: blink 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: 0.15s; }
.dots i:nth-child(3) { animation-delay: 0.3s; }
.jump {
  position: absolute;
  bottom: 14px;
  left: 50%;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: var(--toast-bg);
  color: var(--toast-fg);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow);
  transform: translateX(-50%);
}
.composer {
  display: flex;
  flex-shrink: 0;
  align-items: flex-end;
  gap: 10px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.composer-input {
  flex: 1;
  min-height: 46px;
  max-height: 160px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--subtle);
  color: var(--ink);
  font-size: 16px; /* 16px or more stops iPhones from zooming in on focus */
  line-height: 1.4;
  resize: none;
  transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}
.composer-input::placeholder { color: var(--faint); }
.composer-input:focus { outline: none; border-color: var(--brand-500); background: var(--input-bg); box-shadow: var(--ring); }
.send-btn {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 14px;
  background: var(--brand-600);
  color: #fff;
  transition: background-color 0.15s, opacity 0.15s, transform 0.05s;
}
.send-btn:hover:not(:disabled) { background: var(--brand-hover); }
.send-btn:active:not(:disabled) { transform: scale(0.96); }
.send-btn:disabled { opacity: 0.4; cursor: default; }

/* candidate chat page */
.chat-page { display: flex; flex: 1; justify-content: center; min-height: 0; padding: 20px; }
.chat-page .chat { width: 100%; max-width: 920px; overflow: hidden; border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow-sm); }

/* --------------------------------------------------------- announcements */

.ann-mark { background: linear-gradient(135deg, #f59e0b, #ef4444); }
.ann-mark .icon { color: #fff; }
.channel-row .peer-mark { width: 46px; height: 46px; border-radius: 14px; }
.channel-row { margin-bottom: 4px; }

/* An announcement inside a conversation, between the messages */
.msg-ann { display: flex; justify-content: center; margin: 14px 0 4px; }
.msg-ann-card {
  width: min(100%, 560px);
  padding: 12px 14px;
  border: 1px solid var(--amber-200);
  border-radius: 16px;
  background: var(--amber-50);
  box-shadow: var(--shadow-xs);
}
.msg-ann-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--ink); font-size: 13px; }
.msg-ann-icon {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 8px;
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: #fff;
}
.msg-ann-time { color: var(--muted); font-size: 12px; }
.msg-ann-body { margin-top: 6px; color: var(--ink-2); font-size: 14.5px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-ann-body a, .ann-card-body a { color: var(--brand-text); text-decoration: underline; }
.ann-new { padding: 1px 8px; border-radius: 999px; background: #ef4444; color: #fff; font-size: 11px; font-weight: 700; letter-spacing: 0.02em; }

/* Announcement cards in the admin Announcements channel */
.ann-feed { gap: 0; }
.ann-card {
  width: 100%;
  max-width: 680px;
  margin: 12px auto 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}
.ann-card-body { color: var(--ink); font-size: 15px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.ann-card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; color: var(--muted); font-size: 12.5px; }
.ann-card-meta strong { color: var(--ink-2); font-weight: 650; }
.ann-card-meta .icon { color: #f59e0b; }
.ann-seen { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; }
.ann-seen .icon { color: var(--muted); }
.ann-seen.all, .ann-seen.all .icon { color: var(--green); }
.ann-del { width: 30px; height: 30px; margin-left: auto; }
.ann-composer { flex-shrink: 0; border-top: 1px solid var(--line); background: var(--surface); }
.ann-composer .composer { padding-bottom: 6px; border-top: 0; }
.composer-tip { padding: 0 16px 10px; color: var(--muted); font-size: 12px; }
.announce-btn { flex-shrink: 0; height: 46px; }

/* ----------------------------------------------------------------- admin */

.admin-body { display: grid; flex: 1; grid-template-columns: 340px minmax(0, 1fr); min-height: 0; background: var(--surface); }
.admin-body.show-profile { grid-template-columns: 340px minmax(0, 1fr) 320px; }
.sidebar { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); background: var(--surface); }
.sidebar-head { display: flex; flex-direction: column; gap: 14px; padding: 18px 16px 12px; border-bottom: 1px solid var(--line-2); }
.sidebar-title { display: flex; align-items: center; gap: 10px; }
.sidebar-title h1 { font-size: 20px; }
.count { padding: 1px 9px; border-radius: 999px; background: var(--subtle); color: var(--ink-3); font-size: 13px; font-weight: 700; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stat { padding: 8px 10px; border-radius: 12px; background: var(--subtle); }
.stat-value { color: var(--ink); font-size: 18px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-label { margin-top: 2px; color: var(--muted); font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.stat.green .stat-value { color: var(--green); }
.stat.accent .stat-value { color: var(--brand-text); }
.search { position: relative; }
.search .icon { position: absolute; top: 50%; left: 12px; color: var(--faint); pointer-events: none; transform: translateY(-50%); }
.search-input { height: 40px; padding-left: 38px; border-color: transparent; background: var(--subtle); font-size: 16px; box-shadow: none; }
.search-input:hover { border-color: var(--line); }
.search-input:focus { background: var(--input-bg); }
.tabs { display: flex; gap: 4px; padding: 3px; border-radius: 10px; background: var(--subtle); }
.tab {
  display: inline-flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
.tab.active { background: var(--tab-active); color: var(--ink); box-shadow: var(--shadow-xs); }
.tab-count { padding: 0 6px; border-radius: 999px; background: var(--line); color: var(--ink-3); font-size: 11px; line-height: 17px; }
.tab.active .tab-count { background: var(--brand-50); color: var(--brand-700); }

.cand-list { flex: 1; overflow-y: auto; padding: 6px; }
.cand {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  text-align: left;
  transition: background-color 0.12s;
}
.cand:hover { background: var(--subtle); }
.cand.active { background: var(--brand-50); }
.cand-main { flex: 1; min-width: 0; }
.cand-top, .cand-bottom { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cand-name { overflow: hidden; color: var(--ink); font-size: 14.5px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.cand-time { flex-shrink: 0; margin-left: auto; color: var(--faint); font-size: 12px; }
.cand-meta { margin-top: 1px; overflow: hidden; color: var(--ink-3); font-size: 12.5px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.cand-preview { margin-top: 2px; overflow: hidden; color: var(--muted); font-size: 13.5px; text-overflow: ellipsis; white-space: nowrap; }
.cand.has-unread .cand-name { font-weight: 800; }
.cand.has-unread .cand-preview { color: var(--ink-2); font-weight: 600; }
.cand.has-unread .cand-time { color: var(--brand-text); font-weight: 700; }
.you { color: var(--faint); font-weight: 500; }
.none { color: var(--faint); font-style: italic; }
.typing-text { color: var(--brand-text); font-style: italic; font-weight: 600; }
.unread-badge {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--brand-600);
  color: #fff;
  font-size: 11.5px;
  font-weight: 700;
}
.list-empty { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 40px 20px; color: var(--muted); text-align: center; }
.skeleton { display: flex; align-items: center; gap: 12px; padding: 10px; }
.sk { display: block; border-radius: 8px; background: linear-gradient(90deg, var(--subtle), var(--skeleton-hi), var(--subtle)); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
.sk-avatar { width: 46px; height: 46px; flex-shrink: 0; border-radius: 50%; }
.sk-lines { display: flex; flex: 1; flex-direction: column; gap: 8px; }
.sk-line { height: 12px; }
.sk-line.short { width: 60%; }

.conversation { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.convo-empty { display: flex; flex: 1; align-items: center; justify-content: center; padding: 24px; background: var(--chat-bg); }

.profile-panel { display: none; min-height: 0; overflow-y: auto; padding: 0 20px 24px; border-left: 1px solid var(--line); background: var(--surface); }
.show-profile .profile-panel { display: block; }
.panel-backdrop { display: none; }
.panel-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
  margin: 0 -20px 20px;
  padding: 0 12px 0 20px;
  border-bottom: 1px solid var(--line-2);
  background: var(--surface);
}
.panel-head h2 { font-size: 15px; }
.panel-hero { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-bottom: 20px; text-align: center; }
.panel-name { margin-top: 8px; color: var(--ink); font-size: 18px; font-weight: 800; }
.panel-sub { color: var(--muted); font-size: 13px; }
.panel-sub.online { color: var(--green); font-weight: 600; }
.details { display: flex; flex-direction: column; gap: 2px; margin-bottom: 20px; }
.detail { display: flex; align-items: flex-start; gap: 12px; padding: 10px 12px; border-radius: 12px; }
.detail:hover { background: var(--subtle); }
.detail-icon { display: grid; flex-shrink: 0; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--subtle); color: var(--ink-3); }
.detail:hover .detail-icon { background: var(--surface); }
.detail-text { min-width: 0; }
.detail-label { color: var(--muted); font-size: 12px; font-weight: 600; }
.detail-value { margin-top: 1px; color: var(--ink); font-size: 14.5px; font-weight: 500; overflow-wrap: anywhere; }
.panel-actions { display: grid; gap: 10px; }
.back-btn { display: none; }

/* ------------------------------------------------- pages (profiles, tests) */

.page-scroll { flex: 1; min-height: 0; overflow-y: auto; }
.page { width: 100%; max-width: 1240px; margin: 0 auto; padding: 28px 28px 48px; }
.page-head { margin-bottom: 20px; }
.page-title { display: flex; align-items: center; gap: 10px; }
.page-title h1 { font-size: 26px; letter-spacing: -0.02em; }
.page-sub { margin-top: 6px; color: var(--ink-3); }
.page-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 20px; }
.page-tools .search { flex: 1 1 260px; max-width: 420px; }
.page-tools .tabs { flex: 0 0 auto; }
.page-tools .tab { padding: 0 12px; }
.page-empty { display: flex; min-height: 320px; }

.view-toggle { display: inline-flex; gap: 2px; margin-left: auto; padding: 3px; border-radius: 10px; background: var(--subtle); }
.view-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
.view-btn:hover { color: var(--ink); }
.view-btn.active { background: var(--tab-active); color: var(--ink); box-shadow: var(--shadow-xs); }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* List view: one row per person. */
.ptable-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-xs); }
.ptable { width: 100%; border-collapse: collapse; font-size: 14px; }
.ptable th {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--subtle);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}
.ptable td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); color: var(--ink-2); white-space: nowrap; vertical-align: middle; }
.ptable tbody tr:last-child td { border-bottom: 0; }
.ptable tbody tr:hover td { background: var(--subtle); }
.ptable td a:not(.btn) { color: var(--ink-2); }
.ptable td a:not(.btn):hover { color: var(--brand-text); }
.pt-person { display: flex; align-items: center; gap: 12px; min-width: 0; }
.pt-person-text { min-width: 0; max-width: 240px; }
.pt-name, .pt-email, .pt-sub, .clip { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pt-name { color: var(--ink); font-weight: 650; }
.pt-email { color: var(--muted); font-size: 12.5px; }
.pt-sub { display: none; margin-top: 2px; color: var(--ink-3); font-size: 12.5px; }
.clip { max-width: 220px; }
.pt-status { color: var(--muted); font-size: 13px; }
.pt-status.online { color: var(--green); font-weight: 600; }
.col-status .badge { margin-left: 8px; }
.ptable .col-action { text-align: right; }

.profile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.grid-empty { grid-column: 1 / -1; display: flex; justify-content: center; padding: 24px 0; }
.pcard {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.pcard:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.pcard-top { display: flex; align-items: center; gap: 14px; min-width: 0; }
.pcard-id { min-width: 0; }
.pcard-id h3 { overflow: hidden; font-size: 16px; text-overflow: ellipsis; white-space: nowrap; }
.pcard-loc { display: flex; align-items: center; gap: 4px; margin-top: 3px; color: var(--ink-3); font-size: 13px; }
.pcard-loc span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcard-status { margin-top: 2px; color: var(--muted); font-size: 12.5px; }
.pcard-status.online { color: var(--green); font-weight: 600; }
.pcard-badge { align-self: flex-start; }
.pcard-rows { display: flex; flex-direction: column; gap: 9px; padding: 12px 0; border-top: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2); }
.pcard-row { display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--ink-2); font-size: 13.5px; }
.pcard-row .icon { color: var(--muted); }
.pcard-row a, .pcard-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcard-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-top: auto; }
.pcard-joined { color: var(--muted); font-size: 12.5px; }
.sk-block { height: 92px; }

/* -------------------------------------------------------------- payments */

.page-head-row { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 16px; }
.summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.sum-card { padding: 14px 16px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-xs); }
.sum-label { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.sum-value { margin-top: 4px; color: var(--ink); font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 32px;
  padding: 0 4px 0 12px;
  border-radius: 999px;
  background: var(--brand-50);
  color: var(--brand-text);
  font-size: 13px;
  font-weight: 600;
}
.filter-chip button { display: grid; place-items: center; width: 24px; height: 24px; border: 0; border-radius: 999px; background: transparent; color: inherit; }
.filter-chip button:hover { background: var(--brand-100); }
.link-like { padding: 0; border: 0; background: none; color: var(--ink); font-weight: 650; text-align: left; cursor: pointer; }
.link-like:hover { color: var(--brand-text); text-decoration: underline; }
.amount { color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }
.paytable .col-del { width: 1%; text-align: right; }
.danger-btn:hover { background: var(--red-50); color: var(--red); }

/* The payments sheet: names on the left, the days of a month across the top. */
.page-wide { max-width: none; }
.month-picker { display: inline-flex; align-items: center; gap: 6px; }
.month-picker .select-wrap { width: 190px; }
.month-select { height: 40px; font-weight: 600; }
.month-step { border: 1px solid var(--line); background: var(--surface); }
.month-step:disabled { opacity: 0.4; cursor: default; }
.sheet-hint { margin-top: 10px; color: var(--muted); font-size: 13px; }

.sheet-wrap {
  position: relative;
  max-height: max(360px, calc(100dvh - 330px));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  /* keep the selected cell clear of the pinned header, footer and columns */
  scroll-padding: 50px 140px 44px 250px;
}
.sheet { border-collapse: separate; border-spacing: 0; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.sheet th, .sheet td { border-right: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2); background: var(--surface); }
.sheet thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  height: 50px;
  padding: 4px;
  border-bottom: 1px solid var(--line);
  background: var(--subtle);
  color: var(--muted);
  font-weight: 600;
  text-align: center;
}
.sheet tfoot th, .sheet tfoot td {
  position: sticky;
  bottom: 0;
  z-index: 2;
  border-top: 1px solid var(--line);
  border-bottom: 0;
  background: var(--subtle);
  color: var(--ink);
  font-weight: 700;
}
.sheet .sticky-left { position: sticky; left: 0; z-index: 1; border-right: 1px solid var(--line); }
.sheet .sticky-right { position: sticky; right: 0; z-index: 1; border-left: 1px solid var(--line); }
.sheet thead .sticky-left, .sheet thead .sticky-right, .sheet tfoot .sticky-left, .sheet tfoot .sticky-right { z-index: 3; }
.sh-name { min-width: 230px; max-width: 260px; padding: 6px 12px; text-align: left; }
.sheet thead .sh-name, .sheet tfoot .sh-name, .sheet thead .sh-total { color: var(--ink-3); font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; }
.sheet thead .sh-name { text-align: left; }
.sh-person { display: flex; align-items: center; gap: 9px; min-width: 0; }
.sh-person-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.sh-pname { overflow: hidden; color: var(--ink); font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.sh-psub { overflow: hidden; color: var(--muted); font-size: 11.5px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.sh-day { width: 76px; min-width: 76px; max-width: 76px; padding: 0; }
.sh-daynum { display: block; color: var(--ink-2); font-size: 14px; font-weight: 700; line-height: 1.2; }
.sh-wd { display: block; font-size: 10.5px; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; }
.sheet thead th.weekend .sh-daynum { color: var(--muted); }
.sheet td.weekend { background: var(--weekend-bg); }
.sheet td.today { background: var(--today-bg); }
.sheet td.future { background: var(--subtle); }
.sheet .week-start { border-left: 2px solid var(--line); }
.sheet thead th.today, .sheet thead th.today .sh-daynum { color: var(--brand-text); }
.sheet thead th.col-focus { box-shadow: inset 0 -3px 0 var(--brand-500); }
.sheet tr.row-focus .sh-name { box-shadow: inset 3px 0 0 var(--brand-500); }
.sheet tfoot td.sh-day { background: var(--subtle); }
.cell {
  display: block;
  width: 100%;
  height: 40px;
  padding: 0 8px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: right;
  outline: none;
}
.cell:focus { background: var(--input-bg); box-shadow: inset 0 0 0 2px var(--brand-500); }
.cell[readonly] { cursor: not-allowed; }
.sheet td.has-pay .cell { font-weight: 650; }
.sheet td.multi .cell { text-decoration: underline dotted var(--muted); }
.sheet td.saving .cell { color: var(--muted); }
.cell.flash-ok { animation: cell-ok 1s ease-out; }
.cell.flash-bad { animation: cell-bad 1.2s ease-out; }
.sh-total { min-width: 130px; padding: 6px 12px; color: var(--ink); font-weight: 700; text-align: right; white-space: nowrap; }
.sh-daytotal { padding: 0 6px; overflow: hidden; font-size: 11.5px; text-align: right; text-overflow: ellipsis; white-space: nowrap; }
@keyframes cell-ok { from { background: rgb(34 197 94 / 0.3); } to { background: transparent; } }
@keyframes cell-bad { from { background: rgb(239 68 68 / 0.32); } to { background: transparent; } }

/* The candidate's own payments, month by month */
.page-narrow { max-width: 820px; }
.salary-note { color: var(--ink-2); font-weight: 600; }
.pay-month { margin-bottom: 22px; }
.pay-month-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 4px 10px; }
.pay-month-head h2 { font-size: 16px; }
.pay-month-total { color: var(--ink); font-weight: 800; font-variant-numeric: tabular-nums; }
.pay-rows { overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-xs); }
.pay-row { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-bottom: 1px solid var(--line-2); }
.pay-row:last-child { border-bottom: 0; }
.pay-row-icon { display: grid; flex-shrink: 0; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: var(--green-50); color: var(--green); }
.pay-row-main { flex: 1; min-width: 0; }
.pay-row-date { color: var(--ink); font-weight: 600; }
.pay-row-note { margin-top: 2px; overflow: hidden; color: var(--muted); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.pay-row-amount { color: var(--green); font-size: 16px; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* The "Add payment" window */
.dialog {
  width: min(540px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  color: var(--ink-2);
  box-shadow: var(--shadow-lg);
}
.dialog[open] { animation: pop 0.16s ease-out; }
.dialog::backdrop { background: var(--backdrop); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 16px 4px 22px; }
.dialog-head h2 { overflow: hidden; font-size: 18px; text-overflow: ellipsis; white-space: nowrap; }
.dialog form { padding: 12px 22px 22px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* Payments inside the candidate details panel */
.panel-section { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line-2); }
.panel-section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.panel-section-head h3 { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.panel-section-head h3 .icon { color: var(--muted); }
.panel-loading { display: flex; justify-content: center; padding: 14px; }
.pay-summary { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; margin-bottom: 10px; }
.pay-summary > div { padding: 10px 12px; border-radius: 12px; background: var(--subtle); }
.pay-label { color: var(--muted); font-size: 12px; font-weight: 600; }
.pay-total, .pay-last { margin-top: 2px; color: var(--ink); font-weight: 700; overflow-wrap: anywhere; }
.pay-list { display: flex; flex-direction: column; margin: 0 0 12px; padding: 0; list-style: none; }
.pay-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 9px 0; border-bottom: 1px solid var(--line-2); font-size: 13.5px; }
.pay-date { color: var(--ink-3); }
.pay-amount { color: var(--ink); font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.pay-note { grid-column: 1 / -1; overflow: hidden; color: var(--muted); font-size: 12.5px; text-overflow: ellipsis; white-space: nowrap; }
.small { font-size: 13px; }

/* --------------------------------------------------------------- profile */

.profile-page { flex: 1; overflow-y: auto; padding: 28px 16px 48px; }
.profile-wrap { max-width: 580px; margin: 0 auto; }
.back-link { margin-bottom: 14px; }
.profile-card { padding: 32px; }
.avatar-uploader {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 16px;
  border: 1px dashed var(--line-strong);
  border-radius: 16px;
  background: var(--subtle);
  transition: border-color 0.15s, background-color 0.15s;
}
.avatar-uploader.dragging { border-color: var(--brand-500); background: var(--brand-50); }
.avatar-uploader.has-error { border-color: var(--red); background: var(--red-50); }
.avatar-drop { position: relative; flex-shrink: 0; padding: 0; border: 0; border-radius: 50%; background: none; }
.avatar-drop .avatar, .avatar-placeholder { box-shadow: 0 0 0 4px var(--surface), var(--shadow-sm); }
.avatar-placeholder { display: grid; place-items: center; width: 96px; height: 96px; border-radius: 50%; background: var(--surface); color: var(--faint); }
.camera-badge {
  position: absolute;
  right: -2px;
  bottom: -2px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 3px solid var(--surface);
  border-radius: 50%;
  background: var(--brand-600);
  color: #fff;
}
.uploader-text { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.uploader-title { color: var(--ink); font-weight: 700; }
.form-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 4px; }
.signed-in-as { margin-top: 20px; text-align: center; font-size: 13.5px; color: var(--muted); }

/* -------------------------------------------------------------- notfound */

.notfound { display: grid; place-items: center; min-height: 100vh; padding: 24px; text-align: center; }
.notfound-inner { display: flex; flex-direction: column; align-items: center; gap: 12px; max-width: 420px; }
.nf-code {
  margin-top: 24px;
  background: linear-gradient(120deg, var(--brand-600), var(--violet));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-size: 88px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.04em;
}
.notfound h1 { font-size: 24px; }
.notfound .btn { margin-top: 8px; }

/* ------------------------------------------------------------ animations */

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes blink { 0%, 60%, 100% { opacity: 0.3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-2px); } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes slidein { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@keyframes shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(3px); }
  30%, 50%, 70% { transform: translateX(-6px); }
  40%, 60% { transform: translateX(6px); }
}

/* ------------------------------------------------------------ responsive */

/* Below 1440px the candidate details open as a drawer instead of a third column. */
@media (max-width: 1439px) {
  .admin-body.show-profile { grid-template-columns: 340px minmax(0, 1fr); }
  .profile-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    width: min(360px, 100vw);
    box-shadow: var(--shadow-lg);
  }
  .show-profile .profile-panel { animation: slidein 0.2s ease-out; }
  .show-profile .panel-backdrop { position: fixed; inset: 0; z-index: 55; display: block; background: var(--backdrop); }
}

/* List view: drop the less important columns as space runs out. */
@media (max-width: 1499px) {
  .ptable .col-joined, .ptable .col-tg { display: none; }
}
@media (max-width: 1199px) {
  .ptable .col-wa, .ptable .col-by { display: none; }
}
@media (max-width: 999px) {
  .ptable .col-phone, .ptable .col-status, .ptable .col-method { display: none; }
  .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .sh-name { min-width: 150px; max-width: 160px; padding: 6px 8px; }
  .sh-person .avatar { display: none; }
  .sheet-wrap { scroll-padding: 50px 120px 44px 160px; }
  .month-picker { flex-wrap: wrap; }
  .announce-btn span { display: none; }
  .announce-btn { width: 46px; padding: 0; }
  .ptable thead, .ptable .col-loc, .ptable .col-salary, .ptable .col-paid, .ptable .col-note { display: none; }
  .pt-sub { display: block; }
  .ptable .msg-label, .view-btn span { display: none; }
}

/* Medium screens: the left bar shrinks to icons only. */
@media (max-width: 1199px) {
  .shell { grid-template-columns: 76px minmax(0, 1fr); }
  .side-nav { align-items: center; padding: 16px 10px 14px; }
  .side-logo { padding: 0 0 18px; }
  .side-logo .logo-word, .side-logo .badge, .nav-label, .user-chip-text, .user-chip.wide > .icon { display: none; }
  .nav { align-items: center; }
  .nav-item { justify-content: center; width: 48px; padding: 0; }
  .side-bottom { flex-direction: column; }
  .side-bottom .user-menu { flex: none; }
  .user-chip.wide { width: auto; padding: 3px; border-radius: 999px; }
}

@media (max-width: 960px) {
  .hero { padding-top: 72px; padding-bottom: 56px; }
  .steps { grid-template-columns: 1fr; }
}

/* Phones: top bar + bottom tabs; both hide while a conversation is open. */
@media (max-width: 899px) {
  .shell {
    grid-template-areas: "top" "main" "tabs";
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
  }
  .side-nav { display: none; }
  .mobile-top {
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 58px;
    padding: 0 12px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
  }
  .tabbar {
    z-index: 20;
    display: flex;
    padding-bottom: env(safe-area-inset-bottom);
    border-top: 1px solid var(--line);
    background: var(--surface);
  }
  .tab-item {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    height: 58px;
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 600;
    text-decoration: none !important;
  }
  .tab-item.active { color: var(--brand-text); }
  .shell.in-conversation .mobile-top, .shell.in-conversation .tabbar { display: none; }
  .page { padding: 20px 16px 32px; }
  .admin-body, .admin-body.show-profile { grid-template-columns: minmax(0, 1fr); }
  .admin-body .conversation { display: none; }
  .admin-body.show-chat .sidebar { display: none; }
  .admin-body.show-chat .conversation { display: flex; }
  .sidebar { border-right: 0; }
  .back-btn { display: inline-grid; }
  .chat-head { padding: 10px 12px; }
}

@media (max-width: 700px) {
  .chat-page { padding: 0; }
  .chat-page .chat { border: 0; border-radius: 0; box-shadow: none; }
  .chat-scroll { --chat-pad: 12px; padding: 12px var(--chat-pad) 8px; }
  .bubble { max-width: 86%; }
}

@media (max-width: 560px) {
  .container { padding: 0 16px; }
  .hero { padding: 56px 16px 48px; }
  .hero-sub { font-size: 17px; }
  .steps-section { padding: 8px 16px 64px; }
  .land-nav .btn { height: 40px; padding: 0 12px; }
  .land-nav .btn-secondary span { display: none; }
  .hero-cta .btn { flex: 1 1 100%; }
  .user-chip { padding: 3px; }
  .user-chip-name, .user-chip .icon { display: none; }
  .toasts { left: 16px; right: 16px; max-width: none; }
  .stats { gap: 6px; }
  .stat { padding: 7px 8px; }
  .profile-card { padding: 24px 18px; }
}

@media (max-width: 420px) {
  .land-nav .btn-ghost { display: none; }
}

@media (max-width: 480px) {
  .auth-card { padding: 28px 20px 24px; border-radius: 20px; }
  .auth-top { padding: 18px; }
  .auth-top .theme-toggle { right: 14px; }
  .auth-main { padding-top: 4px; }
  .code-input { gap: 6px; }
  .code-box { width: 44px; height: 54px; font-size: 22px; }
  .avatar-uploader { flex-direction: column; text-align: center; }
  .uploader-text { align-items: center; }
  .field-row.two { grid-template-columns: minmax(0, 1fr); }
}

/* -------------------------------------------------------- alerts */

.alerts-prompt {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 10px;
  padding: 8px 12px 8px 16px;
  border-bottom: 1px solid var(--brand-100);
  background: var(--brand-50);
  color: var(--ink-2);
  font-size: 13.5px;
}
.alerts-prompt > .icon { color: var(--brand-text); }
.alerts-prompt-text { flex: 1; min-width: 0; }
.alerts-prompt .btn { flex-shrink: 0; }
.menu-state { margin-left: auto; padding: 1px 8px; border-radius: 999px; background: var(--subtle); color: var(--muted); font-size: 11.5px; font-weight: 700; }
.menu-state.on { background: var(--green-50); color: var(--green); }
@media (max-width: 560px) {
  .alerts-prompt { flex-wrap: wrap; }
  .alerts-prompt-text { flex-basis: calc(100% - 64px); }
}

/* -------------------------------------------------------- referrals */

code {
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--subtle);
  color: var(--ink-2);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.86em;
  overflow-wrap: anywhere;
}

.invite-note {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  padding: 10px 12px;
  border: 1px solid var(--brand-100);
  border-radius: 12px;
  background: var(--brand-50);
  color: var(--brand-800);
  font-size: 14px;
  font-weight: 500;
}

.invite-card { margin-top: 16px; padding: 24px 32px 26px; }
.invite-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 16px; }
.invite-head h2 { font-size: 18px; }
.invite-head p { margin-top: 4px; font-size: 14px; }
.invite-icon { display: grid; flex-shrink: 0; place-items: center; width: 44px; height: 44px; border-radius: 14px; background: var(--brand-50); color: var(--brand-text); }
.invite-row { display: flex; gap: 8px; }
.invite-input { flex: 1; min-width: 0; font-size: 14px; text-overflow: ellipsis; }
.invite-row .btn { flex-shrink: 0; }
.invite-status { margin-top: 12px; color: var(--ink-3); font-size: 14px; }

.page-loading { display: grid; place-items: center; min-height: 320px; }
.demo-toggle { align-self: center; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.ref-notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid var(--brand-100);
  border-radius: 12px;
  background: var(--brand-50);
  color: var(--ink-2);
  font-size: 13.5px;
  line-height: 1.5;
}
.ref-notice > .icon { margin-top: 1px; color: var(--brand-text); }
.ref-notice code { background: var(--surface); }
.demo-hint { max-width: 460px; margin-top: 4px; }

/* Stat tiles: big numbers keep proportional figures. */
.ref-tile .sum-value { font-size: 26px; font-weight: 750; font-variant-numeric: normal; letter-spacing: -0.02em; }
.sum-note { margin-top: 2px; overflow: hidden; color: var(--muted); font-size: 12.5px; text-overflow: ellipsis; white-space: nowrap; }

.ref-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 16px; margin-bottom: 16px; }

/* Chart cards */
.chart-card { min-width: 0; padding: 18px 20px 20px; }
.chart-head { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px 16px; margin-bottom: 14px; }
.chart-title { flex: 1 1 200px; min-width: 0; }
.chart-title h2 { font-size: 16px; letter-spacing: -0.01em; }
.chart-sub { margin-top: 3px; color: var(--muted); font-size: 13px; }
.chart-head .view-toggle { margin-left: auto; }
.chart-head .view-btn { height: 30px; padding: 0 10px; }
.chart-empty { padding: 28px 0; text-align: center; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table td .badge { margin-left: 8px; }

.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; color: var(--muted); font-size: 12.5px; font-weight: 500; }
.chart-body > .legend { margin: -4px 0 8px; }
.legend-item { display: inline-flex; align-items: center; gap: 7px; }
.chart-key { display: inline-block; flex-shrink: 0; width: 14px; height: 2px; border-radius: 2px; background: var(--muted); }
.chart-key.s1, .chart-key.bar-key { background: var(--series-1); }
.chart-key.s2 { background: var(--series-2); }
.chart-key.blank { background: transparent; }

.line-chart { position: relative; touch-action: pan-y; border-radius: 8px; -webkit-tap-highlight-color: transparent; }
.line-chart:focus { outline: none; }
.line-chart:focus-visible { box-shadow: var(--ring); }
.chart-svg { display: block; overflow: visible; font-family: var(--font); }
.chart-grid { stroke: var(--line-2); stroke-width: 1; shape-rendering: crispEdges; }
.chart-base { stroke: var(--line-strong); stroke-width: 1; shape-rendering: crispEdges; }
.chart-tick { fill: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.chart-line { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chart-line.s1 { stroke: var(--series-1); }
.chart-line.s2 { stroke: var(--series-2); }
.chart-dot { stroke: var(--surface); stroke-width: 2; }
.chart-dot.s1 { fill: var(--series-1); }
.chart-dot.s2 { fill: var(--series-2); }
.chart-end { fill: var(--ink); font-size: 12px; font-weight: 650; font-variant-numeric: tabular-nums; }
.chart-vline { stroke: var(--faint); stroke-width: 1; shape-rendering: crispEdges; }

.chart-tip {
  position: absolute;
  z-index: 5;
  min-width: 150px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  box-shadow: var(--shadow);
  color: var(--ink-3);
  font-size: 12.5px;
  pointer-events: none;
}
.chart-tip-title { margin-bottom: 5px; color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; }
.chart-tip-row { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.chart-tip-row + .chart-tip-row { margin-top: 3px; }
.chart-tip-row strong { min-width: 18px; color: var(--ink); font-size: 13.5px; font-variant-numeric: tabular-nums; }

/* Ranked bars */
.bar-chart { position: relative; }
.bars { display: flex; flex-direction: column; gap: 2px; margin: 0; padding: 0; list-style: none; }
.bar-row {
  display: grid;
  grid-template-columns: minmax(0, 150px) minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 38px;
  padding: 4px 6px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  text-align: left;
}
.bar-row:hover, .bar-row:focus-visible { background: var(--subtle); }
.bar-name { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--ink-2); font-size: 13.5px; font-weight: 600; }
.bar-name-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { display: flex; align-items: center; min-width: 0; }
.bar {
  flex-shrink: 0;
  width: calc((100% - 36px) * var(--w, 0));
  min-width: 4px;
  height: 14px;
  border-radius: 0 4px 4px 0;
  background: var(--series-1);
  transition: filter 0.15s ease;
}
.bar-row:hover .bar, .bar-row:focus-visible .bar { filter: brightness(1.12) saturate(1.05); }
.bar-value { margin-left: 8px; color: var(--ink); font-size: 13px; font-weight: 650; font-variant-numeric: tabular-nums; }

/* Referral tree */
.rtree-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 14px; }
.rtree-tools .search { flex: 0 1 260px; }
.find-hint { color: var(--muted); font-size: 13px; }
.find-hint:empty { display: none; }
.rtree-buttons { display: flex; gap: 8px; margin-left: auto; }
.demo-key { display: inline-block; width: 16px; height: 11px; border: 1.5px dashed var(--faint); border-radius: 4px; }
.demo-badge { height: 20px; padding: 0 7px; border: 1px solid var(--line-strong); background: var(--subtle); color: var(--muted); font-size: 11px; }

.rtree-info {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--subtle);
}
.rtree-info-text { flex: 1; min-width: 0; }
.rtree-info-name { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 15px; font-weight: 700; }
.rtree-info-meta { margin-top: 2px; color: var(--ink-3); font-size: 13px; }
.rtree-info-meta .link-btn { font-size: inherit; }
.rtree-info-actions { display: flex; flex-shrink: 0; align-items: center; gap: 6px; }

.rtree-scroll { overflow-x: auto; overflow-y: hidden; padding: 4px 2px 10px; }
.rtree-canvas { position: relative; }
.rtree-links { position: absolute; top: 0; left: 0; overflow: visible; pointer-events: none; }
.rtree-link { fill: none; stroke: var(--line-strong); stroke-width: 1.5; transition: opacity 0.15s ease; }
.rtree-link.on { stroke: var(--series-1); stroke-width: 2; }
.has-selection .rtree-link:not(.on) { opacity: 0.45; }

.rtree-root, .rtree-node {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 12px;
}
.rtree-root { padding: 0 12px; border: 1px solid var(--brand-100); background: var(--brand-50); }
.rtree-mark { width: 30px; height: 30px; border-radius: 10px; font-size: 12px; }
.rtree-node {
  padding: 0 18px 0 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  color: inherit;
  text-align: left;
  transition: opacity 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.rtree-node:hover { border-color: var(--brand-200); }
.rtree-node.is-demo { border-style: dashed; border-color: var(--line-strong); box-shadow: none; }
.rtree-node.is-demo:hover { border-color: var(--brand-300); }
.rtree-node.is-selected { border: 1.5px solid var(--series-1); box-shadow: var(--ring); }
.has-selection .rtree-node:not(.is-selected):not(.is-related) { opacity: 0.45; }
.rtree-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.rtree-name { overflow: hidden; color: var(--ink); font-size: 13.5px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.rtree-sub { overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.rtree-toggle {
  position: absolute;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 5px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}
.rtree-toggle:hover { border-color: var(--brand-300); color: var(--brand-text); }
.rtree-toggle.is-collapsed { border-color: var(--brand-200); background: var(--brand-50); color: var(--brand-text); }

@media (max-width: 1199px) {
  .ref-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .ref-tile .sum-value { font-size: 22px; }
  .rtree-buttons { margin-left: 0; }
  .rtree-tools .search { flex: 1 1 100%; }
  .rtree-info { flex-wrap: wrap; }
  .rtree-info-actions { width: 100%; justify-content: flex-end; }
}
@media (max-width: 560px) {
  .invite-card { padding: 20px 18px; }
  .invite-row { flex-wrap: wrap; }
  .invite-row .invite-input { flex-basis: 100%; }
  .invite-row .btn { flex: 1; }
  .bar-row { grid-template-columns: minmax(0, 1fr); gap: 6px; padding: 6px; }
  .chart-card { padding: 16px 14px 18px; }
}

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