/* 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-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;
}

.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;
  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;
}

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

.user-select-all .user-checkbox {
  margin-top: 0;
}

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

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

.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-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.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;
}

.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 .num {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.04em;
  flex-shrink: 0;
}

.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-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-lang,
.settings-card-bg {
  grid-column: span 7;
}

.settings-card-redirect {
  grid-column: 1 / -1;
}

.settings-card-password,
.settings-card-perms {
  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 .field {
  flex: 1;
  min-width: 0;
  margin-bottom: 0;
}

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

.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-lang,
  .settings-card-password,
  .settings-card-bg,
  .settings-card-perms {
    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-lang,
  .settings-card-password,
  .settings-card-bg,
  .settings-card-perms {
    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;
  }
}
