:root {
  --bg: #f4f8fd;
  --surface: #ffffff;
  --paper: #f8fbff;
  --blue: #2e60a1;
  --blue-dark: #234a7d;
  --blue-soft: #dce8f5;
  --green: #0d6f5e;
  --green-soft: #d9ebe7;
  --orange: #cf5819;
  --orange-dark: #a84614;
  --orange-soft: #f5e6dc;
  --ink: #1a2e44;
  --muted: #5a6d82;
  --line: rgba(46, 96, 161, 0.14);
  --shadow: 0 16px 40px rgba(30, 58, 95, 0.08);
  --radius: 20px;
  --radius-sm: 12px;
  --font: "Raleway", system-ui, sans-serif;
  --bottom-nav-h: 72px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 0%, rgba(46, 96, 161, 0.12), transparent 32%),
    radial-gradient(circle at 92% 8%, rgba(13, 111, 94, 0.1), transparent 28%),
    radial-gradient(circle at 70% 100%, rgba(207, 88, 25, 0.08), transparent 30%),
    var(--bg);
}

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

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
  color: var(--blue-dark);
  text-decoration: none;
  font-weight: 800;
  flex-wrap: wrap;
}

.brand img, .brand-logo {
  width: auto;
  height: 40px;
  max-width: min(100%, 280px);
  display: block;
}

.brand--compact {
  margin-bottom: 0;
  gap: 0;
}

.brand--compact .brand-logo {
  height: 32px;
  max-width: 200px;
}

.brand-product {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.04em;
  line-height: 1.2;
}

.auth-page {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-page::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 18% 22%, rgba(46, 96, 161, 0.18), transparent 24%),
    radial-gradient(circle at 82% 72%, rgba(207, 88, 25, 0.14), transparent 22%);
}

.auth-card {
  position: relative;
  width: min(100%, 480px);
  padding: 34px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.auth-card--paused {
  border-top: 4px solid var(--orange);
}

.stub-icon {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 1.4rem;
  margin-bottom: 16px;
}

.stub-note {
  margin: 0;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.dev-bypass {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px dashed var(--line);
}

.dev-bypass summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.turnstile-wrap { min-height: 65px; margin: 4px 0 8px; }
.captcha-block { margin: 4px 0 8px; }
.captcha-hint { margin-bottom: 8px; color: var(--muted); }
.captcha-error { color: #b33b2f; font-weight: 600; }

.otp-input {
  font-size: 1.35rem;
  letter-spacing: 0.35em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.auth-actions {
  justify-content: space-between;
  margin-top: 4px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }
h1 {
  margin-bottom: 10px;
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  line-height: 1.08;
  letter-spacing: -0.03em;
  color: var(--blue-dark);
}
h2 { margin-bottom: 16px; font-size: 1.12rem; color: var(--blue-dark); }
.muted, .page-head p, .form-hint { color: var(--muted); }

.form-stack,
.form-grid { display: grid; gap: 14px; }
.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .wide { grid-column: 1 / -1; }
.form-section-title { margin: 0 0 10px; font-size: 1rem; }
.checkbox-row { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.checkbox-row input { width: auto; }
.mini-list { margin: 10px 0 0; padding-left: 18px; color: var(--muted); font-size: 0.9rem; }

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

input, select, textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--ink);
  background: var(--paper);
}

textarea { resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(46, 96, 161, 0.28);
  border-color: var(--blue);
}

.input-readonly {
  background: var(--paper);
  color: var(--muted);
  cursor: not-allowed;
}

.btn {
  min-height: 44px;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 0 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.16s ease-out, background 0.16s ease-out, box-shadow 0.16s ease-out;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary {
  background: var(--orange);
  color: #fff;
  box-shadow: 0 10px 24px rgba(207, 88, 25, 0.22);
}
.btn-primary:hover { background: var(--orange-dark); }
.btn-secondary { background: var(--green-soft); color: var(--green); }
.btn-ghost { background: var(--surface); color: var(--muted); border: 1px solid var(--line); }
.btn-sm { min-height: 36px; padding-inline: 12px; font-size: 0.82rem; }

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  padding: 22px 18px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(18px);
}

.sidebar .brand { margin-bottom: 24px; max-width: 100%; }
.sidebar .brand-logo {
  height: 40px;
  width: auto;
  max-width: 100%;
}

.side-nav { display: grid; gap: 6px; }

.side-nav button {
  border: 0;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  font-weight: 700;
  cursor: pointer;
}

.side-nav button:hover,
.side-nav button.active {
  background: var(--blue-soft);
  color: var(--blue-dark);
}

.workspace {
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 64px;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(244, 248, 253, 0.9);
  backdrop-filter: blur(16px);
}

.topbar .brand {
  margin: 0;
}

.topbar .brand img, .topbar .brand-logo { height: 30px; }

.topbar-user strong { display: block; color: var(--blue-dark); }
.topbar-user span { display: block; color: var(--muted); font-size: 0.82rem; }

.topbar-actions { display: flex; gap: 8px; align-items: center; }

.icon-btn {
  position: relative;
  min-width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
}

.icon-btn b {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 20px;
  height: 20px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--orange);
  color: #fff;
  font-size: 0.7rem;
}

.content {
  width: min(100% - 40px, 1100px);
  margin: 0 auto;
  padding: 28px 0 calc(28px + var(--bottom-nav-h));
  flex: 1;
}

.page-head {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: end;
  margin-bottom: 24px;
}

.page-head p { max-width: 58ch; margin-bottom: 0; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric, .panel, .list-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
}

.metric { padding: 20px; display: grid; gap: 6px; }
.metric span, .metric small { color: var(--muted); font-size: 0.82rem; }
.metric strong { font-size: 2rem; letter-spacing: -0.04em; color: var(--blue-dark); }

.panel { padding: 22px; margin-bottom: 18px; }
.action-row { display: flex; flex-wrap: wrap; gap: 10px; }

.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }

.tabs button {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 14px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
}

.tabs button.active {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}

.cards, .list { display: grid; gap: 12px; }
.list-card { padding: 16px; display: grid; gap: 6px; }
.list-card span, .list-card small { color: var(--muted); }
.empty { color: var(--muted); margin: 0; }

.telegram-card p { color: var(--muted); }

.link-code {
  display: inline-flex;
  margin: 8px 0 12px;
  padding: 12px 18px;
  border-radius: 16px;
  background: var(--blue);
  color: #fff;
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: 0.14em;
}

code {
  padding: 3px 7px;
  border-radius: 8px;
  background: var(--blue-soft);
  color: var(--blue-dark);
}

.bell-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 50;
  width: min(100%, 380px);
  height: 100dvh;
  padding: 20px;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: -20px 0 60px rgba(30, 58, 95, 0.14);
  transform: translateX(105%);
  transition: transform 0.28s cubic-bezier(0.23, 1, 0.32, 1);
}

.bell-drawer.open { transform: translateX(0); }

.alert-popup-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(20, 36, 58, 0.45);
  backdrop-filter: blur(4px);
}

.alert-popup {
  width: min(100%, 420px);
  display: grid;
  gap: 12px;
  padding: 22px;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 24px 60px rgba(30, 58, 95, 0.28);
}

.alert-popup-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.alert-popup-head strong {
  font-size: 1.05rem;
  line-height: 1.35;
}

.alert-popup-close {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  font-size: 1.4rem;
  line-height: 1;
}

.alert-popup-body {
  margin: 0;
  color: var(--ink);
  line-height: 1.45;
}

.alert-popup-meta {
  color: var(--muted);
}

.alert-popup .btn-primary {
  margin-top: 4px;
}

.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.list-item {
  width: 100%;
  display: grid;
  gap: 5px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--paper);
  text-align: left;
  cursor: pointer;
}

.list-item.unread {
  border-color: rgba(46, 96, 161, 0.35);
  background: var(--surface);
}

.list-item span, .list-item small { color: var(--muted); }
.inline-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 4px; }
.inline-actions .btn { cursor: pointer; }

.bottom-nav {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  min-height: var(--bottom-nav-h);
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(16px);
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
}

.bottom-nav button {
  border: 0;
  border-radius: 12px;
  padding: 8px 4px;
  background: transparent;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  cursor: pointer;
  display: grid;
  gap: 4px;
  justify-items: center;
}

.bottom-nav button .nav-icon {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 0.95rem;
  background: transparent;
}

.bottom-nav button.active { color: var(--blue-dark); }
.bottom-nav button.active .nav-icon { background: var(--blue-soft); }

.mobile-more {
  position: fixed;
  inset: 0;
  z-index: 45;
  background: rgba(26, 46, 68, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.mobile-more.open {
  opacity: 1;
  pointer-events: auto;
}

.mobile-more-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  border-radius: 20px 20px 0 0;
  background: var(--surface);
  transform: translateY(100%);
  transition: transform 0.24s ease;
}

.mobile-more.open .mobile-more-panel { transform: translateY(0); }

.mobile-more-grid {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.mobile-more-grid button {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
  background: var(--paper);
  text-align: left;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--bottom-nav-h));
  z-index: 100;
  transform: translateX(-50%);
  padding: 12px 16px;
  border-radius: 999px;
  background: var(--blue-dark);
  color: #fff;
  box-shadow: var(--shadow);
  font-weight: 700;
}

.toast.error { background: #b33b2f; }

@media (max-width: 920px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .bottom-nav { display: grid; }
  .topbar { padding-inline: 16px; }
  .content { width: min(100% - 28px, 1100px); }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .content { width: min(100% - 20px, 1100px); padding-top: 20px; }
  .form-grid, .metric-grid { grid-template-columns: 1fr; }
  .page-head { display: block; }
  .auth-card { padding: 24px; }
  .topbar-user span { display: none; }
}

@media (min-width: 921px) {
  .topbar .brand { display: none; }
  .toast { bottom: 24px; }
}

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