/* NowApp Ops — Commercial Operations Design System */
:root {
  color-scheme: light;
  --bg: #f3f6fa;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --surface-3: #eef3f8;
  --ink: #0b1220;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #dde5ef;
  --line-strong: #c4d0df;
  --primary: #0f172a;
  --accent: #0878bd;
  --accent-hover: #0369a1;
  --accent-soft: #e8f5fc;
  --success: #047857;
  --success-soft: #d1fae5;
  --warn: #b45309;
  --warn-soft: #ffedd5;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --violet: #5b21b6;
  --violet-soft: #ede9fe;
  --rail: #0b1220;
  --rail-line: rgba(148, 163, 184, 0.12);
  --rail-hover: rgba(255, 255, 255, 0.06);
  --rail-active: #0369a1;
  --input-bg: #ffffff;
  --topbar-bg: rgba(255, 255, 255, 0.88);
  --table-head: #f6f8fb;
  --row-hover: #f3f7fb;
  --row-active: #eaf5fc;
  --scrim: rgba(2, 6, 23, 0.52);
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 10px 30px rgba(15, 23, 42, 0.045);
  --shadow-lg: 0 20px 60px rgba(15, 23, 42, 0.18);
  --radius: 12px;
  --radius-sm: 8px;
  --font: "Source Sans 3", "PingFang SC", "Noto Sans SC", sans-serif;
  --font-display: Syne, "Source Sans 3", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --z-rail: 30;
  --z-overlay: 80;
  --z-drawer: 90;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #080d16;
  --surface: #0f1724;
  --surface-2: #131e2d;
  --surface-3: #192638;
  --ink: #f1f5f9;
  --ink-2: #cbd5e1;
  --muted: #8fa1b7;
  --line: #223147;
  --line-strong: #34465e;
  --primary: #26384e;
  --accent: #38a9e8;
  --accent-hover: #5bbbf0;
  --accent-soft: rgba(14, 165, 233, 0.14);
  --success: #34d399;
  --success-soft: rgba(16, 185, 129, 0.14);
  --warn: #fbbf24;
  --warn-soft: rgba(245, 158, 11, 0.14);
  --danger: #fb7185;
  --danger-soft: rgba(244, 63, 94, 0.14);
  --violet: #a78bfa;
  --violet-soft: rgba(139, 92, 246, 0.15);
  --rail: #070c14;
  --rail-line: rgba(148, 163, 184, 0.1);
  --rail-hover: rgba(148, 163, 184, 0.09);
  --rail-active: #0c78b8;
  --input-bg: #0b1320;
  --topbar-bg: rgba(10, 16, 27, 0.9);
  --table-head: #121d2b;
  --row-hover: #142132;
  --row-active: #102b3e;
  --scrim: rgba(0, 0, 0, 0.7);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.28), 0 12px 30px rgba(0, 0, 0, 0.18);
  --shadow-lg: 0 24px 72px rgba(0, 0, 0, 0.45);
}

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

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body,
.topbar,
.panel,
.kpi,
.drawer,
.app-dialog-card,
.export-dialog-card,
.broadcast-modal,
.field input,
.field textarea,
.input,
.btn,
table.data th,
table.data td {
  transition:
    color 0.18s var(--ease),
    background-color 0.18s var(--ease),
    border-color 0.18s var(--ease),
    box-shadow 0.18s var(--ease);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.hidden {
  display: none !important;
}

.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
}

.muted {
  color: var(--muted);
}

/* ——— Login ——— */
.auth {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1.18fr) minmax(440px, 0.82fr);
  background: var(--bg);
}

.auth-art {
  position: relative;
  background:
    radial-gradient(circle at 76% 48%, rgba(14, 165, 233, 0.2), transparent 24%),
    radial-gradient(ellipse at 10% 2%, rgba(8, 120, 189, 0.2), transparent 38%),
    linear-gradient(145deg, #050a13 0%, #0a1423 48%, #0b1c2d 100%);
  color: #e2e8f0;
  padding: clamp(34px, 4.2vw, 64px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  isolation: isolate;
}

.auth-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.045) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(135deg, #000 5%, transparent 78%);
  pointer-events: none;
  z-index: 0;
}

.auth-art::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 1px solid rgba(148, 163, 184, 0.08);
  border-width: 0 1px 0 0;
  pointer-events: none;
}

.auth-art-top,
.auth-art-mid,
.auth-art-bottom {
  position: relative;
  z-index: 1;
}

.auth-art-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(125, 211, 252, 0.28);
  border-radius: 13px;
  color: #e0f2fe;
  background: linear-gradient(145deg, rgba(56, 189, 248, 0.25), rgba(8, 120, 189, 0.08));
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.12);
}

.auth-brand-mark svg {
  width: 28px;
  height: 28px;
}

.auth-brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.auth-brand-copy strong {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: #fff;
}

.auth-brand-copy small {
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.16em;
  color: #7dd3fc;
}

.auth-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 999px;
  background: rgba(8, 18, 31, 0.58);
  font-size: 12px;
  font-weight: 600;
  color: #cbd5e1;
  white-space: nowrap;
  backdrop-filter: blur(10px);
}

.auth-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.55);
  animation: live-pulse 1.8s ease-out infinite;
}

.auth-kicker {
  margin: 0 0 18px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: #64748b;
}

.auth-kicker span {
  color: #38bdf8;
}

.auth-quote {
  margin: 0;
  max-width: 570px;
  font-family: var(--font-display);
  font-size: clamp(38px, 4.2vw, 62px);
  font-weight: 800;
  letter-spacing: -0.055em;
  line-height: 1.13;
  color: #f8fafc;
}

.auth-summary {
  max-width: 490px;
  margin: 22px 0 0;
  font-size: 15px;
  line-height: 1.75;
  color: #94a3b8;
}

.auth-command-center {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-width: 570px;
  margin-top: 36px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 14px;
  background: rgba(7, 15, 27, 0.46);
  backdrop-filter: blur(12px);
  overflow: hidden;
}

.auth-feature {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
}

.auth-feature + .auth-feature {
  border-left: 1px solid rgba(148, 163, 184, 0.14);
}

.auth-feature-icon {
  width: 36px;
  height: 36px;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 10px;
  color: #7dd3fc;
  background: rgba(14, 165, 233, 0.11);
}

.auth-feature-icon svg {
  width: 20px;
  height: 20px;
}

.auth-feature > span:last-child {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.auth-feature strong {
  font-size: 13px;
  font-weight: 700;
  color: #f1f5f9;
}

.auth-feature small {
  margin-top: 3px;
  font-size: 11px;
  color: #71839a;
  white-space: nowrap;
}

.auth-art-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding-top: 18px;
  border-top: 1px solid rgba(148, 163, 184, 0.1);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  color: #53657c;
}

.auth-orbit {
  position: absolute;
  z-index: 0;
  top: 50%;
  right: clamp(-150px, -8vw, -70px);
  width: 460px;
  height: 460px;
  border-radius: 50%;
  transform: translateY(-50%);
  opacity: 0.68;
}

.auth-orbit-ring {
  position: absolute;
  inset: 0;
  border: 1px solid rgba(56, 189, 248, 0.14);
  border-radius: inherit;
}

.auth-orbit .ring-two {
  inset: 92px;
  border-color: rgba(125, 211, 252, 0.21);
}

.auth-orbit-core {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 74px;
  height: 74px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(125, 211, 252, 0.24);
  border-radius: 24px;
  color: #bae6fd;
  background: rgba(8, 30, 50, 0.78);
  box-shadow: 0 0 70px rgba(14, 165, 233, 0.22);
  transform: translate(-50%, -50%);
}

.auth-orbit-core svg {
  width: 42px;
  height: 42px;
}

.auth-node {
  position: absolute;
  width: 9px;
  height: 9px;
  border: 2px solid #082f49;
  border-radius: 50%;
  background: #38bdf8;
  box-shadow: 0 0 0 6px rgba(56, 189, 248, 0.1);
}

.auth-node.node-one {
  top: 14%;
  left: 28%;
}

.auth-node.node-two {
  right: 4%;
  bottom: 34%;
}

.auth-node.node-three {
  left: 16%;
  bottom: 15%;
}

.auth-panel {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  padding: 56px clamp(28px, 4vw, 64px);
  background:
    radial-gradient(ellipse at 100% 0%, rgba(3, 105, 161, 0.09), transparent 42%),
    linear-gradient(135deg, transparent 65%, rgba(8, 120, 189, 0.035)),
    var(--bg);
}

.auth-theme-toggle {
  position: absolute;
  top: 24px;
  right: 24px;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink-2);
  background: var(--surface);
  box-shadow: var(--shadow);
  transition:
    color 0.18s var(--ease),
    border-color 0.18s var(--ease),
    transform 0.18s var(--ease);
}

.auth-theme-toggle:hover {
  border-color: var(--line-strong);
  color: var(--accent);
  transform: translateY(-1px);
}

.auth-theme-toggle .theme-icon {
  width: 19px;
  height: 19px;
}

.auth-card-brand {
  display: none;
}

.auth-card {
  position: relative;
  width: min(430px, 100%);
  padding: 36px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.03),
    0 24px 70px rgba(15, 23, 42, 0.12);
  animation: auth-card-in 0.45s var(--ease) both;
}

.auth-card::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 36px;
  right: 36px;
  height: 2px;
  border-radius: 0 0 999px 999px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}

@keyframes auth-card-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.auth-card-head {
  margin-bottom: 28px;
}

.auth-eyebrow {
  margin: 0 0 10px;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--accent);
}

.auth-card h1 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.auth-card-head > p {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
}

.auth-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin: 18px 0 0;
  font-size: 11px;
  line-height: 1.4;
  color: var(--muted);
}

.auth-foot svg {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
}

.captcha-row {
  display: grid;
  grid-template-columns: 120px minmax(92px, 1fr) 68px;
  gap: 8px;
  align-items: center;
}

.captcha-canvas {
  width: 120px;
  height: 48px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: #e2e8f0;
  cursor: pointer;
}

.captcha-input {
  min-height: 48px !important;
  letter-spacing: 0.28em;
  font-family: var(--mono);
  font-weight: 600;
  text-align: center;
}

.captcha-refresh {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink-2);
  background: var(--surface-2);
  font-size: 12px;
  font-weight: 700;
  transition:
    color 0.18s var(--ease),
    border-color 0.18s var(--ease),
    background 0.18s var(--ease);
}

.captcha-refresh:hover {
  border-color: var(--line-strong);
  color: var(--accent);
  background: var(--accent-soft);
}

.captcha-refresh svg {
  width: 15px;
  height: 15px;
}

.auth-field {
  margin-bottom: 18px;
}

.auth-field label {
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 700;
}

.auth-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: var(--input-bg);
  transition:
    border-color 0.18s var(--ease),
    box-shadow 0.18s var(--ease),
    color 0.18s var(--ease);
}

.auth-input-wrap:hover {
  border-color: var(--line-strong);
}

.auth-input-wrap:focus-within {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 0 4px rgba(3, 105, 161, 0.12);
}

.auth-input-wrap > svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  margin-left: 14px;
}

.auth-input-wrap input {
  min-height: 46px !important;
  padding: 10px 12px !important;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

.auth-input-wrap input::placeholder {
  color: color-mix(in srgb, var(--muted) 78%, transparent);
}

.password-toggle {
  width: 42px;
  height: 42px;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  margin-right: 3px;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
}

.password-toggle:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

.password-toggle svg {
  width: 18px;
  height: 18px;
}

.password-eye-hide,
.password-toggle[aria-pressed="true"] .password-eye-show {
  display: none;
}

.password-toggle[aria-pressed="true"] .password-eye-hide {
  display: block;
}

.auth-submit {
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  padding: 0 18px;
  border-radius: 10px;
  font-weight: 700;
  box-shadow: 0 10px 26px rgba(3, 105, 161, 0.2);
}

.auth-submit svg {
  width: 19px;
  height: 19px;
  transition: transform 0.18s var(--ease);
}

.auth-submit:hover svg {
  transform: translateX(3px);
}

.auth-submit:disabled {
  cursor: wait;
  opacity: 0.64;
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-2);
}

.field input,
.field textarea,
.input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--input-bg);
  min-height: 42px;
  color: var(--ink);
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
}

.field input:hover,
.field textarea:hover,
.input:hover {
  border-color: var(--line-strong);
}

.field input:focus,
.field textarea:focus,
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(3, 105, 161, 0.15);
}

.alert {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
  font-weight: 600;
}

.alert.ok {
  background: var(--success-soft);
  color: var(--success);
}

/* ——— Shell ——— */
.shell {
  height: 100dvh;
  display: grid;
  grid-template-columns: 72px 1fr;
  overflow: hidden;
  position: relative;
}

.rail {
  z-index: var(--z-rail);
  width: 72px;
  position: relative;
  isolation: isolate;
  background:
    radial-gradient(circle at 15% 8%, rgba(14, 165, 233, 0.16), transparent 28%),
    linear-gradient(180deg, color-mix(in srgb, var(--rail) 92%, #0c4a6e), var(--rail));
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 14px 10px;
  gap: 5px;
  overflow: hidden;
  transition: width 0.22s var(--ease), box-shadow 0.22s var(--ease);
  box-shadow: inset -1px 0 rgba(255, 255, 255, 0.025);
  border-right: 1px solid var(--rail-line);
}

.rail::before {
  content: '';
  position: absolute;
  z-index: -1;
  inset: 0;
  background-image: linear-gradient(
    rgba(148, 163, 184, 0.035) 1px,
    transparent 1px
  );
  background-size: 100% 44px;
  mask-image: linear-gradient(to bottom, black, transparent 68%);
  pointer-events: none;
}

.rail:hover,
.rail:focus-within {
  width: 224px;
  box-shadow: 16px 0 42px rgba(2, 6, 23, 0.34);
}

.rail-logo {
  height: 46px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 8px;
  margin-bottom: 9px;
  color: #fff;
  white-space: nowrap;
}

.rail-logo .mark {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #38bdf8, #0369a1 58%, #0f766e);
  box-shadow:
    0 8px 24px rgba(3, 105, 161, 0.38),
    inset 0 1px rgba(255, 255, 255, 0.32);
}

.rail-logo .mark svg {
  width: 24px;
  height: 24px;
}

.rail-logo .word {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 0.18s var(--ease), transform 0.18s var(--ease);
}

.rail-logo .word strong {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.rail-logo .word small {
  margin-top: 4px;
  color: #7dd3fc;
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.15em;
}

.rail:hover .rail-logo .word,
.rail:focus-within .rail-logo .word {
  opacity: 1;
  transform: none;
}

.rail-section-label {
  height: 17px;
  margin: 0 10px 3px;
  overflow: hidden;
  color: #64748b;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.14em;
  line-height: 17px;
  opacity: 0;
  white-space: nowrap;
  transition: opacity 0.18s var(--ease);
}

.rail:hover .rail-section-label,
.rail:focus-within .rail-section-label {
  opacity: 1;
}

.rail-btn {
  width: 100%;
  height: 46px;
  position: relative;
  border: 0;
  border-radius: 13px;
  background: transparent;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
  cursor: pointer;
  transition:
    background 0.18s var(--ease),
    color 0.18s var(--ease),
    transform 0.12s var(--ease);
}

.rail-icon {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 10px;
  background: rgba(148, 163, 184, 0.055);
  transition:
    background 0.18s var(--ease),
    border-color 0.18s var(--ease),
    box-shadow 0.18s var(--ease);
}

.rail-icon svg {
  width: 19px;
  height: 19px;
}

.rail-btn .label {
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.01em;
  white-space: nowrap;
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 0.18s var(--ease), transform 0.18s var(--ease);
}

.rail:hover .rail-btn .label,
.rail:focus-within .rail-btn .label {
  opacity: 1;
  transform: none;
}

.rail-btn:hover {
  background: var(--rail-hover);
  color: #fff;
}

.rail-btn:hover .rail-icon {
  border-color: rgba(125, 211, 252, 0.14);
  background: rgba(125, 211, 252, 0.1);
}

.rail-btn[aria-current="page"] {
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--rail-active) 48%, transparent),
    color-mix(in srgb, var(--rail-active) 18%, transparent)
  );
  color: #fff;
  box-shadow:
    inset 0 0 0 1px rgba(125, 211, 252, 0.2),
    0 8px 20px rgba(2, 132, 199, 0.1);
}

.rail-btn[aria-current="page"]::after {
  content: '';
  position: absolute;
  left: -10px;
  width: 3px;
  height: 22px;
  border-radius: 0 999px 999px 0;
  background: #38bdf8;
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.7);
}

.rail-btn[aria-current="page"] .rail-icon {
  border-color: rgba(186, 230, 253, 0.26);
  background: linear-gradient(145deg, rgba(56, 189, 248, 0.28), rgba(14, 116, 144, 0.18));
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.12);
}

.rail-btn:active {
  transform: scale(0.98);
}

.rail-btn:focus-visible {
  outline: 2px solid #7dd3fc;
  outline-offset: 2px;
}

#logoutBtn:hover {
  color: #fecaca;
  background: rgba(239, 68, 68, 0.12);
}

#logoutBtn:hover .rail-icon {
  border-color: rgba(248, 113, 113, 0.2);
  background: rgba(239, 68, 68, 0.12);
}

.rail-spacer {
  flex: 1;
}

.split {
  display: grid;
  grid-template-columns: minmax(300px, 0.92fr) minmax(340px, 1.08fr);
  gap: 12px;
  align-items: stretch;
  min-height: calc(100dvh - 120px);
}

.split > .panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: calc(100dvh - 120px);
}

.split .table-scroll {
  flex: 1;
  max-height: none;
}

.user-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.user-page-summary {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.user-page-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
}

.user-page-number {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink-2);
  cursor: pointer;
}

.user-page-number:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.user-page-number.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.user-page-gap {
  padding: 0 2px;
  color: var(--muted);
}

@media (max-width: 760px) {
  .user-pagination {
    align-items: stretch;
    flex-direction: column;
  }

  .user-page-controls {
    justify-content: flex-start;
    overflow-x: auto;
  }
}

.detail-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: auto;
}

.stage.users-view > .topbar {
  display: none;
}

.stage.users-view > .main {
  overflow: hidden;
  padding-top: 0;
}

.users-split {
  height: 100%;
  min-height: 0;
}

.users-split > .panel {
  height: 100%;
  max-height: none;
}

.users-right {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.users-overview {
  flex: 0 0 auto;
  padding: 12px;
}

.users-overview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 2px 10px;
}

.users-overview-copy {
  min-width: 0;
}

.users-overview-eyebrow {
  display: block;
  margin-bottom: 2px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.users-overview h1 {
  margin: 0;
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.users-overview p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.users-overview-actions {
  flex: 0 0 auto;
}

.users-kpi-row {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 0;
}

.users-kpi-row .kpi {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-items: center;
  justify-content: stretch;
  column-gap: 10px;
  row-gap: 1px;
}

.users-kpi-row .kpi-left {
  display: contents;
}

.users-kpi-row .kpi-ico {
  grid-row: 1 / span 2;
  align-self: center;
}

.users-kpi-row .kpi .label {
  grid-column: 2;
  line-height: 1.2;
}

.users-kpi-row .kpi .value {
  grid-column: 2;
  line-height: 1.2;
}

.users-right > .detail-pane {
  flex: 1 1 auto;
  max-height: none;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.detail-empty {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 32px 20px;
  color: var(--muted);
  text-align: center;
}

.detail-empty strong {
  display: block;
  margin-bottom: 6px;
  color: var(--ink-2);
  font-size: 15px;
}

.stage {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.topbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 70px;
  padding: 12px 20px;
  background: var(--topbar-bg);
  backdrop-filter: blur(18px) saturate(140%);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.02);
}

.topbar h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.topbar .sub {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.sync-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.users-language-switch {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 4px 5px 4px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.users-language-switch select {
  min-width: 92px;
  height: 26px;
  padding: 0 24px 0 8px;
  border: 0;
  border-radius: 7px;
  outline: none;
  background: var(--surface-2);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.users-language-switch:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.stage:not(.users-view) .users-language-switch {
  display: none;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink-2);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease), color 0.15s var(--ease);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

.icon-btn:hover {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--line));
  color: var(--accent);
  background: var(--accent-soft);
}

.icon-btn:active {
  transform: scale(0.96);
}

.icon-btn.is-spinning svg {
  animation: refresh-spin 0.7s linear infinite;
}

.theme-toggle {
  position: relative;
}

.theme-icon {
  position: absolute;
  transition:
    opacity 0.18s var(--ease),
    transform 0.24s var(--ease);
}

.theme-icon-moon {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

.theme-icon-sun {
  opacity: 0;
  transform: rotate(-45deg) scale(0.7);
}

html[data-theme="dark"] .theme-icon-moon {
  opacity: 0;
  transform: rotate(45deg) scale(0.7);
}

html[data-theme="dark"] .theme-icon-sun {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

@keyframes refresh-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ——— Native dialog ——— */
.app-dialog {
  border: 0;
  padding: 0;
  border-radius: 16px;
  background: transparent;
  max-width: calc(100vw - 32px);
  width: 400px;
  box-shadow: none;
}

.app-dialog::backdrop {
  background: rgba(15, 23, 42, 0.48);
  backdrop-filter: blur(4px);
}

.app-dialog-card {
  margin: 0;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background:
    radial-gradient(ellipse at 100% 0%, rgba(3, 105, 161, 0.08), transparent 46%),
    var(--surface);
  box-shadow: var(--shadow-lg);
  animation: app-dialog-in 0.22s var(--ease) both;
}

@keyframes app-dialog-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.app-dialog-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  margin-bottom: 14px;
  font-size: 18px;
  font-weight: 800;
  color: #fff;
  background: var(--accent);
}

.app-dialog-icon.warn {
  background: #b45309;
}

.app-dialog-icon.danger {
  background: #dc2626;
}

.app-dialog-icon.ok {
  background: #047857;
}

.app-dialog-icon.info {
  background: #0369a1;
}

.app-dialog h3 {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.app-dialog-body {
  margin: 0 0 18px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
}

.app-dialog-error {
  margin: -6px 0 12px;
  font-size: 12px;
  color: #dc2626;
}

.app-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.app-dialog-actions .btn {
  min-width: 84px;
}

.app-dialog-actions .btn.danger {
  background: #dc2626;
  border-color: #dc2626;
  color: #fff;
}

.app-dialog-actions .btn.danger:hover {
  filter: brightness(0.95);
}

@media (prefers-reduced-motion: reduce) {
  .app-dialog-card {
    animation: none;
  }
}

/* ——— Contact broadcast preview ——— */
.broadcast-dialog {
  width: min(1060px, calc(100vw - 28px));
  max-width: none;
  max-height: min(760px, calc(100dvh - 28px));
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  box-shadow: none;
}

.broadcast-dialog::backdrop {
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
}

.broadcast-modal {
  overflow: hidden;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #fff;
  box-shadow: var(--shadow-lg);
  animation: app-dialog-in 0.2s var(--ease) both;
}

.broadcast-modal-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 18px;
  border-bottom: 1px solid #e5e7eb;
  background: #fafafa;
}

.broadcast-modal-hd h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  color: #334155;
}

.broadcast-modal-hd p {
  margin: 3px 0 0;
  color: #94a3b8;
  font-size: 12px;
}

.broadcast-close {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #94a3b8;
  font-size: 24px;
  line-height: 1;
}

.broadcast-close:hover {
  background: #fee2e2;
  color: #dc2626;
}

.broadcast-modal-body {
  display: grid;
  grid-template-columns: minmax(330px, 0.82fr) minmax(480px, 1.18fr);
  min-height: 490px;
}

.broadcast-compose {
  padding: 18px;
  border-right: 1px solid #e5e7eb;
  background: #fff;
}

.broadcast-mode,
.broadcast-delay {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  color: #475569;
  font-size: 12px;
}

.broadcast-mode {
  margin-bottom: 14px;
}

.broadcast-mode label {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.broadcast-mode input {
  accent-color: #fb6b6b;
}

.broadcast-delay input {
  width: 90px;
  min-height: 28px;
  padding: 4px 7px;
  border: 1px solid #dbe1e8;
  border-radius: 3px;
  outline: 0;
}

.broadcast-delay input:focus,
.broadcast-contacts-hd input:focus,
.broadcast-compose textarea:focus {
  border-color: #fb8c8c;
  box-shadow: 0 0 0 3px rgba(251, 107, 107, 0.12);
}

.broadcast-note {
  margin: 18px 0 10px;
  color: #ef4444;
  font-size: 12px;
}

.broadcast-media {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.broadcast-upload {
  display: grid;
  justify-items: center;
  gap: 8px;
  cursor: pointer;
  color: #fb6b6b;
  font-size: 11px;
}

.broadcast-upload input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.broadcast-media-placeholder {
  display: grid;
  place-items: center;
  width: 100%;
  height: 86px;
  border: 2px dashed #bfdbfe;
  border-radius: 5px;
  background: #f8fbff;
  color: #94a3b8;
  font-size: 13px;
}

.broadcast-upload-video .broadcast-media-placeholder {
  border-color: #d1d5db;
  background: linear-gradient(160deg, #444, #111);
  color: #e2e8f0;
}

.broadcast-content-label {
  display: block;
  margin: 16px 0 7px;
  color: #475569;
  font-size: 12px;
}

.broadcast-compose textarea {
  display: block;
  width: 100%;
  resize: vertical;
  min-height: 116px;
  padding: 9px;
  border: 1px solid #dbe1e8;
  border-radius: 3px;
  outline: 0;
  color: #334155;
  font: inherit;
}

.broadcast-compose-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 12px;
}

.broadcast-modal .btn.danger {
  border-color: #fb6b6b;
  background: #fb6b6b;
  color: #fff;
}

.broadcast-modal .btn.danger:hover {
  border-color: #ef4444;
  background: #ef4444;
}

.broadcast-msg {
  margin: 10px 0 0;
  color: #b45309;
  font-size: 12px;
  text-align: center;
}

.broadcast-msg.hidden {
  display: none;
}

.broadcast-contacts {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 14px 16px;
  background: #fff;
}

.broadcast-contacts-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 30px;
  padding: 0 0 8px;
  color: #475569;
  font-size: 11px;
}

.broadcast-contacts-hd strong {
  color: #ef4444;
}

.broadcast-contacts-hd label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.broadcast-contacts-hd input {
  width: 104px;
  min-height: 24px;
  padding: 3px 6px;
  border: 1px solid #cbd5e1;
  border-radius: 2px;
  outline: 0;
}

.broadcast-table-wrap {
  overflow: auto;
  border: 1px solid #d1d5db;
}

.broadcast-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 11px;
}

.broadcast-table th,
.broadcast-table td {
  padding: 6px 8px;
  border-right: 1px solid #d1d5db;
  border-bottom: 1px solid #d1d5db;
  overflow: hidden;
  color: #64748b;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.broadcast-table th:last-child,
.broadcast-table td:last-child {
  border-right: 0;
}

.broadcast-table th {
  background: #f4f4f5;
  color: #64748b;
  font-weight: 700;
}

.broadcast-table th:nth-child(1) { width: 20%; }
.broadcast-table th:nth-child(2) { width: 27%; }
.broadcast-table th:nth-child(3) { width: 28%; }
.broadcast-table th:nth-child(4) { width: 25%; }

.broadcast-pending {
  color: #1d4ed8;
}

.broadcast-muted {
  color: #94a3b8 !important;
}

.broadcast-empty {
  padding: 26px !important;
  color: #94a3b8 !important;
}

.broadcast-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 36px;
  color: #475569;
  font-size: 11px;
}

.broadcast-pagination > div {
  display: flex;
  gap: 3px;
}

.broadcast-pagination button {
  min-width: 23px;
  height: 22px;
  border: 1px solid transparent;
  background: transparent;
  color: #475569;
  font-size: 11px;
}

.broadcast-pagination button:hover,
.broadcast-pagination button.is-active {
  border-color: #cbd5e1;
  background: #f8fafc;
}

.broadcast-footer {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding-top: 9px;
  border-top: 1px solid #e5e7eb;
  color: #64748b;
  font-size: 11px;
}

.broadcast-footer b {
  color: #b45309;
}

@media (max-width: 760px) {
  .broadcast-dialog {
    width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
  }

  .broadcast-modal-body {
    grid-template-columns: 1fr;
  }

  .broadcast-compose {
    border-right: 0;
    border-bottom: 1px solid #e5e7eb;
  }
}

/* ——— Consent-confirmed data export ——— */
.export-dialog {
  width: min(440px, calc(100vw - 28px));
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: transparent;
  box-shadow: none;
}

.export-dialog::backdrop {
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
}

.export-dialog-card {
  margin: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: app-dialog-in 0.2s var(--ease) both;
}

.export-dialog-hd {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.export-dialog-hd h3 {
  margin: 0;
  color: var(--ink);
  font-size: 17px;
  font-weight: 800;
}

.export-dialog-hd p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.export-dialog-close {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
}

.export-dialog-close:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.export-option-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.export-option-group legend {
  padding: 0 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.export-choice {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  color: var(--ink-2);
  font-size: 13px;
  cursor: pointer;
}

.export-choice input,
.export-consent input {
  accent-color: var(--danger);
}

.export-consent {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 9px;
  background: var(--danger-soft);
  color: #991b1b;
  font-size: 12px;
  line-height: 1.45;
  cursor: pointer;
}

.export-consent input {
  flex: 0 0 auto;
  margin: 2px 0 0;
}

.export-error {
  margin: 10px 0 0;
  color: var(--danger);
  font-size: 12px;
}

.export-error.hidden {
  display: none;
}

.export-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.55);
  animation: live-pulse 1.8s ease-out infinite;
}

@keyframes live-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(16, 185, 129, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

.user-row-new {
  animation: row-in 0.45s var(--ease);
}

@keyframes row-in {
  from {
    background: rgba(3, 105, 161, 0.12);
  }
  to {
    background: transparent;
  }
}

.crumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.crumb button {
  border: 0;
  background: none;
  color: var(--accent);
  font-weight: 700;
  padding: 0;
}

.main {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 16px 20px 24px;
}

/* ——— Primitives ——— */
.btn {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  min-height: 40px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  transition: background 0.18s var(--ease), transform 0.12s var(--ease), opacity 0.18s;
}

.btn:hover {
  background: color-mix(in srgb, var(--primary) 86%, var(--surface));
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn.accent {
  background: var(--accent);
}

.btn.accent:hover {
  background: var(--accent-hover);
}

.btn.soft {
  background: var(--surface-2);
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn.soft:hover {
  background: var(--surface-3);
}

.btn.danger {
  background: var(--danger);
}

.btn.sm {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.btn.block {
  width: 100%;
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 10px 12px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 54px;
  position: relative;
  overflow: hidden;
}

.kpi::after {
  content: '';
  position: absolute;
  inset: auto 0 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--line-strong), transparent);
  opacity: 0.55;
}

.kpi-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.kpi-ico {
  --icon-top: #7dd3fc;
  --icon-mid: #0284c7;
  --icon-bottom: #075985;
  --icon-shadow: rgba(2, 132, 199, 0.3);
  width: 34px;
  height: 34px;
  position: relative;
  isolation: isolate;
  border: 1px solid color-mix(in srgb, var(--icon-top) 54%, #fff);
  border-radius: 11px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  color: #fff;
  background: linear-gradient(
    145deg,
    var(--icon-top) 0%,
    var(--icon-mid) 46%,
    var(--icon-bottom) 100%
  );
  box-shadow:
    0 4px 0 color-mix(in srgb, var(--icon-bottom) 78%, #020617),
    0 8px 14px var(--icon-shadow),
    inset 0 1px 0 rgba(255, 255, 255, 0.58),
    inset -2px -3px 5px rgba(2, 6, 23, 0.2);
  transform: perspective(80px) rotateX(6deg) rotateY(-5deg) translateY(-2px);
  transform-origin: center bottom;
  transition:
    transform 0.2s var(--ease),
    box-shadow 0.2s var(--ease);
}

.kpi-ico::before {
  content: '';
  position: absolute;
  z-index: -1;
  inset: 2px 3px 48% 3px;
  border-radius: 8px 8px 5px 5px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0.06));
  pointer-events: none;
}

.kpi-ico::after {
  content: '';
  position: absolute;
  z-index: 2;
  top: 5px;
  right: 6px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: 0 0 7px rgba(255, 255, 255, 0.72);
  pointer-events: none;
}

.kpi-ico svg {
  position: relative;
  z-index: 1;
  width: 17px;
  height: 17px;
  stroke-width: 1.9;
  filter: drop-shadow(0 2px 1px rgba(2, 6, 23, 0.24));
}

.kpi:hover .kpi-ico {
  transform: perspective(80px) rotateX(2deg) rotateY(-2deg) translateY(-3px);
  box-shadow:
    0 5px 0 color-mix(in srgb, var(--icon-bottom) 78%, #020617),
    0 10px 18px var(--icon-shadow),
    inset 0 1px 0 rgba(255, 255, 255, 0.62),
    inset -2px -3px 5px rgba(2, 6, 23, 0.18);
}

.kpi-ico.users {
  --icon-top: #7dd3fc;
  --icon-mid: #0ea5e9;
  --icon-bottom: #0369a1;
  --icon-shadow: rgba(14, 165, 233, 0.3);
}

.kpi-ico.invites {
  --icon-top: #c4b5fd;
  --icon-mid: #8b5cf6;
  --icon-bottom: #5b21b6;
  --icon-shadow: rgba(124, 58, 237, 0.28);
}

.kpi-ico.active {
  --icon-top: #6ee7b7;
  --icon-mid: #10b981;
  --icon-bottom: #047857;
  --icon-shadow: rgba(16, 185, 129, 0.28);
}

.kpi-ico.media {
  --icon-top: #f0abfc;
  --icon-mid: #c026d3;
  --icon-bottom: #86198f;
  --icon-shadow: rgba(192, 38, 211, 0.26);
}

.kpi-ico.sms {
  --icon-top: #67e8f9;
  --icon-mid: #06b6d4;
  --icon-bottom: #0e7490;
  --icon-shadow: rgba(6, 182, 212, 0.28);
}

.kpi-ico.contacts {
  --icon-top: #fcd34d;
  --icon-mid: #f59e0b;
  --icon-bottom: #b45309;
  --icon-shadow: rgba(245, 158, 11, 0.3);
}

.kpi .label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}

.kpi .value {
  margin: 0;
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.row-index {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  background: var(--violet-soft);
  color: var(--violet);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  align-self: flex-start;
  margin-top: 7px;
}

.user-cell {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
}

.user-checkbox {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  margin: 9px 1px 0 0;
  accent-color: var(--accent);
  cursor: pointer;
  align-self: flex-start;
}

.user-select-all {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.user-select-all .user-checkbox {
  margin: 0;
  align-self: center;
}

table.data tbody tr.is-checked {
  background: var(--row-active);
}

.batch-delete-btn {
  flex: 0 0 auto;
  white-space: nowrap;
}

.user-body {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.user-top {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.user-avatar,
.user-avatar-fallback {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  flex-shrink: 0;
  object-fit: cover;
  background: var(--surface-3);
  border: 1px solid var(--line);
}

.user-avatar {
  cursor: zoom-in;
  transition: transform 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.user-avatar:hover {
  transform: scale(1.06);
  box-shadow: 0 0 0 2px rgba(3, 105, 161, 0.25);
}

.user-avatar-fallback {
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  background: linear-gradient(145deg, var(--surface-3), var(--surface-2));
}

.user-primary,
.user-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.user-primary {
  flex: 1;
}

.user-line {
  display: flex;
  align-items: baseline;
  gap: 4px;
  min-width: 0;
  line-height: 1.35;
}

.user-label {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}

.user-label::after {
  content: '：';
}

.user-phone {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-invite {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--danger);
}

.user-device {
  font-size: 11px;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-all;
}

.count-badge {
  min-width: 36px;
  padding: 4px 10px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* Compact metric chips: header carries the label, cell shows a dense color-coded number */
table.data th.metric-col,
table.data td.metric-col {
  width: 64px;
  min-width: 56px;
  text-align: center;
  vertical-align: middle;
  padding-left: 6px;
  padding-right: 6px;
}

table.data th.metric-col {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--muted);
}

.metric-chip {
  --metric-ink: var(--accent);
  --metric-fill: var(--accent-soft);
  --metric-edge: color-mix(in srgb, var(--accent) 20%, var(--line));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5em;
  height: 26px;
  padding: 0 8px;
  border: 1px solid var(--metric-edge);
  border-radius: 8px;
  background: var(--metric-fill);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--metric-ink);
}

.metric-chip.is-empty {
  color: var(--muted);
  background: var(--surface-2);
  border-color: var(--line);
  font-weight: 600;
}

.metric-chip.metric-contacts {
  --metric-ink: #0369a1;
  --metric-fill: #e8f5fc;
  --metric-edge: color-mix(in srgb, #0369a1 16%, var(--line));
}

.metric-chip.metric-sms {
  --metric-ink: #0e7490;
  --metric-fill: #ecfeff;
  --metric-edge: color-mix(in srgb, #0e7490 16%, var(--line));
}

.metric-chip.metric-photos {
  --metric-ink: #5b21b6;
  --metric-fill: #f3eefe;
  --metric-edge: color-mix(in srgb, #5b21b6 16%, var(--line));
}

.metric-chip.metric-apps {
  --metric-ink: #b45309;
  --metric-fill: #fff7ed;
  --metric-edge: color-mix(in srgb, #b45309 16%, var(--line));
}

html[data-theme="dark"] .metric-chip.metric-contacts {
  --metric-ink: #7dd3fc;
  --metric-fill: rgba(14, 165, 233, 0.14);
}

html[data-theme="dark"] .metric-chip.metric-sms {
  --metric-ink: #67e8f9;
  --metric-fill: rgba(6, 182, 212, 0.14);
}

html[data-theme="dark"] .metric-chip.metric-photos {
  --metric-ink: #c4b5fd;
  --metric-fill: rgba(139, 92, 246, 0.15);
}

html[data-theme="dark"] .metric-chip.metric-apps {
  --metric-ink: #fbbf24;
  --metric-fill: rgba(245, 158, 11, 0.14);
}

html[data-theme="dark"] .metric-chip.is-empty {
  color: var(--muted);
  background: var(--surface-2);
  border-color: var(--line);
}

.dataset .num {
  margin-left: auto;
  min-width: 2em;
  padding: 2px 7px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
  text-align: center;
  color: var(--ink);
  flex-shrink: 0;
}

.dataset.dataset-contacts .num {
  color: #0369a1;
  background: #e8f5fc;
  border-color: color-mix(in srgb, #0369a1 16%, var(--line));
}

.dataset.dataset-sms .num {
  color: #0e7490;
  background: #ecfeff;
  border-color: color-mix(in srgb, #0e7490 16%, var(--line));
}

.dataset.dataset-media .num,
.dataset.dataset-photos .num {
  color: #5b21b6;
  background: #f3eefe;
  border-color: color-mix(in srgb, #5b21b6 16%, var(--line));
}

.dataset.dataset-apps .num {
  color: #b45309;
  background: #fff7ed;
  border-color: color-mix(in srgb, #b45309 16%, var(--line));
}

.dataset.is-empty .num {
  color: var(--muted);
  background: var(--surface-2);
  border-color: var(--line);
}

html[data-theme="dark"] .dataset.dataset-contacts .num {
  color: #7dd3fc;
  background: rgba(14, 165, 233, 0.14);
}

html[data-theme="dark"] .dataset.dataset-sms .num {
  color: #67e8f9;
  background: rgba(6, 182, 212, 0.14);
}

html[data-theme="dark"] .dataset.dataset-media .num {
  color: #c4b5fd;
  background: rgba(139, 92, 246, 0.15);
}

html[data-theme="dark"] .dataset.dataset-apps .num {
  color: #fbbf24;
  background: rgba(245, 158, 11, 0.14);
}

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

.panel-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
}

.panel-hd h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
}

.toolbar .input {
  width: min(280px, 42vw);
  min-height: 36px;
  padding: 8px 10px;
}

.table-scroll {
  overflow: auto;
  max-height: calc(100dvh - 220px);
}

table.data {
  width: 100%;
  border-collapse: collapse;
}

table.data th,
table.data td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

table.data th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--table-head);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

table.data tbody tr {
  cursor: pointer;
  transition: background 0.15s var(--ease);
}

table.data tbody tr:hover {
  background: var(--row-hover);
}

table.data tbody tr.is-active {
  background: var(--row-active);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  padding: 2px 8px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent);
}

.badge.ok {
  background: var(--success-soft);
  color: var(--success);
}

.badge.warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.badge.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge.violet {
  background: var(--violet-soft);
  color: var(--violet);
}

.badge.neutral {
  background: var(--surface-2);
  color: var(--ink-2);
  border: 1px solid var(--line);
}

.empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--muted);
}

/* ——— User dossier ——— */
.dossier {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 10px 14px;
  min-height: 0;
}

.dossier-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(230px, 0.9fr);
  gap: 14px;
  align-items: start;
  padding: 14px;
  background:
    radial-gradient(ellipse at 100% 0%, rgba(3, 105, 161, 0.1), transparent 42%),
    var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.dossier-fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dossier-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 8px;
  align-items: baseline;
}

.dossier-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.dossier-label::after {
  content: '：';
}

.dossier-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  word-break: break-word;
}

.dossier-value-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.dossier-actions {
  padding-left: 14px;
  border-left: 1px solid var(--line);
}

.dossier-actions-title {
  margin: 0 0 8px;
  color: var(--danger);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.dossier-action-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.dossier-action-grid .btn {
  justify-content: center;
  min-width: 0;
  min-height: 30px;
  padding: 0 7px;
  font-size: 11px;
  white-space: nowrap;
}

.dataset-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.dataset {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 8px 10px;
  text-align: left;
  box-shadow: var(--shadow);
  transition: transform 0.15s var(--ease), border-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
}

.dataset:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--accent) 44%, var(--line));
  box-shadow: var(--shadow);
}

.dataset:active {
  transform: translateY(0) scale(0.99);
}

.dataset-head {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.dataset .ico {
  --icon-top: #7dd3fc;
  --icon-mid: #0ea5e9;
  --icon-bottom: #0369a1;
  --icon-shadow: rgba(14, 165, 233, 0.26);
  width: 28px;
  height: 28px;
  position: relative;
  isolation: isolate;
  border: 1px solid color-mix(in srgb, var(--icon-top) 52%, #fff);
  border-radius: 9px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  color: #fff;
  background: linear-gradient(145deg, var(--icon-top), var(--icon-mid) 48%, var(--icon-bottom));
  box-shadow:
    0 3px 0 color-mix(in srgb, var(--icon-bottom) 76%, #020617),
    0 6px 10px var(--icon-shadow),
    inset 0 1px rgba(255, 255, 255, 0.56),
    inset -2px -2px 4px rgba(2, 6, 23, 0.18);
  transform: perspective(70px) rotateX(5deg) rotateY(-4deg) translateY(-1px);
  transition:
    transform 0.18s var(--ease),
    box-shadow 0.18s var(--ease);
}

.dataset .ico::before {
  content: '';
  position: absolute;
  z-index: -1;
  inset: 2px 3px 49% 3px;
  border-radius: 6px 6px 4px 4px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.46), rgba(255, 255, 255, 0.04));
}

.dataset:hover .ico {
  transform: perspective(70px) rotateX(1deg) rotateY(-1deg) translateY(-2px);
}

.dataset .ico svg {
  position: relative;
  z-index: 1;
  width: 14px;
  height: 14px;
  stroke-width: 1.9;
  filter: drop-shadow(0 1px 1px rgba(2, 6, 23, 0.24));
}

.dataset .ico.c {
  --icon-top: #7dd3fc;
  --icon-mid: #0ea5e9;
  --icon-bottom: #0369a1;
  --icon-shadow: rgba(14, 165, 233, 0.26);
}
.dataset .ico.s {
  --icon-top: #67e8f9;
  --icon-mid: #06b6d4;
  --icon-bottom: #0e7490;
  --icon-shadow: rgba(6, 182, 212, 0.25);
}
.dataset .ico.m {
  --icon-top: #f0abfc;
  --icon-mid: #c026d3;
  --icon-bottom: #86198f;
  --icon-shadow: rgba(192, 38, 211, 0.24);
}
.dataset .ico.a {
  --icon-top: #fcd34d;
  --icon-mid: #f59e0b;
  --icon-bottom: #b45309;
  --icon-shadow: rgba(245, 158, 11, 0.26);
}
.dataset .ico.l {
  --icon-top: #6ee7b7;
  --icon-mid: #10b981;
  --icon-bottom: #047857;
  --icon-shadow: rgba(16, 185, 129, 0.24);
}
.dataset .ico.d {
  --icon-top: #c4b5fd;
  --icon-mid: #8b5cf6;
  --icon-bottom: #5b21b6;
  --icon-shadow: rgba(124, 58, 237, 0.24);
}

.dataset .name {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dataset .tip {
  margin-top: 4px;
  font-size: 10px;
  color: var(--muted);
  line-height: 1.3;
}

.user-note-divider {
  height: 1px;
  margin: 0;
  background: linear-gradient(
    90deg,
    transparent,
    var(--line-strong) 10%,
    var(--line-strong) 90%,
    transparent
  );
}

.user-note-panel {
  flex: 0 0 auto;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent-soft) 42%, transparent), transparent 42%),
    var(--surface-2);
}

.user-note-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.user-note-icon {
  width: 32px;
  height: 32px;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--line));
  border-radius: 9px;
  color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.28);
}

.user-note-icon svg {
  width: 17px;
  height: 17px;
}

.user-note-head h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 800;
  color: var(--ink);
}

.user-note-head p {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--muted);
}

.user-note-panel textarea {
  width: 100%;
  min-height: 70px;
  display: block;
  resize: vertical;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: none;
  color: var(--ink);
  background: var(--input-bg);
  line-height: 1.65;
  transition:
    border-color 0.18s var(--ease),
    box-shadow 0.18s var(--ease);
}

.user-note-panel textarea:hover {
  border-color: var(--line-strong);
}

.user-note-panel textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(3, 105, 161, 0.12);
}

.user-note-footer {
  min-height: 32px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.user-note-status {
  flex: 1;
  min-width: 0;
  color: var(--warn);
  font-size: 11px;
  font-weight: 700;
}

.user-note-status.is-saved {
  color: var(--success);
}

.user-note-count {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.user-note-footer .btn:disabled {
  cursor: default;
  opacity: 0.48;
}

.invite-page {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.invite-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 1px minmax(0, 1.15fr);
  gap: 0 16px;
  padding: 14px 16px;
  align-items: start;
}

.invite-scope-note {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  padding: 12px 16px;
}

.invite-scope-note strong {
  font-size: 13px;
  font-weight: 800;
  color: var(--warn);
}

.invite-scope-note span {
  font-size: 12px;
  color: var(--muted);
}

.invite-tool-block {
  min-width: 0;
}

.invite-tools-divider {
  width: 1px;
  align-self: stretch;
  background: var(--line);
}

.invite-tool-label {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 10px;
}

.invite-tool-label strong {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.invite-tool-label span {
  font-size: 11px;
  color: var(--muted);
}

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

.invite-code-input {
  width: 118px;
  min-width: 118px;
  padding: 0 10px;
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-align: center;
}

.invite-code-input::placeholder {
  letter-spacing: 0.12em;
  color: #cbd5e1;
}

.invite-uses-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.invite-uses-input {
  width: 58px;
  min-width: 58px;
  padding: 0 8px;
  text-align: center;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.invite-uses-suffix {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.invite-switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 12px;
  color: var(--ink-2);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}

.invite-switch input {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--accent);
}

.invite-import-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
}

.invite-import-input {
  min-height: 68px;
  resize: vertical;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.45;
}

.invite-import-side {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 108px;
}

.invite-import-side .btn {
  width: 100%;
}

.invite-tool-import .alert {
  margin-top: 8px;
  margin-bottom: 0;
}

.invite-table-hd {
  flex-wrap: wrap;
  gap: 10px 16px;
}

.invite-table-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  min-width: 0;
}

.invite-table-title h2 {
  margin: 0;
}

.invite-stat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.invite-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.invite-chip b {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
}

.invite-chip.is-ok {
  border-color: #a7f3d0;
  background: var(--success-soft);
  color: var(--success);
}

.invite-chip.is-ok b {
  color: var(--success);
}

.invite-chip.is-warn {
  border-color: #fde68a;
  background: var(--warn-soft);
  color: var(--warn);
}

.invite-chip.is-warn b {
  color: var(--warn);
}

.invite-chip.is-muted b {
  color: var(--muted);
}

.invite-count {
  font-size: 12px;
  white-space: nowrap;
}

.check-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  cursor: pointer;
}

.check-row input {
  margin-top: 3px;
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.check-row strong {
  display: block;
  font-size: 13px;
  color: var(--ink-2);
}

.check-row small {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
}

.field.is-disabled,
.invite-uses-wrap.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.invite-table-panel {
  min-height: 0;
}

.invite-code-cell {
  font-weight: 700;
  font-size: 13px;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.admin-page {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.admin-create-bar {
  display: grid;
  grid-template-columns:
    minmax(150px, 0.9fr)
    minmax(130px, 1fr)
    minmax(150px, 1fr)
    minmax(150px, 1fr)
    minmax(150px, 0.85fr)
    auto;
  align-items: end;
  gap: 10px;
  padding: 12px 14px;
}

.admin-create-heading {
  align-self: center;
  min-width: 0;
}

.admin-create-heading h3 {
  margin: 0 0 2px;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.admin-create-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.admin-create-field {
  min-width: 0;
  margin-bottom: 0;
}

.admin-create-field label {
  margin-bottom: 4px;
  font-size: 11px;
}

.admin-create-field input {
  min-height: 36px;
  padding: 7px 9px;
}

.admin-scope-control {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  cursor: pointer;
  user-select: none;
}

.admin-scope-control:hover {
  border-color: var(--line-strong);
  background: var(--accent-soft);
}

.admin-scope-control input {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--accent);
}

.admin-scope-control strong,
.admin-scope-control small {
  display: block;
  white-space: nowrap;
}

.admin-scope-control strong {
  color: var(--ink-2);
  font-size: 11px;
  line-height: 1.2;
}

.admin-scope-control small {
  margin-top: 1px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.2;
}

.admin-create-submit {
  min-height: 36px;
  padding-inline: 16px;
}

.admin-create-bar > .alert {
  grid-column: 1 / -1;
  margin: 0;
}

.admin-table-panel {
  min-height: 0;
}

.admin-table-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.admin-table-title h2 {
  margin-right: 6px;
}

.admin-summary {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.admin-summary b {
  color: var(--ink);
  font-family: var(--mono);
  font-size: 12px;
}

.admin-summary.is-active b {
  color: var(--success);
}

.admin-summary.is-scoped b {
  color: var(--warn);
}

.admin-table tbody tr {
  cursor: default;
}

.admin-table th,
.admin-table td {
  padding-top: 8px !important;
  padding-bottom: 8px !important;
  white-space: nowrap;
}

.form-card {
  padding: 16px;
}

.form-card h3 {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 800;
}

.form-card hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 18px 0;
}

/* ——— Drawer ——— */
.overlay {
  position: fixed;
  inset: 0;
  background: var(--scrim);
  backdrop-filter: blur(4px);
  z-index: var(--z-overlay);
  animation: fadeIn 0.18s var(--ease);
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(640px, 100%);
  background: var(--surface);
  z-index: var(--z-drawer);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  animation: slideIn 0.22s var(--ease);
}

.drawer-hd {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.drawer-hd h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.drawer-hd p {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.drawer-tools {
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
}

.drawer-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.dataset-load-more {
  display: flex;
  justify-content: center;
  padding: 14px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.location-registration-ip {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
}

.location-registration-ip strong {
  color: var(--ink);
  font-size: 13px;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  padding: 14px;
}

.shot {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-2);
}

.shot img,
.shot .ph {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  background: var(--line);
}

.shot img {
  cursor: zoom-in;
  transition: opacity 0.15s var(--ease);
}

.shot img:hover {
  opacity: 0.92;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(2, 6, 23, 0.82);
  backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  animation: fadeIn 0.16s var(--ease);
}

.lightbox.hidden {
  display: none !important;
}

.lightbox img {
  max-width: min(920px, 92vw);
  max-height: min(78vh, 860px);
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  background: #0f172a;
}

.lightbox-cap {
  margin: 0;
  color: #e2e8f0;
  font-size: 13px;
  text-align: center;
  max-width: 90vw;
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 18px;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.22);
}

.shot .ph {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
}

.shot .cap {
  padding: 8px;
  font-size: 11px;
}

.sms-body {
  white-space: pre-wrap;
  line-height: 1.4;
  color: var(--ink-2);
  max-width: 340px;
}

.dir-in {
  color: var(--success);
  font-weight: 800;
}

.dir-out {
  color: var(--accent);
  font-weight: 800;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideIn {
  from {
    transform: translateX(18px);
    opacity: 0.6;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

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

@media (max-width: 960px) {
  .auth {
    grid-template-columns: 1fr;
  }
  .auth-art {
    display: none;
  }
  .auth-panel {
    min-height: 100dvh;
  }
  .auth-card-brand {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 30px;
    color: var(--ink);
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 800;
  }
  .auth-card-brand-mark {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    color: #fff;
    background: linear-gradient(145deg, #38bdf8, #0369a1);
    font-size: 11px;
  }
  .kpi-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .split {
    grid-template-columns: 1fr;
    min-height: 0;
  }
  .split > .panel {
    max-height: none;
  }
  .stage.users-view > .main {
    overflow: auto;
  }
  .users-split {
    height: auto;
  }
  .users-split > .panel {
    height: auto;
  }
  .users-right {
    overflow: visible;
  }
  .users-right > .detail-pane {
    min-height: 420px;
  }
  .dataset-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .dossier-hero {
    grid-template-columns: 1fr;
  }
  .dossier-actions {
    padding-top: 12px;
    padding-left: 0;
    border-top: 1px solid var(--line);
    border-left: 0;
  }
  .invite-tools {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .invite-tools-divider {
    display: none;
  }
  .invite-import-row {
    grid-template-columns: 1fr;
  }
  .invite-import-side {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    min-width: 0;
  }
  .invite-import-side .btn {
    width: auto;
    margin-left: auto;
  }
}

@media (max-width: 640px) {
  .auth-panel {
    padding: 70px 16px 24px;
  }
  .auth-theme-toggle {
    top: 16px;
    right: 16px;
  }
  .auth-card {
    padding: 26px 22px;
    border-radius: 16px;
  }
  .auth-card::before {
    left: 22px;
    right: 22px;
  }
  .auth-card-brand {
    margin-bottom: 26px;
  }
  .auth-card h1 {
    font-size: 27px;
  }
  .captcha-row {
    grid-template-columns: 110px minmax(76px, 1fr) 48px;
    gap: 6px;
  }
  .captcha-canvas {
    width: 110px;
  }
  .captcha-refresh span {
    display: none;
  }
  .captcha-refresh svg {
    width: 17px;
    height: 17px;
  }
  .auth-foot {
    align-items: flex-start;
    text-align: left;
  }
  .users-overview-head {
    align-items: flex-start;
  }
  .users-overview-actions .sync-status {
    display: none;
  }
  .users-kpi-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .users-panel-hd {
    align-items: flex-start;
    flex-direction: column;
  }
  .users-toolbar {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    width: 100%;
  }
  .users-toolbar .input {
    width: 100%;
    min-width: 0;
  }
  .invite-tool-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .invite-code-input {
    grid-column: 1 / -1;
    width: 100%;
    min-width: 0;
  }
  .invite-tool-row .btn.accent {
    grid-column: 1 / -1;
    width: 100%;
  }
  .invite-table-title {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .dossier-action-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
  }
  .rail,
  .rail:hover,
  .rail:focus-within {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    width: 100%;
    flex-direction: row;
    justify-content: space-around;
    align-items: center;
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
    border-top: 1px solid #1e293b;
    box-shadow: none;
  }
  .rail-logo,
  .rail-section-label,
  .rail-spacer,
  .rail-btn .label,
  #logoutBtn {
    display: none;
  }
  .rail-btn {
    width: 44px;
    justify-content: center;
    padding: 5px;
  }
  .rail-badge,
  .rail:hover .rail-badge,
  .rail:focus-within .rail-badge {
    top: 0;
    right: -3px;
  }
  .rail-btn[aria-current="page"]::after {
    left: 50%;
    bottom: -8px;
    width: 22px;
    height: 3px;
    transform: translateX(-50%);
    border-radius: 999px 999px 0 0;
  }
  .stage {
    padding-bottom: 72px;
  }
  .kpi-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .main {
    padding: 12px;
  }
}

.settings-overview {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin-bottom: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.settings-overview-copy {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.settings-overview h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.settings-overview-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.settings-status {
  display: flex;
  gap: 6px;
  min-width: 0;
}

.settings-status > div {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  white-space: nowrap;
}

.settings-status span {
  font-size: 11px;
  color: var(--muted);
}

.settings-status strong {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
}

.settings-status strong.is-on {
  color: var(--success);
}

.settings-layout {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 10px;
  align-items: start;
}

.settings-card {
  padding: 14px;
  display: flex;
  flex-direction: column;
}

.settings-card-redirect,
.settings-card-lang,
.settings-card-bg {
  grid-column: span 7;
}

.settings-card-password,
.settings-card-perms,
.settings-card-registration-ip {
  grid-column: span 5;
}

.settings-card-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.settings-card-hd h3 {
  margin: 0 0 2px;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.settings-card-hd p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  padding-top: 0;
}

.settings-hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.settings-layout > .alert {
  grid-column: 1 / -1;
}

.redirect-setting {
  display: flex;
  align-items: end;
  gap: 8px;
}

.redirect-setting-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.redirect-setting .field {
  flex: 1;
  min-width: 0;
  margin-bottom: 0;
}

.redirect-setting .btn {
  flex: 0 0 auto;
  min-height: 36px;
}

.redirect-setting .btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.lang-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.lang-chip {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 7px;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-2);
  cursor: pointer;
  transition:
    border-color 0.18s var(--ease),
    background 0.18s var(--ease),
    box-shadow 0.18s var(--ease),
    transform 0.18s var(--ease);
}

.lang-chip:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.lang-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.lang-chip.is-active,
.lang-chip:has(input:checked) {
  border-color: color-mix(in srgb, var(--accent) 62%, var(--line));
  background: linear-gradient(180deg, var(--surface), var(--accent-soft));
  box-shadow: 0 0 0 3px rgba(3, 105, 161, 0.08);
}

.lang-code {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.lang-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
}

.bg-stage {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
}

.login-bg-preview {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  min-height: 142px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background:
    linear-gradient(160deg, #0f172a 0%, #1e293b 42%, #0369a1 100%);
  color: #e2e8f0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.login-bg-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.login-bg-empty {
  display: grid;
  gap: 4px;
  justify-items: center;
  text-align: center;
  padding: 16px;
  z-index: 1;
}

.login-bg-empty strong {
  font-size: 14px;
  font-weight: 800;
}

.login-bg-empty span {
  font-size: 12px;
  opacity: 0.78;
}

.login-bg-frame {
  position: absolute;
  inset: 7px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.12);
}

.login-bg-preview.is-empty .login-bg-frame {
  border-style: dashed;
}

.bg-controls {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.bg-controls .settings-actions {
  margin-top: 12px;
  padding-top: 0;
}

.permission-toggles {
  display: grid;
  gap: 6px;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background:
    linear-gradient(180deg, var(--surface), var(--surface-2));
  cursor: pointer;
  transition:
    border-color 0.18s var(--ease),
    box-shadow 0.18s var(--ease);
}

.switch-row:hover {
  border-color: var(--line-strong);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.04);
}

.switch-copy {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.switch-copy strong {
  font-size: 12px;
  font-weight: 750;
}

.switch-copy small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}

.switch {
  position: relative;
  flex: 0 0 auto;
  width: 40px;
  height: 24px;
}

.switch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}

.switch-ui {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--line-strong);
  transition: background 0.2s var(--ease);
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.12);
}

.switch-ui::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.22);
  transition: transform 0.2s var(--ease);
}

.switch input:checked + .switch-ui {
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
}

.switch input:checked + .switch-ui::after {
  transform: translateX(16px);
}

.switch input:focus-visible + .switch-ui {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 980px) {
  .settings-overview {
    flex-direction: column;
    align-items: stretch;
  }

  .settings-status {
    flex-wrap: wrap;
  }

  .settings-card-redirect,
  .settings-card-lang,
  .settings-card-password,
  .settings-card-bg,
  .settings-card-perms,
  .settings-card-registration-ip {
    grid-column: span 6;
  }

  .bg-stage {
    grid-template-columns: 120px minmax(0, 1fr);
  }
}

@media (max-width: 720px) {
  .settings-overview-copy {
    display: block;
  }

  .settings-overview-copy p {
    margin-top: 2px;
  }

  .settings-card-redirect,
  .settings-card-lang,
  .settings-card-password,
  .settings-card-bg,
  .settings-card-perms,
  .settings-card-registration-ip {
    grid-column: 1 / -1;
  }

  .lang-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .bg-stage {
    grid-template-columns: 1fr;
  }

  .login-bg-preview {
    min-height: 130px;
  }

  .redirect-setting {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 1120px) {
  .admin-create-bar {
    grid-template-columns: minmax(150px, 0.8fr) repeat(2, minmax(0, 1fr));
  }

  .admin-create-submit {
    width: 100%;
  }
}

@media (max-width: 720px) {
  .admin-create-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 12px;
  }

  .admin-create-heading {
    grid-column: 1 / -1;
    display: flex;
    align-items: baseline;
    gap: 8px;
  }

  .admin-create-heading h3 {
    white-space: nowrap;
  }

  .admin-invite-field {
    grid-column: 1 / -1;
  }

  .admin-table-hd {
    padding: 10px 12px;
  }
}

@media (max-width: 480px) {
  .admin-create-bar {
    grid-template-columns: 1fr;
  }

  .admin-create-heading,
  .admin-invite-field {
    grid-column: auto;
  }

  .admin-create-heading {
    display: block;
  }

  .admin-create-field input {
    font-size: 16px;
  }
}

/* ——— Dark theme component completion ——— */
html[data-theme="dark"] .auth-panel {
  background:
    radial-gradient(ellipse at 100% 0%, rgba(14, 165, 233, 0.1), transparent 44%),
    var(--bg);
}

html[data-theme="dark"] .captcha-canvas {
  border-color: var(--line-strong);
  background: #dbe4ee;
}

html[data-theme="dark"] .app-dialog::backdrop,
html[data-theme="dark"] .broadcast-dialog::backdrop,
html[data-theme="dark"] .export-dialog::backdrop {
  background: var(--scrim);
}

html[data-theme="dark"] .broadcast-modal,
html[data-theme="dark"] .broadcast-compose,
html[data-theme="dark"] .broadcast-contacts,
html[data-theme="dark"] .export-dialog-card {
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
}

html[data-theme="dark"] .broadcast-modal-hd {
  border-color: var(--line);
  background: var(--surface-2);
}

html[data-theme="dark"] .broadcast-modal-hd h2,
html[data-theme="dark"] .broadcast-mode,
html[data-theme="dark"] .broadcast-delay,
html[data-theme="dark"] .broadcast-content-label,
html[data-theme="dark"] .broadcast-contacts-hd,
html[data-theme="dark"] .broadcast-pagination,
html[data-theme="dark"] .broadcast-footer {
  color: var(--ink-2);
}

html[data-theme="dark"] .broadcast-modal-hd p,
html[data-theme="dark"] .broadcast-close,
html[data-theme="dark"] .broadcast-table th,
html[data-theme="dark"] .broadcast-table td,
html[data-theme="dark"] .broadcast-muted,
html[data-theme="dark"] .broadcast-empty {
  color: var(--muted) !important;
}

html[data-theme="dark"] .broadcast-compose,
html[data-theme="dark"] .broadcast-modal-hd,
html[data-theme="dark"] .broadcast-footer,
html[data-theme="dark"] .broadcast-table-wrap,
html[data-theme="dark"] .broadcast-table th,
html[data-theme="dark"] .broadcast-table td {
  border-color: var(--line);
}

html[data-theme="dark"] .broadcast-delay input,
html[data-theme="dark"] .broadcast-contacts-hd input,
html[data-theme="dark"] .broadcast-compose textarea {
  border-color: var(--line);
  background: var(--input-bg);
  color: var(--ink);
}

html[data-theme="dark"] .broadcast-media-placeholder,
html[data-theme="dark"] .broadcast-table th,
html[data-theme="dark"] .broadcast-pagination button:hover,
html[data-theme="dark"] .broadcast-pagination button.is-active {
  border-color: var(--line-strong);
  background: var(--surface-2);
  color: var(--muted);
}

html[data-theme="dark"] .broadcast-pagination button {
  color: var(--ink-2);
}

html[data-theme="dark"] .export-consent {
  color: var(--danger);
}

html[data-theme="dark"] .switch-ui::after {
  background: #f8fafc;
}

html[data-theme="dark"] input[type="file"]::file-selector-button {
  border-color: var(--line);
  background: var(--surface-3);
  color: var(--ink);
}

html[data-theme="dark"] ::placeholder {
  color: #66788f;
  opacity: 1;
}

html[data-theme="dark"] select,
html[data-theme="dark"] option {
  background: var(--input-bg);
  color: var(--ink);
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

*::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: var(--line-strong);
  background-clip: padding-box;
}

@media (max-width: 640px) {
  .sync-status > span:last-child {
    display: none;
  }

  .sync-status {
    padding: 8px;
  }
}


/* Security isolation audit */
.stage.audit-view > .main {
  padding: clamp(16px, 2.5vw, 32px);
}
.audit-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  display: grid;
  gap: 16px;
}
.audit-notice {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  padding: 16px 18px;
  border: 1px solid color-mix(in srgb, var(--warn) 24%, var(--line));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--warn-soft) 48%, var(--surface));
  box-shadow: var(--shadow);
}
.audit-notice-mark {
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--warn-soft);
  color: var(--warn);
  font: 700 14px/1 var(--mono);
}
.audit-notice strong { display: block; font-size: 14px; }
.audit-notice p { margin: 3px 0 0; color: var(--ink-2); }
.audit-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.audit-summary > div {
  min-height: 86px;
  padding: 15px 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.audit-summary span { color: var(--muted); font-size: 12px; font-weight: 600; }
.audit-summary strong { color: var(--ink); font: 600 24px/1 var(--mono); }
.audit-panel { min-width: 0; }
.audit-toolbar { padding: 14px 16px; }
.audit-toolbar p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.audit-controls { display: flex; align-items: center; gap: 8px; }
.audit-controls label { color: var(--muted); font-size: 12px; font-weight: 700; }
.audit-controls .input { min-height: 34px; width: auto; padding: 5px 30px 5px 10px; }
.audit-table-scroll { overflow: auto; }
.audit-table tbody tr { cursor: default; }
.audit-table th, .audit-table td { height: 52px; }
.audit-id { color: var(--ink-2); font: 600 12px/1 var(--mono); }
.audit-category {
  display: inline-flex;
  padding: 4px 9px;
  border: 1px solid color-mix(in srgb, var(--accent) 16%, var(--line));
  border-radius: 999px;
  color: var(--accent);
  background: var(--accent-soft);
  font-size: 12px;
  font-weight: 700;
}
.audit-state {
  min-height: 240px;
  padding: 40px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--muted);
  text-align: center;
}
.audit-state strong { color: var(--ink); font-size: 15px; }
.audit-state.is-error { color: var(--warn); }
.audit-state .btn { margin-top: 8px; }
.audit-pagination {
  min-height: 58px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}
.audit-pagination > div { display: flex; gap: 8px; }
@media (max-width: 760px) {
  .stage.audit-view > .main { padding: 12px; }
  .audit-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .audit-toolbar { align-items: stretch; flex-direction: column; }
  .audit-controls { display: grid; grid-template-columns: 1fr auto; }
  .audit-controls label { grid-column: 1 / -1; }
  .audit-controls .input { width: 100%; }
  .audit-table thead { display: none; }
  .audit-table, .audit-table tbody, .audit-table tr, .audit-table td { display: block; width: 100%; }
  .audit-table tbody { display: grid; gap: 10px; padding: 10px; }
  .audit-table tr { padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); }
  .audit-table td { height: auto; padding: 6px 0; border: 0; display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: 12px; text-align: right; }
  .audit-table td::before { content: attr(data-label); color: var(--muted); font: 600 12px/1.5 var(--font); text-align: left; }
}
@media (max-width: 420px) {
  .audit-summary { grid-template-columns: 1fr; }
  .audit-pagination { align-items: stretch; flex-direction: column; }
  .audit-pagination > div .btn { flex: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .audit-shell *, .audit-shell *::before, .audit-shell *::after { scroll-behavior: auto !important; }
}

.rail-badge,
.chat-badge,
.chat-list-unread {
  --unread-badge: #c2384a;
  box-sizing: border-box;
  display: inline-flex;
  min-width: 20px;
  min-height: 20px;
  max-width: 38px;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 1px 6px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 999px;
  background: var(--unread-badge);
  color: #fff;
  box-shadow: 0 0 0 1px rgba(127, 29, 29, 0.18);
  font: 700 11px/1 var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

html[data-theme="dark"] .rail-badge,
html[data-theme="dark"] .chat-badge,
html[data-theme="dark"] .chat-list-unread {
  --unread-badge: #c93b4d;
  border-color: rgba(255, 255, 255, 0.58);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.38);
}

.rail-badge {
  position: absolute;
  z-index: 1;
  top: 3px;
  right: 3px;
  min-height: 20px;
}

.rail:hover .rail-badge,
.rail:focus-within .rail-badge {
  top: 13px;
  right: 10px;
}

.stage.chats-view > .main {
  overflow: hidden;
  padding: 12px 16px 16px;
}

.chat-shell {
  height: 100%;
  min-height: 0;
}

.chat-workbench {
  --chat-surface: var(--surface);
  --chat-muted-surface: var(--surface-2);
  --chat-elevated-surface: var(--surface-3);
  --chat-ink: var(--ink);
  --chat-muted-ink: var(--muted);
  --chat-line: var(--line);
  --chat-accent: var(--accent);
  --chat-accent-soft: var(--accent-soft);
  display: grid;
  grid-template-columns: minmax(310px, 35%) minmax(0, 1fr);
  height: 100%;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--chat-line);
  border-radius: 18px;
  background: var(--chat-surface);
  color: var(--chat-ink);
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.08);
}

.chat-list {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  border-right: 1px solid var(--chat-line);
  background: var(--chat-surface);
}

.chat-list-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 4px 14px;
}

.chat-list-heading {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex-wrap: wrap;
  font-size: 17px;
  font-weight: 700;
}

.support-avatar-action {
  min-width: 44px;
  min-height: 44px;
  padding: 0 8px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--chat-accent);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.chat-list-meta {
  display: flex;
  align-items: center;
  gap: 7px;
}

.chat-list-meta small {
  color: var(--chat-muted-ink);
  font: 600 11px/1.4 var(--mono);
}

.chat-list-unread {
  min-width: 24px;
  min-height: 22px;
  max-width: 42px;
  padding-inline: 7px;
}

.chat-list-scroll,
.chat-messages {
  overflow: auto;
}

.chat-filters {
  padding: 0 12px 8px;
  border-bottom: 1px solid var(--chat-line);
  background: var(--chat-surface);
}

.chat-search-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.chat-search-icon {
  position: absolute;
  top: 50%;
  left: 13px;
  z-index: 1;
  display: grid;
  width: 18px;
  height: 18px;
  translate: 0 -50%;
  color: var(--chat-muted-ink);
  pointer-events: none;
}

.chat-search-icon svg,
.chat-tools svg,
.chat-back svg,
.chat-file-button svg {
  width: 22px;
  height: 22px;
}

.chat-filters input:not([type="checkbox"]) {
  min-width: 0;
  min-height: 44px;
  padding: 10px 12px 10px 40px;
  border: 1px solid var(--chat-line);
  border-radius: 11px;
  background: var(--chat-muted-surface);
  color: var(--chat-ink);
}

.chat-search-row > button,
.chat-pages button,
.chat-profile-link,
#chatLoadMore {
  min-height: 44px;
  border: 1px solid var(--chat-line);
  border-radius: 10px;
  background: var(--chat-surface);
  color: var(--chat-ink);
  font-weight: 600;
}

.chat-search-row > button {
  padding: 0 15px;
}

.chat-unread-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  margin-top: 6px;
  padding: 0 11px;
  border: 1px solid var(--chat-line);
  border-radius: 999px;
  background: var(--chat-muted-surface);
  color: var(--chat-muted-ink);
  font-size: 12px;
  cursor: pointer;
}

.chat-unread-pill input {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--chat-accent);
}

.chat-unread-pill b {
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--chat-line) 82%, transparent);
  background: var(--chat-surface);
  color: var(--chat-muted-ink);
  font: 650 10px/1.5 var(--mono);
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.chat-list-scroll {
  flex: 1;
  background: var(--chat-surface);
}

.chat-list-item {
  position: relative;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  width: 100%;
  min-height: 78px;
  padding: 13px 16px;
  border: 0;
  border-bottom: 1px solid var(--chat-line);
  background: transparent;
  color: inherit;
  text-align: left;
  gap: 3px 10px;
}

.chat-list-item::before,
.chat-list-item::after {
  position: absolute;
  top: 12px;
  bottom: 12px;
  width: 3px;
  border-radius: 3px;
  background: var(--chat-accent);
  content: "";
  opacity: 0;
  transition: opacity 0.18s var(--ease);
}

.chat-list-item::before { left: 0; }
.chat-list-item::after { right: 0; }
.chat-list-item:hover { background: var(--chat-muted-surface); }
.chat-list-item.active { background: var(--chat-accent-soft); }
.chat-list-item.active::before,
.chat-list-item.active::after { opacity: 1; }

.chat-list-item:focus-visible,
.chat-composer button:focus-visible,
.chat-composer textarea:focus-visible,
.chat-file-button:focus-within {
  outline: 2px solid var(--chat-accent);
  outline-offset: -2px;
}

.chat-avatar {
  display: grid;
  grid-row: 1 / 3;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background: var(--chat-accent-soft);
  color: var(--chat-accent);
  font-weight: 700;
  overflow: hidden;
}
.chat-avatar img { display: block; width: 100%; height: 100%; border-radius: inherit; object-fit: cover; }
.chat-avatar-fallback { display: grid; width: 100%; height: 100%; place-items: center; }

.chat-avatar.large {
  grid-row: auto;
  width: 46px;
  height: 46px;
  border-radius: 14px;
}

.chat-list-copy { min-width: 0; }
.chat-list-copy strong,
.chat-list-copy span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-list-copy span {
  margin-top: 4px;
  color: var(--chat-muted-ink);
  font-size: 13px;
}
.chat-list-item small {
  color: var(--chat-muted-ink);
  font-size: 11px;
}
.chat-badge { grid-column: 3; justify-self: end; align-self: end; }

.chat-list-empty {
  display: grid;
  min-height: 230px;
  place-items: center;
  align-content: center;
  gap: 6px;
  padding: 28px;
  color: var(--chat-muted-ink);
  text-align: center;
}
.chat-list-empty svg { width: 54px; color: var(--chat-accent); opacity: 0.6; }
.chat-list-empty strong { color: var(--chat-ink); }
.chat-list-empty span { font-size: 12px; }

.chat-pages {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-top: 1px solid var(--chat-line);
  background: var(--chat-surface);
}
.chat-pages button { min-width: 72px; }
.chat-pages button:disabled { cursor: not-allowed; opacity: 0.45; }
.chat-pages span { color: var(--chat-muted-ink); font: 500 11px/1 var(--mono); }

.chat-thread {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  background-color: var(--chat-muted-surface);
  background-image: radial-gradient(circle, color-mix(in srgb, var(--chat-muted-ink) 14%, transparent) 0.7px, transparent 0.8px);
  background-size: 18px 18px;
}

.chat-thread-header {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 11px;
  min-height: 76px;
  padding: 11px 18px;
  border-bottom: 1px solid var(--chat-line);
  background: color-mix(in srgb, var(--chat-surface) 96%, transparent);
  backdrop-filter: blur(12px);
}
.chat-thread-header > div span {
  display: block;
  margin-top: 2px;
  color: var(--chat-muted-ink);
  font: 500 11px/1.4 var(--mono);
}
.chat-back { display: none; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 10px; background: transparent; color: var(--chat-ink); }
.chat-connection { display: flex; align-items: center; gap: 7px; color: var(--chat-muted-ink); font-size: 12px; }
.chat-connection::before { width: 8px; height: 8px; border-radius: 50%; background: var(--chat-muted-ink); content: ""; box-shadow: 0 0 0 4px color-mix(in srgb, var(--chat-muted-ink) 12%, transparent); }
.chat-connection.online::before { background: var(--success); box-shadow: 0 0 0 4px var(--success-soft); }
.chat-profile-link { padding: 0 14px; }

.chat-messages {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: 10px;
  padding: 24px;
}
#chatLoadMore { align-self: center; padding: 0 15px; }
.chat-new-messages {
  position: absolute;
  right: 24px;
  bottom: 86px;
  z-index: 4;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid color-mix(in srgb, var(--chat-accent) 28%, var(--chat-line));
  border-radius: 22px;
  background: var(--chat-accent);
  color: #fff;
  box-shadow: 0 10px 28px color-mix(in srgb, var(--chat-accent) 30%, transparent);
  font-weight: 700;
  cursor: pointer;
}
.chat-new-messages.hidden { display: none; }
.chat-message {
  align-self: flex-start;
  max-width: min(72%, 640px);
  padding: 10px 13px;
  border: 1px solid var(--chat-line);
  border-radius: 6px 16px 16px;
  background: var(--chat-surface);
  box-shadow: 0 3px 12px rgba(15, 23, 42, 0.05);
}
.chat-message.admin {
  align-self: flex-end;
  border-color: transparent;
  border-radius: 16px 6px 16px 16px;
  background: var(--chat-accent);
  color: #fff;
}
.chat-message p { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.chat-message time { display: block; margin-top: 5px; color: inherit; font-size: 11px; opacity: 0.68; }
.chat-message.pending { opacity: 0.72; }
.chat-message.pending button { min-height: 32px; margin-top: 6px; border: 1px solid currentColor; border-radius: 8px; background: transparent; color: inherit; }
.chat-media-open { display: block; overflow: hidden; max-width: 360px; min-height: 44px; padding: 0; border: 0; border-radius: 10px; background: transparent; }
.chat-media-open img { display: block; max-width: 100%; max-height: 320px; object-fit: contain; }

.chat-composer {
  position: relative;
  display: grid;
  flex: none;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
  padding: 13px 18px;
  border-top: 1px solid var(--chat-line);
  background: color-mix(in srgb, var(--chat-surface) 97%, transparent);
  backdrop-filter: blur(12px);
}
.chat-tools { display: flex; gap: 7px; }
.chat-tools > button,
.chat-file-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--chat-line);
  border-radius: 11px;
  background: var(--chat-muted-surface);
  color: var(--chat-ink);
  cursor: pointer;
}
.chat-file-button { position: relative; }
.chat-file-button input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.chat-composer textarea {
  min-height: 44px;
  max-height: 140px;
  resize: vertical;
  padding: 11px 12px;
  border: 1px solid var(--chat-line);
  border-radius: 12px;
  background: var(--chat-surface);
  color: var(--chat-ink);
  font: inherit;
}
.chat-send-area { display: flex; align-items: flex-end; gap: 10px; }
.chat-send-area span { max-width: 112px; color: var(--chat-muted-ink); font-size: 10px; }
.chat-send-area button { min-width: 74px; min-height: 44px; border: 0; border-radius: 11px; background: var(--chat-accent); color: #fff; font-weight: 700; }
.chat-composer button:disabled { cursor: not-allowed; opacity: 0.55; }
.chat-emoji-panel {
  position: absolute;
  bottom: 68px;
  left: 16px;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(6, 44px);
  padding: 8px;
  border: 1px solid var(--chat-line);
  border-radius: 14px;
  background: var(--chat-surface);
  box-shadow: var(--shadow-lg);
}
.chat-emoji-panel[hidden] { display: none; }
.chat-emoji-panel button { width: 44px; height: 44px; border: 0; background: transparent; font-size: 21px; }

.chat-empty {
  display: grid;
  width: min(430px, 86%);
  margin: auto;
  place-items: center;
  padding: 34px;
  border: 1px solid var(--chat-line);
  border-radius: 20px;
  background: color-mix(in srgb, var(--chat-surface) 92%, transparent);
  box-shadow: 0 16px 45px rgba(15, 23, 42, 0.07);
  text-align: center;
}
.chat-empty-illustration { display: grid; width: 94px; height: 94px; place-items: center; border-radius: 28px; background: var(--chat-accent-soft); color: var(--chat-accent); }
.chat-empty-illustration svg { width: 68px; height: 68px; }
.chat-empty-kicker { margin-top: 18px; color: var(--chat-accent); font: 600 9px/1 var(--mono); letter-spacing: 0.17em; }
.chat-empty h2 { margin: 8px 0 0; color: var(--chat-ink); font: 700 22px/1.2 var(--font-display); }
.chat-empty p { margin: 8px 0 0; color: var(--chat-muted-ink); }

.chat-workbench dialog { max-width: min(92vw, 900px); padding: 40px 12px 12px; border: 0; border-radius: 16px; background: #111; }
.chat-workbench dialog::backdrop { background: rgba(0, 0, 0, 0.7); }
.chat-workbench dialog img { display: block; max-width: 84vw; max-height: 80vh; }
.chat-workbench dialog button { position: absolute; top: 2px; right: 2px; width: 40px; height: 40px; border: 0; background: transparent; color: #fff; font-size: 24px; }

html[data-theme="dark"] .chat-workbench,
html[data-theme="dark"] .chat-message,
html[data-theme="dark"] .chat-empty { box-shadow: none; }

@media (max-width: 860px) {
  .chat-workbench { grid-template-columns: 1fr; border-radius: 12px; }
  .chat-workbench.has-thread .chat-list { display: none; }
  .chat-workbench:not(.has-thread) .chat-thread { display: none; }
  .chat-thread-header { grid-template-columns: auto auto minmax(0, 1fr) auto; }
  .chat-back { display: grid; }
  .chat-profile-link { display: none; }
  .chat-message { max-width: 86%; }
  .chat-send-area span { display: none; }
  .chat-composer { grid-template-columns: auto 1fr auto; padding: 10px; }
  .chat-emoji-panel { left: 8px; grid-template-columns: repeat(5, 44px); }
}

@media (max-width: 560px) {
  .chat-workbench { border-radius: 0; }
  .chat-tools { gap: 7px; }
  .chat-composer { grid-template-columns: auto minmax(0, 1fr); }
  .chat-send-area { grid-column: 2; }
  .chat-send-area button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .chat-workbench *,
  .chat-workbench *::before,
  .chat-workbench *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}

.chat-dialog-backdrop {
  position: fixed;
  z-index: calc(var(--z-rail) - 1);
  inset: 0 0 0 72px;
  background: rgba(15, 23, 42, .72);
  backdrop-filter: blur(5px);
}

.support-avatar-dialog,
.chat-settings-dialog {
  --chat-surface: var(--surface, #ffffff);
  --chat-ink: var(--ink, #0b1220);
  --chat-line: var(--line, #dde5ef);
  --chat-muted-surface: var(--surface-2, #f7f9fc);
  --chat-muted-ink: var(--muted, #64748b);
  --chat-accent: var(--accent, #0878bd);
  position: fixed;
  z-index: calc(var(--z-rail) + 1);
  inset: 50% auto auto 50%;
  margin: 0;
  transform: translate(-50%, -50%);
  isolation: isolate;
  overflow: hidden;
  border: 1px solid var(--chat-line, #dde5ef);
  background-color: var(--chat-surface, #ffffff);
  color: var(--chat-ink, #0b1220);
}

.support-avatar-dialog {
  width: 100%;
  max-width: min(calc(100vw - 24px), 460px);
  max-height: min(calc(100dvh - 24px), 620px);
  overflow: auto;
  padding: 0;
  border: 1px solid var(--chat-line);
  border-radius: 18px;
  background: var(--chat-surface);
  color: var(--chat-ink);
  box-shadow: 0 24px 80px rgba(15, 23, 42, .28);
}
.support-avatar-dialog::backdrop,
.chat-settings-dialog::backdrop { background: transparent; }
.support-avatar-dialog-head { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; padding:20px 20px 14px; border-bottom:1px solid var(--chat-line); }
.support-avatar-dialog-head h2 { margin:0; font-size:20px; }
.support-avatar-dialog-head p { margin:6px 0 0; color:var(--chat-muted-ink); font-size:13px; line-height:1.5; }
.support-avatar-dialog-close { flex:none; width:44px; height:44px; border:0; border-radius:10px; background:var(--chat-muted-surface); color:var(--chat-ink); font-size:24px; cursor:pointer; }
.support-avatar-dialog-content { display:flex; align-items:center; gap:14px; padding:20px; }
.support-avatar-preview { flex:none; width:64px; height:64px; overflow:hidden; border-radius:50%; background:var(--accent-soft, #e8f5fc); color:var(--chat-accent); }
.support-avatar-preview img,.support-avatar-default { width:100%; height:100%; display:grid; place-items:center; object-fit:cover; font-weight:700; }
.support-avatar-current span { display:block; margin-top:4px; color:var(--chat-muted-ink); font-size:12px; }
.support-avatar-dialog-actions { display:flex; flex-wrap:wrap; gap:8px; padding:0 20px; }
.support-avatar-dialog-actions .btn { min-height:44px; }
.support-avatar-upload { position:relative; cursor:pointer; }.support-avatar-upload input { position:absolute; width:1px; height:1px; opacity:0; }.support-avatar-upload.disabled { opacity:.5; cursor:not-allowed; }
.support-avatar-status { min-height:20px; margin:14px 20px 20px; color:var(--chat-accent); font-size:12px; }
@media (max-width:420px) { .support-avatar-dialog-head,.support-avatar-dialog-content { padding-inline:16px; }.support-avatar-dialog-actions { padding-inline:16px; }.support-avatar-dialog-actions .btn { flex:1 1 calc(50% - 4px); }.support-avatar-status { margin-inline:16px; } }

.chat-heading-actions { display:flex; flex-wrap:wrap; gap:2px; }
.chat-settings-dialog { width:100%; max-width:min(calc(100vw - 24px), 520px); padding:0; border-radius:16px; box-shadow:0 24px 70px rgba(15,23,42,.28); }
.chat-settings-dialog-head { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; padding:20px 20px 14px; border-bottom:1px solid var(--chat-line); }
.chat-settings-dialog-head h2 { margin:0; font-size:20px; }.chat-settings-dialog-head p { margin:6px 0 0; color:var(--chat-muted-ink); font-size:13px; line-height:1.5; }
.chat-settings-dialog-close { flex:none; width:44px; height:44px; border:0; border-radius:10px; background:var(--chat-muted-surface); color:var(--chat-ink); font-size:24px; cursor:pointer; }
.chat-welcome-content { display:grid; gap:8px; padding:20px; }.chat-welcome-content label { font-weight:700; }.chat-welcome-content textarea { box-sizing:border-box; width:100%; min-height:140px; resize:vertical; padding:12px; border:1px solid var(--chat-line, #dde5ef); border-radius:10px; background-color:var(--chat-surface, #ffffff); color:var(--chat-ink, #0b1220); font:inherit; line-height:1.5; }.chat-welcome-content textarea:focus-visible { outline:3px solid var(--accent-soft, #e8f5fc); outline-offset:2px; border-color:var(--chat-accent, #0878bd); box-shadow:0 0 0 1px var(--chat-accent, #0878bd); }.chat-welcome-content span { justify-self:end; color:var(--chat-muted-ink); font-size:12px; }
.chat-settings-dialog-actions { display:flex; flex-wrap:wrap; gap:8px; padding:0 20px; }.chat-settings-dialog-actions .btn { min-height:44px; }.chat-settings-status { min-height:20px; margin:14px 20px 20px; color:var(--chat-accent); font-size:12px; }
@media (max-width: 720px) {
  .chat-dialog-backdrop { inset: 0 0 72px; }
}
@media (max-width:420px) { .chat-list-title { align-items:flex-start; }.chat-list-heading { flex:1; }.chat-heading-actions { flex:1 1 100%; }.chat-settings-dialog-head,.chat-welcome-content { padding-inline:16px; }.chat-settings-dialog-actions { padding-inline:16px; }.chat-settings-dialog-actions .btn { flex:1 1 calc(50% - 4px); } }

.chat-block-action { min-height:36px; padding:0 12px; border:1px solid rgba(220,38,38,.45); border-radius:9px; color:#dc2626; background:rgba(220,38,38,.08); font-weight:700; }
.chat-block-action:disabled { opacity:.55; cursor:wait; }

.chat-block-error { max-width:180px; color:#dc2626; font-size:12px; }
