:root {
  --bg-main: #0b0e14;
  --bg-soft: #111827;
  --bg-card: #020617;
  --border: #1f2937;

  --yellow-main: #facc15;
  --yellow-soft: #eab308;

  --text-main: #f9fafb;
  --text-muted: #9ca3af;
  --danger: #7f1d1d;

  --radius-xl: 20px;
  --radius-lg: 16px;
  --radius-md: 14px;

  --shadow-main: 0 20px 50px rgba(0,0,0,.6);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-main);
  color: var(--text-main);
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--yellow-main);
  text-decoration: none;
}

blockquote {
  margin: 12px 0;
  padding: 12px 16px;
  border-left: 3px solid var(--yellow-main);
  background: rgba(250, 204, 21, 0.06);
  border-radius: 8px;
  color: var(--text-muted);
}

.center {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.card {
  width: 100%;
  max-width: 380px;
  background: linear-gradient(160deg, var(--bg-soft), var(--bg-card));
  border-radius: var(--radius-xl);
  padding: 28px;
  box-shadow: var(--shadow-main);
  animation: fadeUp .8s ease;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 6px;
}

.logo h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: 2px;
  color: var(--yellow-main);
}

.bolt {
  font-size: 34px;
  animation: pulse 2s infinite;
}

.subtitle {
  text-align: center;
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

input {
  width: 100%;
  padding: 14px 16px;
  margin: 8px 0;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-main);
  font-size: 16px;
  outline: none;
  transition: .2s;
}

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

input:focus {
  border-color: var(--yellow-main);
  box-shadow: 0 0 0 2px rgba(250, 204, 21, .15);
}

button {
  width: 100%;
  margin-top: 14px;
  padding: 14px;
  border-radius: var(--radius-md);
  border: none;
  background: linear-gradient(135deg, var(--yellow-main), var(--yellow-soft));
  color: #020617;
  font-weight: 800;
  font-size: 16px;
  cursor: pointer;
  transition: .2s ease;
}

button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(250, 204, 21, .25);
}

button:active {
  transform: translateY(0);
}

.error {
  background: var(--danger);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
  margin-bottom: 12px;
}

header.top {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}

header.top h2 {
  margin: 0;
  font-size: 18px;
  color: var(--yellow-main);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
  padding: 20px;
}

.box {
  background: linear-gradient(160deg, var(--bg-soft), var(--bg-card));
  border-radius: var(--radius-lg);
  padding: 22px;
  text-align: center;
  font-size: 16px;
  cursor: pointer;
  transition: .25s ease;
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

.box::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    circle at top,
    rgba(250,204,21,.15),
    transparent 60%
  );
  opacity: 0;
  transition: .25s;
}

.box:hover::after {
  opacity: 1;
}

.box:hover {
  transform: translateY(-4px);
  border-color: var(--yellow-main);
}

@keyframes pulse {
  0% { opacity: .6; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.08); }
  100% { opacity: .6; transform: scale(1); }
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 480px) {
  .card {
    padding: 22px;
  }

  .logo h1 {
    font-size: 24px;
  }

  header.top h2 {
    font-size: 16px;
  }

  .box {
    font-size: 15px;
    padding: 18px;
  }
}

/* Admin panel usability tweaks */
.table-responsive {
  border-radius: var(--radius-lg);
  overflow: auto;
}

.smallcode code { word-break: break-all; }

@media (max-width: 768px) {
  .container { padding-left: 12px; padding-right: 12px; }
  .navbar .btn { flex: 1 1 auto; }
  .table td, .table th { white-space: nowrap; }
  form.d-flex.gap-1.mt-1 { flex-direction: column; }
  form.d-flex.gap-1.mt-1 > * { width: 100% !important; }
  form.d-flex.gap-2 { flex-wrap: wrap; }
}

/* Admin UI v2 */
:root {
  --ink-900: #0f172a;
  --ink-700: #334155;
  --ink-500: #64748b;
  --paper: #f8fafc;
  --card: rgba(255, 255, 255, 0.9);
  --line: rgba(15, 23, 42, 0.14);
  --accent: #0ea5a4;
  --accent-strong: #0891b2;
  --warn: #f59e0b;
  --danger-2: #dc2626;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 24px 70px rgba(2, 6, 23, 0.14);
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--ink-900);
  background:
    radial-gradient(circle at 10% 5%, rgba(14, 165, 164, 0.15), transparent 42%),
    radial-gradient(circle at 95% 0%, rgba(245, 158, 11, 0.2), transparent 38%),
    linear-gradient(180deg, #ecfeff 0%, #f8fafc 45%, #f8fafc 100%);
  font-family: "Manrope", "Segoe UI", sans-serif;
}

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

button {
  width: auto;
  margin: 0;
  padding: 0.5rem 0.9rem;
}

.app-shell {
  position: relative;
  min-height: 100vh;
}

.noise-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(rgba(15, 23, 42, 0.045) 1px, transparent 1px);
  background-size: 3px 3px;
  opacity: 0.4;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
}

.ico {
  width: 1rem;
  height: 1rem;
  flex: 0 0 auto;
}

.topbar-wrap {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(12px);
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.9), rgba(248, 250, 252, 0.75));
  border-bottom: 1px solid var(--line);
}

.topbar {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0.8rem 1rem;
  display: grid;
  gap: 0.8rem;
  align-items: center;
  grid-template-columns: auto 1fr auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--ink-900);
  text-decoration: none;
}

.brand-ico {
  width: 2rem;
  height: 2rem;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--accent), #22d3ee);
  color: white;
  display: grid;
  place-items: center;
  box-shadow: 0 8px 18px rgba(14, 165, 164, 0.35);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand-text strong {
  font-family: "Space Grotesk", sans-serif;
  letter-spacing: 0.03em;
  font-size: 1rem;
}

.brand-text small {
  color: var(--ink-500);
  font-size: 0.72rem;
}

.nav-scroll {
  display: flex;
  gap: 0.45rem;
  overflow: auto;
  padding-bottom: 0.15rem;
}

.nav-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  text-decoration: none;
  color: var(--ink-700);
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.72);
  transition: transform 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.nav-pill:hover {
  transform: translateY(-1px);
  border-color: rgba(14, 165, 164, 0.45);
  color: var(--ink-900);
}

.nav-pill.active {
  background: linear-gradient(120deg, rgba(14, 165, 164, 0.14), rgba(14, 165, 164, 0.05));
  border-color: rgba(14, 165, 164, 0.55);
  color: var(--accent-strong);
}

.admin-pop {
  position: relative;
}

.admin-pop summary {
  list-style: none;
}

.admin-pop summary::-webkit-details-marker {
  display: none;
}

.admin-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  border: 1px solid var(--line);
  padding: 0.35rem 0.55rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  cursor: pointer;
}

.admin-name {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink-700);
  font-size: 0.84rem;
}

.avatar-img,
.avatar-fallback {
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  object-fit: cover;
}

.avatar-fallback {
  background: linear-gradient(135deg, var(--accent), #14b8a6);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
}

.admin-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.5rem);
  width: min(320px, 92vw);
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: var(--radius-sm);
  padding: 0.7rem;
  animation: popIn 0.2s ease;
}

.stack-form .tiny-label {
  margin-bottom: 0.35rem;
}

.page-wrap {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1rem;
  position: relative;
  z-index: 2;
}

.section-head {
  margin-bottom: 0.9rem;
}

.section-head h1 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(1.25rem, 1vw + 1rem, 1.8rem);
}

.section-head p {
  margin: 0.3rem 0 0;
  color: var(--ink-500);
  font-size: 0.94rem;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.9rem;
  animation: fadeRise 0.35s ease both;
}

.panel h2 {
  font-size: 1.05rem;
  margin: 0 0 0.8rem;
  font-weight: 700;
}

.tiny-label {
  display: block;
  font-size: 0.72rem;
  color: var(--ink-500);
  margin-bottom: 0.2rem;
}

.form-control,
.form-select {
  margin: 0;
  border-radius: 12px;
  border-color: rgba(100, 116, 139, 0.28);
  padding: 0.5rem 0.7rem;
}

.form-control:focus,
.form-select:focus {
  border-color: rgba(14, 165, 164, 0.5);
  box-shadow: 0 0 0 0.25rem rgba(14, 165, 164, 0.13);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 0.7rem;
}

.stat-card {
  grid-column: span 4;
  background: linear-gradient(150deg, rgba(255, 255, 255, 0.92), rgba(240, 253, 250, 0.9));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.9rem;
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: "";
  position: absolute;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  right: -50px;
  top: -50px;
  background: radial-gradient(circle, rgba(14, 165, 164, 0.25), transparent 70%);
}

.stat-card small {
  font-size: 0.78rem;
  color: var(--ink-500);
}

.stat-card h3 {
  margin: 0.15rem 0 0;
  font-size: 1.6rem;
  font-family: "Space Grotesk", sans-serif;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.7rem;
}

.quick-link {
  display: block;
  text-decoration: none;
  color: var(--ink-900);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.75);
  padding: 0.8rem;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.quick-link:hover {
  transform: translateY(-2px);
  border-color: rgba(14, 165, 164, 0.45);
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}

.entity-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem;
  box-shadow: var(--shadow);
  animation: fadeRise 0.35s ease both;
}

.entity-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.6rem;
}

.entity-top h3 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.3;
}

.entity-top p {
  margin: 0.2rem 0 0;
  color: var(--ink-500);
  font-size: 0.8rem;
}

.chips {
  margin-top: 0.55rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid rgba(14, 165, 164, 0.3);
  color: #0f766e;
  background: rgba(204, 251, 241, 0.55);
  padding: 0.2rem 0.5rem;
  font-size: 0.72rem;
}

.payload-box {
  margin-top: 0.55rem;
  max-height: 115px;
  overflow: auto;
  padding: 0.55rem;
  border-radius: 10px;
  border: 1px dashed rgba(100, 116, 139, 0.4);
  background: rgba(255, 255, 255, 0.6);
}

.payload-box code {
  white-space: pre-wrap;
  word-break: break-word;
}

.entity-actions {
  margin-top: 0.7rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.entity-actions > form {
  flex: 1 1 180px;
}

.entity-actions.two-col > form {
  flex: 1 1 45%;
}

.tiny-note {
  margin-top: 0.5rem;
  color: var(--ink-500);
  font-size: 0.8rem;
}

.tabs-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.tab-pill {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--line);
  color: var(--ink-700);
  background: rgba(255, 255, 255, 0.8);
}

.tab-pill.active {
  border-color: rgba(14, 165, 164, 0.5);
  color: var(--accent-strong);
  background: rgba(204, 251, 241, 0.7);
}

.user-title {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.user-dot {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--warn), #f97316);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 0.8rem;
  font-weight: 700;
}

.empty-box {
  grid-column: 1 / -1;
  background: rgba(255, 255, 255, 0.7);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--ink-500);
  text-align: center;
  padding: 1rem;
}

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

.auth-bg {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 14% 8%, rgba(14, 165, 164, 0.32), transparent 36%),
    radial-gradient(circle at 86% 16%, rgba(234, 179, 8, 0.24), transparent 34%),
    linear-gradient(160deg, #ecfeff, #f8fafc 52%, #fff7ed);
  animation: drift 7s ease-in-out infinite alternate;
}

.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
  position: relative;
  z-index: 2;
}

.auth-card {
  width: min(440px, 95vw);
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 1rem;
  box-shadow: var(--shadow);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.8rem;
}

.auth-logo {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(145deg, var(--accent), #22d3ee);
  color: white;
  display: grid;
  place-items: center;
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
}

.auth-brand h1 {
  font-size: 1.25rem;
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
}

.auth-brand p {
  margin: 0.15rem 0 0;
  color: var(--ink-500);
  font-size: 0.82rem;
}

.auth-form label {
  font-size: 0.8rem;
  color: var(--ink-500);
  margin-bottom: 0.25rem;
}

button:hover,
button:active {
  transform: none;
  box-shadow: none;
}

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

@keyframes fadeRise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes drift {
  from {
    filter: hue-rotate(0deg);
    transform: scale(1);
  }
  to {
    filter: hue-rotate(12deg);
    transform: scale(1.02);
  }
}

@media (max-width: 1100px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .stat-card {
    grid-column: auto;
  }
  .quick-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .topbar {
    grid-template-columns: 1fr auto;
  }
  .brand {
    grid-column: 1 / -1;
  }
  .cards-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 0.7rem 0.7rem 0.75rem;
  }
  .page-wrap {
    padding: 0.75rem;
  }
  .brand-text small {
    display: none;
  }
  .admin-name {
    display: none;
  }
  .quick-grid,
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .entity-actions.two-col > form {
    flex-basis: 100%;
  }
}

.top-tools {
  display: grid;
  gap: 0.45rem;
}

.lang-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.35rem;
}

.mini-inline {
  margin: 0;
}

.auth-note {
  font-size: 0.86rem;
  color: var(--ink-700);
}

.tg-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 0.35rem;
}

html[data-theme="dark"] {
  --ink-900: #f3f4f6;
  --ink-700: #d1d5db;
  --ink-500: #9ca3af;
  --paper: #0b1220;
  --card: rgba(15, 23, 42, 0.84);
  --line: rgba(148, 163, 184, 0.25);
  --accent: #22d3ee;
  --accent-strong: #38bdf8;
  --warn: #f59e0b;
  --danger-2: #ef4444;
  --shadow: 0 24px 70px rgba(2, 6, 23, 0.65);
}

html[data-theme="dark"] body {
  color: var(--ink-900);
  background:
    radial-gradient(circle at 12% 8%, rgba(34, 211, 238, 0.13), transparent 42%),
    radial-gradient(circle at 92% 0%, rgba(245, 158, 11, 0.16), transparent 36%),
    linear-gradient(180deg, #0b1220 0%, #111827 48%, #0f172a 100%);
}

html[data-theme="dark"] .topbar-wrap {
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.9), rgba(15, 23, 42, 0.76));
}

html[data-theme="dark"] .nav-pill,
html[data-theme="dark"] .admin-chip,
html[data-theme="dark"] .quick-link,
html[data-theme="dark"] .tab-pill,
html[data-theme="dark"] .payload-box,
html[data-theme="dark"] .empty-box {
  background: rgba(15, 23, 42, 0.7);
  color: var(--ink-700);
}

html[data-theme="dark"] .panel,
html[data-theme="dark"] .entity-card,
html[data-theme="dark"] .admin-menu,
html[data-theme="dark"] .auth-card {
  background: var(--card);
  border-color: var(--line);
}

html[data-theme="dark"] .entity-top p,
html[data-theme="dark"] .tiny-label,
html[data-theme="dark"] .section-head p,
html[data-theme="dark"] .tiny-note,
html[data-theme="dark"] .auth-brand p,
html[data-theme="dark"] .auth-note {
  color: var(--ink-500);
}

html[data-theme="dark"] .chip {
  color: #bae6fd;
  border-color: rgba(56, 189, 248, 0.35);
  background: rgba(14, 116, 144, 0.28);
}

html[data-theme="dark"] .stat-card {
  background: linear-gradient(150deg, rgba(15, 23, 42, 0.9), rgba(30, 41, 59, 0.85));
}

html[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-select {
  color: var(--ink-900);
  background: rgba(15, 23, 42, 0.6);
  border-color: rgba(148, 163, 184, 0.34);
}

html[data-theme="dark"] .auth-bg {
  background:
    radial-gradient(circle at 14% 8%, rgba(34, 211, 238, 0.24), transparent 38%),
    radial-gradient(circle at 86% 16%, rgba(234, 179, 8, 0.17), transparent 36%),
    linear-gradient(160deg, #0b1220, #111827 52%, #1e293b);
}

/* Support + bottom controls */
.page-wrap {
  padding-bottom: 6rem;
}

.topbar-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.bottom-tools {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 45;
  border-top: 1px solid var(--line);
  background: rgba(248, 250, 252, 0.93);
  backdrop-filter: blur(10px);
}

.bottom-tools-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0.55rem 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
}

.support-meta {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

textarea.form-control {
  min-height: 130px;
}

html[data-theme="dark"] .bottom-tools {
  background: rgba(15, 23, 42, 0.92);
  border-top-color: var(--line);
}

@media (max-width: 900px) {
  .bottom-tools-inner {
    flex-direction: column;
    align-items: stretch;
  }

  .bottom-tools .lang-row {
    width: 100%;
  }

  .bottom-tools .mini-inline {
    width: 100%;
  }

  .bottom-tools .mini-inline .btn {
    width: 100%;
  }
}

/* --- Layout fixes + local fallback UI (no Bootstrap dependency) --- */
.topbar {
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.nav-scroll {
  min-width: 0;
  scrollbar-width: thin;
}

.topbar-actions {
  flex-wrap: nowrap;
}

.page-wrap {
  padding-bottom: 7rem;
}

/* Local button system fallback */
button,
.btn {
  border-radius: 12px;
  border: 1px solid transparent;
  font-weight: 600;
  line-height: 1.2;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.55rem 0.85rem;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease, filter 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.02);
}

.btn-sm {
  padding: 0.45rem 0.7rem;
  font-size: 0.88rem;
}

.btn-primary,
.btn-success {
  color: #ffffff;
  background: linear-gradient(135deg, #0ea5a4, #0284c7);
  border-color: rgba(2, 132, 199, 0.45);
}

.btn-outline-primary {
  color: #0369a1;
  background: rgba(255, 255, 255, 0.85);
  border-color: rgba(14, 165, 164, 0.45);
}

.btn-outline-secondary {
  color: var(--ink-700);
  background: rgba(255, 255, 255, 0.85);
  border-color: var(--line);
}

.btn-outline-success {
  color: #166534;
  background: rgba(236, 253, 245, 0.8);
  border-color: rgba(34, 197, 94, 0.4);
}

.btn-outline-danger {
  color: #b91c1c;
  background: rgba(254, 242, 242, 0.85);
  border-color: rgba(239, 68, 68, 0.45);
}

.w-100 {
  width: 100%;
}

.alert {
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 0.7rem 0.8rem;
  margin-bottom: 0.65rem;
}

.alert-danger {
  border-color: rgba(239, 68, 68, 0.42);
  background: rgba(254, 242, 242, 0.85);
  color: #7f1d1d;
}

.alert-success {
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(236, 253, 245, 0.85);
  color: #14532d;
}

.alert-warning {
  border-color: rgba(245, 158, 11, 0.35);
  background: rgba(255, 251, 235, 0.88);
  color: #78350f;
}

.badge,
.text-bg-danger,
.text-bg-success,
.text-bg-secondary {
  display: inline-flex;
  align-items: center;
  padding: 0.24rem 0.48rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
}

.text-bg-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #7f1d1d;
}

.text-bg-success {
  background: rgba(34, 197, 94, 0.15);
  color: #14532d;
}

.text-bg-secondary {
  background: rgba(100, 116, 139, 0.16);
  color: #334155;
}

/* Simple layout utility fallback */
.row {
  display: flex;
  flex-wrap: wrap;
  margin: -0.35rem;
}

.row > [class^="col-"] {
  padding: 0.35rem;
}

.col-12 { width: 100%; }
.col-9 { width: 75%; }
.col-6 { width: 50%; }
.col-4 { width: 33.3333%; }
.col-3 { width: 25%; }

.d-flex { display: flex; }
.d-grid { display: grid; }
.gap-2 { gap: 0.5rem; }
.align-items-end { align-items: end; }
.justify-content-sm-start { justify-content: flex-start; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }

.form-check {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.form-check-input {
  width: 1rem;
  height: 1rem;
  margin: 0;
}

.form-check-label,
.text-muted {
  color: var(--ink-500);
  font-size: 0.9rem;
}

@media (min-width: 992px) {
  .col-lg-2 { width: 16.6667%; }
  .col-lg-4 { width: 33.3333%; }
  .col-lg-6 { width: 50%; }
}

@media (max-width: 900px) {
  .topbar {
    grid-template-columns: 1fr;
    gap: 0.55rem;
  }

  .brand,
  .nav-scroll,
  .topbar-actions {
    grid-column: auto;
  }

  .topbar-actions {
    justify-content: flex-end;
  }

  .bottom-tools {
    position: static;
    border-top: 0;
    border-top: 1px solid var(--line);
    margin-top: 0.4rem;
  }

  .page-wrap {
    padding-bottom: 0.8rem;
  }
}

@media (max-width: 640px) {
  .nav-pill {
    padding: 0.45rem 0.62rem;
    font-size: 0.95rem;
  }

  .brand-text strong {
    font-size: 0.94rem;
  }

  .btn,
  .btn-sm {
    min-height: 2.35rem;
  }
}

html[data-theme="dark"] .btn-outline-primary,
html[data-theme="dark"] .btn-outline-secondary,
html[data-theme="dark"] .btn-outline-success,
html[data-theme="dark"] .btn-outline-danger {
  background: rgba(15, 23, 42, 0.66);
  color: var(--ink-700);
}

html[data-theme="dark"] .alert-danger {
  background: rgba(127, 29, 29, 0.28);
  color: #fecaca;
}

html[data-theme="dark"] .alert-success {
  background: rgba(20, 83, 45, 0.28);
  color: #bbf7d0;
}

html[data-theme="dark"] .text-bg-danger {
  color: #fecaca;
  background: rgba(127, 29, 29, 0.35);
}

html[data-theme="dark"] .text-bg-success {
  color: #bbf7d0;
  background: rgba(20, 83, 45, 0.35);
}

/* --- AMOLED + amber accent override --- */
:root {
  --accent: #f59e0b;
  --accent-strong: #ea580c;
}

.brand-ico,
.auth-logo {
  background: linear-gradient(145deg, #f59e0b, #f97316);
  box-shadow: 0 8px 18px rgba(249, 115, 22, 0.34);
}

.nav-pill.active {
  background: linear-gradient(120deg, rgba(245, 158, 11, 0.2), rgba(249, 115, 22, 0.12));
  border-color: rgba(249, 115, 22, 0.65);
  color: #b45309;
}

.nav-pill:hover,
.quick-link:hover,
.btn:hover {
  border-color: rgba(249, 115, 22, 0.58);
}

.avatar-fallback {
  background: linear-gradient(135deg, #f59e0b, #ea580c);
}

.chip {
  color: #9a3412;
  border-color: rgba(251, 146, 60, 0.45);
  background: rgba(255, 237, 213, 0.75);
}

.btn-primary,
.btn-success {
  color: #1c1917;
  background: linear-gradient(135deg, #facc15, #f97316);
  border-color: rgba(251, 146, 60, 0.7);
}

.btn-outline-primary {
  color: #b45309;
  border-color: rgba(249, 115, 22, 0.58);
}

html[data-theme="dark"] {
  --ink-900: #f5f5f4;
  --ink-700: #e7e5e4;
  --ink-500: #a8a29e;
  --paper: #020202;
  --card: rgba(8, 8, 8, 0.96);
  --line: rgba(245, 158, 11, 0.22);
  --accent: #f59e0b;
  --accent-strong: #f97316;
  --warn: #f59e0b;
  --danger-2: #ef4444;
  --shadow: 0 22px 64px rgba(0, 0, 0, 0.7);
}

html[data-theme="dark"] body {
  background:
    radial-gradient(circle at 10% 0%, rgba(245, 158, 11, 0.11), transparent 35%),
    radial-gradient(circle at 98% 0%, rgba(249, 115, 22, 0.09), transparent 30%),
    #020202;
}

html[data-theme="dark"] .topbar-wrap {
  background: linear-gradient(180deg, rgba(2, 2, 2, 0.95), rgba(2, 2, 2, 0.84));
  border-bottom-color: rgba(245, 158, 11, 0.18);
}

html[data-theme="dark"] .nav-pill,
html[data-theme="dark"] .admin-chip,
html[data-theme="dark"] .quick-link,
html[data-theme="dark"] .tab-pill,
html[data-theme="dark"] .payload-box,
html[data-theme="dark"] .empty-box,
html[data-theme="dark"] .bottom-tools {
  background: rgba(10, 10, 10, 0.95);
  border-color: rgba(245, 158, 11, 0.22);
}

html[data-theme="dark"] .panel,
html[data-theme="dark"] .entity-card,
html[data-theme="dark"] .auth-card,
html[data-theme="dark"] .stat-card {
  background: rgba(8, 8, 8, 0.97);
  border-color: rgba(245, 158, 11, 0.2);
}

html[data-theme="dark"] .chip {
  color: #fdba74;
  border-color: rgba(249, 115, 22, 0.42);
  background: rgba(67, 20, 7, 0.5);
}

html[data-theme="dark"] .btn-outline-primary,
html[data-theme="dark"] .btn-outline-secondary,
html[data-theme="dark"] .btn-outline-success,
html[data-theme="dark"] .btn-outline-danger {
  background: rgba(10, 10, 10, 0.94);
  border-color: rgba(245, 158, 11, 0.35);
}

html[data-theme="dark"] .btn-primary,
html[data-theme="dark"] .btn-success {
  color: #111827;
  background: linear-gradient(135deg, #facc15, #f97316);
}

html[data-theme="dark"] .auth-bg {
  background:
    radial-gradient(circle at 14% 8%, rgba(245, 158, 11, 0.15), transparent 38%),
    radial-gradient(circle at 86% 14%, rgba(249, 115, 22, 0.11), transparent 34%),
    #020202;
}

/* --- Final amber cleanup for all legacy teal accents --- */
:root {
  --focus-ring: rgba(249, 115, 22, 0.22);
}

html,
body {
  background:
    radial-gradient(circle at 10% 5%, rgba(245, 158, 11, 0.14), transparent 42%),
    radial-gradient(circle at 95% 0%, rgba(249, 115, 22, 0.12), transparent 38%),
    linear-gradient(180deg, #fff7ed 0%, #fffbeb 45%, #fffbeb 100%);
}

.nav-pill:hover,
.quick-link:hover,
.tab-pill.active {
  border-color: rgba(249, 115, 22, 0.58) !important;
}

.tab-pill.active {
  color: #b45309;
  background: rgba(255, 237, 213, 0.8);
}

.form-control:focus,
.form-select:focus,
input:focus,
textarea:focus,
select:focus {
  border-color: rgba(249, 115, 22, 0.62) !important;
  box-shadow: 0 0 0 0.25rem var(--focus-ring) !important;
}

.stat-card::after {
  background: radial-gradient(circle, rgba(249, 115, 22, 0.22), transparent 70%);
}

.auth-bg {
  background:
    radial-gradient(circle at 14% 8%, rgba(245, 158, 11, 0.24), transparent 36%),
    radial-gradient(circle at 86% 16%, rgba(249, 115, 22, 0.2), transparent 34%),
    linear-gradient(160deg, #fff7ed, #fffbeb 52%, #fff7ed);
}

html[data-theme="dark"] .nav-pill.active,
html[data-theme="dark"] .tab-pill.active {
  background: linear-gradient(120deg, rgba(245, 158, 11, 0.22), rgba(249, 115, 22, 0.16));
  color: #fdba74;
  border-color: rgba(249, 115, 22, 0.62) !important;
}

/* --- Motion + blur + scrollbar polish --- */
html,
body {
  overflow-x: hidden;
}

/* remove native horizontal bar in nav strip */
.nav-scroll {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.nav-scroll::-webkit-scrollbar {
  display: none;
}

/* custom page scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(249, 115, 22, 0.7) rgba(255, 255, 255, 0.04);
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.04);
}

*::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(250, 204, 21, 0.95), rgba(249, 115, 22, 0.95));
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:hover {
  filter: brightness(1.05);
}

/* smooth transitions */
*,
*::before,
*::after {
  transition:
    color 0.28s ease,
    background-color 0.28s ease,
    border-color 0.28s ease,
    box-shadow 0.28s ease,
    transform 0.28s ease,
    opacity 0.28s ease;
}

/* glass effect for all major blocks */
.topbar-wrap,
.nav-pill,
.panel,
.stat-card,
.quick-link,
.entity-card,
.tab-pill,
.admin-chip,
.admin-menu,
.bottom-tools,
.payload-box,
.empty-box {
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* motion on load */
.section-head,
.panel,
.stat-card,
.quick-link,
.entity-card,
.tab-pill,
.bottom-tools {
  animation: fadeRise 0.45s ease both;
}

.stats-grid .stat-card:nth-child(2),
.quick-grid .quick-link:nth-child(2),
.cards-grid .entity-card:nth-child(2) { animation-delay: 0.04s; }
.stats-grid .stat-card:nth-child(3),
.quick-grid .quick-link:nth-child(3),
.cards-grid .entity-card:nth-child(3) { animation-delay: 0.08s; }
.stats-grid .stat-card:nth-child(4),
.quick-grid .quick-link:nth-child(4),
.cards-grid .entity-card:nth-child(4) { animation-delay: 0.12s; }
.stats-grid .stat-card:nth-child(5),
.quick-grid .quick-link:nth-child(5),
.cards-grid .entity-card:nth-child(5) { animation-delay: 0.16s; }
.stats-grid .stat-card:nth-child(6),
.quick-grid .quick-link:nth-child(6),
.cards-grid .entity-card:nth-child(6) { animation-delay: 0.2s; }

/* three-dot menu */
.more-btn {
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(10, 10, 10, 0.78);
  color: var(--ink-700);
  display: inline-grid;
  place-items: center;
  cursor: pointer;
}

.more-btn .ico {
  width: 1.15rem;
  height: 1.15rem;
}

.admin-menu-compact {
  min-width: 170px;
}

.admin-menu .admin-chip {
  justify-content: center;
}

/* remove browser resize handle and blue textarea tint */
textarea,
textarea.form-control {
  resize: none;
}

textarea.form-control {
  background: rgba(6, 16, 42, 0.75) !important;
  border-color: rgba(249, 115, 22, 0.34) !important;
}

html[data-theme="dark"] textarea.form-control,
html[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-select {
  background: rgba(5, 5, 5, 0.92) !important;
  border-color: rgba(249, 115, 22, 0.38) !important;
}

html[data-theme="dark"] *::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.03);
}

html[data-theme="dark"] .more-btn {
  background: rgba(8, 8, 8, 0.95);
  border-color: rgba(249, 115, 22, 0.3);
  color: #fdba74;
}

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

  .admin-pop {
    justify-self: end;
  }

  .admin-menu {
    right: 0;
  }
}

/* Broadcast helper drawer */
.broadcast-guide {
  margin-top: 0.8rem;
  border: 1px solid rgba(249, 115, 22, 0.38);
  border-radius: 14px;
  background: rgba(255, 250, 240, 0.82);
  overflow: hidden;
}

.broadcast-guide summary {
  list-style: none;
  cursor: pointer;
  padding: 0.75rem 0.85rem;
  display: grid;
  gap: 0.12rem;
  border-bottom: 1px solid transparent;
}

.broadcast-guide summary::-webkit-details-marker {
  display: none;
}

.broadcast-guide summary::after {
  content: "Развернуть";
  justify-self: end;
  font-size: 0.72rem;
  color: #9a3412;
}

.broadcast-guide[open] summary::after {
  content: "Свернуть";
}

.broadcast-guide[open] summary {
  border-bottom-color: rgba(249, 115, 22, 0.24);
}

.guide-title {
  font-weight: 700;
  color: #9a3412;
}

.guide-sub {
  font-size: 0.8rem;
  color: var(--ink-500);
}

.guide-body {
  padding: 0.8rem;
  gap: 0.7rem;
}

.guide-card {
  border: 1px solid rgba(249, 115, 22, 0.22);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.7);
  padding: 0.7rem;
  min-width: 0;
}

.guide-slide {
  flex: 0 0 auto;
}

.guide-card h3 {
  margin: 0 0 0.45rem;
  font-size: 0.95rem;
}

.guide-card p {
  margin: 0 0 0.45rem;
  color: var(--ink-700);
  font-size: 0.82rem;
}

.guide-card pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px dashed rgba(249, 115, 22, 0.36);
  border-radius: 10px;
  padding: 0.55rem;
  background: rgba(255, 251, 235, 0.8);
}

.guide-card code {
  color: #9a3412;
}

.guide-index-list {
  margin: 0;
  padding: 0.2rem 0.2rem 0.2rem 1.2rem;
  display: grid;
  gap: 0.28rem;
}

.guide-index-list li {
  font-size: 0.8rem;
  color: var(--ink-700);
}

.guide-scroller {
  display: grid;
  gap: 0.65rem;
}

.composer-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.composer-tools .btn {
  min-width: 2.2rem;
  padding: 0.35rem 0.55rem;
}

.composer-tools button b,
.composer-tools button i,
.composer-tools button u,
.composer-tools button s {
  font-size: 0.92rem;
}

.broadcast-buttons-example {
  margin: 0.45rem 0 0;
  border: 1px dashed rgba(249, 115, 22, 0.36);
  border-radius: 10px;
  background: rgba(255, 251, 235, 0.76);
  padding: 0.55rem;
  font-size: 0.78rem;
}

.broadcast-buttons-example code {
  white-space: pre-wrap;
  word-break: break-word;
}

.tg-preview {
  border: 1px solid rgba(249, 115, 22, 0.34);
  border-radius: 14px;
  background: rgba(255, 250, 240, 0.82);
  overflow: hidden;
}

.tg-preview-head {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid rgba(249, 115, 22, 0.2);
}

.tg-avatar {
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(145deg, #f59e0b, #f97316);
}

.tg-head-text {
  display: grid;
  line-height: 1.2;
}

.tg-head-text strong {
  font-size: 0.88rem;
}

.tg-head-text small {
  color: var(--ink-500);
  font-size: 0.72rem;
}

.tg-preview-body {
  padding: 0.75rem;
  background:
    radial-gradient(circle at 6% 0%, rgba(249, 115, 22, 0.15), transparent 45%),
    rgba(255, 255, 255, 0.62);
}

.tg-bubble {
  max-width: 100%;
  padding: 0.65rem 0.75rem;
  border-radius: 12px 12px 12px 5px;
  background: #fff;
  border: 1px solid rgba(148, 163, 184, 0.28);
  color: #111827;
  white-space: pre-wrap;
  word-break: break-word;
}

.tg-inline-preview {
  margin-top: 0.45rem;
  display: grid;
  gap: 0.35rem;
}

.tg-inline-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tg-inline-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2rem;
  padding: 0.35rem 0.7rem;
  border-radius: 10px;
  background: #e0f2fe;
  border: 1px solid rgba(14, 116, 144, 0.28);
  color: #0c4a6e;
  font-size: 0.8rem;
  max-width: 100%;
}

html[data-theme="dark"] .broadcast-guide {
  background: rgba(12, 12, 12, 0.88);
  border-color: rgba(251, 146, 60, 0.35);
}

html[data-theme="dark"] .guide-card {
  background: rgba(18, 18, 18, 0.95);
}

html[data-theme="dark"] .guide-index-list li {
  color: var(--ink-700);
}

html[data-theme="dark"] .tg-preview {
  background: rgba(12, 12, 12, 0.88);
  border-color: rgba(251, 146, 60, 0.35);
}

html[data-theme="dark"] .tg-preview-head {
  border-bottom-color: rgba(251, 146, 60, 0.24);
}

html[data-theme="dark"] .tg-preview-body {
  background:
    radial-gradient(circle at 6% 0%, rgba(249, 115, 22, 0.13), transparent 45%),
    rgba(12, 12, 12, 0.85);
}

html[data-theme="dark"] .tg-bubble {
  background: rgba(18, 18, 18, 0.96);
  border-color: rgba(251, 146, 60, 0.26);
  color: var(--ink-900);
}

html[data-theme="dark"] .broadcast-buttons-example {
  background: rgba(28, 25, 23, 0.9);
  border-color: rgba(251, 146, 60, 0.4);
}

html[data-theme="dark"] .tg-inline-btn {
  background: rgba(12, 74, 110, 0.42);
  border-color: rgba(56, 189, 248, 0.35);
  color: #bae6fd;
}

html[data-theme="dark"] .guide-card pre {
  background: rgba(28, 25, 23, 0.9);
  border-color: rgba(251, 146, 60, 0.4);
}

html[data-theme="dark"] .guide-title,
html[data-theme="dark"] .guide-card code {
  color: #fdba74;
}

@media (max-width: 900px) {
  .composer-tools .btn {
    flex: 1 1 calc(25% - 0.35rem);
  }
}
