:root {
  --font-body: 'Manrope', sans-serif;
  --font-display: 'Oswald', sans-serif;
  --color-bg: #050b16;
  --color-bg-2: #0b1629;
  --color-surface: rgba(13, 24, 43, 0.82);
  --color-surface-strong: rgba(17, 33, 60, 0.92);
  --color-surface-bright: rgba(24, 46, 82, 0.9);
  --color-border: rgba(120, 150, 190, 0.22);
  --color-border-strong: rgba(160, 190, 230, 0.38);
  --color-text: #eef3ff;
  --color-muted: #9fb0cd;
  --color-gold: #d7b86a;
  --color-gold-strong: #f2d28a;
  --color-ice: #5ad5ff;
  --color-accent: #8bd45c;
  --color-accent-strong: #b9f276;
  --color-danger: #ff8d96;
  --shadow-card: 0 24px 60px rgba(4, 10, 20, 0.55);
  --radius-xl: 30px;
  --radius-l: 22px;
  --radius-m: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--color-text);
  background:
    radial-gradient(circle at 15% 20%, rgba(90, 160, 255, 0.12), transparent 55%),
    radial-gradient(circle at 85% 15%, rgba(215, 184, 106, 0.12), transparent 50%),
    linear-gradient(180deg, #050b16 0%, #0a162c 40%, #0b1629 100%);
  min-height: 100vh;
}

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

button,
input,
select {
  font: inherit;
}

.hidden {
  display: none !important;
}

.page-shell {
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

.backdrop {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.backdrop-grid {
  position: absolute;
  inset: 0;
  background-image: linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 140px 140px;
  opacity: 0.15;
}

.backdrop-glow {
  position: absolute;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  filter: blur(18px);
  opacity: 0.2;
}

.backdrop-glow-left {
  left: -120px;
  top: 60px;
  background: rgba(90, 213, 255, 0.3);
}

.backdrop-glow-right {
  right: -100px;
  top: 120px;
  background: rgba(215, 184, 106, 0.24);
}

.backdrop-mountains {
  position: absolute;
  left: -10%;
  right: -10%;
  bottom: -80px;
  height: 340px;
  background: linear-gradient(180deg, rgba(6, 12, 22, 0) 0%, rgba(6, 12, 22, 0.7) 45%, #020409 100%);
  clip-path: polygon(0 70%, 10% 54%, 22% 64%, 34% 42%, 48% 60%, 58% 38%, 72% 58%, 84% 35%, 100% 50%, 100% 100%, 0 100%);
  opacity: 0.9;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 6vw;
  background: rgba(5, 11, 22, 0.72);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(120, 150, 190, 0.2);
}

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

.brand strong {
  font-family: var(--font-display);
  font-size: 30px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
}

.brand-kicker,
.eyebrow {
  color: var(--color-gold-strong);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.22em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-content {
  position: relative;
  z-index: 1;
  padding: 34px 6vw 64px;
}

.hero-card,
.panel,
.stat-card {
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(18px);
}

.hero-card {
  border-radius: var(--radius-xl);
  padding: 30px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 26px;
  background:
    radial-gradient(circle at 85% 20%, rgba(90, 213, 255, 0.1), transparent 40%),
    linear-gradient(140deg, rgba(11, 22, 42, 0.85) 0%, rgba(17, 34, 64, 0.85) 100%);
}

.hero-card h1,
.panel h2,
.detail-head h3 {
  margin: 0;
  font-family: var(--font-display);
  letter-spacing: 0.03em;
}

.hero-card h1 {
  font-size: clamp(30px, 4vw, 52px);
}

.subtitle {
  color: var(--color-muted);
  line-height: 1.6;
  max-width: 720px;
}

.subtitle.compact {
  margin-top: 8px;
}

.hero-badge {
  border-radius: 999px;
  padding: 10px 16px;
  background: rgba(90, 213, 255, 0.16);
  color: var(--color-ice);
  font-weight: 700;
  white-space: nowrap;
}

.panel {
  border-radius: var(--radius-l);
  padding: 24px;
}

.auth-panel {
  max-width: 560px;
}

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

.panel-heading-inline {
  align-items: center;
}

.panel-copy {
  color: var(--color-muted);
  margin-top: 0;
  line-height: 1.6;
}

.telegram-login-box {
  min-height: 56px;
}

.stats-grid,
.admin-grid,
.bottom-grid {
  display: grid;
  gap: 20px;
}

.stats-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  margin-bottom: 20px;
}

.admin-grid {
  grid-template-columns: minmax(0, 1.5fr) minmax(360px, 0.9fr);
  margin-bottom: 20px;
}

.bottom-grid {
  grid-template-columns: minmax(280px, 0.85fr) minmax(0, 1.15fr);
}

.stat-card {
  border-radius: var(--radius-m);
  padding: 18px 20px;
}

.stat-card span {
  color: var(--color-muted);
  display: block;
  margin-bottom: 10px;
}

.stat-card strong {
  font-size: 30px;
}

.header-button {
  border: 1px solid rgba(90, 213, 255, 0.25);
  background: linear-gradient(120deg, var(--color-ice), #6fb6ff);
  color: #071225;
  border-radius: 999px;
  padding: 11px 18px;
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.2s ease, filter 0.2s ease, border-color 0.2s ease;
}

.header-button:hover {
  transform: translateY(-1px);
  filter: brightness(1.04);
}

.header-button:disabled {
  opacity: 0.65;
  cursor: wait;
}

.header-button-muted {
  background: rgba(10, 20, 36, 0.8);
  color: var(--color-text);
  border-color: var(--color-border);
}

.header-button-danger {
  background: rgba(120, 20, 30, 0.82);
  border-color: rgba(242, 143, 143, 0.35);
  color: #ffe6e8;
}

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

.filters,
.inline-form,
.detail-actions {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.detail-actions {
  margin-bottom: 20px;
}

.filters {
  margin-bottom: 18px;
}

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

.field span {
  color: var(--color-muted);
  font-size: 13px;
}

.field input,
.field select {
  border-radius: 14px;
  border: 1px solid var(--color-border);
  background: linear-gradient(145deg, rgba(9, 18, 34, 0.85), rgba(7, 15, 30, 0.85));
  color: var(--color-text);
  padding: 13px 15px;
  outline: none;
}

.field-compact {
  max-width: 220px;
}

.users-table-wrap {
  overflow: auto;
  border-radius: 16px;
  border: 1px solid rgba(120, 150, 190, 0.16);
}

.users-table {
  width: 100%;
  border-collapse: collapse;
}

.users-table th,
.users-table td {
  padding: 16px;
  text-align: left;
  border-bottom: 1px solid rgba(120, 150, 190, 0.12);
}

.users-table th {
  font-size: 12px;
  text-transform: uppercase;
  color: var(--color-muted);
  letter-spacing: 0.18em;
}

.users-table td strong,
.users-table td span {
  display: block;
}

.users-table tbody tr {
  cursor: pointer;
  transition: background 0.18s ease, transform 0.18s ease;
}

.users-table tbody tr:hover,
.users-table tbody tr.selected {
  background: rgba(90, 213, 255, 0.08);
}

.users-table tbody tr.selected {
  box-shadow: inset 3px 0 0 rgba(90, 213, 255, 0.7);
}

.empty-table {
  text-align: center;
  color: var(--color-muted);
}

.status-pill,
.metric-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  padding: 8px 12px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.status-active {
  color: var(--color-accent-strong);
  border-color: rgba(139, 212, 92, 0.4);
  background: rgba(12, 22, 16, 0.7);
}

.status-blocked {
  color: var(--color-danger);
  border-color: rgba(255, 141, 150, 0.3);
  background: rgba(30, 10, 16, 0.8);
}

.status-expired,
.status-reissued {
  color: var(--color-gold-strong);
  border-color: rgba(215, 184, 106, 0.35);
  background: rgba(33, 24, 10, 0.8);
}

.status-never,
.status-disabled {
  color: var(--color-muted);
  background: rgba(10, 20, 36, 0.7);
}

.detail-panel {
  min-height: 520px;
}

.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.detail-meta,
.detail-card {
  display: grid;
  gap: 12px;
}

.detail-meta {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 20px;
}

.detail-meta span,
.detail-card span,
.history-item span {
  color: var(--color-muted);
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
}

.detail-card {
  padding: 18px;
  border-radius: 18px;
  border: 1px solid rgba(120, 150, 190, 0.16);
  background: rgba(9, 18, 34, 0.72);
}

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

.detail-card-wide {
  grid-column: 1 / -1;
}

.detail-summary {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.section-copy,
.audit-meta,
.device-meta-line,
.devices-note {
  color: var(--color-muted);
  line-height: 1.5;
}

.section-copy,
.audit-meta {
  margin: 0;
}

.detail-section + .detail-section {
  margin-top: 20px;
}

.history-list,
.audit-list,
.devices-list {
  display: grid;
  gap: 12px;
}

.history-item,
.audit-item {
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(9, 18, 34, 0.72);
  border: 1px solid rgba(120, 150, 190, 0.14);
}

.history-item,
.audit-item > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.device-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-radius: 16px;
  background: rgba(9, 18, 34, 0.72);
  border: 1px solid rgba(120, 150, 190, 0.14);
}

.device-stack {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.device-stack strong {
  overflow-wrap: anywhere;
}

.device-meta-line {
  font-size: 13px;
  overflow-wrap: anywhere;
}

.device-actions {
  display: flex;
  align-items: center;
}

.history-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.pool-metrics {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.empty-state {
  border-radius: 18px;
  padding: 22px;
  text-align: center;
  color: var(--color-muted);
  background: rgba(10, 20, 36, 0.5);
  border: 1px dashed rgba(120, 150, 190, 0.18);
}

.empty-state.compact {
  padding: 16px;
}

.flash {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid transparent;
}

.flash-success {
  background: rgba(139, 212, 92, 0.12);
  color: var(--color-accent-strong);
  border-color: rgba(139, 212, 92, 0.32);
}

.flash-error {
  background: rgba(255, 141, 150, 0.1);
  color: #ffd8dc;
  border-color: rgba(255, 141, 150, 0.24);
}

.link-inline {
  color: var(--color-ice);
  overflow-wrap: anywhere;
}

.mono,
.code-block {
  font-family: 'Courier New', monospace;
}

.code-block {
  margin: 0;
  white-space: pre-wrap;
  font-size: 12px;
  line-height: 1.5;
  color: var(--color-gold-strong);
}

@media (max-width: 1200px) {
  .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .admin-grid,
  .bottom-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 780px) {
  .page-content,
  .site-header {
    padding-left: 18px;
    padding-right: 18px;
  }

  .hero-card,
  .panel {
    padding: 18px;
  }

  .hero-card,
  .site-header {
    flex-direction: column;
    align-items: flex-start;
  }

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

  .detail-meta {
    grid-template-columns: 1fr;
  }

  .detail-card-grid {
    grid-template-columns: 1fr;
  }

  .section-head,
  .device-item {
    flex-direction: column;
  }

  .device-actions {
    width: 100%;
  }

  .device-actions .header-button {
    width: 100%;
  }
}
