/* Ocean Hunt web — real API data inside a Lovable-inspired ocean command centre. */
:root {
  color-scheme: dark;
  --abyss-0: #020712;
  --abyss: #030b1b;
  --navy: #071426;
  --navy-soft: #0a1b31;
  --reef: #0c223b;
  --current: #123654;
  --cyan: #32d8ff;
  --cyan-bright: #70e8ff;
  --green: #40eea2;
  --amber: #ffc857;
  --coral: #ff7180;
  --telegram-accent: #32d8ff;
  --pearl: #f2f8ff;
  --mist: #94adc7;
  --muted: #6f89a4;
  --line: rgba(126, 196, 226, .17);
  --line-strong: rgba(98, 219, 255, .28);
  --glass: rgba(7, 22, 42, .70);
  --glass-strong: rgba(8, 28, 50, .88);
  --radius-s: 12px;
  --radius-m: 18px;
  --radius-l: 26px;
  --sans: Inter, "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  --display: Manrope, Inter, "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
  --mono: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  --shadow: 0 24px 70px rgba(0, 4, 13, .42);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--abyss-0); }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 76% -12%, rgba(30, 181, 224, .14), transparent 34rem),
    radial-gradient(circle at 8% 106%, rgba(32, 109, 183, .13), transparent 38rem),
    linear-gradient(145deg, #020712 0%, #04101f 52%, #020813 100%);
  color: var(--pearl);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.device-create-inline {
  display: flex;
  flex: 1 1 300px;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}
.device-create-inline input {
  flex: 1 1 180px;
  min-width: 0;
  max-width: 240px;
  min-height: 40px;
}

button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--cyan); text-underline-offset: 3px; }
button { color: inherit; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
::selection { background: rgba(50, 216, 255, .26); color: #fff; }

/* ---------- ambient ocean ---------- */
#ocean-bg { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.caustics { position: absolute; inset: -22%; opacity: .78; filter: blur(34px); animation: caustics 18s ease-in-out infinite alternate; }
.caustics::before,
.caustics::after { content: ""; position: absolute; inset: 0; }
.caustics::before {
  background:
    radial-gradient(38% 30% at 17% 17%, rgba(37, 196, 244, .20), transparent 72%),
    radial-gradient(34% 27% at 82% 28%, rgba(56, 242, 199, .11), transparent 72%),
    radial-gradient(45% 36% at 57% 86%, rgba(28, 86, 178, .21), transparent 72%);
}
.caustics::after {
  background:
    radial-gradient(28% 22% at 45% 14%, rgba(105, 231, 255, .10), transparent 72%),
    radial-gradient(30% 27% at 26% 68%, rgba(35, 147, 211, .11), transparent 72%);
  animation: caustics-shift 15s ease-in-out infinite alternate-reverse;
}
.ocean-grid {
  position: absolute;
  inset: 0;
  opacity: .15;
  background-image:
    linear-gradient(to right, rgba(93, 181, 218, .20) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(93, 181, 218, .20) 1px, transparent 1px);
  background-size: 58px 58px;
  -webkit-mask-image: radial-gradient(80% 70% at 54% 20%, #000, transparent 90%);
  mask-image: radial-gradient(80% 70% at 54% 20%, #000, transparent 90%);
}
.ambient-sonar { position: absolute; left: 72%; top: 36%; width: 1px; height: 1px; }
.ambient-sonar i {
  position: absolute;
  left: 0;
  top: 0;
  width: 260px;
  height: 260px;
  border: 1px solid rgba(50, 216, 255, .10);
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(.25);
  animation: ambient-ping 8s linear infinite;
}
.ambient-sonar i:nth-child(2) { animation-delay: -2s; }
.ambient-sonar i:nth-child(3) { animation-delay: -4s; }
.ambient-sonar i:nth-child(4) { animation-delay: -6s; }
.bubbles i {
  position: absolute;
  bottom: -50px;
  width: 7px;
  height: 7px;
  border: 1px solid rgba(153, 235, 255, .45);
  border-radius: 50%;
  background: radial-gradient(circle at 30% 25%, rgba(255,255,255,.6), rgba(50,216,255,.04) 70%);
  box-shadow: 0 0 12px rgba(50,216,255,.15);
  animation: bubble 20s linear infinite;
}
.bubbles i:nth-child(1) { left: 7%; animation-duration: 22s; animation-delay: -4s; }
.bubbles i:nth-child(2) { left: 18%; width: 12px; height: 12px; animation-duration: 28s; animation-delay: -18s; }
.bubbles i:nth-child(3) { left: 36%; width: 5px; height: 5px; animation-duration: 19s; animation-delay: -9s; }
.bubbles i:nth-child(4) { left: 53%; width: 9px; height: 9px; animation-duration: 25s; animation-delay: -2s; }
.bubbles i:nth-child(5) { left: 67%; width: 4px; height: 4px; animation-duration: 17s; animation-delay: -13s; }
.bubbles i:nth-child(6) { left: 79%; width: 13px; height: 13px; animation-duration: 30s; animation-delay: -21s; }
.bubbles i:nth-child(7) { left: 90%; width: 6px; height: 6px; animation-duration: 21s; animation-delay: -7s; }
.bubbles i:nth-child(8) { left: 46%; width: 10px; height: 10px; animation-duration: 27s; animation-delay: -25s; }
@keyframes caustics { to { transform: translate3d(4%, -2%, 0) rotate(2deg) scale(1.06); } }
@keyframes caustics-shift { to { transform: translate3d(-4%, 5%, 0) scale(1.08); } }
@keyframes ambient-ping { 0% { opacity: .55; transform: translate(-50%, -50%) scale(.25); } 100% { opacity: 0; transform: translate(-50%, -50%) scale(4); } }
@keyframes bubble { 0% { transform: translate3d(0,0,0); opacity: 0; } 10% { opacity: .65; } 85% { opacity: .4; } 100% { transform: translate3d(28px,-115vh,0); opacity: 0; } }

/* ---------- shared shell ---------- */
#app { position: relative; z-index: 1; min-height: 100vh; min-height: 100dvh; }
.boot { display: grid; min-height: 72vh; place-items: center; align-content: center; gap: 18px; color: var(--mist); }
.boot p { margin: 0; }
.sonar-mini {
  width: 48px;
  height: 48px;
  border: 2px solid rgba(50,216,255,.25);
  border-top-color: var(--cyan);
  border-radius: 50%;
  box-shadow: 0 0 22px rgba(50,216,255,.16);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.app-shell { display: flex; min-height: 100vh; min-height: 100dvh; }
.desktop-sidebar {
  display: none;
  position: sticky;
  top: 0;
  flex: 0 0 auto;
  height: 100vh;
  height: 100dvh;
  padding: 16px 12px;
}
.sidebar-panel {
  display: flex;
  height: 100%;
  flex-direction: column;
  gap: 18px;
  padding: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  background: linear-gradient(160deg, rgba(11,34,58,.84), rgba(4,17,34,.70));
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,.035);
  -webkit-backdrop-filter: blur(24px) saturate(135%);
  backdrop-filter: blur(24px) saturate(135%);
}
.brand-button {
  display: flex;
  width: 100%;
  min-height: 54px;
  align-items: center;
  gap: 12px;
  padding: 5px;
  border: 0;
  border-radius: 16px;
  background: transparent;
  cursor: pointer;
  text-align: left;
}
.brand-button:hover { background: rgba(50,216,255,.06); }
.brand-mark {
  position: relative;
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  place-items: center;
  overflow: hidden;
  padding: 2px;
  border: 1px solid rgba(99,226,255,.32);
  border-radius: 14px 18px 14px 18px;
  background:
    radial-gradient(circle at 34% 28%, rgba(150,242,255,.34), transparent 30%),
    linear-gradient(145deg, rgba(31,194,232,.27), rgba(3,34,63,.84));
  box-shadow: 0 0 28px rgba(50,216,255,.17), inset 0 1px 0 rgba(255,255,255,.12);
}
.brand-mark img { display: block; width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 0 7px rgba(50,216,255,.34)); }
.brand-copy { min-width: 0; }
.brand-copy b { display: block; overflow: hidden; font-family: var(--display); font-size: 14px; font-weight: 800; line-height: 1.2; text-overflow: ellipsis; white-space: nowrap; }
.brand-copy span { display: block; margin-top: 2px; overflow: hidden; color: var(--mist); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.side-nav { min-height: 0; flex: 1; }
.side-nav-list { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.side-nav button {
  position: relative;
  display: flex;
  width: 100%;
  min-height: 48px;
  align-items: center;
  gap: 12px;
  overflow: hidden;
  padding: 8px 11px;
  border: 0;
  border-radius: 15px;
  background: transparent;
  color: var(--mist);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 650;
  text-align: left;
  transition: color .18s ease, background .18s ease;
}
.side-nav button::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 3px;
  height: 26px;
  border-radius: 0 4px 4px 0;
  background: var(--cyan);
  opacity: 0;
  transform: translateY(-50%);
  box-shadow: 0 0 14px rgba(50,216,255,.65);
}
.side-nav button:hover { background: rgba(50,216,255,.055); color: var(--pearl); }
.side-nav button.on { background: rgba(50,216,255,.105); color: var(--cyan-bright); }
.side-nav button.on::before { opacity: 1; }
.nav-icon {
  display: grid;
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  place-items: center;
  color: currentColor;
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 500;
  line-height: 1;
}
.side-status { padding: 9px 5px 4px; }
.sidebar-version { display: block; margin-top: 10px; overflow: hidden; color: var(--muted); font-family: var(--mono); font-size: 10px; text-align: center; text-overflow: ellipsis; white-space: nowrap; }

.workspace { min-width: 0; flex: 1; padding: 0 14px 94px; }
.content { width: 100%; max-width: 1360px; margin: 0 auto; padding: 20px 0 30px; }
.mobile-top {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 3px 1px 18px;
}
.mobile-top .brand-copy { flex: 1; }
.mobile-top .brand-copy b { font-size: 15px; }
.mobile-top .brand-mark { width: 40px; height: 40px; flex-basis: 40px; border-radius: 13px 16px 13px 16px; }
.mobile-context { display: grid; justify-items: end; gap: 2px; text-align: right; }
.client-mode { color: var(--mist); font-family: var(--mono); font-size: 9px; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; }
.client-mode.telegram { color: var(--telegram-accent); }
.mobile-signal { color: var(--muted); font-size: 9.5px; white-space: nowrap; }
.mobile-signal.on { color: var(--green); }
.bottom-nav {
  position: fixed;
  z-index: 50;
  inset: auto 0 0;
  padding-bottom: env(safe-area-inset-bottom, 0);
  border-top: 1px solid var(--line);
  background: rgba(3, 12, 25, .88);
  box-shadow: 0 -12px 40px rgba(0,4,13,.34);
  -webkit-backdrop-filter: blur(22px) saturate(145%);
  backdrop-filter: blur(22px) saturate(145%);
}
.bottom-nav ul { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); margin: 0; padding: 0; list-style: none; }
.bottom-nav button {
  display: flex;
  width: 100%;
  min-height: 62px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 4px;
  padding: 6px 2px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 9.5px;
  font-weight: 700;
}
.bottom-nav button.on { color: var(--cyan-bright); }
.bottom-nav .nav-icon { width: 22px; height: 22px; flex-basis: 22px; font-size: 18px; }
.bottom-nav .nav-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#view { animation: view-in .28s ease both; }
@keyframes view-in { from { opacity: 0; transform: translateY(5px); } }

/* ---------- typography and primitives ---------- */
h1, h2, h3, p { overflow-wrap: anywhere; }
h1, h2, h3 { font-family: var(--display); }
h1 { margin: 0; font-size: clamp(27px, 4vw, 42px); font-weight: 800; letter-spacing: -.04em; line-height: 1.1; }
h2 { margin: 0; font-size: 18px; font-weight: 750; letter-spacing: -.02em; }
h3 { margin: 0; font-size: 15px; font-weight: 700; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin: 10px 0 24px; }
.page-head-copy { min-width: 0; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 8px; color: var(--cyan); font-family: var(--mono); font-size: 10.5px; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; }
.eyebrow::before { content: ""; width: 18px; height: 1px; background: currentColor; box-shadow: 0 0 8px currentColor; }
.sub { max-width: 760px; margin: 8px 0 0; color: var(--mist); font-size: 14px; }
.muted { color: var(--mist); }
.mono { font-family: var(--mono); }
.glass-panel,
.card {
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: linear-gradient(145deg, rgba(11,34,58,.76), rgba(5,20,39,.70));
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,.035);
  -webkit-backdrop-filter: blur(19px) saturate(125%);
  backdrop-filter: blur(19px) saturate(125%);
}
.card { padding: 20px; }
.card + .card { margin-top: 16px; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.card-head-copy { min-width: 0; }
.card-kicker { display: block; margin-bottom: 3px; color: var(--cyan); font-family: var(--mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; }
.divider { height: 1px; margin: 16px 0; background: linear-gradient(90deg, var(--line-strong), rgba(126,196,226,.05), transparent); }
.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.row { display: flex; align-items: center; gap: 11px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }

.status-pill,
.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  width: fit-content;
  border: 1px solid rgba(148,173,199,.24);
  border-radius: 999px;
  background: rgba(148,173,199,.09);
  color: var(--mist);
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 650;
  white-space: nowrap;
}
.status-pill { min-height: 34px; padding: 7px 12px; }
.badge { padding: 4px 9px; }
.status-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-pill.ok,
.badge.ok { border-color: rgba(64,238,162,.30); background: rgba(64,238,162,.10); color: var(--green); }
.status-pill.ok::before { box-shadow: 0 0 0 0 rgba(64,238,162,.5); animation: live-pulse 2.4s infinite; }
.status-pill.wait,
.badge.wait { border-color: rgba(255,200,87,.30); background: rgba(255,200,87,.10); color: var(--amber); }
.status-pill.bad,
.badge.bad { border-color: rgba(255,113,128,.32); background: rgba(255,113,128,.10); color: var(--coral); }
.badge.off { color: var(--mist); }
@keyframes live-pulse { 70% { box-shadow: 0 0 0 8px rgba(64,238,162,0); } 100% { box-shadow: 0 0 0 0 rgba(64,238,162,0); } }

.btn {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--cyan-bright), var(--cyan));
  box-shadow: 0 8px 24px rgba(50,216,255,.14);
  color: #03131e;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 750;
  text-decoration: none;
  transition: transform .16s ease, filter .16s ease, border-color .16s ease, background .16s ease;
}
.btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.ghost { border-color: var(--line-strong); background: rgba(8,27,49,.60); box-shadow: none; color: var(--pearl); }
.btn.ghost:hover { background: rgba(50,216,255,.09); filter: none; }
.btn.small { min-height: 36px; padding: 7px 12px; font-size: 12.5px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .48; cursor: not-allowed; transform: none; }

input, select {
  width: 100%;
  min-height: 46px;
  padding: 11px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: rgba(2,12,25,.72);
  color: var(--pearl);
  font-size: 15px;
}
input::placeholder { color: #56718c; }
label { display: block; margin: 0 0 6px; color: var(--mist); font-size: 10.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
.field + .field { margin-top: 13px; }
.form-actions { margin-top: 15px; }

/* ---------- dashboard ---------- */
.dashboard-hero {
  position: relative;
  display: grid;
  min-height: 460px;
  align-items: center;
  gap: 28px;
  margin: 8px 0 18px;
  padding: clamp(24px, 5vw, 56px);
  overflow: hidden;
  border: 1px solid rgba(83, 220, 255, .27);
  border-radius: clamp(22px, 4vw, 34px);
  background:
    radial-gradient(circle at 86% 18%, rgba(64,238,162,.12), transparent 24rem),
    radial-gradient(circle at 67% 78%, rgba(255,113,128,.12), transparent 22rem),
    linear-gradient(128deg, rgba(10,40,68,.94), rgba(3,16,32,.88) 58%, rgba(2,12,26,.94));
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,.055);
  isolation: isolate;
}
.dashboard-hero::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  opacity: .32;
  background-image:
    linear-gradient(rgba(74,193,232,.14) 1px, transparent 1px),
    linear-gradient(90deg, rgba(74,193,232,.14) 1px, transparent 1px);
  background-size: 52px 52px;
  -webkit-mask-image: linear-gradient(90deg, #000, transparent 76%);
  mask-image: linear-gradient(90deg, #000, transparent 76%);
}
.hero-copy { position: relative; z-index: 3; min-width: 0; }
.hero-copy h1 { max-width: 850px; font-size: clamp(35px, 6.2vw, 68px); line-height: .99; }
.hero-copy p { max-width: 720px; margin: 18px 0 0; color: #b4cbe0; font-size: clamp(14px, 1.6vw, 17px); }
.hero-noise { color: var(--coral); text-shadow: 0 0 24px rgba(255,113,128,.25); }
.hero-target { color: var(--green); text-shadow: 0 0 24px rgba(64,238,162,.24); }
.hero-actions { display: flex; gap: 10px; margin-top: 22px; flex-wrap: wrap; }
.hero-visual { position: relative; z-index: 1; display: grid; place-items: center; min-width: 0; }
.sonar-stage.hero-sonar {
  width: min(100%, 430px);
  margin: 0 auto;
  border-color: rgba(112,232,255,.34);
  background-size: 25% 25%, 25% 25%, auto;
  box-shadow: inset 0 0 80px rgba(50,216,255,.11), 0 0 80px rgba(31,184,224,.13);
}
.sonar-logo {
  position: absolute;
  z-index: 4;
  left: 50%;
  top: 50%;
  display: grid;
  width: 75%;
  aspect-ratio: 1;
  place-items: center;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 0 22px rgba(50,216,255,.22));
}
.sonar-logo.compact { width: 64%; }
.sonar-logo img { display: block; width: 100%; height: 100%; object-fit: contain; }
.noise-dot,
.target-dot { position: absolute; z-index: 5; border-radius: 50%; }
.noise-dot { width: 11px; height: 11px; background: var(--coral); box-shadow: 0 0 0 6px rgba(255,113,128,.08), 0 0 20px var(--coral); animation: blip 2.8s ease-in-out infinite; }
.noise-dot.one { left: 19%; top: 28%; }
.noise-dot.two { left: 28%; top: 73%; animation-delay: -.9s; }
.noise-dot.three { left: 77%; top: 22%; animation-delay: -1.7s; }
.target-dot { width: 13px; height: 13px; border: 2px solid #dcfff1; background: var(--green); box-shadow: 0 0 0 7px rgba(64,238,162,.11), 0 0 24px var(--green); animation: target-lock 2.2s ease-in-out infinite; }
.target-dot.one { right: 14%; bottom: 24%; }
.target-dot.two { right: 25%; top: 44%; animation-delay: -1.1s; }
@keyframes target-lock { 50% { box-shadow: 0 0 0 13px rgba(64,238,162,0), 0 0 28px var(--green); } }

.command-console { max-width: 720px; margin-top: 16px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: rgba(2,13,27,.62); }
.command-console label { margin-bottom: 8px; }
.command-console.read-only p { margin: 3px 0 0; color: var(--mist); font-size: 12.5px; }
.command-device-row { display: grid; gap: 9px; }
.command-device-row select { min-width: 0; }
.command-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.command-buttons .btn { flex: 1 1 155px; }
.command-caption { display: block; margin-top: 8px; color: var(--muted); font-size: 10.5px; }
.station-card .sonar-stats { margin-top: 16px; padding-top: 14px; border-top: 1px solid rgba(126,196,226,.10); }
.dashboard-layout { display: grid; gap: 16px; }
.dashboard-primary { min-width: 0; }
.grid.metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 16px; }
.metric {
  position: relative;
  min-width: 0;
  min-height: 126px;
  overflow: hidden;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: linear-gradient(145deg, rgba(12,40,66,.76), rgba(5,19,37,.72));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.03);
}
.metric::after { content: ""; position: absolute; width: 90px; height: 90px; right: -35px; bottom: -44px; border: 1px solid rgba(50,216,255,.12); border-radius: 50%; box-shadow: 0 0 35px rgba(50,216,255,.05); }
.metric-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.metric-icon { display: grid; width: 30px; height: 30px; place-items: center; border: 1px solid rgba(50,216,255,.18); border-radius: 10px; background: rgba(50,216,255,.07); color: var(--cyan); font-family: var(--mono); font-size: 15px; }
.metric-label { color: var(--mist); font-size: 11px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; }
.metric strong { display: block; margin-top: 11px; font-family: var(--display); font-size: clamp(26px, 4vw, 34px); font-weight: 800; letter-spacing: -.04em; line-height: 1; font-variant-numeric: tabular-nums; }
.metric.ok strong { color: var(--green); }
.metric.warn strong { color: var(--amber); }
.metric.bad strong { color: var(--coral); }
.sonar-card { position: relative; overflow: hidden; padding: 20px; }
.sonar-card::before { content: ""; position: absolute; inset: auto -35% -45% 5%; height: 65%; background: radial-gradient(ellipse, rgba(50,216,255,.10), transparent 70%); pointer-events: none; }
.sonar-stage { position: relative; width: min(100%, 230px); aspect-ratio: 1; margin: 18px auto; overflow: hidden; border: 1px solid rgba(50,216,255,.24); border-radius: 50%; background:
  linear-gradient(rgba(50,216,255,.12) 1px, transparent 1px),
  linear-gradient(90deg, rgba(50,216,255,.12) 1px, transparent 1px),
  radial-gradient(circle, rgba(15,71,94,.42), rgba(2,16,30,.78) 70%);
  background-size: 50% 50%, 50% 50%, auto;
  box-shadow: inset 0 0 48px rgba(50,216,255,.07), 0 0 34px rgba(50,216,255,.08);
}
.sonar-stage::before,
.sonar-stage::after { content: ""; position: absolute; border: 1px solid rgba(50,216,255,.20); border-radius: 50%; inset: 19%; }
.sonar-stage::after { inset: 38%; }
.sonar-sweep { position: absolute; inset: 0; border-radius: 50%; background: conic-gradient(from 0deg, transparent 0 78%, rgba(50,216,255,.03) 83%, rgba(50,216,255,.40) 100%); animation: sweep 5s linear infinite; }
.sonar-core { position: absolute; z-index: 2; left: 50%; top: 50%; width: 11px; height: 11px; border: 2px solid var(--cyan-bright); border-radius: 50%; background: var(--cyan); transform: translate(-50%,-50%); box-shadow: 0 0 20px var(--cyan); }
.sonar-blip { position: absolute; z-index: 2; width: 7px; height: 7px; left: 69%; top: 31%; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 5px rgba(64,238,162,.08), 0 0 14px var(--green); animation: blip 2.4s ease-in-out infinite; }
.sonar-stage.idle .sonar-sweep { animation-duration: 10s; opacity: .35; }
.sonar-stage.idle .sonar-blip { display: none; }
@keyframes sweep { to { transform: rotate(360deg); } }
@keyframes blip { 50% { opacity: .38; transform: scale(.7); } }
.sonar-stats { display: grid; gap: 10px; margin: 0; }
.sonar-stats div { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 10px; border-bottom: 1px solid rgba(126,196,226,.10); }
.sonar-stats div:last-child { padding-bottom: 0; border-bottom: 0; }
.sonar-stats dt { color: var(--mist); font-size: 12px; }
.sonar-stats dd { margin: 0; font-family: var(--mono); font-size: 12px; font-weight: 700; text-align: right; }

/* ---------- leads and analytics ---------- */
.lead-list { display: grid; gap: 10px; }
.lead {
  position: relative;
  padding: 15px;
  border: 1px solid rgba(126,196,226,.12);
  border-radius: 14px;
  background: rgba(3,16,31,.40);
  transition: border-color .18s ease, background .18s ease, transform .18s ease;
}
.lead:hover { border-color: var(--line-strong); background: rgba(8,32,54,.58); transform: translateY(-1px); }
.lead .head { display: flex; align-items: center; gap: 10px; }
.lead .score { display: grid; width: 42px; height: 42px; flex: 0 0 42px; place-items: center; border: 1px solid rgba(50,216,255,.25); border-radius: 50%; background: rgba(50,216,255,.08); color: var(--cyan-bright); font-family: var(--mono); font-size: 12px; font-weight: 800; box-shadow: inset 0 0 15px rgba(50,216,255,.05); }
.lead .score.ok { border-color: rgba(64,238,162,.35); color: var(--green); }
.lead .score.wait { border-color: rgba(255,200,87,.35); color: var(--amber); }
.lead .co { min-width: 0; flex: 1; overflow: hidden; font-family: var(--display); font-size: 14.5px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.lead .need { margin: 9px 0 0 52px; color: var(--mist); font-size: 13px; }
.lead-meta { display: flex; gap: 7px 13px; margin: 10px 0 0 52px; flex-wrap: wrap; color: var(--muted); font-size: 11.5px; }
.lead-meta span { display: inline-flex; align-items: center; gap: 5px; }
.lead-meta span::before { content: ""; width: 4px; height: 4px; border-radius: 50%; background: var(--cyan); opacity: .7; }
.lead-actions { display: flex; gap: 7px; margin: 12px 0 0 52px; flex-wrap: wrap; }
.lead-actions button {
  min-height: 30px;
  padding: 5px 9px;
  border: 1px solid rgba(126,196,226,.18);
  border-radius: 9px;
  background: rgba(7,27,48,.74);
  color: var(--mist);
  cursor: pointer;
  font-size: 10.5px;
  font-weight: 700;
}
.lead-actions button:hover { border-color: var(--line-strong); color: var(--pearl); }
.lead-actions button[data-status="won"] { border-color: rgba(64,238,162,.24); color: var(--green); }
.lead-actions button[data-status="rejected"] { border-color: rgba(255,113,128,.23); color: var(--coral); }
.lead-actions button:disabled { opacity: .55; cursor: wait; }
.funnel { display: grid; gap: 17px; }
.funnel-row { display: grid; gap: 7px; }
.funnel-label { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13px; }
.funnel-label span:last-child { color: var(--mist); font-family: var(--mono); font-size: 11.5px; }
progress.funnel-progress { width: 100%; height: 9px; overflow: hidden; border: 0; border-radius: 999px; background: rgba(2,12,25,.76); color: var(--cyan); }
progress.funnel-progress::-webkit-progress-bar { border-radius: 999px; background: rgba(2,12,25,.76); }
progress.funnel-progress::-webkit-progress-value { border-radius: 999px; background: currentColor; box-shadow: 0 0 14px currentColor; }
progress.funnel-progress::-moz-progress-bar { border-radius: 999px; background: currentColor; box-shadow: 0 0 14px currentColor; }
progress.funnel-progress.amber { color: var(--amber); }
progress.funnel-progress.green { color: var(--green); }
progress.funnel-progress.coral { color: var(--coral); }

/* ---------- devices, integrations, settings ---------- */
.device { display: flex; align-items: center; gap: 13px; min-height: 62px; padding: 11px 0; border-bottom: 1px solid rgba(126,196,226,.10); }
.device:last-child { border-bottom: 0; }
.device-mark { display: grid; width: 38px; height: 38px; flex: 0 0 38px; place-items: center; border: 1px solid var(--line); border-radius: 12px; background: rgba(50,216,255,.07); color: var(--cyan); font-family: var(--mono); font-size: 13px; }
.device .info { min-width: 0; flex: 1; }
.device .info b { display: block; overflow: hidden; font-size: 13.5px; text-overflow: ellipsis; white-space: nowrap; }
.device .info span { display: block; margin-top: 2px; color: var(--mist); font-family: var(--mono); font-size: 10.5px; }
.integration-stack { display: grid; gap: 16px; }
.integration-title { display: flex; align-items: flex-start; gap: 13px; }
.integration-logo { display: grid; width: 44px; height: 44px; flex: 0 0 44px; place-items: center; border: 1px solid var(--line-strong); border-radius: 14px; background: rgba(50,216,255,.08); color: var(--cyan-bright); font-family: var(--mono); font-size: 12px; font-weight: 800; box-shadow: 0 0 24px rgba(50,216,255,.08); }
.integration-logo.tg { border-color: rgba(70,184,255,.37); background: linear-gradient(145deg, rgba(44,165,231,.24), rgba(30,95,161,.12)); }
.integration-logo.crm { border-color: rgba(64,238,162,.28); background: rgba(64,238,162,.08); color: var(--green); }
.integration-copy { min-width: 0; flex: 1; }
.integration-copy .sub { margin-top: 4px; }
.telegram-card { position: relative; overflow: hidden; padding: 0; border-color: rgba(61,192,255,.31); }
.telegram-card::before { content: ""; position: absolute; width: 420px; height: 420px; right: -180px; top: -210px; border-radius: 50%; background: radial-gradient(circle, rgba(50,181,242,.20), transparent 68%); pointer-events: none; }
.telegram-hero { position: relative; padding: 22px; border-bottom: 1px solid var(--line); background: linear-gradient(120deg, rgba(24,109,163,.14), transparent 62%); }
.telegram-layout { position: relative; display: grid; gap: 18px; padding: 22px; }
.telegram-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; margin: 18px 0; }
.telegram-fact { min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 13px; background: rgba(2,15,29,.46); }
.telegram-fact span { display: block; color: var(--mist); font-size: 10px; letter-spacing: .05em; text-transform: uppercase; }
.telegram-fact b { display: block; margin-top: 5px; overflow: hidden; font-family: var(--mono); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.miniapp-device { width: min(100%, 300px); margin: 0 auto; padding: 9px; border: 1px solid rgba(112,232,255,.28); border-radius: 31px; background: linear-gradient(145deg, rgba(18,52,78,.85), rgba(1,9,19,.94)); box-shadow: 0 26px 60px rgba(0,4,12,.44), inset 0 1px 0 rgba(255,255,255,.09); }
.miniapp-screen { min-height: 390px; padding: 17px; overflow: hidden; border: 1px solid rgba(126,196,226,.12); border-radius: 23px; background:
  radial-gradient(circle at 80% 0, rgba(50,216,255,.12), transparent 48%),
  linear-gradient(160deg, #071a2d, #03101f 70%); }
.miniapp-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-bottom: 13px; border-bottom: 1px solid rgba(126,196,226,.12); }
.miniapp-top .brand-mark { width: 34px; height: 34px; flex-basis: 34px; border-radius: 11px 13px 11px 13px; font-size: 12px; }
.miniapp-title { min-width: 0; flex: 1; }
.miniapp-title b { display: block; font-size: 11.5px; }
.miniapp-title span { display: block; color: var(--mist); font-size: 9.5px; }
.miniapp-body { padding: 22px 2px 4px; }
.miniapp-body > span { color: var(--mist); font-size: 10.5px; letter-spacing: .07em; text-transform: uppercase; }
.miniapp-total { display: block; margin: 4px 0 18px; color: var(--pearl); font-family: var(--display); font-size: 44px; font-weight: 800; letter-spacing: -.05em; line-height: 1; }
.miniapp-status { display: grid; gap: 9px; }
.miniapp-status div { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 11px; border: 1px solid rgba(126,196,226,.12); border-radius: 11px; background: rgba(2,12,25,.48); font-size: 10.5px; }
.miniapp-status span { color: var(--mist); }
.miniapp-status b { color: var(--cyan-bright); font-family: var(--mono); font-size: 10px; text-align: right; }
.steps { counter-reset: step; display: grid; gap: 10px; margin: 16px 0 0; padding: 0; list-style: none; }
.steps li { counter-increment: step; display: grid; grid-template-columns: 27px minmax(0,1fr); align-items: start; gap: 10px; color: var(--mist); font-size: 13px; }
.steps li::before { content: counter(step); display: grid; width: 25px; height: 25px; place-items: center; border: 1px solid rgba(50,216,255,.20); border-radius: 50%; background: rgba(50,216,255,.07); color: var(--cyan); font-family: var(--mono); font-size: 10px; font-weight: 700; }
.steps b { color: var(--pearl); }
.integration-actions { display: flex; gap: 9px; margin-top: 16px; flex-wrap: wrap; }
.settings-list { margin: 0; }
.settings-list div { display: grid; grid-template-columns: minmax(120px, 1fr) minmax(0, 1.4fr); align-items: center; gap: 14px; padding: 11px 0; border-bottom: 1px solid rgba(126,196,226,.10); }
.settings-list div:last-child { border-bottom: 0; }
.settings-list dt { color: var(--mist); font-size: 12.5px; }
.settings-list dd { min-width: 0; margin: 0; overflow: hidden; font-family: var(--mono); font-size: 11.5px; text-align: right; text-overflow: ellipsis; white-space: nowrap; }

.empty { padding: 34px 15px; color: var(--mist); text-align: center; }
.empty-mark { display: grid; width: 48px; height: 48px; margin: 0 auto 12px; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: rgba(50,216,255,.05); color: var(--cyan); font-family: var(--mono); font-size: 21px; }
.empty b { display: block; margin-bottom: 4px; color: var(--pearl); font-family: var(--display); font-size: 14px; }
.note { margin-top: 14px; padding: 11px 13px; border: 1px solid rgba(50,216,255,.15); border-left: 3px solid var(--cyan); border-radius: 4px 12px 12px 4px; background: rgba(50,216,255,.065); color: #c9e3f2; font-size: 12.5px; }
.note.warn { border-color: rgba(255,200,87,.16); border-left-color: var(--amber); background: rgba(255,200,87,.07); }
.copy { display: flex; align-items: center; gap: 8px; margin-top: 10px; padding: 8px 9px 8px 12px; border: 1px solid var(--line); border-radius: 11px; background: rgba(2,12,25,.65); }
.copy code { min-width: 0; flex: 1; overflow-x: auto; color: var(--pearl); font-family: var(--mono); font-size: 11.5px; white-space: nowrap; scrollbar-width: thin; }
.clipboard-helper { position: fixed; left: -9999px; top: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* ---------- login / pairing ---------- */
.login { width: min(100% - 28px, 450px); margin: 0 auto; padding: max(9vh, 46px) 0 30px; }
.login .card { padding: 26px; }
.login-brand { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 20px; }
.login .sub { margin: 0 0 20px; text-align: center; }
.login-brand .brand-copy { text-align: left; }

/* ---------- feedback ---------- */
#toast {
  position: fixed;
  z-index: 80;
  left: 50%;
  bottom: calc(78px + env(safe-area-inset-bottom, 0));
  max-width: min(90vw, 460px);
  padding: 11px 17px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: rgba(5,22,40,.95);
  box-shadow: var(--shadow);
  color: var(--pearl);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 16px);
  transition: opacity .2s ease, transform .2s ease;
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}
#toast.on { opacity: 1; transform: translate(-50%, 0); }
#toast.bad { border-color: rgba(255,113,128,.45); }

@media (min-width: 680px) {
  .workspace { padding-inline: 22px; }
  .content { padding-top: 25px; }
  .grid.metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .command-device-row { grid-template-columns: minmax(210px, 1fr) auto; align-items: center; }
  .telegram-layout { grid-template-columns: minmax(0, 1.35fr) minmax(260px, .65fr); align-items: center; padding: 26px; }
  .telegram-hero { padding: 26px; }
}

@media (min-width: 940px) {
  .dashboard-hero { grid-template-columns: minmax(0, 1.35fr) minmax(300px, .65fr); }
}

@media (min-width: 860px) {
  .desktop-sidebar { display: block; width: 88px; }
  .workspace { padding: 0 28px 40px 12px; }
  .content { padding-top: 34px; }
  .mobile-top, .bottom-nav { display: none; }
  .sidebar-panel { padding-inline: 10px; }
  .desktop-sidebar .brand-copy, .side-nav .nav-label, .side-status .status-pill { display: none; }
  .brand-button, .side-nav button { justify-content: center; }
  .side-nav button { padding-inline: 8px; }
  #toast { bottom: 28px; }
}

@media (min-width: 1080px) {
  .dashboard-layout { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }
  .sonar-card { position: sticky; top: 32px; }
  .grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1180px) {
  .desktop-sidebar { width: 248px; padding: 16px 12px; }
  .sidebar-panel { padding: 12px; }
  .desktop-sidebar .brand-copy, .side-nav .nav-label, .side-status .status-pill { display: block; }
  .brand-button, .side-nav button { justify-content: flex-start; }
  .side-status .status-pill { display: inline-flex; width: 100%; justify-content: center; }
  .sidebar-version { text-align: left; padding-inline: 5px; }
}

@media (max-width: 679px) {
  .page-head { align-items: flex-start; flex-direction: column; margin-top: 2px; }
  .page-head .status-pill { align-self: flex-start; }
  .grid.two { grid-template-columns: 1fr; }
  .telegram-facts { grid-template-columns: 1fr; }
  .telegram-fact { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
  .telegram-fact b { margin-top: 0; text-align: right; }
  .lead .head { align-items: flex-start; flex-wrap: wrap; }
  .lead .co { flex-basis: calc(100% - 54px); padding-top: 8px; }
  .lead .head .badge { margin-left: 52px; }
  .lead .need, .lead-meta, .lead-actions { margin-left: 0; }
  .settings-list div { grid-template-columns: 1fr; gap: 3px; }
  .settings-list dd { text-align: left; }
}

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