:root {
  --bg: #0b0d12;
  --panel: #141821;
  --panel-2: #1a1f2b;
  --panel-3: #202635;
  --text: #f4f6fb;
  --muted: #9ea7ba;
  --line: #2b3343;
  --accent: #8b5cf6;
  --accent-2: #5b7cfa;
  --danger: #ef4444;
  --success: #22c55e;
  --shadow: 0 24px 60px rgba(0,0,0,.35);
  --radius: 18px;
}
* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 0%, rgba(139,92,246,.14), transparent 32%),
    radial-gradient(circle at 100% 12%, rgba(91,124,250,.12), transparent 28%),
    var(--bg);
  font: 15px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 32px; }
.login-card {
  width: min(560px, 100%);
  padding: 56px;
  text-align: center;
  background: linear-gradient(180deg, rgba(26,31,43,.96), rgba(20,24,33,.96));
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
}
.brand-mark { color: var(--accent); font-size: 54px; line-height: 1; text-shadow: 0 0 30px rgba(139,92,246,.55); }
.brand-mark.small { font-size: 24px; }
.eyebrow { margin: 10px 0 4px; color: #b9a5ff; font-size: 12px; font-weight: 800; letter-spacing: .18em; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 12px; font-size: clamp(32px, 5vw, 52px); line-height: 1.05; letter-spacing: -.035em; }
h2 { margin-bottom: 10px; font-size: 28px; }
.login-copy { max-width: 440px; margin: 0 auto 28px; color: var(--muted); font-size: 17px; }
.fineprint { margin: 16px 0 0; color: #727d92; font-size: 12px; }

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 9px 15px; border: 1px solid transparent; border-radius: 11px;
  cursor: pointer; transition: .18s ease; font-weight: 750;
}
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .55; transform: none; }
.button-primary { color: white; background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 10px 24px rgba(91,124,250,.22); }
.button-primary:hover { filter: brightness(1.08); }
.button-ghost { color: var(--text); background: #151a24; border-color: var(--line); }
.button-ghost:hover { background: var(--panel-3); }
.button-danger { color: #fecaca; background: rgba(239,68,68,.12); border-color: rgba(239,68,68,.35); }
.button-large { min-height: 50px; padding-inline: 22px; font-size: 16px; }

.site-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: 14px 28px; border-bottom: 1px solid rgba(43,51,67,.8);
  background: rgba(11,13,18,.82); backdrop-filter: blur(18px);
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 850; font-size: 17px; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.profile-chip { display: flex; align-items: center; gap: 10px; padding: 6px 12px 6px 7px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; }
.profile-chip div { display: grid; line-height: 1.2; }
.profile-chip span { color: var(--muted); font-size: 12px; }
.avatar { width: 34px; height: 34px; object-fit: cover; border-radius: 50%; background: var(--panel-3); }

.page-shell { width: min(1380px, calc(100% - 40px)); margin: 0 auto; padding: 28px 0 64px; }
.tabs { display: flex; gap: 8px; margin-bottom: 28px; }
.tab-button { padding: 11px 18px; color: var(--muted); background: transparent; border: 1px solid transparent; border-radius: 12px; cursor: pointer; font-weight: 800; }
.tab-button:hover { color: var(--text); background: rgba(255,255,255,.03); }
.tab-button.active { color: white; background: linear-gradient(135deg, rgba(139,92,246,.22), rgba(91,124,250,.18)); border-color: rgba(139,92,246,.35); }

.hero-row { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 26px; }
.hero-row h1 { margin-bottom: 8px; font-size: clamp(34px, 5vw, 58px); }
.muted { color: var(--muted); }
.balance-card { min-width: 245px; padding: 18px 20px; border: 1px solid var(--line); border-radius: 16px; background: linear-gradient(145deg, rgba(139,92,246,.13), rgba(91,124,250,.05)); }
.balance-card span, .balance-card small { display: block; color: var(--muted); }
.balance-card strong { display: block; margin: 2px 0; font-size: 32px; }

.filters-panel {
  display: grid; grid-template-columns: minmax(240px, 1.5fr) repeat(4, minmax(140px, .7fr)) auto;
  gap: 12px; align-items: end; padding: 16px; margin-bottom: 16px;
  border: 1px solid var(--line); border-radius: var(--radius); background: rgba(20,24,33,.86);
}
.filters-panel label, .form-grid label { display: grid; gap: 7px; }
.filters-panel label > span, .form-grid label > span { color: var(--muted); font-size: 12px; font-weight: 750; }
input, select, textarea {
  width: 100%; color: var(--text); background: #0f131b; border: 1px solid var(--line); border-radius: 10px; outline: none;
  padding: 10px 12px; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(139,92,246,.12); }
textarea { min-height: 110px; resize: vertical; }
.filters-reset { white-space: nowrap; }
.catalog-meta { display: flex; justify-content: space-between; margin: 18px 2px; color: var(--muted); }

.catalog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; }
.product-card {
  overflow: hidden; display: flex; flex-direction: column; min-height: 100%;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 12px 34px rgba(0,0,0,.18);
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.product-card:hover { transform: translateY(-4px); border-color: rgba(139,92,246,.52); box-shadow: 0 20px 42px rgba(0,0,0,.3); }
.product-image-wrap { aspect-ratio: 4 / 3; overflow: hidden; background: linear-gradient(135deg, #232a3b, #151924); cursor: pointer; }
.product-image { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .35s ease; }
.product-card:hover .product-image { transform: scale(1.035); }
.image-placeholder { width: 100%; height: 100%; display: grid; place-items: center; color: #6f7890; font-size: 38px; }
.product-body { display: flex; flex-direction: column; flex: 1; padding: 16px; }
.product-topline { min-height: 24px; }
.category-badge { display: inline-flex; padding: 4px 8px; border-radius: 999px; color: #c7baff; background: rgba(139,92,246,.13); font-size: 11px; font-weight: 800; }
.product-name { margin: 10px 0 7px; font-size: 19px; line-height: 1.25; cursor: pointer; }
.product-description { margin-bottom: 18px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.product-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: auto; }
.product-price { font-size: 18px; }
.product-price::after { content: ' кэшбэка'; color: var(--muted); font-size: 12px; font-weight: 500; }

.placeholder-card, .empty-state {
  padding: 70px 30px; text-align: center; border: 1px dashed var(--line); border-radius: 22px; background: rgba(20,24,33,.6);
}
.placeholder-card p { max-width: 620px; margin: 0 auto 20px; color: var(--muted); }
.placeholder-icon { margin-bottom: 12px; color: var(--accent); font-size: 44px; }
.status-pill { display: inline-flex; padding: 5px 9px; border: 1px solid rgba(139,92,246,.28); border-radius: 999px; color: #c8bbff; background: rgba(139,92,246,.1); font-size: 12px; font-weight: 800; }

.product-dialog { width: min(860px, calc(100% - 28px)); padding: 0; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); }
.product-dialog::backdrop { background: rgba(3,5,9,.78); backdrop-filter: blur(7px); }
.dialog-close { position: absolute; top: 12px; right: 12px; z-index: 2; width: 38px; height: 38px; border: 1px solid rgba(255,255,255,.12); border-radius: 50%; color: white; background: rgba(0,0,0,.45); cursor: pointer; font-size: 24px; }
.dialog-image-wrap { aspect-ratio: 16 / 7; overflow: hidden; background: var(--panel-3); border-radius: 22px 22px 0 0; }
.dialog-image { width: 100%; height: 100%; object-fit: cover; }
.dialog-content { padding: 26px; }
.dialog-content h2 { margin-top: 12px; font-size: 32px; }
.dialog-description { color: var(--muted); white-space: pre-wrap; }
.dialog-footer { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: 26px; padding-top: 20px; border-top: 1px solid var(--line); }
.dialog-price { font-size: 25px; }
.dialog-price::after { content: ' кэшбэка'; color: var(--muted); font-size: 13px; font-weight: 500; }

.toast { position: fixed; right: 22px; bottom: 22px; z-index: 100; max-width: 380px; padding: 13px 16px; color: white; background: #252b3a; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.toast.error { border-color: rgba(239,68,68,.45); background: #321b22; }
.toast.success { border-color: rgba(34,197,94,.4); background: #173120; }

/* Admin */
.admin-shell { width: min(1320px, calc(100% - 40px)); margin: 0 auto; padding: 30px 0 70px; }
.admin-grid { display: grid; grid-template-columns: 340px 1fr; gap: 22px; align-items: start; }
.admin-panel { padding: 20px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.admin-panel h2 { font-size: 22px; }
.section-header { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-bottom: 16px; }
.category-list, .product-admin-list { display: grid; gap: 9px; }
.category-row, .product-admin-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; }
.category-row small, .product-admin-row small { display: block; color: var(--muted); }
.product-admin-row { align-items: center; }
.product-admin-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.admin-thumb { width: 72px; height: 54px; object-fit: cover; border-radius: 9px; background: var(--panel-3); }
.admin-product-copy { min-width: 0; }
.admin-product-copy strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-actions { display: flex; gap: 7px; flex-wrap: wrap; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.checkbox-row { display: flex !important; align-items: center; gap: 9px !important; }
.checkbox-row input { width: auto; }
.admin-dialog { width: min(820px, calc(100% - 24px)); max-height: calc(100vh - 30px); overflow: auto; padding: 24px; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 20px; }
.admin-dialog::backdrop { background: rgba(0,0,0,.75); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.admin-note { padding: 12px 14px; color: var(--muted); background: rgba(91,124,250,.08); border: 1px solid rgba(91,124,250,.2); border-radius: 12px; }

@media (max-width: 1050px) {
  .filters-panel { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .search-field { grid-column: span 2; }
  .admin-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .site-header { align-items: flex-start; padding: 12px 16px; }
  .brand span:last-child { display: none; }
  .header-actions { flex-wrap: wrap; justify-content: flex-end; }
  .profile-chip div { display: none; }
  .page-shell, .admin-shell { width: min(100% - 24px, 1380px); }
  .hero-row { align-items: stretch; flex-direction: column; }
  .balance-card { min-width: 0; }
  .filters-panel { grid-template-columns: 1fr 1fr; }
  .search-field { grid-column: 1 / -1; }
  .filters-reset { grid-column: 1 / -1; }
  .catalog-grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  .product-admin-row { align-items: flex-start; flex-direction: column; }
  .login-card { padding: 38px 24px; }
}
@media (max-width: 480px) {
  .filters-panel { grid-template-columns: 1fr; }
  .search-field, .filters-reset { grid-column: auto; }
  .catalog-grid { grid-template-columns: 1fr; }
  .tabs { overflow-x: auto; }
  .dialog-footer { align-items: stretch; flex-direction: column; }
}
