:root {
  --bg: #0a0a0a;
  --bg-elev: #111111;
  --bg-card: #151515;
  --bg-card-2: #1a1a1a;
  --bg-card-hover: #1f1f1f;
  --border: #262626;
  --border-strong: #383838;
  --text: #f5f5f5;
  --text-muted: #9a9a9a;
  --text-soft: #6a6a6a;

  --primary: #e11d2e;
  --primary-2: #ef4444;
  --primary-soft: rgba(225, 29, 46, 0.1);
  --primary-glow: rgba(225, 29, 46, 0.28);
  --accent: #e11d2e;
  --accent-soft: rgba(225, 29, 46, 0.1);

  --ok: #16a34a;
  --ok-soft: rgba(22, 163, 74, 0.12);
  --warn: #ca8a04;
  --warn-soft: rgba(202, 138, 4, 0.12);
  --err: #dc2626;
  --err-soft: rgba(220, 38, 38, 0.12);
  --info: #737373;
  --info-soft: rgba(115, 115, 115, 0.14);

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.6);

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --t-fast: 120ms;
  --t-base: 180ms;
  --t-slow: 320ms;

  --sidebar-w: 244px;
  --topbar-h: 60px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 14.5px;
  line-height: 1.5;
}

a {
  color: var(--text);
  text-decoration: none;
  transition: color var(--t-fast) var(--ease);
}
a:hover { color: var(--primary-2); text-decoration: none; }

img { max-width: 100%; }

button { font-family: inherit; }

:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 6px;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #2a2e44, #232639);
  border-radius: 8px;
  border: 2px solid var(--bg);
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #353b57, #2a2e44);
  background-clip: padding-box;
}

/* ---------- Layout ---------- */

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  background: #0d0d0d;
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  gap: 18px;
}

.sidebar-brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 6px 8px 14px;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand .logo {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 900;
  letter-spacing: -0.04em;
  font-size: 13px;
  box-shadow: 0 4px 14px rgba(225, 29, 46, 0.35);
}
.sidebar-brand .name {
  font-weight: 700;
  letter-spacing: -0.01em;
  font-size: 16px;
}
.sidebar-brand .sub {
  color: var(--text-soft);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 2px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  flex: 1;
  padding-right: 4px;
}
.nav-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-soft);
  padding: 12px 10px 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  color: var(--text-muted);
  font-weight: 500;
  position: relative;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.nav-item:hover {
  background: var(--bg-card);
  color: var(--text);
  text-decoration: none;
}
.nav-item.active {
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
  box-shadow: inset 0 0 0 1px var(--border);
}
.nav-item.active::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 6px;
  bottom: 6px;
  width: 3px;
  border-radius: 0 4px 4px 0;
  background: var(--primary);
}
.nav-item .nav-ico {
  width: 18px;
  display: inline-flex;
  justify-content: center;
}
.nav-item .nav-badge {
  margin-left: auto;
  background: var(--err-soft);
  color: var(--err);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
}

.sidebar-foot {
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--r-md);
  flex: 1;
  background: var(--bg-card);
}
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  background: #2a2a2a;
  color: #fff;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  border: 1px solid var(--border-strong);
}
.user-chip .meta { line-height: 1.2; min-width: 0; }
.user-chip .name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
}
.user-chip .role {
  font-size: 11px;
  color: var(--text-muted);
}
.icon-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 10px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: 0.15s;
}
.icon-btn:hover { color: #fff; background: var(--bg-card-hover); }

/* ---------- Top bar ---------- */

.main-area {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  background: rgba(10, 10, 10, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 12px 28px;
  display: flex;
  align-items: center;
  gap: 16px;
  z-index: 10;
}
.topbar h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.topbar .crumbs {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 2px;
}
.topbar .right {
  margin-left: auto;
  display: flex;
  gap: 10px;
  align-items: center;
}

.content {
  padding: 24px 28px 64px;
  animation: fadeUp var(--t-slow) var(--ease-out) both;
}
.content-narrow {
  max-width: 880px;
  margin: 0 auto;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: none; }
}
@keyframes pop {
  0%   { transform: scale(0.96); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* ---------- Cards / Surfaces ---------- */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px;
}
.card.hover { transition: 0.18s; }
.card.hover:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.card-title {
  font-size: 12px;
  text-transform: uppercase;
  color: var(--text-soft);
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 12px;
}
.card-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.grid { display: grid; gap: 16px; }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

@media (max-width: 1100px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .grid.cols-4, .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; }
}

.stat-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  overflow: hidden;
}
.stat-card .label {
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.stat-card .value {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.stat-card .meta {
  color: var(--text-soft);
  font-size: 12px;
}
.stat-card .ico {
  position: absolute;
  right: 14px;
  top: 14px;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  border: 1px solid var(--border);
  font-size: 16px;
}
.stat-card.green .ico { background: var(--ok-soft); color: var(--ok); border-color: rgba(22, 163, 74, 0.25); }
.stat-card.red .ico,
.stat-card.cyan .ico { background: var(--primary-soft); color: var(--primary-2); border-color: rgba(225, 29, 46, 0.25); }
.stat-card.warn .ico { background: var(--warn-soft); color: var(--warn); border-color: rgba(202, 138, 4, 0.25); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--bg-card);
  color: var(--text);
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  text-decoration: none !important;
  transition: background var(--t-fast) var(--ease),
              transform var(--t-fast) var(--ease),
              filter var(--t-fast) var(--ease),
              box-shadow var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease);
  white-space: nowrap;
  user-select: none;
  position: relative;
}
.btn { border-color: var(--border); }
.btn:hover { background: var(--bg-card-hover); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.btn.primary:hover { background: var(--primary-2); border-color: var(--primary-2); }
.btn.ghost {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text);
}
.btn.ghost:hover { background: rgba(255, 255, 255, 0.04); border-color: var(--text-soft); }
.btn.danger {
  background: var(--err);
  color: #fff;
  border-color: var(--err);
}
.btn.danger:hover { background: #b91c1c; border-color: #b91c1c; }
.btn.success {
  background: var(--ok);
  color: #fff;
  border-color: var(--ok);
}
.btn.success:hover { background: #15803d; border-color: #15803d; }
.btn.warn {
  background: var(--warn);
  color: #fff;
  border-color: var(--warn);
}
.btn.warn:hover { background: #a16207; border-color: #a16207; }
.btn.sm { padding: 6px 11px; font-size: 12px; border-radius: 8px; }
.btn.lg { padding: 13px 20px; font-size: 15px; border-radius: 12px; }
.btn.icon { padding: 8px; width: 36px; height: 36px; }
.btn[disabled], .btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; filter: grayscale(0.3); }
.btn .ico {
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
}

.btn-group { display: inline-flex; gap: 8px; flex-wrap: wrap; }

/* Кнопка-чип (для пресетов сумм и т.п.) */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
}
.chip:hover { color: var(--text); border-color: var(--text-soft); }
.chip.active {
  background: var(--primary-soft);
  color: var(--primary-2);
  border-color: rgba(225, 29, 46, 0.4);
}

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.input,
.select,
textarea.input {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 14px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--t-fast) var(--ease),
              box-shadow var(--t-fast) var(--ease),
              background var(--t-fast) var(--ease);
  width: 100%;
}
.input::placeholder { color: var(--text-soft); }
.input:hover:not(:focus) { border-color: var(--border-strong); }
.input:focus,
.select:focus,
textarea.input:focus {
  border-color: var(--text-soft);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.08);
  background: var(--bg-card);
}
textarea.input { min-height: 90px; resize: vertical; line-height: 1.5; }
.input.compact { padding: 8px 12px; font-size: 13px; }
.input.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 13px; letter-spacing: 0.02em; }
.input-hint {
  font-size: 11.5px;
  color: var(--text-soft);
  margin-top: 4px;
}

.search-input {
  position: relative;
  display: flex;
  align-items: center;
}
.search-input .ico {
  position: absolute; left: 12px;
  color: var(--text-soft);
  pointer-events: none;
}
.search-input .input { padding-left: 36px; }

/* ---------- Pills / Chips ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
}
.pill.ok { background: var(--ok-soft); color: #4ade80; border-color: rgba(22, 163, 74, 0.3); }
.pill.warn { background: var(--warn-soft); color: #facc15; border-color: rgba(202, 138, 4, 0.3); }
.pill.err { background: var(--err-soft); color: #f87171; border-color: rgba(220, 38, 38, 0.3); }
.pill.info { background: rgba(255, 255, 255, 0.04); color: var(--text-muted); border-color: var(--border); }
.pill.brand { background: var(--primary-soft); color: var(--primary-2); border-color: rgba(225, 29, 46, 0.35); }
.pill.muted { background: rgba(255, 255, 255, 0.03); color: var(--text-muted); border-color: var(--border); }
.pill .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
}

/* ---------- Tabs ---------- */
.tabs {
  display: inline-flex;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 4px;
  border-radius: 12px;
  gap: 4px;
}
.tabs a {
  padding: 7px 14px;
  border-radius: 8px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 13px;
  text-decoration: none;
}
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active {
  background: var(--primary);
  color: #fff;
}

/* ---------- Tables ---------- */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-soft);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}
.table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--bg-card); }

/* ---------- Pagination ---------- */
.pager {
  display: inline-flex;
  gap: 6px;
  margin-top: 18px;
}
.pager a, .pager span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 13px;
  text-decoration: none;
  border: 1px solid var(--border);
}
.pager a:hover { color: var(--text); background: var(--bg-card-hover); text-decoration: none; }
.pager .current {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.pager .disabled { opacity: 0.4; pointer-events: none; }

/* ---------- Models grid ---------- */
.models-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.model-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: 0.15s;
}
.model-card:hover {
  border-color: var(--primary);
  transform: translateY(-3px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.5);
}
.model-card a { color: inherit; text-decoration: none; }
.model-card .photo {
  aspect-ratio: 3/4;
  background: #0d0d0d;
  position: relative;
  display: grid;
  place-items: center;
  color: var(--text-soft);
  overflow: hidden;
}
.model-card .photo img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transition: 0.4s;
}
.model-card:hover .photo img { transform: scale(1.05); }
.model-card .photo .badge {
  position: absolute;
  top: 10px; left: 10px;
  background: rgba(13, 15, 22, 0.7);
  backdrop-filter: blur(8px);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
}
.model-card .photo .badge.tg {
  right: 10px; left: auto;
  background: rgba(225, 29, 46, 0.2);
  color: #fca5a5;
  border: 1px solid rgba(225, 29, 46, 0.4);
}
.model-card .body {
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.model-card .name {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
}
.model-card .row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-muted);
  font-size: 12px;
}

/* ---------- Model details ---------- */
.model-detail {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: 24px;
  align-items: start;
}
.model-detail > .model-main { min-width: 0; }
.model-detail > .model-side { min-width: 0; }
@media (max-width: 980px) {
  .model-detail { grid-template-columns: 1fr; gap: 16px; }
}
.gallery {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
@media (max-width: 1200px) { .gallery { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 720px)  { .gallery { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 480px)  { .gallery { grid-template-columns: repeat(2, 1fr); } }
.gallery .thumb {
  aspect-ratio: 1;
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--bg-card);
  cursor: pointer;
}
.gallery .thumb img { width: 100%; height: 100%; object-fit: cover; transition: 0.3s; }
.gallery .thumb:hover img { transform: scale(1.06); }

.gallery-main {
  aspect-ratio: 16/9;
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--bg-card);
  margin-bottom: 0;
  border: 1px solid var(--border);
}
.gallery-main img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }

.model-summary { padding: 14px; }
.model-summary-row { display: flex; gap: 14px; align-items: center; }
.model-summary-pic {
  width: 84px; height: 84px; border-radius: 50%;
  overflow: hidden; flex: 0 0 auto;
  background: var(--bg-card-2); border: 1px solid var(--border);
}
.model-summary-pic img { width: 100%; height: 100%; object-fit: cover; }
.model-summary-pic .placeholder {
  width: 100%; height: 100%; display: grid; place-items: center;
  font-size: 32px; color: var(--text-soft);
}
.model-summary-meta { flex: 1; min-width: 0; }

@media (max-width: 640px) {
  .model-summary { padding: 12px; }
  .model-summary-row { gap: 10px; }
  .model-summary-pic { width: 64px; height: 64px; }
  .gallery-main { aspect-ratio: 4/3; }
}

.info-block {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  white-space: pre-wrap;
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  line-height: 1.65;
  color: var(--text);
  max-height: 600px;
  overflow: auto;
}
.info-block b, .info-block strong { color: #fff; font-weight: 600; }
.info-block code { background: rgba(255, 255, 255, 0.06); padding: 1px 5px; border-radius: 4px; color: var(--primary-2); }
.info-block i, .info-block em { color: var(--text-muted); }

/* ---------- Notice / Alert ---------- */
.alert {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  align-items: flex-start;
  margin-bottom: 14px;
  animation: pop var(--t-base) var(--ease-out);
}
.alert::before {
  content: "";
  width: 4px;
  border-radius: 2px;
  align-self: stretch;
  background: currentColor;
  opacity: 0.6;
  flex-shrink: 0;
}
.alert.ok { background: var(--ok-soft); color: #bbf7d0; border-color: rgba(22, 163, 74, 0.3); }
.alert.ok::before { color: var(--ok); }
.alert.warn { background: var(--warn-soft); color: #fde68a; border-color: rgba(202, 138, 4, 0.3); }
.alert.warn::before { color: var(--warn); }
.alert.err { background: var(--err-soft); color: #fecaca; border-color: rgba(220, 38, 38, 0.4); }
.alert.err::before { color: var(--err); }
.alert.info { background: rgba(255, 255, 255, 0.04); color: var(--text); border-color: var(--border-strong); }
.alert.info::before { color: var(--text-muted); }
.alert > div { flex: 1; min-width: 0; }

/* ---------- Login page ---------- */
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(800px 500px at 50% 0%, rgba(225, 29, 46, 0.08), transparent 70%),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 32px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.login-card .logo-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}
.login-card .logo-block .logo {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 900;
  font-size: 19px;
  letter-spacing: -0.05em;
  box-shadow: 0 8px 22px rgba(239, 68, 68, 0.35);
  box-shadow: 0 8px 24px rgba(225, 29, 46, 0.4);
}
.login-card h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.login-card p {
  color: var(--text-muted);
  margin: 6px 0 0;
}
.tg-widget-wrap {
  display: grid;
  place-items: center;
  margin: 28px 0 14px;
  min-height: 64px;
}
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-soft);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 22px 0 16px;
}
.divider::before, .divider::after {
  content: ""; flex: 1;
  height: 1px;
  background: var(--border);
}
.help {
  color: var(--text-soft);
  font-size: 12px;
  margin-top: 16px;
  line-height: 1.6;
}
.help code {
  background: rgba(255, 255, 255, 0.05);
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--text);
  border: 1px solid var(--border);
}

/* ---------- Photos preview ---------- */
.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
}
.preview-grid .item {
  aspect-ratio: 1;
  border-radius: var(--r-md);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-card);
  position: relative;
}
.preview-grid .item img { width: 100%; height: 100%; object-fit: cover; }
.preview-grid .item .x {
  position: absolute; top: 4px; right: 4px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 13px;
}

.dropzone {
  display: block;
  border: 2px dashed var(--border-strong);
  border-radius: var(--r-lg);
  padding: 36px 20px;
  text-align: center;
  background: var(--bg-card);
  transition: border-color var(--t-fast) var(--ease),
              background var(--t-fast) var(--ease),
              transform var(--t-fast) var(--ease);
  cursor: pointer;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--primary);
  background: var(--primary-soft);
  transform: translateY(-1px);
}
.dropzone .big {
  font-size: 22px;
  margin-bottom: 6px;
  color: var(--text);
  font-weight: 700;
}
.dropzone .sub { color: var(--text-muted); font-size: 13px; }

/* ---------- Spinner ---------- */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
.spinner.lg { width: 32px; height: 32px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 9, 14, 0.78);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn var(--t-base) var(--ease);
}
.modal-backdrop.show { display: flex; }
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-xl);
  padding: 24px;
  max-width: 520px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  animation: pop var(--t-slow) var(--ease-out);
}
.modal h3 {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 10px;
}
.modal .modal-ico {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.modal .modal-ico.danger { background: var(--err-soft); color: var(--err); }
.modal .modal-ico.warn { background: var(--warn-soft); color: var(--warn); }
.modal .modal-ico.info { background: var(--info-soft); color: var(--info); }
.modal .modal-ico.ok { background: var(--ok-soft); color: var(--ok); }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ---------- Misc ---------- */
.muted { color: var(--text-muted); }
.soft { color: var(--text-soft); }
.flex { display: flex; gap: 10px; align-items: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.grow { flex: 1; }
.gap-8 { gap: 8px; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }
.text-c { text-align: center; }
.nowrap { white-space: nowrap; }
.kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  border: 1px solid var(--border);
  color: var(--text);
}

.code-block {
  background: #0c0d14;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 14px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12.5px;
  white-space: pre-wrap;
  word-break: break-word;
  color: #d1d5db;
  max-height: 360px;
  overflow: auto;
}

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px;
}
.lightbox.show { display: flex; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 12px; }
.lightbox .close {
  position: absolute; top: 18px; right: 18px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  width: 40px; height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  cursor: pointer;
  border: none;
  font-size: 20px;
}

/* ---------- Mobile ---------- */
.mobile-toggle {
  display: none;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 40px; height: 40px;
  align-items: center;
  justify-content: center;
  color: var(--text);
  cursor: pointer;
}

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 280px;
    transform: translateX(-100%);
    transition: 0.25s ease;
    z-index: 50;
  }
  .sidebar.open { transform: translateX(0); }
  .mobile-toggle { display: inline-flex; }
  .topbar { padding: 12px 16px; }
  .content { padding: 18px 16px 56px; }
}

.scrim {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 40;
}
.scrim.show { display: block; }

/* selection */
::selection { background: var(--primary); color: #fff; }

/* ---------- Toast (slide-in) ---------- */
#toast-container {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 1000;
  pointer-events: none;
  max-width: calc(100vw - 40px);
}
.toast {
  pointer-events: all;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px 12px 12px;
  border-radius: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  min-width: 280px;
  max-width: 380px;
  animation: slideInRight var(--t-slow) var(--ease-out);
  position: relative;
}
.toast.fade-out {
  animation: fadeOut var(--t-base) var(--ease) forwards;
}
@keyframes fadeOut {
  to { opacity: 0; transform: translateX(20px); }
}
.toast .ico {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  font-size: 14px;
  font-weight: 800;
}
.toast.ok .ico { background: var(--ok-soft); color: #4ade80; }
.toast.err .ico { background: var(--err-soft); color: var(--primary-2); }
.toast.warn .ico { background: var(--warn-soft); color: #facc15; }
.toast.info .ico { background: rgba(255, 255, 255, 0.06); color: var(--text); }
.toast .body {
  flex: 1;
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--text);
  word-wrap: break-word;
  min-width: 0;
}
.toast .x {
  background: transparent;
  border: none;
  color: var(--text-soft);
  cursor: pointer;
  padding: 4px 6px;
  font-size: 16px;
  border-radius: 6px;
  transition: all var(--t-fast);
}
.toast .x:hover { color: var(--text); background: var(--bg-card-hover); }

/* ---------- Sticky actions side panel ---------- */
@media (min-width: 981px) {
  .sticky-actions { position: sticky; top: calc(var(--topbar-h) + 16px); }
}

/* ---------- Danger zone ---------- */
.danger-zone {
  border: 1px dashed rgba(248, 113, 113, 0.4);
  border-radius: var(--r-md);
  padding: 14px;
  background: rgba(248, 113, 113, 0.04);
}
.danger-zone .danger-zone-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--err);
  margin-bottom: 8px;
  font-weight: 700;
}

/* ---------- Mobile-friendly tables ---------- */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ---------- Skeleton loaders ---------- */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-2) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  border-radius: 6px;
}
@keyframes shimmer {
  to { background-position: -200% 0; }
}

/* ---------- Status indicator dot ---------- */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-soft);
  margin-right: 6px;
  position: relative;
}
.status-dot.ok { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); }
.status-dot.warn { background: var(--warn); box-shadow: 0 0 0 4px var(--warn-soft); }
.status-dot.err { background: var(--err); box-shadow: 0 0 0 4px var(--err-soft); }
.status-dot.live::after {
  content: "";
  position: absolute; inset: -4px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.4;
  animation: pulse 1.6s ease-out infinite;
}
@keyframes pulse {
  0% { transform: scale(0.8); opacity: 0.5; }
  100% { transform: scale(1.6); opacity: 0; }
}

/* ---------- Page hero ---------- */
.page-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border-radius: var(--r-lg);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  margin-bottom: 18px;
}
.page-hero .ico {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 18px;
  flex-shrink: 0;
  border: 1px solid var(--border);
}

/* ---------- Topbar improvements ---------- */
.topbar-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none !important;
  transition: all var(--t-fast);
}
.topbar-pill:hover { color: var(--text); border-color: var(--text-soft); }
.topbar-pill.warn { border-color: rgba(202, 138, 4, 0.5); color: #fbbf24; }
.topbar-pill.ok { border-color: rgba(22, 163, 74, 0.5); color: #4ade80; }
.topbar-pill.err { border-color: rgba(220, 38, 38, 0.5); color: var(--primary-2); }

/* Sidebar nav badge for waiting users etc. */
.nav-item .nav-count {
  margin-left: auto;
  background: var(--warn-soft);
  color: var(--warn);
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  min-width: 18px;
  text-align: center;
}

/* ---------- Quick action grid ---------- */
.quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}
.quick-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 16px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  text-decoration: none !important;
  color: var(--text);
  transition: all var(--t-fast) var(--ease);
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.quick-action:hover {
  border-color: var(--primary);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}
.quick-action .ico {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  border: 1px solid var(--border);
  transition: all var(--t-fast);
}
.quick-action:hover .ico {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* ---------- Helper: copy button ---------- */
.copy-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 6px;
  border: 1px solid var(--border);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12.5px;
  cursor: pointer;
  transition: all var(--t-fast);
  user-select: all;
  word-break: break-all;
  color: var(--text);
}
.copy-row:hover { background: var(--bg-card-hover); border-color: var(--text-soft); }
.copy-row::after {
  content: "⧉";
  margin-left: auto;
  color: var(--text-soft);
  font-size: 13px;
  flex-shrink: 0;
}

/* ---------- Section titles inside cards ---------- */
.subhead {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-soft);
  margin: 12px 0 6px;
  font-weight: 700;
}

/* nav-section-title spacing fix when followed by item */
.nav-section-title:first-child { padding-top: 0; }

/* ---------- Bootstrap Icons sizing helpers ---------- */
.bi { display: inline-block; vertical-align: -0.125em; line-height: 1; }
.btn .bi { font-size: 1em; }
.nav-item .bi {
  font-size: 16px;
  width: 18px;
  display: inline-flex;
  justify-content: center;
}
.stat-card .ico .bi { font-size: 16px; }
.quick-action .ico .bi { font-size: 18px; }
.modal-ico .bi { font-size: 18px; }
.toast .ico .bi { font-size: 14px; }
.page-hero .ico .bi { font-size: 18px; }
.sidebar-brand .logo .bi { font-size: 20px; }

/* Кнопка-action для inline-операций (как Bootstrap btn-link, но в нашей палитре) */
.icon-action {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--t-fast);
  font-size: 14px;
  text-decoration: none !important;
}
.icon-action:hover { background: var(--bg-card-hover); color: var(--text); border-color: var(--border); }
.icon-action.danger:hover { color: var(--primary-2); border-color: var(--primary); background: var(--primary-soft); }

/* ============================================================
   Mobile tuning — детальная адаптация под смартфоны
   ============================================================ */

/* Планшет/небольшой ноут */
@media (max-width: 900px) {
  :root { --topbar-h: 56px; }
  .topbar h1 { font-size: 18px; }
  .page-hero { padding: 14px 16px; }
  .card { padding: 14px; }
  .stat-card .value { font-size: 22px; }
  .btn { padding: 8px 12px; font-size: 13px; }
  .btn.sm { padding: 6px 10px; font-size: 12px; }
  .input, .input.compact { font-size: 14px; }
  .table th, .table td { padding: 10px 8px; font-size: 13px; }
  .tabs { overflow-x: auto; gap: 4px; -webkit-overflow-scrolling: touch; scrollbar-width: none; flex-wrap: nowrap; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs a { white-space: nowrap; }
}

/* Смартфон */
@media (max-width: 640px) {
  :root { --topbar-h: 52px; }
  body { font-size: 14px; }

  .topbar {
    position: sticky; top: 0; z-index: 30;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 10px 12px;
  }
  .topbar h1 {
    font-size: 16px; font-weight: 700;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 55vw;
  }
  .topbar .crumbs { display: none; }
  .topbar .right { gap: 6px; flex-wrap: nowrap; }
  .topbar .right .topbar-pill {
    padding: 5px 8px; font-size: 11.5px;
    max-width: 120px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .topbar .right .btn {
    padding: 8px 10px; font-size: 12.5px;
  }
  .topbar .right .btn .bi { font-size: 15px; }

  .content { padding: 14px 12px 72px; }

  /* Карточки и сетки — в один столбец */
  .grid.cols-4, .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; gap: 10px; }
  .grid { gap: 10px; }
  .card { padding: 12px; border-radius: 12px; }
  .card-head { flex-wrap: wrap; gap: 8px; }
  .card-head h2 { font-size: 15px; }

  .stat-card .label { font-size: 11px; }
  .stat-card .value { font-size: 20px; }
  .stat-card .ico { width: 28px; height: 28px; right: 10px; top: 10px; }
  .stat-card .ico .bi { font-size: 13px; }

  /* Кнопки */
  .btn { padding: 9px 12px; font-size: 13px; }
  .btn.sm { padding: 6px 10px; font-size: 12px; }
  .btn-group { flex-wrap: wrap; gap: 4px; }
  .btn-group form { display: inline-flex; }
  .btn-group .btn.sm { padding: 5px 8px; font-size: 11.5px; }

  /* Формы */
  .field label { font-size: 12.5px; }
  .input, textarea.input, select.input {
    font-size: 16px; /* чтобы iOS не зумил */
    padding: 10px 12px;
  }
  .input.compact { font-size: 14px; padding: 8px 10px; }

  /* Таблицы — горизонтальный скролл + тонкая типографика */
  .table-responsive { margin: 0 -12px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-responsive .table { min-width: 520px; }
  .table th, .table td { padding: 8px 6px; font-size: 12.5px; }
  .table .nowrap { white-space: nowrap; }

  /* Page-hero компактнее */
  .page-hero { padding: 10px 12px; border-radius: 10px; gap: 10px; }
  .page-hero .ico { width: 36px; height: 36px; font-size: 16px; }
  .page-hero > div > div:first-child { font-size: 14px !important; }

  /* Pager */
  .pager { flex-wrap: wrap; justify-content: center; gap: 4px; }
  .pager a, .pager span { padding: 6px 10px; min-width: 32px; font-size: 13px; }

  /* Quick actions grid — 2 в ряд */
  .quick-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 8px; }
  .quick-action { padding: 14px 10px; font-size: 12px; }
  .quick-action .ico { width: 32px; height: 32px; }
  .quick-action .ico .bi { font-size: 16px; }

  /* Tabs — скролл */
  .tabs { gap: 4px; padding-bottom: 4px; }
  .tabs a { padding: 6px 10px; font-size: 12.5px; }

  /* Модалки */
  .modal { padding: 12px; }
  .modal-body { max-width: 100%; padding: 16px; border-radius: 14px; }
  .modal-body h3 { font-size: 16px; }
  .modal-actions { flex-wrap: wrap; gap: 8px; }
  .modal-actions .btn { flex: 1 1 100%; justify-content: center; }

  /* Тосты */
  #toast-container { left: 12px; right: 12px; bottom: 12px; }
  .toast { min-width: 0; max-width: 100%; width: 100%; }

  /* Сайдбар на мобиле — шире */
  .sidebar { width: 84vw !important; max-width: 320px; }
  .nav-item { padding: 10px 12px; font-size: 14px; }

  /* Login — центрируем и делаем узкий */
  .login-card { max-width: 100% !important; padding: 18px; }

  /* Типичные формы с двумя колонками */
  .grid[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }

  /* Кастомные блоки */
  .danger-zone { padding: 12px; }
  .sticky-actions { position: static !important; }

  /* Иконки-действия чуть крупнее для тапа */
  .icon-action { width: 34px; height: 34px; font-size: 15px; }
}

/* Узкий телефон (≤ 380px) */
@media (max-width: 380px) {
  .topbar h1 { font-size: 15px; }
  .card { padding: 10px; }
  .btn { padding: 8px 10px; font-size: 12.5px; }
  .quick-grid { grid-template-columns: 1fr !important; }
  .stat-card .value { font-size: 18px; }
}

