:root {
  color-scheme: dark;
  --bg: #07101f;
  --panel: rgba(16, 31, 52, 0.82);
  --panel-strong: rgba(19, 39, 67, 0.95);
  --border: rgba(116, 178, 255, 0.18);
  --text: #eef7ff;
  --muted: #8ba7c7;
  --blue: #00a3ff;
  --blue-2: #3ad8ff;
  --danger: #ff5470;
  --ok: #52ffa8;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% 10%, rgba(0, 163, 255, 0.18), transparent 30rem),
    radial-gradient(circle at 80% 0%, rgba(58, 216, 255, 0.14), transparent 24rem),
    linear-gradient(135deg, #050914 0%, var(--bg) 50%, #08172e 100%);
  color: var(--text);
  overflow-x: hidden;
}

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

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

.bg-orb {
  position: fixed;
  width: 24rem;
  height: 24rem;
  border-radius: 999px;
  filter: blur(80px);
  opacity: 0.16;
  pointer-events: none;
}

.bg-orb-a {
  background: var(--blue);
  left: -8rem;
  top: 8rem;
}

.bg-orb-b {
  background: #815cff;
  right: -10rem;
  bottom: 8rem;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem clamp(1rem, 3vw, 2rem);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(22px);
  background: rgba(5, 10, 21, 0.72);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.brand-logo {
  display: grid;
  place-items: center;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 0.9rem;
  background: linear-gradient(135deg, var(--blue), #004dff);
  box-shadow: 0 0 34px rgba(0, 163, 255, 0.38);
}

.admin-chip {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--muted);
}

.admin-chip button,
.search-box button,
.login-form button,
.inline-form button,
.admin-form button {
  border: 0;
  border-radius: 1rem;
  color: white;
  background: linear-gradient(135deg, var(--blue), #0069ff);
  padding: 0.8rem 1rem;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(0, 105, 255, 0.24);
}

.admin-chip button {
  padding: 0.55rem 0.8rem;
  background: rgba(255,255,255,0.08);
  box-shadow: none;
}

.app-shell {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 1rem;
  width: min(1480px, calc(100% - 2rem));
  margin: 0 auto;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 5.4rem;
  display: grid;
  gap: 0.35rem;
  max-height: calc(100vh - 6rem);
  overflow: auto;
  margin-top: 2rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 1.4rem;
  background: rgba(8, 20, 38, 0.78);
  backdrop-filter: blur(22px);
}

.sidebar a {
  padding: 0.72rem 0.85rem;
  border-radius: 0.9rem;
  color: var(--muted);
}

.sidebar a:hover {
  color: var(--text);
  background: rgba(255,255,255,0.06);
}

.layout {
  width: 100%;
  padding: 2rem 0 4rem;
}

.login-card,
.hero-card,
.panel,
.stat-card {
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(24px);
}

.login-card {
  width: min(460px, 100%);
  margin: 10vh auto;
  padding: 2rem;
  border-radius: 2rem;
}

.login-card h1,
.hero-card h1,
.panel h1,
.panel h2 {
  margin: 0.75rem 0;
}

.login-card p,
.hero-card p,
.stat-card p,
.table-row span,
.mini-row span {
  color: var(--muted);
}

.badge {
  display: inline-flex;
  color: #b7ecff;
  border: 1px solid rgba(58, 216, 255, 0.28);
  background: rgba(0, 163, 255, 0.12);
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  font-size: 0.85rem;
}

.login-form,
.search-box {
  display: flex;
  gap: 0.75rem;
}

.search-box {
  align-items: stretch;
}

.search-box.wide {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  align-items: stretch;
}

.login-form {
  flex-direction: column;
  margin-top: 1.5rem;
}

.login-form label {
  display: grid;
  gap: 0.5rem;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 1rem;
  color: var(--text);
  background: rgba(1, 10, 23, 0.72);
  padding: 0.9rem 1rem;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(58, 216, 255, 0.7);
  box-shadow: 0 0 0 4px rgba(0, 163, 255, 0.12);
}

textarea {
  min-height: 7rem;
  resize: vertical;
}

.hero-card {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 2rem;
  align-items: center;
  border-radius: 2rem;
  padding: clamp(1.25rem, 3vw, 2rem);
}

.search-box.wide {
  margin: 1rem 0 1.4rem;
}

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

.cards-grid.compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stat-card,
.panel {
  border-radius: 1.4rem;
  padding: 1.25rem;
}

.stat-card span {
  color: var(--muted);
}

.stat-card strong {
  display: block;
  margin: 0.55rem 0;
  font-size: clamp(1.5rem, 4vw, 2.2rem);
}

.panel {
  margin-top: 1rem;
  background: var(--panel-strong);
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
}

.section-head p,
.count-line {
  color: var(--muted);
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0;
}

.tabs a,
.pill {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.42rem 0.72rem;
  color: var(--muted);
  background: rgba(255,255,255,0.04);
}

.tabs a.active,
.tabs a:hover {
  color: var(--text);
  border-color: rgba(58,216,255,0.5);
  background: rgba(0,163,255,0.14);
}

.pill {
  display: inline-flex;
  white-space: nowrap;
  font-size: 0.86rem;
}

.pill.ok {
  color: var(--ok);
  border-color: rgba(82,255,168,0.32);
}

.pill.danger {
  color: var(--danger);
  border-color: rgba(255,84,112,0.32);
}

.pill.muted {
  color: var(--muted);
}

.inline-form {
  display: inline-flex;
}

.inline-form button {
  padding: 0.5rem 0.72rem;
  border-radius: 0.75rem;
  background: rgba(0,163,255,0.18);
  box-shadow: none;
}

.inline-form button.danger-btn {
  background: rgba(255,84,112,0.18);
}

button.danger-btn {
  border-color: rgba(255,84,112,0.45) !important;
  background: rgba(255,84,112,0.18) !important;
}

.actions {
  display: flex !important;
  flex-wrap: wrap;
  gap: 0.35rem !important;
}

.admin-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}

.admin-form .check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
}

.admin-form .check input {
  width: auto;
}

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

.action-card {
  display: grid;
  gap: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 1.1rem;
  padding: 1rem;
  background: rgba(255,255,255,0.04);
}

.action-card h3 {
  margin: 0;
}

.action-card p,
.panel > p {
  color: var(--muted);
  margin: 0.2rem 0 0.6rem;
}

.action-card .check {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  color: var(--muted);
}

.action-card .check input {
  width: auto;
}

.bot-action-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.7rem;
  margin-top: 1rem;
}

.bot-action-grid a,
.bot-action-grid form,
.bot-action-grid button {
  width: 100%;
}

.bot-action-grid a,
.bot-action-grid button {
  display: grid;
  place-items: center;
  min-height: 3rem;
  border: 1px solid var(--border);
  border-radius: 1rem;
  color: var(--text);
  background: rgba(255,255,255,0.055);
  cursor: pointer;
}

.bot-action-grid a:hover,
.bot-action-grid button:hover {
  border-color: rgba(58,216,255,0.45);
  background: rgba(0,163,255,0.12);
}

.quick-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.8rem 0;
}

.compact-form {
  grid-template-columns: minmax(220px, 1fr) auto;
  max-width: 560px;
}

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

.server-toggle {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 0.85rem;
  background: rgba(255,255,255,0.035);
}

.server-toggle.selected {
  border-color: rgba(82,255,168,0.35);
  background: rgba(82,255,168,0.07);
}

.key-links {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.key-links > div {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1rem;
  background: rgba(255,255,255,0.035);
}

.key-links h3 {
  margin: 0 0 0.7rem;
}

.key-links code,
.key-links small {
  display: block;
  overflow-wrap: anywhere;
  color: #9fe9ff;
}

.key-links small {
  margin-top: 0.5rem;
  color: var(--muted);
}

.danger-zone {
  border-color: rgba(255,84,112,0.34);
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1rem;
  color: var(--muted);
}

.pager a {
  color: var(--blue-2);
}

.feature-list {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.75rem;
}

.feature-list div,
.empty {
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1rem;
  color: var(--muted);
  background: rgba(255,255,255,0.04);
}

.table-list,
.mini-table {
  display: grid;
  gap: 0.6rem;
}

.table-row,
.mini-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.3fr) repeat(4, minmax(90px, auto));
  gap: 1rem;
  align-items: center;
  border: 1px solid rgba(116, 178, 255, 0.13);
  border-radius: 1rem;
  padding: 0.9rem 1rem;
  background: rgba(255,255,255,0.035);
}

.table-row:hover {
  border-color: rgba(58, 216, 255, 0.5);
  background: rgba(0, 163, 255, 0.09);
}

.table-row.danger {
  border-color: rgba(255, 84, 112, 0.4);
}

.table-row div,
.mini-row div {
  display: grid;
  gap: 0.25rem;
}

.user-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.balance {
  font-size: 2rem;
  font-weight: 800;
  color: #b7ecff;
}

.alert {
  margin: 1rem 0;
  border: 1px solid rgba(255, 208, 97, 0.4);
  border-radius: 1rem;
  color: #ffe2a1;
  background: rgba(255, 208, 97, 0.1);
  padding: 1rem;
}

.alert.danger {
  border-color: rgba(255, 84, 112, 0.45);
  color: #ffb4c0;
  background: rgba(255, 84, 112, 0.1);
}

.alert.ok {
  border-color: rgba(82, 255, 168, 0.45);
  color: #b7ffd5;
  background: rgba(82, 255, 168, 0.1);
}

.back-link {
  color: var(--muted);
}

@media (max-width: 900px) {
  .app-shell {
    display: block;
  }

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

  .hero-card,
  .cards-grid,
  .cards-grid.compact,
  .feature-list,
  .action-grid,
  .bot-action-grid,
  .key-links,
  .server-grid,
  .admin-form,
  .table-row,
  .mini-row {
    grid-template-columns: 1fr;
  }

  .search-box {
    flex-direction: column;
  }

  .search-box.wide {
    grid-template-columns: 1fr;
  }

  .search-box button {
    width: 100%;
    min-width: 0;
  }
}

/* FML-style polish pass: cleaner glass cards, no overflowing text, finished admin sections. */
:root {
  --bg: #020712;
  --panel: rgba(8, 18, 34, 0.72);
  --panel-strong: rgba(10, 24, 45, 0.86);
  --border: rgba(122, 177, 255, 0.20);
  --text: #f4f9ff;
  --muted: #98add0;
  --blue: #0a84ff;
  --blue-2: #5ee7ff;
}

html {
  scroll-behavior: smooth;
}

body {
  background:
    radial-gradient(circle at 50% -12rem, rgba(10, 132, 255, 0.32), transparent 34rem),
    radial-gradient(circle at 92% 16rem, rgba(94, 231, 255, 0.16), transparent 28rem),
    linear-gradient(135deg, #020712 0%, #061426 52%, #020712 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.32;
  background-image:
    linear-gradient(rgba(94, 231, 255, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(94, 231, 255, 0.06) 1px, transparent 1px);
  background-size: 52px 52px;
  mask-image: radial-gradient(circle at top, black, transparent 72%);
}

.topbar {
  padding: 1.15rem clamp(1rem, 4vw, 3rem);
  background: rgba(2, 7, 18, 0.76);
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.24);
}

.app-shell {
  grid-template-columns: 278px minmax(0, 1fr);
  gap: 1.35rem;
  width: min(1540px, calc(100% - 2.5rem));
}

.sidebar,
.panel,
.stat-card,
.hero-card,
.login-card {
  border-color: rgba(122, 177, 255, 0.18);
  box-shadow: 0 24px 90px rgba(0, 0, 0, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.sidebar,
.panel {
  border-radius: 1.75rem;
}

.sidebar a {
  min-width: 0;
  overflow-wrap: anywhere;
}

.sidebar a:hover {
  transform: translateX(2px);
}

.hero-card {
  border-radius: 2.25rem;
  min-height: 220px;
  background:
    radial-gradient(circle at 72% 24%, rgba(10, 132, 255, 0.24), transparent 22rem),
    linear-gradient(135deg, rgba(9, 24, 48, 0.88), rgba(5, 14, 29, 0.86));
}

.panel {
  padding: clamp(1rem, 2vw, 1.55rem);
}

.panel h1,
.panel h2,
.hero-card h1 {
  letter-spacing: -0.035em;
}

.admin-chip button,
.search-box button,
.login-form button,
.inline-form button,
.admin-form button,
.tariff-form button,
.reply-form button {
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

button:hover,
.inline-form button:hover,
.tariff-form button:hover,
.reply-form button:hover {
  transform: translateY(-1px);
}

button,
.search-box button,
.inline-form button,
.admin-form button,
.tariff-form button,
.reply-form button,
.filters-form button,
.reset-link {
  white-space: nowrap;
  word-break: keep-all;
  overflow-wrap: normal;
  min-width: max-content;
}

.search-box button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 8rem;
}

.table-row,
.mini-row {
  grid-template-columns: minmax(0, 1.4fr) repeat(4, minmax(0, 0.72fr));
  min-width: 0;
  border-radius: 1.15rem;
  background: rgba(255, 255, 255, 0.045);
}

.table-row > *,
.mini-row > *,
.stat-card,
.panel,
.action-card,
.server-toggle,
.key-links > div {
  min-width: 0;
}

.table-row *,
.mini-row *,
.panel *,
.stat-card * {
  overflow-wrap: anywhere;
}

.mini-row:hover {
  border-color: rgba(94, 231, 255, 0.36);
  background: rgba(10, 132, 255, 0.08);
}

code,
pre,
.long-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

pre {
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1rem;
  color: #bfeeff;
  background: rgba(0, 0, 0, 0.20);
}

details {
  margin-top: 0.8rem;
}

summary {
  cursor: pointer;
  color: var(--blue-2);
}

.admin-form,
.tariff-form {
  align-items: end;
}

.tariff-list {
  display: grid;
  gap: 1rem;
}

.tariff-card {
  border: 1px solid var(--border);
  border-radius: 1.5rem;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.035);
}

.tariff-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.9fr);
  gap: 1rem;
  align-items: start;
  margin-bottom: 1rem;
}

.tariff-head h2 {
  margin: 0.65rem 0 0.25rem;
}

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

.tariff-form label,
.reply-form label {
  display: grid;
  gap: 0.38rem;
  color: var(--muted);
}

.tariff-form .full,
.tariff-form button {
  grid-column: 1 / -1;
}

.tariff-form textarea {
  min-height: 8rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88rem;
}

.ticket-thread {
  display: grid;
  gap: 0.8rem;
}

.message-bubble {
  width: min(760px, 100%);
  border: 1px solid var(--border);
  border-radius: 1.2rem;
  padding: 0.95rem;
  background: rgba(255, 255, 255, 0.045);
}

.message-bubble.admin {
  justify-self: end;
  border-color: rgba(82, 255, 168, 0.28);
  background: rgba(82, 255, 168, 0.075);
}

.message-meta {
  margin-bottom: 0.45rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.attachments-block {
  margin-top: 1.2rem;
}

.attachments-block h3 {
  margin: 0 0 0.75rem;
  color: var(--blue-2);
}

.attachments-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.85rem;
}

.attachment-card,
.message-media {
  min-width: 0;
}

.attachment-card {
  display: grid;
  gap: 0.75rem;
  border: 1px solid rgba(122, 177, 255, 0.20);
  border-radius: 1.15rem;
  padding: 0.85rem;
  background: rgba(255, 255, 255, 0.045);
}

.media-preview {
  display: block;
  width: min(360px, 100%);
  overflow: hidden;
  border: 1px solid rgba(122, 177, 255, 0.24);
  border-radius: 1rem;
  background: rgba(0, 0, 0, 0.22);
}

.message-bubble.admin .media-preview {
  border-color: rgba(82, 255, 168, 0.28);
}

.media-preview img {
  display: block;
  width: 100%;
  max-height: 420px;
  object-fit: contain;
  background: rgba(0, 0, 0, 0.18);
}

.media-meta {
  display: grid;
  gap: 0.35rem;
  min-width: 0;
}

.media-meta span,
.media-meta p {
  margin: 0;
  color: var(--muted);
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.media-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.55rem;
}

.media-actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(94, 231, 255, 0.28);
  border-radius: 999px;
  padding: 0.42rem 0.7rem;
  color: #c8f4ff;
  background: rgba(10, 132, 255, 0.12);
  line-height: 1.15;
}

.media-actions a:hover {
  border-color: rgba(94, 231, 255, 0.55);
  background: rgba(10, 132, 255, 0.20);
}

.media-file,
.media-file-icon {
  display: grid;
  align-items: center;
  gap: 0.3rem;
  border: 1px solid rgba(122, 177, 255, 0.22);
  border-radius: 1rem;
  padding: 0.85rem;
  background: rgba(255, 255, 255, 0.04);
}

.media-file {
  grid-template-columns: auto minmax(0, 1fr);
}

.media-file small {
  color: var(--muted);
}

.media-file-icon {
  place-items: center;
  min-height: 8rem;
  font-size: 2.2rem;
}

.reply-form {
  display: grid;
  gap: 0.85rem;
}

.filters-form {
  display: grid;
  grid-template-columns: minmax(240px, 1.6fr) repeat(3, minmax(160px, 0.8fr)) auto auto;
  gap: 0.75rem;
  align-items: end;
  border: 1px solid rgba(122, 177, 255, 0.18);
  border-radius: 1.2rem;
  padding: 0.9rem;
  background: rgba(255, 255, 255, 0.035);
}

.filters-form label {
  display: grid;
  gap: 0.35rem;
  min-width: 0;
  color: var(--muted);
}

.filters-form button {
  border: 0;
  border-radius: 0.9rem;
  color: white;
  background: linear-gradient(135deg, var(--blue), #0069ff);
  padding: 0.82rem 1rem;
  cursor: pointer;
}

.reset-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.9rem;
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  padding: 0.75rem 0.9rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
}

input[type="file"] {
  padding: 0.75rem;
}

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

@media (max-width: 1180px) {
  .cards-grid,
  .cards-grid.compact,
  .feature-list,
  .action-grid,
  .tariff-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .table-row,
  .mini-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 0.7fr);
  }

  .tariff-head {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .app-shell {
    width: min(100% - 1rem, 760px);
  }

  .sidebar {
    margin-top: 1rem;
  }

  .layout {
    padding-top: 1rem;
  }
}

/* Final density/responsive layer: fixes "слиплось" across all admin pages. */
.layout {
  display: grid;
  gap: 1.25rem;
}

.panel {
  margin-top: 0;
}

.panel > * + * {
  margin-top: 1rem;
}

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

.section-head h1,
.panel > h1,
.panel > h2 {
  margin: 0;
  line-height: 1.08;
}

.section-head p,
.panel > p {
  margin-top: 0.5rem;
  line-height: 1.55;
}

.back-link {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.9rem;
  color: var(--muted);
  line-height: 1.2;
}

.user-head {
  gap: 1.25rem;
}

.user-head h1 {
  margin: 0.75rem 0 0.45rem;
  line-height: 1.05;
}

.user-head p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.cards-grid {
  margin: 1.1rem 0 0;
}

.stat-card {
  padding: 1.05rem;
}

.stat-card strong {
  line-height: 1.08;
}

.stat-card p {
  line-height: 1.35;
}

.table-list,
.mini-table,
.tariff-list,
.ticket-thread {
  gap: 0.8rem;
}

.mini-table {
  margin-top: 0.85rem;
}

.table-row,
.mini-row {
  gap: 0.8rem 1rem;
  align-items: center;
  line-height: 1.35;
}

.table-row strong,
.mini-row strong {
  line-height: 1.18;
}

.table-row span,
.mini-row span {
  line-height: 1.35;
}

.empty {
  line-height: 1.45;
}

.tabs {
  gap: 0.65rem;
  margin: 1.1rem 0;
}

.tabs a,
.pill,
.badge {
  line-height: 1.2;
}

.search-box.wide {
  margin: 1rem 0 1.2rem;
}

.count-line {
  margin: 0.75rem 0 0.45rem;
}

.action-grid,
.bot-action-grid,
.server-grid,
.key-links,
.settings-grid {
  gap: 1rem;
}

.action-card,
.server-toggle,
.key-links > div,
.tariff-card,
.message-bubble {
  line-height: 1.45;
}

.tariff-card {
  padding: 1.15rem;
}

.tariff-form,
.reply-form,
.admin-form {
  gap: 0.9rem;
}

@media (max-width: 1280px) {
  .app-shell {
    grid-template-columns: 246px minmax(0, 1fr);
    width: min(100% - 1.5rem, 1180px);
  }

  .panel h1,
  .hero-card h1 {
    font-size: clamp(1.7rem, 3.1vw, 2.45rem);
  }

  .panel h2 {
    font-size: clamp(1.35rem, 2.3vw, 1.9rem);
  }
}

@media (max-width: 980px) {
  body {
    font-size: 15px;
  }

  .topbar {
    padding: 0.8rem 1rem;
  }

  .brand-logo {
    width: 2.1rem;
    height: 2.1rem;
    border-radius: 0.75rem;
  }

  .app-shell {
    display: block;
    width: min(100% - 1rem, 820px);
  }

  .layout {
    gap: 0.9rem;
    padding: 0.9rem 0 2rem;
  }

  .sidebar {
    position: static;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    max-height: none;
    margin: 0.85rem 0 0;
    padding: 0.55rem;
    border-radius: 1.1rem;
  }

  .sidebar a {
    padding: 0.55rem 0.65rem;
    border-radius: 0.75rem;
    font-size: 0.92rem;
  }

  .hero-card,
  .panel {
    border-radius: 1.25rem;
    padding: 1rem;
  }

  .hero-card {
    min-height: 0;
  }

  .panel > * + * {
    margin-top: 0.82rem;
  }

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

  .cards-grid,
  .cards-grid.compact,
  .feature-list,
  .action-grid,
  .settings-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
  }

  .bot-action-grid,
  .key-links,
  .server-grid,
  .admin-form,
  .tariff-form,
  .filters-form {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .table-row,
  .mini-row {
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    gap: 0.55rem;
    padding: 0.85rem;
    border-radius: 0.95rem;
  }

  .table-row div,
  .mini-row div {
    gap: 0.32rem;
  }

  .tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 0.25rem;
    scrollbar-width: thin;
  }

  .tabs a {
    flex: 0 0 auto;
    padding: 0.5rem 0.75rem;
    font-size: 0.95rem;
  }

  input,
  select,
  textarea {
    border-radius: 0.85rem;
    padding: 0.75rem 0.85rem;
  }

  .search-box {
    flex-direction: column;
  }

  .stat-card strong {
    font-size: clamp(1.25rem, 5vw, 1.75rem);
  }

  .balance {
    font-size: 1.55rem;
  }
}

@media (max-width: 640px) {
  body {
    font-size: 14px;
  }

  .topbar {
    gap: 0.7rem;
  }

  .brand span:last-child {
    display: none;
  }

  .admin-chip {
    gap: 0.5rem;
  }

  .admin-chip span {
    max-width: 8rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

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

  .layout {
    gap: 0.75rem;
  }

  .panel,
  .hero-card,
  .stat-card {
    border-radius: 1rem;
  }

  .panel {
    padding: 0.9rem;
  }

  .panel h1,
  .hero-card h1 {
    font-size: clamp(1.55rem, 8vw, 2rem);
  }

  .panel h2 {
    font-size: clamp(1.2rem, 6vw, 1.55rem);
  }

  .user-head {
    display: grid;
  }

  .user-head h1 {
    font-size: clamp(1.65rem, 9vw, 2.15rem);
  }

  .cards-grid,
  .cards-grid.compact,
  .feature-list,
  .action-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .badge {
    max-width: 100%;
    white-space: normal;
    border-radius: 0.8rem;
  }

  .back-link {
    margin-bottom: 0.75rem;
  }

  .mini-table {
    margin-top: 0.65rem;
  }

  .table-list,
  .mini-table {
    gap: 0.62rem;
  }

  .table-row,
  .mini-row,
  .empty {
    padding: 0.78rem;
  }

  .tariff-card {
    padding: 0.85rem;
  }

  .tariff-head {
    gap: 0.75rem;
  }

  .actions,
  .quick-buttons {
    gap: 0.45rem !important;
  }

  .inline-form,
  .inline-form button,
  .quick-buttons .inline-form {
    width: 100%;
  }

  .quick-buttons {
    display: grid;
    grid-template-columns: 1fr;
  }
}

@media (max-width: 980px) {
  .attachments-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .media-preview {
    width: 100%;
  }

  .filters-form {
    grid-template-columns: 1fr;
  }
}

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

  .media-preview img {
    max-height: 320px;
  }

  .media-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
}
