@import url("https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700;800&family=Space+Grotesk:wght@500;600;700&display=swap");

:root {
  --bg: #07090c;
  --bg-elev: #0c1016;
  --panel: rgba(16, 22, 30, 0.88);
  --panel-solid: #121820;
  --panel-2: #171e28;
  --line: rgba(90, 120, 140, 0.22);
  --line-strong: rgba(47, 211, 197, 0.35);
  --text: #edf3f8;
  --muted: #8a9aab;
  --accent: #2fd3c5;
  --accent-2: #9b6dff;
  --accent-dim: rgba(47, 211, 197, 0.12);
  --violet-dim: rgba(155, 109, 255, 0.12);
  --danger: #ff5d6c;
  --ok: #3dba7a;
  --radius: 14px;
  --control-h: 44px;
  --gap: 14px;
  --font: "Outfit", sans-serif;
  --display: "Space Grotesk", "Outfit", sans-serif;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --glow: 0 0 0 1px rgba(47, 211, 197, 0.2), 0 0 28px rgba(47, 211, 197, 0.12);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }

body {
  margin: 0;
  display: flex;
  min-height: 100vh;
  color: var(--text);
  font-family: var(--font);
  background:
    radial-gradient(900px 520px at 8% -10%, rgba(47, 211, 197, 0.16), transparent 55%),
    radial-gradient(780px 480px at 100% 0%, rgba(155, 109, 255, 0.12), transparent 50%),
    radial-gradient(700px 420px at 70% 110%, rgba(47, 211, 197, 0.06), transparent 45%),
    linear-gradient(180deg, #090c11 0%, #07090c 100%);
  background-attachment: fixed;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at center, black 20%, transparent 75%);
  z-index: 0;
}

.sidebar,
.content {
  position: relative;
  z-index: 1;
}

/* ——— Sidebar ——— */
.sidebar {
  width: 248px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 24px 16px;
  border-right: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(14, 20, 28, 0.96), rgba(8, 11, 16, 0.98));
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 2px 6px 22px;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid rgba(47, 211, 197, 0.65);
  background:
    linear-gradient(145deg, rgba(47, 211, 197, 0.18), rgba(12, 18, 24, 0.95));
  color: #f4fffd;
  font-family: var(--display);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  box-shadow: var(--glow);
}

.brand-text {
  font-family: var(--display);
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, #fff 20%, #9ff7ee 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
}

.sidebar a {
  color: var(--muted);
  text-decoration: none;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-weight: 500;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.sidebar a:hover {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  transform: translateX(2px);
}

.sidebar a.active {
  background: linear-gradient(90deg, var(--accent-dim), rgba(155, 109, 255, 0.08));
  border-color: rgba(47, 211, 197, 0.35);
  color: #e8fffc;
  box-shadow: inset 3px 0 0 var(--accent);
}

.sidebar .logout {
  color: var(--muted);
  margin-top: 10px;
  border: 1px solid var(--line);
}

.sidebar .logout:hover {
  border-color: rgba(255, 93, 108, 0.4);
  color: #ffc4ca;
}

/* ——— Content ——— */
.content {
  flex: 1;
  min-width: 0;
  padding: 30px 34px 48px;
  max-width: 1420px;
}

.content.full {
  display: grid;
  place-items: center;
  max-width: none;
  width: 100%;
  padding: 28px 18px;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--gap);
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.page-head h1,
h1 {
  margin: 0 0 8px;
  font-family: var(--display);
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.page-head .muted,
.lead {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
  max-width: 54ch;
}

h2 {
  margin: 0 0 12px;
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.muted { color: var(--muted); }
.muted a { color: var(--accent); }

.row-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--gap);
  flex-wrap: wrap;
}

.stack { display: flex; flex-direction: column; gap: var(--gap); }
.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

/* ——— Panels / cards ——— */
.panel,
.create-card,
.edit-card,
.card-form,
.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.create-card,
.edit-card,
.card-form {
  padding: 18px 18px 20px;
  margin-bottom: 14px;
  position: relative;
  overflow: hidden;
}

.create-card::before,
.edit-card::before,
.card-form::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(47, 211, 197, 0.35), rgba(155, 109, 255, 0.25), transparent);
}

.create-card h2,
.edit-card h2,
.card-form h2 {
  margin-top: 0;
}

.login-card {
  width: min(420px, 100%);
  padding: 32px 28px 28px;
  text-align: left;
  position: relative;
  overflow: hidden;
  animation: rise-in 0.55s ease both;
}

.login-card::after {
  content: "";
  position: absolute;
  inset: -40% -20% auto auto;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(47, 211, 197, 0.2), transparent 70%);
  pointer-events: none;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.login-brand .brand-mark {
  width: 52px;
  height: 52px;
  font-size: 1rem;
  border-radius: 14px;
}

.login-card h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.7rem;
}

.login-card .lead {
  margin-top: 4px;
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 20px;
  position: relative;
  z-index: 1;
}

@keyframes rise-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

/* ——— Forms ——— */
label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: var(--muted);
  font-size: 0.84rem;
  min-width: 0;
}

input,
select,
textarea,
button,
.link-btn {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  min-height: var(--control-h);
  background: rgba(7, 10, 14, 0.85);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  padding: 0 14px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea { min-height: 96px; padding: 12px 14px; resize: vertical; }

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(47, 211, 197, 0.55);
  box-shadow: 0 0 0 3px rgba(47, 211, 197, 0.14);
}

button,
.login-card button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--control-h);
  padding: 0 18px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, #3ae0d2, #23c4b7);
  color: #06221f;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 8px 22px rgba(47, 211, 197, 0.25);
  transition: transform 0.15s ease, filter 0.15s ease;
}

button:hover { filter: brightness(1.06); transform: translateY(-1px); }
button.danger {
  background: linear-gradient(135deg, #ff6d7a, #e25b5b);
  color: #fff;
  box-shadow: 0 8px 22px rgba(226, 91, 91, 0.25);
}
button.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  box-shadow: none;
}

.link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--control-h);
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}

.link-btn:hover { color: var(--text); border-color: rgba(47, 211, 197, 0.35); }

.form-row,
.create-grid,
.edit-grid,
.section-add-cat,
.catalog-search {
  display: grid;
  gap: 12px;
  align-items: end;
}

.create-grid {
  grid-template-columns: minmax(0, 1.2fr) minmax(160px, 0.9fr) minmax(120px, 0.55fr) auto;
}

.edit-grid {
  grid-template-columns: minmax(0, 1fr) minmax(140px, 180px) minmax(120px, 160px) auto;
  margin-top: 12px;
}

.section-add-cat {
  grid-template-columns: minmax(0, 1.3fr) minmax(160px, 0.9fr) auto auto;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.catalog-search {
  grid-template-columns: minmax(0, 1fr) 180px auto auto;
  margin-bottom: 14px;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.edit-actions { display: flex; gap: 8px; }

.bulk-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.alert {
  background: rgba(255, 93, 108, 0.12);
  border: 1px solid rgba(255, 93, 108, 0.4);
  color: #ffc9cf;
  padding: 10px 12px;
  border-radius: 12px;
}

.check-row {
  color: var(--text) !important;
  flex-direction: row !important;
  align-items: center;
}

.check-row input {
  width: auto;
  min-height: auto;
}

/* ——— Stats ——— */
.grid.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat {
  background: linear-gradient(160deg, rgba(18, 26, 34, 0.95), rgba(12, 16, 22, 0.92));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 98px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.stat::after {
  content: "";
  position: absolute;
  right: -20px;
  top: -30px;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(47, 211, 197, 0.16), transparent 70%);
}

.stat:hover {
  border-color: rgba(47, 211, 197, 0.3);
  transform: translateY(-2px);
}

.stat span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  position: relative;
  z-index: 1;
}

.stat strong {
  font-family: var(--display);
  font-size: 1.45rem;
  letter-spacing: -0.03em;
  position: relative;
  z-index: 1;
}

/* ——— Tables ——— */
.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th, td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(0, 0, 0, 0.28);
  position: sticky;
  top: 0;
}

tbody tr:hover { background: rgba(47, 211, 197, 0.03); }
.row-off td { opacity: 0.55; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 8px;
  background: #1c2a33;
  font-size: 0.78rem;
  white-space: nowrap;
}

.badge.ok { background: rgba(61, 186, 122, 0.16); color: #9be7b8; }
.badge.bad { background: rgba(255, 93, 108, 0.16); color: #ffb4b4; }

code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.86em;
  color: #b8f5ec;
  background: rgba(47, 211, 197, 0.08);
  padding: 2px 6px;
  border-radius: 6px;
}

/* ——— Catalog ——— */
.section-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.chip {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
  font-size: 0.88rem;
}

.chip span { color: var(--muted); }
.chip.active {
  border-color: rgba(47, 211, 197, 0.5);
  background: var(--accent-dim);
  color: #d7fffa;
}

.catalog-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.catalog-side {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  position: sticky;
  top: 16px;
  box-shadow: var(--shadow);
}

.side-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.cat-list { max-height: calc(100vh - 140px); overflow: auto; }

.cat-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 11px 14px;
  text-decoration: none;
  color: var(--text);
  border-bottom: 1px solid rgba(36, 48, 58, 0.8);
}

.cat-item:hover { background: rgba(255, 255, 255, 0.025); }
.cat-item.active {
  background: var(--accent-dim);
  border-left: 3px solid var(--accent);
}
.cat-item.off .cat-name { color: var(--muted); text-decoration: line-through; }
.cat-meta { color: var(--muted); font-size: 0.75rem; }
.tiny { font-size: 0.8rem; margin-top: 4px; }
.pad { padding: 14px; }

.note {
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.9rem;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px dashed rgba(47, 211, 197, 0.25);
  background: rgba(47, 211, 197, 0.04);
}

/* ——— Responsive ——— */
@media (max-width: 1100px) {
  .grid.stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .catalog-layout { grid-template-columns: 1fr; }
  .catalog-side { position: static; }
  .cat-list { max-height: 240px; }
  .edit-grid,
  .create-grid,
  .section-add-cat,
  .catalog-search { grid-template-columns: 1fr; }
  .edit-grid button,
  .create-grid button,
  .section-add-cat button,
  .catalog-search button,
  .section-add-cat .link-btn { width: 100%; }
}

@media (max-width: 800px) {
  body { flex-direction: column; }
  .sidebar {
    width: 100%;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 14px;
  }
  .sidebar nav {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .sidebar .logout { margin-top: 0; }
  .content { padding: 18px 16px 28px; }
  .grid.stats { grid-template-columns: 1fr 1fr; }
  .page-head h1, h1 { font-size: 1.45rem; }
}
