:root {
  color-scheme: light;
  --bg: #eef2f7;
  --card-bg: #ffffff;
  --text: #1a1d29;
  --muted: #6b7280;
  --accent: #0f766e;
  --accent-hover: #115e59;
  --border: #e5e7eb;
  --success: #16a34a;
  --telegram: #229ed9;
  --telegram-hover: #1a8bc4;
  --nav-bg: linear-gradient(135deg, #0f766e 0%, #115e59 45%, #134e4a 100%);
  --nav-text: #ecfdf5;
  --nav-muted: rgba(236, 253, 245, 0.78);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body:not(:has(.app-shell)) {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

[dir="rtl"] body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-navbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--nav-bg);
  color: var(--nav-text);
  box-shadow: 0 4px 24px rgba(15, 118, 110, 0.22);
  transition: box-shadow 0.2s ease;
}

.app-navbar.is-scrolled {
  box-shadow: 0 10px 32px rgba(15, 23, 42, 0.16);
}

.app-navbar-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
  font-weight: 700;
  min-width: 0;
}

.nav-brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.18);
  font-size: 12px;
  letter-spacing: 0.06em;
}

.nav-brand-text {
  font-size: 15px;
  white-space: nowrap;
}

.nav-steps {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  justify-content: center;
  min-width: 0;
}

.nav-step {
  font-size: 12px;
  font-weight: 600;
  color: var(--nav-muted);
  padding: 6px 10px;
  border-radius: 999px;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-step.is-active {
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
}

.nav-step.is-complete {
  color: rgba(255, 255, 255, 0.92);
}

.nav-step-sep {
  width: 18px;
  height: 1px;
  background: rgba(255, 255, 255, 0.22);
  flex-shrink: 0;
}

.nav-actions {
  margin-inline-start: auto;
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.nav-link {
  color: var(--nav-text);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.nav-link:hover {
  color: #ffffff;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.app-main {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 32px 20px 48px;
}

.app-navbar .lang-switch-label {
  color: var(--nav-muted);
}

.app-navbar .lang-switch {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.18);
}

.app-navbar .lang-switch button {
  color: var(--nav-muted);
}

.app-navbar .lang-switch button.active {
  background: rgba(255, 255, 255, 0.92);
  color: var(--accent);
}

.nav-btn {
  color: var(--accent);
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(255, 255, 255, 0.22);
}

.public-page,
.legal-page {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 48px 20px;
}

.public-hero {
  max-width: 720px;
  padding: 24px 0 32px;
}

.public-hero h1 {
  font-size: 42px;
  line-height: 1.08;
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.public-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

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

.pricing-hero {
  max-width: 780px;
}

.pricing-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  align-items: stretch;
}

.pricing-card {
  min-height: 410px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 22px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}

.pricing-card-featured {
  border-color: rgba(15, 118, 110, 0.42);
  box-shadow: 0 14px 36px rgba(15, 118, 110, 0.13);
}

.pricing-plan {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 14px;
  font-weight: 800;
  text-transform: uppercase;
}

.pricing-price {
  margin: 0;
  color: var(--text);
  font-size: 38px;
  line-height: 1;
  font-weight: 800;
}

.pricing-price span {
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
}

.pricing-summary {
  min-height: 44px;
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.pricing-features {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
  color: var(--text);
  font-size: 14px;
}

.pricing-features li {
  display: flex;
  gap: 9px;
  line-height: 1.45;
}

.pricing-features li::before {
  content: "";
  width: 8px;
  height: 8px;
  margin-top: 7px;
  border-radius: 50%;
  background: var(--accent);
  flex: 0 0 auto;
}

.pricing-note {
  max-width: 780px;
  margin-top: 18px;
  padding: 22px 24px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.pricing-note h2 {
  margin: 0 0 8px;
  font-size: 18px;
}

.pricing-note p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.public-panel,
.legal-document {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}

.public-panel {
  padding: 22px;
}

.public-panel h2 {
  font-size: 18px;
  margin: 0 0 10px;
}

.public-panel p,
.legal-document p {
  color: var(--muted);
  line-height: 1.65;
}

.legal-document {
  padding: 40px;
  max-width: 820px;
  margin: 0 auto;
}

.legal-document h1 {
  font-size: 34px;
}

.legal-document h2 {
  margin: 30px 0 8px;
  font-size: 20px;
}

.legal-updated {
  margin-top: 0;
}

.public-footer {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 18px;
  padding: 0 20px 32px;
  color: var(--muted);
  font-size: 14px;
}

.public-footer a,
.legal-document a {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.card-links {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 20px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.card-links a {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.htmx-indicator {
  opacity: 0;
  transition: opacity 0.15s ease;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  opacity: 1;
}

.btn-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 40px 40px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  text-align: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.1);
}

.card-wide {
  max-width: 480px;
}

.card-top {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}

[dir="rtl"] .card-top {
  justify-content: flex-start;
}

h1 {
  font-size: 24px;
  margin: 0 0 8px;
}

p.subtitle {
  color: var(--muted);
  margin: 0 0 28px;
  font-size: 15px;
  line-height: 1.5;
}

.section-label {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 0 0 12px;
  text-align: start;
}

.section-hint {
  color: var(--muted);
  font-size: 13px;
  margin: -4px 0 12px;
  line-height: 1.45;
  text-align: start;
}

.form-section {
  margin-bottom: 24px;
}

.login-form {
  display: grid;
  gap: 10px;
  margin: 24px 0 12px;
  text-align: start;
}

.login-form label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.login-form input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  font: inherit;
  color: var(--text);
}

.login-form input:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(15, 118, 110, 0.14);
}

.form-hint {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  margin: 0;
  text-align: center;
}

.turnstile-container {
  min-height: 65px;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  margin: 18px 0;
}

.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 13px 20px;
  border-radius: 10px;
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  background: var(--accent);
  color: white;
  transition: background 0.15s ease, transform 0.1s ease;
}

.btn .btn-spinner {
  display: none;
}

.htmx-request.btn .btn-spinner,
.btn.htmx-request .btn-spinner,
.htmx-request.btn-spinner {
  display: inline-block;
}

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

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

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

.btn-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.btn-google {
  background: white;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-google:hover {
  background: #f9fafb;
}

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

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

.btn-secondary {
  background: white;
  color: var(--text);
  border: 1px solid var(--border);
  margin-top: 10px;
}

.btn-secondary:hover {
  background: #f9fafb;
}

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

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

.lang-switch {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  background: #f9fafb;
}

.lang-switch button {
  border: none;
  background: transparent;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted);
  transition: background 0.15s ease, color 0.15s ease;
}

.lang-switch button:hover {
  color: var(--text);
}

.lang-switch button.active {
  background: white;
  color: var(--accent);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

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

.plan-option {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  cursor: pointer;
  text-align: start;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.plan-option:hover {
  border-color: var(--accent);
}

.plan-option:has(input:checked) {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.plan-option input {
  accent-color: var(--accent);
  flex-shrink: 0;
}

.plan-option .plan-name {
  font-weight: 600;
}

.plan-option .plan-price {
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.plan-option .plan-desc {
  color: var(--muted);
  font-size: 13px;
}

.pricing-disclosure {
  margin-top: 12px;
}

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

.lang-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.lang-option:hover {
  border-color: var(--accent);
}

.lang-option:has(input:checked) {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
  background: #ecfdf5;
}

.lang-option input {
  accent-color: var(--accent);
}

.steps {
  list-style: none;
  padding: 0;
  margin: 0 0 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: start;
}

.steps li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--muted);
}

.steps li::before {
  content: counter(step);
  counter-increment: step;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #ecfdf5;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.steps {
  counter-reset: step;
}

.telegram-actions {
  margin-bottom: 8px;
}

.or-scan {
  font-size: 13px;
  color: var(--muted);
  margin: 16px 0 8px;
}

#qr-container {
  display: flex;
  justify-content: center;
  margin: 8px 0 0;
}

#qr-container canvas,
#qr-container img {
  border-radius: 12px;
  border: 1px solid var(--border);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 16px;
}

.status-badge::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #d1d5db;
}

.status-badge.connected {
  color: var(--success);
}

.status-badge.connected::before {
  background: var(--success);
}

.status-badge.disconnected {
  color: #b91c1c;
}

.status-badge.disconnected::before {
  background: #ef4444;
}

.error {
  color: #dc2626;
  font-size: 14px;
  margin-top: 16px;
}

.success {
  color: var(--success);
  font-size: 14px;
  margin-top: 16px;
}

.compact {
  margin-bottom: 0;
}

.text-start {
  text-align: start;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.dashboard {
  width: min(980px, 100%);
  display: grid;
  gap: 18px;
}

.dashboard-hero,
.dashboard-panel {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}

.dashboard-hero {
  padding: 24px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 18px;
}

.dashboard-panel {
  padding: 22px;
  text-align: start;
}

.dashboard-panel-wide {
  width: 100%;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.panel-heading h2 {
  margin: 0 0 5px;
  font-size: 18px;
}

.panel-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.metric-list {
  display: grid;
  gap: 14px;
  margin: 0;
}

.metric-list div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}

.metric-list div:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.metric-list dt {
  color: var(--muted);
  font-size: 13px;
}

.metric-list dd {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  text-align: end;
}

.count-pill {
  min-width: 34px;
  height: 28px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ecfdf5;
  color: var(--accent);
  font-weight: 800;
  font-size: 13px;
}

.groups-list {
  display: grid;
  gap: 10px;
}

.group-row {
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}

.group-row strong,
.group-row span {
  display: block;
}

.group-row strong {
  font-size: 14px;
}

.group-row span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.group-row .status-badge {
  margin: 0;
}

.empty-state {
  color: var(--muted);
  font-size: 14px;
  margin: 0;
}

.invite-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.compact-actions {
  margin-top: 10px;
}

.btn-inline,
.btn-compact {
  width: auto;
}

.btn-inline {
  min-width: 148px;
}

.btn-compact {
  min-width: 76px;
  padding: 9px 14px;
  font-size: 14px;
}

@media (max-width: 720px) {
  .app-navbar-inner {
    flex-wrap: wrap;
    padding: 12px 16px;
  }

  .nav-steps {
    order: 3;
    width: 100%;
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .nav-brand-text {
    display: none;
  }

  .dashboard-hero,
  .panel-heading,
  .metric-list div,
  .group-row {
    flex-direction: column;
    align-items: stretch;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .public-page,
  .legal-page {
    padding: 32px 16px;
  }

  .public-hero h1,
  .legal-document h1 {
    font-size: 30px;
  }

  .public-grid {
    grid-template-columns: 1fr;
  }

  .pricing-grid {
    grid-template-columns: 1fr;
  }

  .pricing-card {
    min-height: auto;
  }

  .legal-document {
    padding: 28px 22px;
  }

  .metric-list dd {
    text-align: start;
  }

  .btn-inline,
  .btn-compact {
    width: 100%;
  }
}

@media (max-width: 420px) {
  .app-main {
    padding: 20px 12px 32px;
  }

  .card {
    padding: 24px 20px 28px;
  }

  .lang-options {
    grid-template-columns: 1fr;
  }
}
