:root {
  --bg: #040b12;
  --bg-2: #07131c;
  --paper: rgba(12, 28, 40, .86);
  --paper-solid: #0c1c28;
  --ink: #f1f8fc;
  --muted: #8ba3b5;
  --line: rgba(148, 200, 230, .12);
  --line-strong: rgba(148, 200, 230, .2);
  --side: #041018;
  --side-2: #071824;
  --side-text: #a8c2d4;
  --brand: #2AABEE;
  --brand-2: #229ED9;
  --brand-3: #54c8f5;
  --accent: #2AABEE;
  --accent-hover: #54c8f5;
  --accent-soft: rgba(42, 171, 238, .2);
  --tg: #2AABEE;
  --tg-deep: #0088cc;
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --shadow: 0 0 0 1px rgba(42,171,238,.06), 0 18px 50px rgba(0,0,0,.45);
  --glow: 0 0 40px rgba(42, 171, 238, .22);
  --radius: 16px;
  --font: "Space Grotesk", "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --grad: linear-gradient(90deg, #0088cc 0%, #2AABEE 55%, #54c8f5 100%);
  --grad-soft: linear-gradient(135deg, rgba(0,136,204,.35), rgba(42,171,238,.16));
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; min-height: 100%; }
body.app-body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(900px 480px at 15% -10%, rgba(42, 171, 238, .26), transparent 55%),
    radial-gradient(700px 420px at 90% 8%, rgba(0, 136, 204, .16), transparent 50%),
    linear-gradient(to right, rgba(255,255,255,.03) 1px, transparent 1px),
    linear-gradient(rgba(255,255,255,.03) 1px, transparent 1px),
    var(--bg);
  background-size: auto, auto, 48px 48px, 48px 48px, auto;
  background-attachment: scroll;
}
body.nav-lock { overflow: hidden; touch-action: none; }
a { color: var(--brand-3); text-decoration: none; }
a:hover { color: #9bdcf8; }

/* Auth */
.auth-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr);
}
.auth-brand {
  background:
    radial-gradient(600px 400px at 20% 20%, rgba(42,171,238,.32), transparent 60%),
    radial-gradient(500px 360px at 80% 80%, rgba(0,136,204,.2), transparent 55%),
    linear-gradient(165deg, #041018, #0a2030 55%, #040b12);
  color: #f1f8fc;
  padding: 56px 64px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  border-right: 1px solid var(--line);
}
.auth-brand::after {
  content: "";
  position: absolute;
  inset: auto -100px -100px auto;
  width: 340px; height: 340px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(42,171,238,.32), transparent 70%);
  pointer-events: none;
}
.auth-brand .muted { color: #8ba3b5; }
.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -.03em;
  position: relative;
  z-index: 1;
}
.logo i, .logo .mark {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--grad);
  color: #fff;
  font-style: normal;
  font-weight: 800;
  font-size: 15px;
  box-shadow: 0 0 24px rgba(42,171,238,.45);
}
.brand-copy { position: relative; z-index: 1; }
.brand-copy h1 {
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.05;
  margin: 40px 0 14px;
  letter-spacing: -.045em;
  font-weight: 700;
}
.brand-copy h1 .grad {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-copy p { color: #c5d8e6; font-size: 16px; max-width: 440px; line-height: 1.6; margin: 0; }
.feature-list { list-style: none; padding: 0; margin: 28px 0 0; position: relative; z-index: 1; }
.feature-list li {
  display: flex; gap: 10px; align-items: flex-start;
  color: #e2eef6; margin: 10px 0; font-size: 14px; line-height: 1.45;
}
.feature-list i { color: var(--brand-3); margin-top: 3px; }
.auth-panel {
  display: grid; place-items: center; padding: 40px 24px;
  background:
    radial-gradient(500px 300px at 80% 0%, rgba(42,171,238,.12), transparent 60%),
    transparent;
}
.auth-card {
  width: min(420px, 100%);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 32px;
  box-shadow: var(--shadow), var(--glow);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}
.auth-card h2 { margin: 0 0 6px; font-size: 26px; letter-spacing: -.03em; }
.auth-card .sub { color: var(--muted); margin: 0 0 22px; font-size: 14px; line-height: 1.5; }

/* Fields */
.field { display: flex; flex-direction: column; gap: 6px; margin: 0; }
.field label { font-size: 12px; font-weight: 600; color: #c5d8e6; letter-spacing: .01em; }
.field input, .field select, .field textarea, .input, .select, .textarea {
  width: 100%;
  min-height: 44px;
  background: rgba(4, 16, 24, .72);
  border: 1px solid var(--line-strong);
  color: var(--ink);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.field input::placeholder, .input::placeholder, .textarea::placeholder { color: #6b8496; }
.field input[type="checkbox"], .toggle-row input[type="checkbox"], .table input[type="checkbox"], .network-box input[type="checkbox"] {
  width: 16px; min-width: 16px; height: 16px; min-height: 16px; max-width: 16px;
  padding: 0; margin: 0; border-radius: 4px; accent-color: var(--brand); flex-shrink: 0; cursor: pointer;
}
.field input[type="file"] { padding: 10px; }
.textarea { min-height: 96px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus, .select:focus, .textarea:focus {
  border-color: rgba(42, 171, 238, .75);
  box-shadow: 0 0 0 4px var(--accent-soft);
  background: rgba(4, 18, 28, .92);
}
.auth-card .field { margin-bottom: 12px; }
option { background: #0c1c28; color: #f1f8fc; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 12px; padding: 0 16px; min-height: 44px;
  font: inherit; font-weight: 650; cursor: pointer; transition: .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn-primary {
  background: var(--grad);
  color: #fff;
  box-shadow: 0 8px 28px rgba(0, 136, 204, .35);
}
.btn-primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn-good {
  background: var(--grad);
  color: #fff;
  width: auto;
  box-shadow: 0 8px 24px rgba(0, 136, 204, .3);
}
.btn-ghost {
  background: rgba(4, 16, 24, .65);
  color: var(--ink);
  border: 1px solid var(--line-strong);
}
.btn-ghost:hover { background: rgba(12, 40, 56, .9); border-color: rgba(42,171,238,.45); }
.btn-danger {
  background: rgba(127, 29, 29, .35);
  color: #fecaca;
  border: 1px solid rgba(248, 113, 113, .35);
}
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 13px; width: auto; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.alert { padding: 10px 12px; border-radius: 12px; font-size: 13px; margin-bottom: 14px; border: 1px solid transparent; }
.alert-bad { background: rgba(127,29,29,.35); color: #fecaca; border-color: rgba(248,113,113,.3); }
.alert-good { background: rgba(6,78,59,.35); color: #a7f3d0; border-color: rgba(52,211,153,.3); }
.muted { color: var(--muted); }
.center { text-align: center; }

/* Shell */
.shell {
  display: grid;
  grid-template-columns: 258px minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
}
.side {
  background:
    radial-gradient(420px 280px at 0% 0%, rgba(42,171,238,.2), transparent 65%),
    linear-gradient(180deg, var(--side) 0%, var(--side-2) 100%);
  color: var(--side-text);
  padding: 16px 12px calc(12px + var(--safe-bottom));
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  z-index: 30;
  border-right: 1px solid var(--line);
  overflow: hidden;
}
.side-top {
  flex: 0 0 auto;
  padding-bottom: 4px;
}
.side .logo { color: #fff; padding: 6px 10px 10px; }
.side-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: rgba(42,171,238,.35) transparent;
}
.side-scroll::-webkit-scrollbar { width: 5px; }
.side-scroll::-webkit-scrollbar-thumb {
  background: rgba(42,171,238,.35);
  border-radius: 999px;
}
.nav-group { margin-top: 14px; }
.nav-group:first-child { margin-top: 6px; }
.nav-label {
  font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: #6b8496; padding: 8px 12px 6px;
}
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side a.nav-link {
  color: var(--side-text);
  padding: 10px 12px; border-radius: 12px;
  display: flex; gap: 10px; align-items: center;
  font-weight: 550; font-size: 14px;
}
.side a.nav-link i { width: 16px; text-align: center; opacity: .9; }
.side a.nav-link:hover { background: rgba(255,255,255,.05); color: #fff; }
.side a.nav-link.active {
  background: linear-gradient(90deg, rgba(0,136,204,.32), rgba(42,171,238,.12));
  color: #fff;
  box-shadow: inset 3px 0 0 #2AABEE;
}
.side-foot {
  flex: 0 0 auto;
  margin-top: 0;
  padding: 12px 8px 4px;
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, transparent, rgba(4,16,24,.55) 18%);
}
.side-user { font-size: 12px; color: #8ba3b5; margin-bottom: 8px; word-break: break-word; }
.main {
  padding: 28px 36px calc(100px + var(--safe-bottom));
  width: 100%;
  max-width: 1180px;
  min-width: 0;
}
.mobile-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(12px + var(--safe-top)) 16px 12px;
  background: rgba(4,16,24,.94);
  color: #fff;
  position: sticky; top: 0; z-index: 40;
  border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}
.mobile-bar .btn-menu {
  background: rgba(255,255,255,.06);
  border: 1px solid var(--line-strong);
  color: #fff;
  min-height: 40px;
  min-width: 44px;
  border-radius: 12px;
  padding: 0 12px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.side-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(4, 11, 18, .72);
  z-index: 25;
}
.shell.nav-open .side-backdrop { display: block; }

.topbar {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px; margin-bottom: 22px;
}
.topbar h1 { margin: 0; font-size: clamp(22px, 3vw, 28px); letter-spacing: -.035em; font-weight: 700; }
.topbar .hint { margin-top: 6px; max-width: 620px; }
.topbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; flex-wrap: wrap; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px; border-radius: 999px; font-size: 12px; font-weight: 650;
  border: 1px solid var(--line-strong); background: rgba(4,16,24,.75); color: #c5d8e6;
}
.pill.good { color: #a7f3d0; border-color: rgba(52,211,153,.35); background: rgba(6,78,59,.35); }
.pill.warn { color: #fde68a; border-color: rgba(251,191,36,.35); background: rgba(120,53,15,.35); }
.pill.bad { color: #fecaca; border-color: rgba(248,113,113,.35); background: rgba(127,29,29,.35); }

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.card-h {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 12px; margin-bottom: 16px;
}
.card-h h2 { margin: 0; font-size: 17px; letter-spacing: -.02em; font-weight: 700; }
.hint { margin: 4px 0 0; color: var(--muted); font-size: 13px; line-height: 1.45; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.stat {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.stat::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%; height: 2px;
  background: var(--grad);
  opacity: .85;
}
.stat .k { font-size: 12px; color: var(--muted); font-weight: 600; }
.stat .v { font-size: 24px; font-weight: 700; letter-spacing: -.03em; margin-top: 6px; }
.stat .s { font-size: 12px; color: var(--muted); margin-top: 4px; }

.page-tabs {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin: -6px 0 16px;
}
.page-tabs a {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: rgba(4,16,24,.65);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
.page-tabs a.active, .page-tabs a:hover {
  background: rgba(42,171,238,.18);
  border-color: rgba(42,171,238,.45);
  color: #b6e7fb;
}

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid-route { grid-template-columns: minmax(0,1fr) minmax(0,1.15fr) minmax(0,1.15fr) 148px; align-items: stretch; }
.card .grid + .grid, .card .grid + .row-actions, .card .grid + .table-wrap { margin-top: 14px; }

.toggle-row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: rgba(4, 16, 24, .55);
  border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px;
  min-height: 48px; font-weight: 550; font-size: 14px;
}
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; color: var(--muted); font-weight: 600; padding: 8px 8px 8px 0; white-space: nowrap; }
.table td { padding: 12px 8px 12px 0; border-top: 1px solid var(--line); vertical-align: middle; }
.mono { font-family: var(--mono); font-size: 12px; color: #c5d8e6; }

.network-box {
  background: rgba(4, 16, 24, .55);
  border: 1px solid var(--line);
  border-radius: 12px; padding: 14px;
  display: flex; flex-direction: column; gap: 8px; min-height: 100%;
}
.network-box .hint { display: flex; align-items: center; gap: 8px; margin: 0; }

.sticky-save {
  position: sticky; bottom: calc(12px + var(--safe-bottom)); display: flex; justify-content: center; z-index: 5;
}
.sticky-save .btn { min-width: min(220px, 100%); width: auto; }

.plan-price { font-size: clamp(32px, 6vw, 44px); font-weight: 750; letter-spacing: -.04em; margin: 4px 0 12px; }
.plan-price span { font-size: 16px; color: var(--muted); font-weight: 600; }
.qr-box {
  background: rgba(255,255,255,.96);
  border: 1px solid var(--line);
  border-radius: 16px; padding: 12px; display: inline-block;
}
.qr-box img { width: min(200px, 70vw); height: auto; aspect-ratio: 1; object-fit: contain; display: block; }
.checks { list-style: none; padding: 0; margin: 0; }
.checks li { display: flex; gap: 8px; margin: 8px 0; line-height: 1.4; }
.checks i { color: var(--brand-3); margin-top: 3px; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.quick-links {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.quick-link {
  display: block;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(4, 16, 24, .45);
  color: inherit;
  transition: .18s ease;
  position: relative;
  overflow: hidden;
}
.quick-link::after {
  content: "";
  position: absolute;
  inset: auto -20% -40% auto;
  width: 120px; height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(42,171,238,.25), transparent 70%);
  pointer-events: none;
}
.quick-link:hover {
  border-color: rgba(42,171,238,.45);
  background: rgba(42,171,238,.12);
  color: inherit;
  box-shadow: var(--glow);
}
.quick-link strong { display: block; margin-bottom: 4px; font-size: 14px; position: relative; z-index: 1; }
.quick-link span { color: var(--muted); font-size: 12px; line-height: 1.4; position: relative; z-index: 1; }

/* Laptop / small desktop */
@media (max-width: 1200px) {
  .main { padding-left: 24px; padding-right: 24px; }
  .grid-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .grid-4, .stat-grid, .quick-links { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-route { grid-template-columns: 1fr 1fr; }
  .shell { grid-template-columns: 230px minmax(0, 1fr); }
}

/* Tablet */
@media (max-width: 980px) {
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .mobile-bar { display: flex; }
  .shell { grid-template-columns: 1fr; }
  .side {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: min(300px, 88vw);
    transform: translateX(-105%);
    transition: transform .22s ease;
    padding-left: calc(12px + var(--safe-left));
    padding-right: calc(8px + var(--safe-right));
    box-shadow: 12px 0 40px rgba(0,0,0,.45);
    z-index: 45;
  }
  .shell.nav-open .side { transform: translateX(0); }
  .side-backdrop { z-index: 42; }
  .main { padding: 18px 16px calc(88px + var(--safe-bottom)); max-width: none; }
  .grid-3, .grid-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .input, .select, .textarea { font-size: 16px; } /* iOS Safari zoom prevent */
}

/* Mobile phones */
@media (max-width: 640px) {
  .auth-panel { padding: 24px 16px; }
  .auth-card { padding: 24px 18px; border-radius: 16px; }
  .grid-2, .grid-3, .grid-4, .grid-5, .grid-route, .stat-grid, .quick-links { grid-template-columns: 1fr; }
  .card { padding: 16px; }
  .topbar { flex-direction: column; }
  .topbar-right { width: 100%; }
  .row-actions .btn, .row-actions input { width: 100%; }
  .sticky-save .btn { width: 100%; min-width: 0; }
  .page-tabs a { font-size: 12px; padding: 7px 10px; }
  .table { font-size: 12px; }
}

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

/* SweetAlert */
.swal2-popup {
  background: #0c1c28 !important;
  color: #f1f8fc !important;
  border: 1px solid rgba(148, 200, 230, .12);
}
.swal2-title, .swal2-html-container { color: #f1f8fc !important; }

.nav-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px; margin-left: 6px;
  border-radius: 999px; font-size: 10px; font-weight: 700;
  background: var(--grad); color: #fff;
}
.alert-warn { margin-bottom: 14px; padding: 10px 12px; border-radius: 12px; font-size: 13px; }

.steps-list {
  margin: 0;
  padding-left: 1.25rem;
  display: grid;
  gap: 8px;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}
.steps-list a { color: var(--accent, #2aabee); word-break: break-all; }
.route-form {
  display: grid;
  grid-template-columns: 1.1fr 1.4fr 1.4fr auto;
  gap: 12px;
  align-items: start;
}
.pick-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}
.pick-preview {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  word-break: break-all;
}
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Chat picker — desktop dialog / mobile bottom sheet */
body.picker-lock {
  overflow: hidden !important;
  touch-action: none;
  overscroll-behavior: none;
}
.picker-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(2, 10, 16, .78);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  padding-left: calc(16px + var(--safe-left));
  padding-right: calc(16px + var(--safe-right));
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.picker-panel {
  width: min(440px, 100%);
  max-height: min(72vh, 640px);
  max-height: min(72dvh, 640px);
  background: #0a1822;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  box-shadow: 0 24px 64px rgba(0,0,0,.55);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
.picker-grab {
  display: none;
  width: 40px;
  height: 4px;
  border-radius: 999px;
  background: rgba(148,200,230,.28);
  margin: 10px auto 0;
  flex: 0 0 auto;
}
.picker-head {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  justify-content: space-between;
  padding: 14px 14px 10px;
  flex: 0 0 auto;
}
.picker-head-text { min-width: 0; }
.picker-role {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: #2aabee;
  margin-bottom: 4px;
}
.picker-role.dest { color: #34d399; }
.picker-head h3 {
  margin: 0;
  font-size: 16px;
  line-height: 1.25;
  letter-spacing: -.02em;
}
.picker-help {
  margin: 0;
  padding: 0 14px 10px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.35;
  flex: 0 0 auto;
}
.picker-help strong { color: var(--ink); font-weight: 600; }
.picker-help.wait { color: #fbbf24; }
.picker-help.error { color: #f87171; }
.picker-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 0 14px 10px;
  flex: 0 0 auto;
}
.picker-filters {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  padding: 0 14px 10px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  flex: 0 0 auto;
}
.picker-filters::-webkit-scrollbar { display: none; }
.chip {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.03);
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  min-height: 34px;
  -webkit-tap-highlight-color: transparent;
}
.chip.on {
  border-color: rgba(42,171,238,.55);
  background: rgba(42,171,238,.16);
  color: #7fd4f7;
}
.picker-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 4px 10px calc(12px + var(--safe-bottom));
  display: grid;
  gap: 4px;
  align-content: start;
  scrollbar-width: thin;
  scrollbar-color: rgba(42,171,238,.35) transparent;
}
.picker-list::-webkit-scrollbar { width: 6px; }
.picker-list::-webkit-scrollbar-track { background: transparent; }
.picker-list::-webkit-scrollbar-thumb {
  background: rgba(42,171,238,.35);
  border-radius: 999px;
}
.picker-empty {
  padding: 28px 12px;
  text-align: center;
  color: var(--muted);
  display: grid;
  gap: 10px;
  justify-items: center;
  font-size: 13px;
}
.picker-item {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 18px;
  gap: 10px;
  align-items: center;
  width: 100%;
  text-align: left;
  min-height: 52px;
  padding: 8px 10px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.picker-item:hover,
.picker-item:focus-visible {
  background: rgba(42, 171, 238, .12);
  outline: none;
}
.picker-item:active { background: rgba(42, 171, 238, .18); }
.picker-avatar {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  color: #041018;
  background: linear-gradient(135deg, #2AABEE, #54c8f5);
  flex-shrink: 0;
}
.picker-avatar[data-type="group"] { background: linear-gradient(135deg, #10b981, #34d399); }
.picker-avatar[data-type="user"] { background: linear-gradient(135deg, #f59e0b, #fbbf24); }
.picker-avatar[data-type="chat"] { background: linear-gradient(135deg, #64748b, #94a3b8); }
.picker-main { min-width: 0; display: grid; gap: 2px; }
.picker-title {
  font-weight: 600;
  font-size: 14px;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.picker-meta {
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: flex;
  gap: 6px;
  align-items: center;
}
.picker-meta .tag {
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 700;
  font-size: 10px;
  opacity: .85;
}
.picker-chevron { color: var(--muted); font-size: 12px; }

@media (max-width: 980px) {
  .route-form { grid-template-columns: 1fr; }
  .picker-backdrop {
    align-items: flex-end;
    justify-content: stretch;
    padding: 0;
  }
  .picker-panel {
    width: 100%;
    max-width: none;
    max-height: min(88vh, 100%);
    max-height: min(88dvh, 100%);
    border-radius: 18px 18px 0 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
  }
  .picker-grab { display: block; }
  .pick-field { grid-template-columns: minmax(0, 1fr); }
  .pick-field .btn { width: 100%; min-height: 44px; }
}
@media (max-width: 640px) {
  .route-form-actions label { display: none; }
  .route-form-actions .btn { width: 100%; min-height: 44px; }
}
[x-cloak] { display: none !important; }

/* Telegram login wizard */
.login-progress {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.login-step-dot {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.login-step-dot span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: rgba(255,255,255,.04);
  font-size: 12px;
}
.login-step-dot.active { color: var(--ink); }
.login-step-dot.active span {
  border-color: #2aabee;
  background: rgba(42,171,238,.18);
  color: #2aabee;
}
.login-step-dot.done span {
  border-color: #2ecc71;
  background: rgba(46,204,113,.16);
  color: #2ecc71;
}
.login-step-line {
  flex: 1;
  min-width: 18px;
  height: 1px;
  margin: 0 8px;
  background: var(--line);
}
.login-banner {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  margin-bottom: 16px;
  background: rgba(42,171,238,.08);
}
.login-banner strong { display: block; margin-bottom: 2px; font-size: 14px; }
.login-banner p { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.45; }
.login-banner-icon { font-size: 16px; margin-top: 2px; color: #2aabee; }
.login-banner-spin { margin-left: auto; color: #2aabee; font-size: 18px; }
.login-banner.wait { border-color: rgba(241,196,15,.35); background: rgba(241,196,15,.1); }
.login-banner.wait .login-banner-icon,
.login-banner.wait .login-banner-spin { color: #f1c40f; }
.login-banner.act { border-color: rgba(42,171,238,.45); background: rgba(42,171,238,.12); }
.login-banner.ok { border-color: rgba(46,204,113,.4); background: rgba(46,204,113,.1); }
.login-banner.ok .login-banner-icon { color: #2ecc71; }
.login-banner.error { border-color: rgba(231,76,60,.4); background: rgba(231,76,60,.1); }
.login-banner.error .login-banner-icon { color: #e74c3c; }
.login-banner.idle { background: rgba(255,255,255,.03); }
.login-panel-title { margin: 0 0 10px; font-size: 15px; }
.login-advanced {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  color: var(--muted);
  font-size: 13px;
}
.login-advanced summary { cursor: pointer; color: var(--ink); }
.pill.bad { background: rgba(231,76,60,.16); color: #ff8f84; }

/* Light theme */
html[data-theme="light"] body.app-body {
  --bg: #eef6fb;
  --bg-2: #e3eef6;
  --paper: rgba(255,255,255,.92);
  --paper-solid: #ffffff;
  --ink: #0b1c28;
  --muted: #5b7384;
  --line: rgba(15, 60, 90, .12);
  --line-strong: rgba(15, 60, 90, .18);
  --side: #0b3a52;
  --side-2: #0d4663;
  --side-text: #d7ebf6;
  --shadow: 0 1px 2px rgba(11,28,40,.04), 0 12px 28px rgba(11,28,40,.08);
  color: var(--ink);
  background:
    radial-gradient(900px 480px at 15% -10%, rgba(42,171,238,.18), transparent 55%),
    radial-gradient(700px 420px at 90% 8%, rgba(0,136,204,.1), transparent 50%),
    var(--bg);
}
html[data-theme="light"] .field input,
html[data-theme="light"] .field select,
html[data-theme="light"] .field textarea,
html[data-theme="light"] .input,
html[data-theme="light"] .select,
html[data-theme="light"] .textarea {
  background: #fff;
  color: var(--ink);
}
html[data-theme="light"] .toggle-row,
html[data-theme="light"] .network-box,
html[data-theme="light"] .quick-link {
  background: #f4fafd;
}
html[data-theme="light"] .pill {
  background: #fff;
  color: #335566;
}
html[data-theme="light"] .btn-ghost {
  background: #fff;
  color: var(--ink);
}
html[data-theme="light"] .swal2-popup {
  background: #fff !important;
  color: #0b1c28 !important;
}
html[data-theme="light"] .swal2-title,
html[data-theme="light"] .swal2-html-container { color: #0b1c28 !important; }
