:root {
  --bg: #0b1020;
  --bg-soft: #11182d;
  --panel: rgba(15, 23, 42, 0.84);
  --panel-strong: rgba(18, 28, 52, 0.94);
  --line: rgba(148, 163, 184, 0.18);
  --text: #edf2ff;
  --text-soft: #a9b6d3;
  --accent: #7dd3fc;
  --accent-strong: #38bdf8;
  --success: #4ade80;
  --danger: #fb7185;
  --warning: #fbbf24;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  --radius: 22px;
  --radius-sm: 14px;
  --font-main: "Trebuchet MS", "Gill Sans", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  font-family: var(--font-main);
  background:
    radial-gradient(circle at top left, rgba(56, 189, 248, 0.18), transparent 30%),
    radial-gradient(circle at bottom right, rgba(251, 191, 36, 0.12), transparent 32%),
    linear-gradient(180deg, #09111f 0%, #0d1427 48%, #111a33 100%);
  min-height: 100vh;
}

.shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: rgba(6, 10, 22, 0.55);
  backdrop-filter: blur(16px);
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent-strong), #2563eb);
  color: #04111f;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 700;
}

.brand-subtitle {
  color: var(--text-soft);
  font-size: 0.9rem;
}

.nav {
  display: grid;
  gap: 10px;
}

.nav-link,
.button {
  border: 0;
  border-radius: 16px;
  padding: 14px 16px;
  cursor: pointer;
  font: inherit;
  transition: transform 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

.nav-link {
  text-align: left;
  background: transparent;
  color: var(--text-soft);
}

.nav-link.active,
.nav-link:hover {
  background: rgba(125, 211, 252, 0.12);
  color: var(--text);
}

.sidebar-foot {
  margin-top: auto;
}

.content {
  padding: 28px;
}

.view {
  display: none;
  gap: 18px;
}

.view.active {
  display: grid;
}

.view-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
}

.view-head h1 {
  margin: 0 0 8px;
  font-size: 2rem;
}

.view-head p {
  margin: 0;
  color: var(--text-soft);
}

.toolbar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.9fr);
  gap: 18px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.table-card,
.detail-card,
.editor-card {
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 22px 0;
}

.card-head h2 {
  margin: 0;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--text-soft);
  font-weight: 700;
  font-size: 0.92rem;
  background: rgba(255, 255, 255, 0.02);
}

td code {
  color: var(--accent);
}

.input {
  width: 100%;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: var(--radius-sm);
  background: rgba(4, 10, 24, 0.55);
  color: var(--text);
  padding: 12px 14px;
  font: inherit;
}

.input::placeholder {
  color: rgba(169, 182, 211, 0.7);
}

.textarea {
  resize: vertical;
}

.select {
  min-width: 190px;
}

.stack-form {
  padding: 18px 22px 22px;
  display: grid;
  gap: 16px;
}

.field {
  display: grid;
  gap: 8px;
}

.field label {
  color: var(--text-soft);
}

.actions-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.button.primary {
  background: linear-gradient(135deg, #7dd3fc, #38bdf8);
  color: #062033;
  font-weight: 700;
}

.button.danger {
  background: linear-gradient(135deg, #fb7185, #f43f5e);
  color: white;
  font-weight: 700;
}

.button.ghost {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.button.wide {
  width: 100%;
}

.button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.preview-box {
  min-height: 180px;
  border-radius: 18px;
  border: 1px dashed rgba(148, 163, 184, 0.25);
  background: rgba(5, 11, 24, 0.5);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.preview-box img {
  width: 100%;
  max-height: 240px;
  object-fit: contain;
}

.preview-placeholder {
  color: var(--text-soft);
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(125, 211, 252, 0.12);
  color: var(--accent);
  font-size: 0.88rem;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 0.82rem;
}

.status-chip.published { color: var(--success); }
.status-chip.deleted_by_admin { color: var(--danger); }
.status-chip.pending_moderation,
.status-chip.pending_publication,
.status-chip.publication_failed { color: var(--warning); }

.inline-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.mini-btn {
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border-radius: 12px;
  padding: 8px 10px;
  cursor: pointer;
  font: inherit;
}

.mini-btn.warn { color: var(--warning); }
.mini-btn.danger { color: var(--danger); }

/* Кликабельные строки таблицы объявлений */
.ad-row {
  cursor: pointer;
  transition: background 0.12s ease;
}

.ad-row:hover {
  background: rgba(125, 211, 252, 0.06);
}

.ad-row.row-selected {
  background: rgba(125, 211, 252, 0.13);
  box-shadow: inset 3px 0 0 var(--accent);
}

/* Блок метаданных объявления в редакторе */
.ad-current-info {
  padding: 14px 22px 0;
}

.ad-current-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
}

.ad-meta-owner {
  color: var(--text-soft);
  font-size: 0.9rem;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ad-meta-stat {
  color: var(--text-soft);
  font-size: 0.88rem;
  white-space: nowrap;
}

.details-panel {
  padding: 20px 22px 22px;
  display: grid;
  gap: 16px;
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.detail-box {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.03);
}

.detail-box strong {
  display: block;
  color: var(--text-soft);
  margin-bottom: 6px;
}

.empty-state {
  color: var(--text-soft);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.stat-card {
  padding: 22px;
}

.stat-label {
  color: var(--text-soft);
  margin-bottom: 10px;
}

.stat-value {
  font-size: clamp(2rem, 4vw, 3.4rem);
  font-weight: 800;
}

.stat-sub {
  margin-top: 8px;
  color: var(--text-soft);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid rgba(125, 211, 252, 0.25);
  box-shadow: var(--shadow);
}

@media (max-width: 1100px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .split-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .content {
    padding: 18px;
  }

  .view-head {
    align-items: stretch;
    flex-direction: column;
  }

  .details-grid,
  .stats-grid {
    grid-template-columns: 1fr;
  }
}