/* Aurora_v2 — лёгкая современная тема. Без внешних зависимостей.
   Палитра взята с agatha.amofess.ru: тёмная — чёрно-синий фон с cyan-акцентом,
   светлая — небесно-голубой фон с глубоким синим акцентом. */
:root {
  --bg: #030712;
  --bg-elev: #060b18;
  --bg-elev-2: #0b1526;
  --glass: rgba(6, 11, 24, .72);
  --glass-2: rgba(6, 11, 24, .55);
  --blob-1: rgba(8, 145, 178, .14);
  --blob-2: rgba(29, 78, 216, .08);
  --grid-line: rgba(6, 182, 212, .045);
  --border: rgba(8, 145, 178, .3);
  --text: #d1d5db;
  --text-dim: #9ca3af;
  --accent: #06b6d4;
  --accent-2: #e879f9;
  --danger: #f87171;
  --warn: #f5c451;
  --ok: #34d399;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 28px rgba(0, 0, 0, .5);
  --overlay: rgba(0, 0, 0, .65);
  --sidebar-w: 300px;
  --btn-text: #04121c;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

[data-theme="light"] {
  --bg: #e0f2fe;
  --bg-elev: #cbebfd;
  --bg-elev-2: #b9e2fc;
  --glass: rgba(186, 230, 253, .60);
  --glass-2: rgba(186, 230, 253, .45);
  --blob-1: rgba(14, 165, 233, .20);
  --blob-2: rgba(3, 105, 161, .10);
  --grid-line: rgba(3, 105, 161, .055);
  --border: rgba(3, 105, 161, .3);
  --text: #0c4a6e;
  --text-dim: #0369a1;
  --accent: #0369a1;
  --accent-2: #86198f;
  --danger: #b91c1c;
  --warn: #a16207;
  --ok: #047857;
  --shadow: 0 8px 28px rgba(3, 105, 161, .15);
  --overlay: rgba(3, 105, 161, .30);
  --btn-text: #f0f9ff;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
/* Фон в стиле agatha.amofess.ru: два мягких блоба + едва заметная сетка.
   Статичны (без анимации) — не тратят GPU в покое; blur «стекла» виден именно за их счёт. */
body::before {
  content: "";
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(560px circle at 12% -8%, var(--blob-1), transparent 70%),
    radial-gradient(640px circle at 88% 108%, var(--blob-2), transparent 70%),
    repeating-linear-gradient(0deg, var(--grid-line) 0 1px, transparent 1px 44px),
    repeating-linear-gradient(90deg, var(--grid-line) 0 1px, transparent 1px 44px);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ── */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 14px;
  font-weight: 700; font-size: 1.1rem;
  border-bottom: 1px solid var(--border);
}
.brand .logo {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center; color: var(--btn-text); font-weight: 800;
}
.nav { padding: 12px 10px; flex: 1; }
.nav-group { margin: 14px 8px 6px; font-size: .72rem; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text-dim); }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--text); text-decoration: none; margin-bottom: 2px;
  transition: background .12s ease;
}
.nav a:hover { background: var(--bg-elev-2); text-decoration: none; }
.nav a.active { background: var(--bg-elev-2); box-shadow: inset 3px 0 0 var(--accent); }
.nav a .ico { width: 20px; text-align: center; }
.sidebar-foot { padding: 12px; border-top: 1px solid var(--border); font-size: .85rem; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 14px 24px; border-bottom: 1px solid var(--border);
  background: var(--glass);
  position: sticky; top: 0; z-index: 10; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.content { padding: 24px; max-width: 1200px; width: 100%; }
.page-title { margin: 0 0 18px; font-size: 1.4rem; }

/* ── Cards ── */
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.card {
  background: var(--glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 12px; font-size: 1rem; }
.stat { font-size: 1.9rem; font-weight: 700; }
.stat-label { color: var(--text-dim); font-size: .85rem; }

/* ── Forms ── */
label { display: block; font-size: .85rem; color: var(--text-dim); margin: 0 0 5px; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-elev-2);
  color: var(--text); font: inherit; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
.field { margin-bottom: 14px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 160px; }

button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
  background: var(--accent); color: var(--btn-text); font: inherit; font-weight: 600;
  cursor: pointer; transition: filter .12s ease, transform .05s ease;
}
button:hover, .btn:hover { filter: brightness(1.08); text-decoration: none; }
button:active { transform: translateY(1px); }
button.ghost, .btn.ghost { background: transparent; color: var(--text); border-color: var(--border); }
button.danger, .btn.danger { background: var(--danger); color: var(--btn-text); }
button.small { padding: 6px 10px; font-size: .85rem; }
button.icon-btn { padding: 8px; width: 38px; height: 38px; font-size: 1.05rem; }
button.icon-btn.small { width: 30px; height: 30px; padding: 4px; font-size: .95rem; }

/* ── Tables ── */
.table-wrap {
  overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--glass-2); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-dim); }
tr:last-child td { border-bottom: none; }

/* ── Badges / alerts ── */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: .72rem; font-weight: 700; vertical-align: middle;
}
.badge.dev { background: color-mix(in srgb, var(--warn) 25%, transparent); color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent); }
.badge.admin { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--accent); }
.badge.user { background: var(--bg-elev-2); color: var(--text-dim); }
.badge.ok { background: color-mix(in srgb, var(--ok) 22%, transparent); color: var(--ok); }
.badge.off { background: color-mix(in srgb, var(--danger) 20%, transparent); color: var(--danger); }

.flash { padding: 11px 14px; border-radius: var(--radius-sm); margin-bottom: 14px; border: 1px solid var(--border); }
.flash.ok { border-color: color-mix(in srgb, var(--ok) 50%, transparent); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.flash.error { border-color: color-mix(in srgb, var(--danger) 50%, transparent); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.muted { color: var(--text-dim); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.spinner {
  width: 15px; height: 15px; border: 2px solid var(--text-dim);
  border-top-color: transparent; border-radius: 50%;
  display: inline-block; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mb-0 { margin-bottom: 0; }

/* ── Карточка товара (предпросмотр в аудите) ── */
.card-preview { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.card-preview-img {
  width: 120px; height: 120px; object-fit: cover; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-elev-2);
}

/* ── Login ── */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 380px; }
.login-card .brand { border: none; justify-content: center; padding-bottom: 4px; }

@media (max-width: 820px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; }
  .nav { display: flex; flex-wrap: wrap; gap: 4px; }
  .nav-group { width: 100%; }
  .content { padding: 16px; }
}

/* Табы (вкладки внутри страницы) */
.tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.tab {
  background: transparent; color: var(--muted); border: 1px solid var(--border);
  padding: 8px 16px; border-radius: 8px; cursor: pointer; font-size: .9rem;
}
.tab:hover { color: var(--text); border-color: var(--accent); }
.tab.active { background: var(--accent); color: var(--btn-text); border-color: var(--accent); }

/* ── Обзор: блоки статистики и QR-модалка ── */
.dash-grid { gap: 12px; }
.dash-block {
  background: var(--glass-2);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px 16px;
}
.dash-block.clickable { cursor: pointer; transition: border-color .12s ease, transform .05s ease; }
.dash-block.clickable:hover { border-color: var(--accent); }
.dash-block.clickable:active { transform: translateY(1px); }
.dash-block .stat.accent { color: var(--accent); }
.dash-inline { display: flex; gap: 12px; flex-wrap: wrap; }
.dash-inline .dash-block { flex: 1; min-width: 140px; }
.modal-overlay {
  position: fixed; inset: 0; background: var(--overlay);
  display: grid; place-items: center; z-index: 100; padding: 20px;
}
.modal {
  background: var(--glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; width: 100%; max-width: 480px;
  max-height: 85vh; overflow-y: auto;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.qr-list { display: flex; flex-direction: column; gap: 16px; }
.qr-item { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.qr-item canvas { border-radius: var(--radius-sm); }
.qr-info { flex: 1; min-width: 140px; }

/* Фолбэк для браузеров без backdrop-filter: стекло становится непрозрачным */
@supports not ((backdrop-filter: blur(10px)) or (-webkit-backdrop-filter: blur(10px))) {
  .sidebar, .card, .modal, .topbar { background: var(--bg-elev); }
  .dash-block, .table-wrap { background: var(--bg-elev-2); }
}
