/* ===== AI Toy Proxy — тёмная тема ===== */

:root {
  color-scheme: dark;

  --bg-0: #0a0a0f;
  --bg-1: #141420;
  --bg-2: #1b1b29;
  --bg-3: #232335;
  --border: #2b2b3d;
  --border-soft: #23233066;

  --text: #ecedf5;
  --text-dim: #9c9cb0;
  --text-faint: #6f6f85;

  --purple: #8b5cf6;
  --purple-strong: #a78bfa;
  --purple-deep: #6d28d9;
  --gray: #7c7c93;
  --orange: #fb923c;
  --orange-strong: #f97316;
  --green: #39ff88;
  --teal: #2dd4bf;
  --danger: #f87171;

  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;

  --shadow-card: 0 12px 30px -14px rgba(0, 0, 0, 0.6);
}

* {
  box-sizing: border-box;
}

html,
body {
  padding: 0;
  margin: 0;
}

body {
  background: var(--bg-0);
  color: var(--text);
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
}

[hidden] {
  display: none !important;
}

code {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 0.85em;
  color: var(--teal);
}

.link-accent {
  color: var(--green);
  font-weight: 600;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s ease;
}

.link-accent:hover {
  border-color: var(--green);
}

/* ===== Бренд ===== */

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: 0.04em;
  color: var(--text);
}

.brand-mark {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  background: linear-gradient(135deg, var(--purple), var(--teal));
  box-shadow: 0 0 14px 1px rgba(139, 92, 246, 0.55);
  flex-shrink: 0;
}

.accent-orange {
  color: var(--orange-strong);
}

/* ===== Экран авторизации ===== */

.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 15% 20%, rgba(139, 92, 246, 0.16), transparent 45%),
    radial-gradient(circle at 85% 80%, rgba(45, 212, 191, 0.12), transparent 45%),
    var(--bg-0);
}

.auth-glow {
  position: absolute;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.35;
  pointer-events: none;
}

.auth-glow--purple {
  background: var(--purple);
  top: -140px;
  left: -120px;
}

.auth-glow--teal {
  background: var(--teal);
  bottom: -160px;
  right: -120px;
}

.auth-card {
  position: relative;
  width: 100%;
  max-width: 400px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  box-shadow: var(--shadow-card);
}

.auth-title {
  margin: 20px 0 4px;
  font-size: 1.5rem;
  font-weight: 700;
}

.auth-subtitle {
  margin: 0 0 20px;
  color: var(--text-dim);
  font-size: 0.9rem;
}

.auth-footnote {
  margin: 18px 0 0;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.9rem;
}

/* ===== Формы ===== */

.form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.input,
input[type="text"],
input[type="email"],
input[type="password"] {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input::placeholder {
  color: var(--text-faint);
}

.input:focus,
input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(57, 255, 136, 0.18);
}

.field-hint {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-faint);
}

.field-error {
  margin: 0;
  font-size: 0.8rem;
  color: var(--danger);
}

/* ===== Кнопки ===== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 11px 20px;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s ease, filter 0.15s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: linear-gradient(135deg, var(--purple), var(--purple-deep));
  color: #fff;
}

.btn-primary:hover {
  filter: brightness(1.1);
}

.btn-accent {
  background: transparent;
  border: 1px solid var(--teal);
  color: var(--teal);
}

.btn-accent:hover {
  background: rgba(45, 212, 191, 0.1);
}

.btn-danger {
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
}

.btn-danger:hover {
  background: rgba(248, 113, 113, 0.1);
}

.form-inline {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

/* ===== Уведомления ===== */

.messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
}

.alert {
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 0.88rem;
  border: 1px solid var(--border);
}

.alert-success {
  border-color: var(--green);
  color: var(--green);
  background: rgba(57, 255, 136, 0.08);
}

.alert-error {
  border-color: var(--danger);
  color: var(--danger);
  background: rgba(248, 113, 113, 0.08);
}

.alert-info,
.alert-warning {
  border-color: var(--orange);
  color: var(--orange);
  background: rgba(251, 146, 60, 0.08);
}

/* ===== Оболочка приложения ===== */

.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand--sidebar {
  padding: 0 6px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.92rem;
  border-left: 3px solid transparent;
  width: 100%;
  background: transparent;
  border-top: none;
  border-right: none;
  border-bottom: none;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.nav-link:hover {
  background: var(--bg-2);
  color: var(--text);
}

.nav-link.active {
  background: var(--bg-2);
  color: var(--text);
  border-left-color: var(--green);
}

.nav-icon {
  width: 18px;
  text-align: center;
  color: var(--purple-strong);
}

.nav-logout {
  margin: 0;
}

.nav-link--logout {
  color: var(--orange-strong);
}

.nav-link--logout .nav-icon {
  color: var(--orange-strong);
}

.nav-link--logout:hover {
  background: rgba(249, 115, 22, 0.1);
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-0);
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 5;
}

.topbar-title {
  font-size: 1.15rem;
  font-weight: 700;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--purple), var(--teal));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
  color: #0a0a0f;
}

.topbar-email {
  color: var(--text-dim);
  font-size: 0.88rem;
}

.content {
  padding: 26px 28px 40px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* ===== Сетка и карточки ===== */

.grid {
  display: grid;
  gap: 18px;
}

.grid-cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

.grid-cols-2 {
  grid-template-columns: repeat(2, 1fr);
}

.card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  border-top: 3px solid var(--border);
  box-shadow: var(--shadow-card);
}

.card--accent-purple {
  border-top-color: var(--purple);
}

.card--accent-teal {
  border-top-color: var(--teal);
}

.card--accent-orange {
  border-top-color: var(--orange-strong);
}

.card-label {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  margin-bottom: 8px;
}

.card-value {
  font-size: 1.15rem;
  font-weight: 700;
  word-break: break-word;
}

.card-sub {
  margin-top: 6px;
  font-size: 0.82rem;
  color: var(--text-dim);
}

.panel {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.panel-header h2 {
  margin: 0;
  font-size: 1rem;
}

.panel-body {
  padding: 20px;
}

.panel-hint {
  margin: 10px 0 0;
  color: var(--text-faint);
  font-size: 0.82rem;
}

.badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-purple {
  background: rgba(139, 92, 246, 0.15);
  color: var(--purple-strong);
}

.badge-teal {
  background: rgba(45, 212, 191, 0.15);
  color: var(--teal);
}

.badge-gray {
  background: rgba(124, 124, 147, 0.18);
  color: var(--text-dim);
}

/* ===== Индикаторы состояния ===== */

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--gray);
}

.dot-green {
  background: var(--green);
  box-shadow: 0 0 8px 1px rgba(57, 255, 136, 0.6);
}

.dot-orange {
  background: var(--orange-strong);
  box-shadow: 0 0 8px 1px rgba(249, 115, 22, 0.5);
}

.dot-danger {
  background: var(--danger);
  box-shadow: 0 0 8px 1px rgba(248, 113, 113, 0.5);
}

/* ===== Устройства ===== */

.code-real-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.code-boxes {
  display: flex;
  gap: 10px;
}

.code-box {
  width: 46px;
  height: 54px;
  padding: 0;
  text-align: center;
  font-size: 1.4rem;
  font-weight: 700;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.code-box:focus {
  border-color: var(--purple-strong);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.18);
}

.code-box--filled,
.code-box--filled:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(57, 255, 136, 0.18);
}

@media (max-width: 420px) {
  .code-box {
    width: 38px;
    height: 46px;
    font-size: 1.2rem;
  }
}

.panel-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.section-hint {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.9rem;
}

.section-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.card--link {
  display: block;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.1s ease;
}

.card--link:hover {
  border-color: var(--green);
  transform: translateY(-2px);
}

.panel--narrow {
  max-width: 480px;
}

.empty-state {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  color: var(--text-dim);
}

.readonly-value {
  background: var(--bg-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text);
  font-size: 0.95rem;
}

.danger-zone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  background: var(--bg-1);
  border: 1px solid rgba(248, 113, 113, 0.35);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}

/* ===== Тарифы ===== */

.tariff-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.tariff-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-top: 3px solid var(--purple);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.tariff-card--inactive {
  border-top-color: var(--border);
  opacity: 0.65;
}

.tariff-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
}

.tariff-card-name {
  font-size: 1.1rem;
  font-weight: 800;
  word-break: break-word;
}

.tariff-card-avatar-wrap {
  width: 100%;
  height: 220px;
  flex-shrink: 0;
  background: var(--bg-2);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.tariff-card-avatar {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.tariff-card-avatar--placeholder {
  font-size: 3.5rem;
  font-weight: 800;
  color: var(--text-faint);
}

.tariff-card-body {
  flex: 1;
  min-width: 0;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: center;
}

.tariff-card-price {
  font-size: 3.2rem;
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: -0.01em;
  background: linear-gradient(135deg, var(--purple-strong), var(--teal));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tariff-card-price-currency {
  font-size: 1.8rem;
  font-weight: 800;
}

.tariff-card-duration {
  color: var(--text-dim);
  font-size: 0.9rem;
}

@media (max-width: 1100px) {
  .tariff-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .tariff-grid {
    grid-template-columns: 1fr;
  }
}

/* ===== Мобильное меню ===== */

.nav-toggle {
  display: none;
  position: fixed;
  top: calc(16px + env(safe-area-inset-top, 0px));
  left: 16px;
  z-index: 20;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  border: 1px solid var(--border);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
}

.nav-toggle span {
  width: 18px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
}

/* ===== Адаптив ===== */

@media (max-width: 900px) {
  .grid-cols-3,
  .grid-cols-2 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 780px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .nav-toggle {
    display: flex;
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 240px;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 15;
    padding-top: calc(22px + env(safe-area-inset-top, 0px));
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 20px 0 40px -20px rgba(0, 0, 0, 0.6);
  }

  .topbar {
    padding-left: 64px;
  }

  .content {
    padding: 20px 16px 32px;
  }
}
