* {
  box-sizing: border-box;
}

:root {
  --bg: #1a2138;
  --bg-2: #1e2544;
  --surface: #242c4d;
  --surface-2: #2c3559;
  --border: rgba(255, 255, 255, 0.12);
  --border-soft: rgba(255, 255, 255, 0.08);
  --text: #f4f6fb;
  --text-muted: #a3abc4;
  --text-dim: #7b84a3;
  --accent: #5b7fff;
  --accent-hover: #4a6cf0;
  --accent-soft: rgba(91, 127, 255, 0.18);
  --success: #3fdba0;
  --success-soft: rgba(63, 219, 160, 0.16);
  --danger: #ff8080;
  --danger-soft: rgba(255, 128, 128, 0.16);
}

html, body {
  height: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text);
  position: relative;
  animation: fadeIn 0.4s ease both;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Анимированный фон: размытые цветные пятна на тёмном фоне */
body::before,
body::after {
  content: "";
  position: fixed;
  z-index: -1;
  border-radius: 50%;
  filter: blur(90px);
  pointer-events: none;
  will-change: transform;
}

body::before {
  width: min(60vw, 60vh, 480px);
  height: min(60vw, 60vh, 480px);
  background: #4c6fff;
  opacity: 0.22;
  top: -15%;
  left: -15%;
  animation: blobMove1 20s ease-in-out infinite alternate;
}

body::after {
  width: min(55vw, 55vh, 420px);
  height: min(55vw, 55vh, 420px);
  background: #9b5cff;
  opacity: 0.16;
  bottom: -15%;
  right: -15%;
  animation: blobMove2 24s ease-in-out infinite alternate;
}

@keyframes blobMove1 {
  0%   { transform: translate(0, 0) scale(1); }
  100% { transform: translate(6vw, 6vh) scale(1.1); }
}

@keyframes blobMove2 {
  0%   { transform: translate(0, 0) scale(1); }
  100% { transform: translate(-6vw, -6vh) scale(1.15); }
}

@media (prefers-reduced-motion: reduce) {
  body::before, body::after { animation: none; }
  body { animation: none; }
}

/* Шапка */
.gos-header {
  background: rgba(20, 27, 46, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  color: var(--text);
  padding: 0.9rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 10;
}

.gos-header .badge {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #9b5cff);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(76, 111, 255, 0.35);
}

.gos-header .org-name {
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.25;
  color: var(--text);
}

.gos-header .org-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 400;
}

.page-wrap {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem;
}

.auth-box {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 2rem 1.5rem;
  border-radius: 18px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  width: 100%;
  max-width: 380px;
  margin: 0 auto;
  animation: cardIn 0.45s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

h1 {
  margin: 0 0 0.25rem;
  font-size: 1.3rem;
  color: var(--text);
  font-weight: 700;
  letter-spacing: -0.01em;
}

h2 {
  margin: 0 0 1.5rem;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text-muted);
}

form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

input {
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  background: var(--surface-2);
  color: var(--text);
  width: 100%;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

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

input:focus {
  outline: none;
  border-color: var(--accent);
  background: #202a4a;
  box-shadow: 0 0 0 4px var(--accent-soft);
}

button, .role-btn, .ad-open-btn {
  display: block;
  margin-top: 0.25rem;
  padding: 0.8rem;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, box-shadow 0.15s ease;
  width: 100%;
  box-sizing: border-box;
  box-shadow: 0 6px 16px rgba(76, 111, 255, 0.3);
}

button:hover, .role-btn:hover, .ad-open-btn:hover {
  background: var(--accent-hover);
}

button:active, .role-btn:active {
  transform: scale(0.97);
}

button:disabled {
  background: #2a3350;
  color: var(--text-dim);
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.switch-link {
  margin-top: 1.25rem;
  font-size: 0.85rem;
  text-align: center;
  color: var(--text-muted);
}

.switch-link a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.gos-footer {
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-dim);
  padding: 1rem;
  flex-shrink: 0;
}

/* --- Бейдж-пилюля, как "Shipper" на референсе --- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  background: var(--accent-soft);
  color: var(--accent);
}
.pill-success { background: var(--success-soft); color: var(--success); }
.pill-danger { background: var(--danger-soft); color: var(--danger); }

/* --- Выбор роли (choice.html) --- */
.role-view {
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.role-view.hidden {
  display: none;
}
.role-btns { display: flex; flex-direction: column; gap: 0.65rem; }
.role-btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  box-shadow: none;
  border: 1px solid var(--border);
}
.role-btn-secondary:hover { background: #232c4d; }

.whitelist-note { font-size: 0.82rem; color: var(--text-muted); margin: 0 0 0.85rem; }

.whitelist-list { list-style: none; padding: 0; margin: 0 0 0.5rem; display: flex; flex-direction: column; gap: 0.6rem; }
.whitelist-list a {
  display: flex; align-items: center; gap: 0.75rem; padding: 0.7rem 0.85rem;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px;
  text-decoration: none; color: var(--text); font-size: 0.88rem; font-weight: 600;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
}
.whitelist-list a:hover {
  background: #202a4a;
  border-color: var(--accent);
  transform: translateX(3px);
}
.wl-logo {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 800; color: #fff;
}
.wl-vk { background: #2787f5; }
.wl-ok { background: #f7931e; }
.wl-max { background: #7c5cff; }
.wl-site { background: linear-gradient(135deg, var(--accent), #9b5cff); }

.back-link {
  display: inline-block; margin-top: 0.75rem; font-size: 0.85rem; color: var(--accent);
  text-decoration: none; cursor: pointer; border: none; background: none; padding: 0; font-weight: 600;
}

/* --- Страница успеха Wi-Fi входа --- */
.success-box { max-width: 480px; }
.ad-card {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px;
  padding: 1.1rem; margin: 0.85rem 0; text-align: center;
}
.ad-card-label {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--accent); font-weight: 700; margin: 0 0 0.4rem;
}
.ad-card-url { font-size: 0.82rem; color: var(--text-muted); word-break: break-all; margin: 0 0 0.85rem; }
#countdown-text { font-size: 0.82rem; color: var(--text-muted); margin: 0 0 1rem; }

/* --- Админ-панель --- */
.admin-box { max-width: 740px; }
table { width: 100%; border-collapse: collapse; margin-top: 0.5rem; font-size: 0.85rem; }
th, td { text-align: left; padding: 0.6rem 0.45rem; border-bottom: 1px solid var(--border-soft); vertical-align: middle; color: var(--text); }
th { color: var(--text-muted); font-weight: 600; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em; }
.role-badge { display: inline-block; padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.7rem; font-weight: 700; }
.role-admin { background: var(--danger-soft); color: var(--danger); }
.role-user { background: var(--accent-soft); color: var(--accent); }
.row-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.row-actions button, .row-actions a { width: auto; margin-top: 0; padding: 0.4rem 0.65rem; font-size: 0.76rem; font-weight: 600; box-shadow: none; }
.btn-reset { background: var(--accent-soft); color: var(--accent); }
.btn-reset:hover { background: rgba(76, 111, 255, 0.24); }
.btn-open { background: var(--success-soft); color: var(--success); text-decoration: none; display: inline-block; border-radius: 10px; }
.btn-open:hover { background: rgba(52, 211, 153, 0.24); }
.btn-delete { background: var(--danger-soft); color: var(--danger); }
.btn-delete:hover { background: rgba(248, 113, 113, 0.24); }
.table-wrap { overflow-x: auto; }
.inline-msg { font-size: 0.78rem; margin-top: 0.5rem; }
.msg-ok { color: var(--success); }
.msg-err { color: var(--danger); }

@media (max-width: 380px) {
  .gos-header { padding: 0.75rem 1rem; }
  .auth-box { padding: 1.5rem 1.1rem; border-radius: 16px; }
  h1 { font-size: 1.1rem; }
}
