:root {
  color-scheme: dark;
  --bg: #060a0c;
  --bg-deep: #0b1214;
  --surface: rgba(16, 28, 31, 0.88);
  --surface-strong: #111d20;
  --surface-soft: rgba(19, 36, 39, 0.68);
  --surface-hover: rgba(27, 48, 51, 0.82);
  --border: rgba(167, 211, 208, 0.16);
  --border-strong: rgba(53, 230, 161, 0.35);
  --text: #edf8f4;
  --muted: #9bb2af;
  --muted-strong: #c3d0cd;
  --accent: #35e6a1;
  --accent-strong: #20c987;
  --accent-soft: rgba(80, 201, 151, 0.12);
  --cyan: #24c8e5;
  --cyan-soft: rgba(85, 184, 204, 0.11);
  --warning: #f6ce62;
  --warning-soft: rgba(217, 183, 97, 0.11);
  --danger: #ff7d87;
  --danger-soft: rgba(230, 127, 136, 0.1);
  --shadow: 0 20px 58px rgba(2, 8, 10, 0.28);
  --glow: rgba(53, 230, 161, 0.17);
  --grid: rgba(167, 211, 208, 0.055);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-synthesis: none;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4fbf8;
  --bg-deep: #eaf7f3;
  --surface: rgba(255, 255, 255, 0.94);
  --surface-strong: #ffffff;
  --surface-soft: rgba(232, 247, 243, 0.76);
  --surface-hover: rgba(218, 240, 235, 0.88);
  --border: rgba(19, 72, 71, 0.16);
  --border-strong: rgba(6, 185, 130, 0.46);
  --text: #142c2e;
  --muted: #526b6b;
  --muted-strong: #354f4f;
  --accent: #06b982;
  --accent-strong: #03966d;
  --accent-soft: rgba(8, 151, 106, 0.1);
  --cyan: #0898ad;
  --cyan-soft: rgba(7, 140, 171, 0.1);
  --warning: #875d00;
  --warning-soft: rgba(204, 147, 0, 0.1);
  --danger: #c64652;
  --danger-soft: rgba(198, 70, 82, 0.09);
  --shadow: 0 22px 70px rgba(25, 78, 75, 0.12);
  --glow: rgba(6, 185, 130, 0.16);
  --grid: rgba(19, 72, 71, 0.065);
}

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

html {
  min-height: 100%;
  background: var(--bg-deep);
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  min-width: 280px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(800px 540px at 88% -8%, var(--glow), transparent 68%),
    radial-gradient(620px 460px at -12% 52%, rgba(85, 184, 204, 0.055), transparent 70%),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

body::before {
  position: fixed;
  z-index: 0;
  inset: 0;
  pointer-events: none;
  content: '';
  opacity: 0.8;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 42px 42px;
  -webkit-mask-image: linear-gradient(to bottom, black, transparent 85%);
  mask-image: linear-gradient(to bottom, black, transparent 85%);
}

button,
input,
textarea {
  color: inherit;
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

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

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.is-hidden,
.app-view.is-hidden,
.context-screen.is-hidden {
  display: none !important;
}

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

.app-shell {
  position: relative;
  z-index: 1;
  width: min(100%, 720px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding-bottom: calc(92px + var(--safe-bottom));
  transition: opacity 180ms ease;
}

.app-shell.is-loading {
  opacity: 0;
}

.app-header {
  position: sticky;
  z-index: 50;
  top: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: calc(64px + var(--safe-top));
  padding: calc(9px + var(--safe-top)) max(14px, var(--safe-right)) 9px max(14px, var(--safe-left));
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-deep) 82%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(130%);
  backdrop-filter: blur(18px) saturate(130%);
}

.brand-mark,
.hero-icon,
.context-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border-strong);
  border-radius: 13px;
  background: linear-gradient(145deg, var(--accent-soft), var(--cyan-soft));
  color: var(--accent);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.08);
}

.brand-mark svg,
.hero-icon svg,
.context-icon svg {
  width: 21px;
  height: 21px;
}

.header-copy {
  min-width: 0;
}

.header-copy span {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-copy strong {
  display: block;
  overflow: hidden;
  margin-top: 2px;
  font-size: 17px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-chip {
  display: flex;
  gap: 9px;
  align-items: center;
  min-width: 0;
  max-width: 166px;
  padding: 6px 8px 6px 6px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: var(--surface-soft);
  text-align: left;
}

.user-avatar {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 34px;
  height: 34px;
  overflow: hidden;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--accent), var(--cyan));
  color: #03221a;
  font-size: 12px;
  font-weight: 800;
}

.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-copy {
  min-width: 0;
}

.user-copy strong,
.user-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-copy strong {
  font-size: 12px;
}

.user-copy small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
}

.app-main {
  padding: 14px max(14px, var(--safe-right)) 28px max(14px, var(--safe-left));
}

.app-view {
  display: grid;
  gap: 13px;
  animation: view-in 180ms ease both;
}

@keyframes view-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.card {
  position: relative;
  overflow: hidden;
  padding: 17px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--surface-strong) 90%, transparent), var(--surface)),
    var(--surface);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.045);
}

.card::after {
  position: absolute;
  z-index: 0;
  inset: 0;
  background: linear-gradient(120deg, rgba(255, 255, 255, 0.045), transparent 28%, transparent 70%, var(--glow));
  opacity: 0.5;
  content: "";
  pointer-events: none;
}

.card > * {
  position: relative;
  z-index: 1;
}

.compact-card {
  padding: 16px;
}

.hero-card {
  border-color: var(--border-strong);
  background:
    radial-gradient(circle at 92% 10%, var(--accent-soft), transparent 47%),
    linear-gradient(150deg, var(--surface-strong), var(--surface));
}

.card-heading {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 15px;
}

.card-heading > div:first-child {
  min-width: 0;
}

.eyebrow {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  line-height: 1.25;
  text-transform: uppercase;
}

.card h3 {
  margin: 0;
  font-size: 17px;
  line-height: 1.28;
}

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

.title-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
}

.status-badge.is-inactive,
.status-badge.is-error {
  background: var(--danger-soft);
  color: var(--danger);
}

.status-badge.is-checking {
  background: var(--surface-soft);
  color: var(--muted);
}

.hero-icon {
  width: 42px;
  height: 42px;
  border: 0;
}

.heading-icon {
  flex: 0 0 auto;
  width: 21px;
  height: 21px;
  color: var(--accent);
}

.traffic-block {
  margin-top: 14px;
}

.traffic-head,
.traffic-foot {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 11px;
}

.traffic-head strong {
  color: var(--muted-strong);
  font-weight: 700;
}

.progress-track {
  height: 7px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-hover);
}

.progress-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  transition: width 450ms cubic-bezier(.2,.8,.2,1);
}

.progress-fill.main {
  background: linear-gradient(90deg, var(--cyan), var(--accent));
}

.progress-fill.whitelist {
  background: linear-gradient(90deg, #7ca8ff, var(--cyan));
}

.whitelist-block {
  padding: 12px;
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}

.traffic-foot {
  margin-top: 8px;
  font-size: 9px;
}

.traffic-foot strong {
  color: inherit;
}

.subscription-stats,
.referral-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 16px;
}

.subscription-stats > div,
.referral-stats > div {
  min-width: 0;
  padding: 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}

.subscription-stats span,
.subscription-stats strong,
.referral-stats span,
.referral-stats strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.subscription-stats span,
.referral-stats span {
  color: var(--muted);
  font-size: 9px;
}

.subscription-stats strong,
.referral-stats strong {
  margin-top: 5px;
  font-size: 12px;
}

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

.action-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin-top: 14px;
}

.primary-button,
.secondary-button,
.danger-link,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 800;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

.primary-button:active,
.secondary-button:active,
.icon-button:active,
.quick-grid button:active,
.bottom-nav button:active {
  transform: scale(0.98);
}

.primary-button {
  gap: 7px;
  padding: 0 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #03241a;
  box-shadow: 0 10px 22px rgba(22, 193, 132, 0.16);
}

:root[data-theme="light"] .primary-button {
  color: #fff;
}

.secondary-button {
  gap: 7px;
  padding: 0 14px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text);
}

.primary-button svg,
.secondary-button svg {
  width: 16px;
  height: 16px;
}

.full-width {
  width: 100%;
}

.danger-link {
  width: 100%;
  margin-top: 9px;
  padding: 0 12px;
  background: var(--warning-soft);
  color: var(--warning);
}

.warning-note,
.info-note,
.success-note {
  margin-top: 10px;
  padding: 11px 12px;
  border: 1px solid color-mix(in srgb, var(--warning) 30%, var(--border));
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--warning) 8%, var(--surface));
  color: color-mix(in srgb, var(--warning) 68%, var(--text));
  font-size: 11px;
  line-height: 1.45;
}

.info-note {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  border-color: color-mix(in srgb, var(--cyan) 29%, var(--border));
  background: color-mix(in srgb, var(--cyan) 7%, var(--surface));
  color: var(--muted-strong);
}

.info-note svg {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  color: var(--cyan);
}

.success-note {
  border-color: color-mix(in srgb, var(--accent) 30%, var(--border));
  background: color-mix(in srgb, var(--accent) 7%, var(--surface));
  color: color-mix(in srgb, var(--accent) 72%, var(--text));
}

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

.quick-grid button {
  display: flex;
  flex-direction: column;
  gap: 7px;
  align-items: center;
  justify-content: flex-start;
  min-width: 0;
  min-height: 85px;
  padding: 10px 5px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: linear-gradient(145deg, var(--surface-soft), transparent);
  color: var(--muted-strong);
  font-size: 9px;
  font-weight: 700;
}

.quick-grid button span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: var(--accent-soft);
  color: var(--accent);
}

.quick-grid svg {
  width: 17px;
  height: 17px;
}

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

.product-summary-item {
  display: grid;
  gap: 5px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: linear-gradient(145deg, var(--surface-soft), transparent);
}

.product-summary-item strong {
  font-size: 12px;
}

.product-summary-item span {
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
}

.product-summary-item small {
  color: var(--muted);
  font-size: 9px;
  line-height: 1.4;
}

.segmented {
  display: inline-flex;
  flex: 0 0 auto;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-soft);
}

.segmented button {
  min-width: 40px;
  min-height: 30px;
  padding: 4px 9px;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.segmented button.is-active {
  background: var(--surface-strong);
  color: var(--accent);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.segmented.small button {
  min-width: 36px;
  min-height: 28px;
  padding: 3px 7px;
}

.loading-state,
.empty-state,
.error-state {
  display: grid;
  min-height: 94px;
  place-items: center;
  padding: 16px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
}

.error-state {
  border-color: color-mix(in srgb, var(--danger) 32%, var(--border));
  background: color-mix(in srgb, var(--danger) 7%, var(--surface));
  color: color-mix(in srgb, var(--danger) 76%, var(--text));
}

.traffic-chart {
  min-height: 190px;
}

.chart-wrap {
  display: grid;
  gap: 10px;
}

.chart-svg {
  display: block;
  width: 100%;
  height: 150px;
  overflow: visible;
}

.chart-grid-line {
  stroke: var(--border);
  stroke-width: 1;
}

.chart-main-line,
.chart-whitelist-line {
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.chart-main-line { stroke: var(--accent); }
.chart-whitelist-line { stroke: var(--cyan); }
.chart-area { fill: url(#chartMainGradient); }

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 9px 14px;
  color: var(--muted);
  font-size: 10px;
}

.chart-legend span {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.chart-legend i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.chart-legend i.whitelist { background: var(--cyan); }

.step-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
  padding: 0;
  margin: 0 0 13px;
  list-style: none;
}

.step-list li {
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-width: 0;
  min-height: 98px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: linear-gradient(145deg, var(--surface-soft), transparent);
}

.step-list strong {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
}

.step-list span {
  margin-top: auto;
  color: var(--muted-strong);
  font-size: 9px;
  line-height: 1.35;
}

.platform-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-top: 14px;
}

.platform-tabs button,
.support-topics button,
.legal-links button {
  min-height: 38px;
  padding: 7px 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.platform-tabs button.is-active {
  border-color: var(--border-strong);
  background: var(--accent-soft);
  color: var(--accent);
}

.guide-body {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.guide-header {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.guide-header strong {
  font-size: 13px;
}

.guide-steps {
  display: grid;
  gap: 7px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.guide-steps li {
  position: relative;
  padding: 11px 11px 11px 37px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: linear-gradient(145deg, var(--surface-soft), transparent);
  color: var(--muted-strong);
  font-size: 11px;
  line-height: 1.45;
}

.guide-steps li::before {
  position: absolute;
  top: 10px;
  left: 10px;
  display: grid;
  width: 19px;
  height: 19px;
  place-items: center;
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--accent);
  content: counter(list-item);
  font-size: 9px;
  font-weight: 800;
}

.icon-button {
  flex: 0 0 auto;
  width: 40px;
  min-height: 40px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--muted-strong);
}

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

.icon-button.is-spinning svg {
  animation: spin 750ms linear infinite;
}

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

.connection-list,
.server-list,
.event-list,
.payment-list {
  display: grid;
  gap: 8px;
}

.connections-heading {
  align-items: flex-start;
}

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

.connection-profile-state {
  display: flex;
  gap: 7px;
  align-items: center;
  margin-top: 8px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
}

.connection-profile-state .status-dot {
  display: inline-block;
  flex: 0 0 auto;
}

.connection-profile-state.is-online { color: var(--accent); }
.connection-profile-state.is-stale { color: var(--warning); }

.capacity-ring {
  --capacity: 0deg;
  position: relative;
  display: grid;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--accent) var(--capacity), var(--surface-soft) 0);
}

.capacity-ring::before {
  position: absolute;
  border: 1px solid var(--border);
  border-radius: inherit;
  background: var(--surface-strong);
  content: "";
  inset: 5px;
}

.capacity-ring span {
  position: relative;
  z-index: 1;
  color: var(--text);
  font-size: 9px;
  font-weight: 900;
}

.capacity-ring.is-warning {
  background: conic-gradient(var(--warning) var(--capacity), var(--surface-soft) 0);
}

.connection-limit-notice {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 11px;
  margin-top: 10px;
  border: 1px solid color-mix(in srgb, var(--warning) 30%, var(--border));
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--warning) 8%, var(--surface));
}

.connection-limit-notice strong,
.connection-limit-notice span {
  display: block;
}

.connection-limit-notice strong {
  color: var(--warning);
  font-size: 11px;
}

.connection-limit-notice span {
  margin-top: 3px;
  color: var(--muted-strong);
  font-size: 9px;
  line-height: 1.4;
}

.connection-limit-notice.is-full {
  border-color: color-mix(in srgb, var(--danger) 34%, var(--border));
  background: color-mix(in srgb, var(--danger) 8%, var(--surface));
}

.connection-limit-notice.is-full strong { color: var(--danger); }

.connection-limit-notice .secondary-button {
  min-height: 36px;
  padding: 0 10px;
  white-space: nowrap;
}

.connection-item,
.server-item,
.event-item,
.payment-item {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: linear-gradient(145deg, var(--surface-soft), transparent);
}

.connection-item {
  gap: 10px;
}

.connection-identity {
  min-width: 0;
}

.connection-identity strong,
.connection-identity span,
.connection-platform {
  display: block;
}

.connection-identity strong {
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.connection-identity span,
.connection-platform {
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
}

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

.connection-dates div {
  min-width: 0;
  padding: 8px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface-strong) 62%, transparent);
}

.connection-dates span,
.connection-dates strong {
  display: block;
}

.connection-dates span {
  color: var(--muted);
  font-size: 8px;
}

.connection-dates strong {
  margin-top: 3px;
  color: var(--muted-strong);
  font-size: 9px;
}

.connection-preferences {
  padding-top: 9px;
  border-top: 1px solid var(--border);
}

.connection-preferences-summary {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

.trusted-source {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  color: var(--muted);
  font-size: 8px;
}

.trusted-source::before {
  width: 5px;
  height: 5px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--muted);
  content: "";
  opacity: 0.65;
}

.trusted-source.is-trusted { color: var(--accent); }
.trusted-source.is-trusted::before { background: var(--accent); opacity: 1; }

.connection-edit-button {
  display: inline-flex;
  min-height: 28px;
  padding: 0 10px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--surface-soft);
  color: var(--muted-strong);
  box-shadow: none;
  font-size: 8px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  transition: border-color 120ms ease, background 120ms ease, color 120ms ease, transform 120ms ease;
}

.connection-edit-button:active {
  border-color: var(--border-strong);
  background: var(--accent-soft);
  color: var(--accent);
  transform: scale(0.97);
}

.connection-edit-button:hover {
  border-color: var(--border-strong);
  background: var(--accent-soft);
  color: var(--accent);
}

.connection-preferences-editor {
  display: grid;
  gap: 8px;
  margin-top: 9px;
}

.connection-preferences-editor input[type="text"] {
  width: 100%;
  min-width: 0;
  padding: 10px 11px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-strong);
  color: var(--text);
  font-size: 10px;
  outline: none;
}

.connection-trust-toggle {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--muted-strong);
  font-size: 9px;
}

.connection-preferences-editor .secondary-button {
  min-height: 36px;
}

.connection-title,
.server-title,
.payment-title,
.connection-meta,
.server-meta,
.payment-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

.connection-title strong,
.server-title strong,
.payment-title strong {
  min-width: 0;
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.connection-meta,
.server-meta,
.payment-meta {
  color: var(--muted);
  font-size: 9px;
}

.online-label,
.payment-status {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  color: var(--accent);
  font-size: 9px;
  font-weight: 700;
  white-space: nowrap;
}

.online-label::before,
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 9px color-mix(in srgb, var(--accent) 65%, transparent);
  content: "";
}

.online-label.offline,
.payment-status.failed,
.payment-status.cancelled { color: var(--danger); }
.online-label.offline::before { background: var(--danger); }
.online-label.checking,
.payment-status.pending { color: var(--warning); }
.online-label.checking::before { background: var(--warning); }

.connection-state {
  flex: 0 0 auto;
  padding: 5px 7px;
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 8px;
  font-weight: 800;
  white-space: nowrap;
}

.connection-state.recent { background: var(--accent-soft); color: var(--accent); }
.connection-state.stale,
.connection-state.checking { background: var(--warning-soft); color: var(--warning); }

.status-dot.online { background: var(--accent); }
.status-dot.idle { background: var(--muted); box-shadow: none; }

.server-summary {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--accent-soft);
}

.server-summary > span {
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.server-summary > span strong {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.server-summary > div {
  flex: 0 0 auto;
  text-align: right;
}

.server-summary > div strong,
.server-summary > div small {
  display: block;
}

.server-summary > div strong {
  color: var(--accent);
  font-size: 17px;
}

.server-summary > div small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 8px;
  text-transform: uppercase;
}

.status-dot {
  display: inline-block;
  flex: 0 0 auto;
}

.status-dot.checking { background: var(--warning); }
.status-dot.error { background: var(--danger); }

.server-group {
  margin-top: 16px;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: linear-gradient(145deg, var(--surface-soft), transparent);
}

.group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.group-title.whitelist-title { color: var(--cyan); }
.group-title small { color: var(--muted); font-size: 9px; }

.event-item {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: flex-start;
}

.event-dot {
  width: 9px;
  height: 9px;
  margin-top: 4px;
  border-radius: 50%;
  background: var(--warning);
}

.event-dot.resolved { background: var(--accent); }
.event-copy { min-width: 0; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.event-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.event-head strong { min-width: 0; font-size: 11px; }
.event-status { flex: 0 0 auto; color: var(--accent); font-size: 9px; font-weight: 800; }
.event-copy p { margin: 4px 0 0; color: var(--muted); font-size: 10px; line-height: 1.45; }
.event-copy time { display: block; margin-top: 5px; color: var(--muted); font-size: 9px; line-height: 1.4; }

.card-footnote,
.field-hint {
  min-height: 16px;
  color: var(--muted) !important;
  font-size: 10px !important;
}

.field {
  display: grid;
  gap: 7px;
  margin-top: 12px;
}

.field > span:first-child {
  color: var(--muted-strong);
  font-size: 10px;
  font-weight: 700;
}

.field small {
  color: var(--muted);
  font-weight: 500;
}

.field input,
.field textarea,
.field-with-unit {
  width: 100%;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}

.field input,
.field textarea {
  padding: 12px 13px;
  outline: none;
  color: var(--text);
  font-size: 12px;
}

.field textarea {
  min-height: 110px;
  resize: vertical;
  line-height: 1.5;
}

.field input::placeholder,
.field textarea::placeholder { color: var(--muted); opacity: 0.75; }

.field input:focus,
.field textarea:focus,
.field-with-unit:focus-within {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field-with-unit {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  min-width: 0;
  align-items: center;
  overflow: hidden;
}

.field-with-unit input {
  min-width: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none !important;
}

.field-with-unit em {
  padding: 0 13px 0 6px;
  color: var(--muted);
  font-size: 10px;
  font-style: normal;
}

.tariff-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.tariff-button {
  position: relative;
  min-height: 82px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: linear-gradient(145deg, var(--surface-soft), transparent);
  text-align: left;
}

.tariff-button strong,
.tariff-button span { display: block; }
.tariff-button strong { font-size: 12px; }
.tariff-button span { margin-top: 6px; color: var(--muted-strong); font-size: 12px; }
.tariff-button small { display: block; margin-top: 4px; color: var(--muted); font-size: 8px; }
.tariff-button.is-featured { border-color: var(--border-strong); background: var(--accent-soft); }
.tariff-button.is-featured::after { position: absolute; top: 7px; right: 7px; color: var(--accent); content: "выгодно"; font-size: 7px; font-weight: 800; text-transform: uppercase; }

.divider {
  height: 1px;
  margin: 18px 0;
  background: var(--border);
}

.topup-choice {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.topup-choice button {
  min-width: 0;
  min-height: 70px;
  padding: 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: linear-gradient(145deg, var(--surface-soft), transparent);
  color: var(--muted-strong);
  text-align: left;
  overflow-wrap: anywhere;
}

.topup-choice button.is-active {
  border-color: var(--border-strong);
  background: var(--accent-soft);
  color: var(--text);
}

.topup-choice strong,
.topup-choice span { display: block; }
.topup-choice strong { font-size: 11px; }
.topup-choice span { margin-top: 5px; color: var(--muted); font-size: 9px; }

.topup-entry {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.topup-entry .field {
  min-width: 0;
  margin-top: 0;
}

.topup-entry .field-with-unit,
.topup-entry .field-with-unit input {
  min-width: 0;
}

.payment-status {
  padding: 4px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
}

.payment-status.pending { background: var(--warning-soft); }
.payment-status.failed,
.payment-status.cancelled { background: var(--danger-soft); }

.form-stack { display: grid; gap: 2px; }

#webappEmailLinkedBlock {
  display: grid;
  gap: 7px;
}

#webappEmailLinkedBlock .connection-edit-button {
  justify-self: start;
}

.account-profile-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.account-profile-head h3 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-profile-avatar {
  display: grid;
  width: 52px;
  height: 52px;
  overflow: hidden;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 15px;
  font-weight: 900;
}

.account-profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.account-status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin-top: 14px;
}

.account-status-grid > div {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: linear-gradient(145deg, var(--surface-soft), transparent);
}

.account-status-grid span,
.account-status-grid strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-status-grid span { color: var(--muted); font-size: 8px; }
.account-status-grid strong { margin-top: 4px; color: var(--muted-strong); font-size: 9px; }

.account-details {
  padding-top: 10px;
  margin-top: 10px;
  border-top: 1px solid var(--border);
}

.account-details summary {
  cursor: pointer;
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
}

.account-details-body { margin-top: 5px; }

.security-badge {
  flex: 0 0 auto;
  padding: 6px 8px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 8px;
  font-weight: 800;
}

.security-badge.is-enabled {
  background: var(--accent-soft);
  color: var(--accent);
}

.two-factor-enrollment {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.two-factor-enrollment > strong { color: var(--text); font-size: 11px; }
.two-factor-enrollment > p { color: var(--muted); font-size: 9px; line-height: 1.45; }

.two-factor-qr {
  width: min(100%, 220px);
  padding: 10px;
  margin: 0 auto;
  border-radius: 18px;
  background: #fff;
}

.two-factor-qr img {
  display: block;
  width: 100%;
  height: auto;
}

.two-factor-secret {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.two-factor-secret code {
  min-width: 0;
  overflow: hidden;
  padding: 11px;
  border-radius: 11px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.two-factor-secret .secondary-button {
  min-height: 38px;
  padding: 0 10px;
}

.one-time-code {
  text-align: center;
  font-size: 16px !important;
  font-weight: 800;
  letter-spacing: 0.28em;
}

.session-list {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

.session-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  padding: 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: linear-gradient(145deg, var(--surface-soft), transparent);
}

.session-icon {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
}

.session-icon svg { width: 15px; height: 15px; }
.session-copy { min-width: 0; }
.session-copy strong,
.session-copy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-copy strong { color: var(--text); font-size: 10px; }
.session-copy span { margin-top: 3px; color: var(--muted); font-size: 8px; }
.session-method { color: var(--muted-strong); font-size: 8px; font-weight: 700; }

.support-topics,
.legal-links {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 12px;
}

.support-topics button.is-active {
  border-color: var(--border-strong);
  background: var(--accent-soft);
  color: var(--accent);
}

.legal-links button {
  min-height: 36px;
}

.bottom-nav {
  position: fixed;
  z-index: 80;
  right: max(8px, var(--safe-right));
  bottom: max(8px, var(--safe-bottom));
  left: max(8px, var(--safe-left));
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 2px;
  width: min(calc(100% - 16px), 704px);
  min-height: 64px;
  padding: 6px;
  margin: 0 auto;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: color-mix(in srgb, var(--surface-strong) 91%, transparent);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.32);
  -webkit-backdrop-filter: blur(20px) saturate(145%);
  backdrop-filter: blur(20px) saturate(145%);
}

.bottom-nav button {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 6px 2px;
  border-radius: 16px;
  background: transparent;
  color: var(--muted);
  font-size: 8px;
  font-weight: 700;
}

.bottom-nav button svg {
  width: 19px;
  height: 19px;
}

.bottom-nav button.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}

.modal-overlay,
.context-screen {
  position: fixed;
  z-index: 200;
  inset: 0;
  display: grid;
  place-items: end center;
  padding: max(14px, var(--safe-top)) max(14px, var(--safe-right)) max(14px, var(--safe-bottom)) max(14px, var(--safe-left));
  background: rgba(0, 7, 6, 0.72);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.modal-panel,
.context-card {
  width: min(100%, 600px);
  max-height: min(88vh, 760px);
  max-height: min(88dvh, 760px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 26px 26px 18px 18px;
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.context-screen { place-items: center; }

.context-card {
  padding: 24px;
  text-align: center;
}

.context-card .context-icon { margin: 0 auto 14px; }
.context-card h1 { margin: 0; font-size: 21px; }
.context-card p:not(.eyebrow) { margin: 9px 0 18px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.context-card .primary-button { width: 100%; }

.modal-heading {
  position: sticky;
  z-index: 2;
  top: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 11px;
  align-items: center;
  padding: 13px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-strong);
}

.modal-heading strong,
.modal-heading span { display: block; }
.modal-heading strong { font-size: 14px; }
.modal-heading span { margin-top: 2px; color: var(--muted); font-size: 9px; }

.legal-body {
  padding: 18px;
  color: var(--muted-strong);
  font-size: 12px;
  line-height: 1.6;
}

.legal-body h1,
.legal-body h2,
.legal-body h3 { color: var(--text); }
.legal-body a { color: var(--accent); }

.toast {
  position: fixed;
  z-index: 300;
  right: 18px;
  bottom: calc(88px + var(--safe-bottom));
  left: 18px;
  width: max-content;
  max-width: calc(100% - 36px);
  padding: 11px 15px;
  margin: auto;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 9%, var(--surface-strong));
  color: color-mix(in srgb, var(--accent) 70%, var(--text));
  box-shadow: var(--shadow);
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  animation: toast-in 180ms ease both;
}

.toast.is-error {
  border-color: color-mix(in srgb, var(--danger) 40%, transparent);
  background: color-mix(in srgb, var(--danger) 9%, var(--surface-strong));
  color: color-mix(in srgb, var(--danger) 76%, var(--text));
}

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

@media (max-width: 420px) {
  .user-copy { display: none; }
  .user-chip { padding-right: 6px; }
  .quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quick-grid button { min-height: 76px; }
  .step-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .step-list li { min-height: 82px; }
  .bottom-nav button span { font-size: 7.5px; }
  .topup-choice { grid-template-columns: 1fr; }
  .connection-limit-notice { grid-template-columns: 1fr; }
  .connection-limit-notice .secondary-button { width: 100%; }
  .connection-dates { grid-template-columns: 1fr; }
  .two-factor-secret { grid-template-columns: 1fr; }
  .two-factor-secret .secondary-button { width: 100%; }
}

@media (min-width: 620px) {
  .app-main { padding-top: 18px; }
  .app-view { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .app-view > .card { grid-column: 1 / -1; }
  .app-view[data-view="overview"] > .hero-card,
  .app-view[data-view="overview"] > .compact-card { grid-column: auto; }
  .hero-card,
  .compact-card { min-height: 100%; }
}

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