:root {
  --bg:        #0b0f1a;
  --bg-soft:   #121829;
  --card:      #161d31;
  --card-2:    #1c2541;
  --border:    #243049;
  --text:      #e8edf7;
  --muted:     #8a96b0;
  --primary:   #4f7cff;
  --primary-2: #6e8bff;
  --accent:    #18c29c;
  --danger:    #ff5470;
  --warn:      #ffb547;
  --radius:    16px;
  --shadow:    0 10px 30px rgba(0,0,0,.35);
  font-synthesis: none;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: radial-gradient(1200px 600px at 80% -10%, #1a2647 0%, transparent 60%),
              radial-gradient(900px 500px at -10% 110%, #16233f 0%, transparent 55%),
              var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.55;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; }

/* ---------- Brand ---------- */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -.02em; }
.brand .logo-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: grid; place-items: center; font-weight: 900; color: #fff;
}
.brand .name { font-size: 1.25rem; }
.brand .sub { font-size: .68rem; color: var(--muted); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }

/* ---------- Auth pages ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card {
  width: 100%; max-width: 410px; background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 36px 32px; box-shadow: var(--shadow);
}
.auth-card .brand { justify-content: center; flex-direction: column; text-align: center; gap: 6px; margin-bottom: 8px; }
.auth-card h1 { font-size: 1.4rem; text-align: center; margin: 14px 0 4px; }
.auth-card .lead { text-align: center; color: var(--muted); margin-bottom: 24px; font-size: .92rem; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: .82rem; color: var(--muted); margin-bottom: 7px; font-weight: 600; }
.input, input[type=text], input[type=password], input[type=email], input[type=tel],
input[type=datetime-local], input[type=number], textarea, select {
  width: 100%; background: var(--bg-soft); border: 1px solid var(--border);
  color: var(--text); padding: 12px 14px; border-radius: 11px; font-size: .95rem;
  outline: none; transition: border .15s, box-shadow .15s;
}
.input:focus, input:focus, textarea:focus, select:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,124,255,.18);
}
textarea { resize: vertical; min-height: 80px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff; border: none; padding: 12px 18px; border-radius: 11px;
  font-size: .95rem; font-weight: 700; cursor: pointer; width: 100%;
  transition: transform .08s, filter .15s; box-shadow: 0 6px 18px rgba(79,124,255,.3);
}
.btn:hover { filter: brightness(1.07); }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: var(--card-2); box-shadow: none; border: 1px solid var(--border); }
.btn.success { background: linear-gradient(135deg, #14b88c, var(--accent)); box-shadow: 0 6px 18px rgba(24,194,156,.25); }
.btn.danger  { background: linear-gradient(135deg, #e23a5a, var(--danger)); box-shadow: none; }
.btn.small   { width: auto; padding: 8px 14px; font-size: .85rem; }
.btn.ghost   { background: transparent; border: 1px solid var(--border); box-shadow: none; }

.alert { padding: 11px 14px; border-radius: 11px; font-size: .88rem; margin-bottom: 18px; }
.alert.error   { background: rgba(255,84,112,.12); border: 1px solid rgba(255,84,112,.4); color: #ff9bad; }
.alert.success { background: rgba(24,194,156,.12); border: 1px solid rgba(24,194,156,.4); color: #6ee7c8; }
.alert.info    { background: rgba(79,124,255,.12); border: 1px solid rgba(79,124,255,.4); color: #a9c0ff; }

.auth-foot { text-align: center; margin-top: 18px; font-size: .85rem; color: var(--muted); }
.auth-foot a { color: var(--primary-2); font-weight: 600; }

/* ---------- App shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 26px; background: rgba(11,15,26,.8); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar .right { display: flex; align-items: center; gap: 14px; }
.user-chip { display: flex; align-items: center; gap: 9px; font-size: .9rem; color: var(--muted); }
.user-chip .avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--card-2);
  display: grid; place-items: center; font-weight: 700; color: var(--text); font-size: .85rem;
}
.container { max-width: 1200px; margin: 0 auto; padding: 32px 26px 60px; }

.page-head { margin-bottom: 26px; }
.page-head h1 { font-size: 1.7rem; letter-spacing: -.02em; }
.page-head p { color: var(--muted); margin-top: 4px; }

/* ---------- Product grid ---------- */
.grid {
  display: grid; gap: 20px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.product-card {
  background: linear-gradient(180deg, var(--card), var(--bg-soft));
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; display: flex; flex-direction: column; gap: 14px;
  transition: transform .15s, border .15s, box-shadow .15s; position: relative; overflow: hidden;
}
.product-card:hover { transform: translateY(-4px); border-color: var(--primary); box-shadow: var(--shadow); }
.product-card .logo-box {
  width: 70px; height: 70px; border-radius: 14px; background: #fff;
  display: grid; place-items: center; padding: 10px; overflow: hidden;
}
.product-card .logo-box img { width: 100%; height: 100%; object-fit: contain; }
.product-card .logo-box.placeholder { background: var(--card-2); color: var(--primary-2); font-weight: 800; font-size: 1.6rem; }
.product-card h3 { font-size: 1.15rem; }
.product-card .desc { color: var(--muted); font-size: .88rem; flex: 1; }
.product-card .card-foot { margin-top: auto; }
.lock-badge {
  position: absolute; top: 14px; right: 14px; font-size: .68rem; font-weight: 700;
  padding: 4px 9px; border-radius: 999px; background: rgba(255,181,71,.15);
  color: var(--warn); border: 1px solid rgba(255,181,71,.4);
}
.unlocked-badge {
  position: absolute; top: 14px; right: 14px; font-size: .68rem; font-weight: 700;
  padding: 4px 9px; border-radius: 999px; background: rgba(24,194,156,.15);
  color: var(--accent); border: 1px solid rgba(24,194,156,.4);
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(4,7,15,.7); backdrop-filter: blur(4px);
  display: none; place-items: center; z-index: 60; padding: 20px;
}
.modal-overlay.open { display: grid; }
.modal {
  width: 100%; max-width: 460px; background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 28px; max-height: 90vh; overflow-y: auto;
}
.modal .modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.modal h2 { font-size: 1.25rem; }
.modal .close { background: none; border: none; color: var(--muted); font-size: 1.5rem; cursor: pointer; line-height: 1; }
.modal .lead { color: var(--muted); font-size: .9rem; margin-bottom: 18px; }

/* ---------- Admin ---------- */
.admin-layout { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.sidebar { background: var(--bg-soft); border-right: 1px solid var(--border); padding: 22px 16px; }
.sidebar .brand { margin-bottom: 26px; padding: 0 8px; }
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 11px;
  color: var(--muted); font-weight: 600; font-size: .92rem; margin-bottom: 4px; cursor: pointer;
}
.nav-link:hover { background: var(--card); color: var(--text); }
.nav-link.active { background: var(--card-2); color: var(--text); }
.admin-main { padding: 0; overflow-x: hidden; }

.table-wrap { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 13px 16px; font-size: .9rem; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: none; }
.tag { font-size: .72rem; padding: 3px 9px; border-radius: 999px; font-weight: 700; }
.tag.green { background: rgba(24,194,156,.15); color: var(--accent); }
.tag.red   { background: rgba(255,84,112,.15); color: var(--danger); }
.tag.gray  { background: var(--card-2); color: var(--muted); }
.tag.amber { background: rgba(255,181,71,.15); color: var(--warn); }

.card-panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; margin-bottom: 22px; }
.card-panel h2 { font-size: 1.15rem; margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.checkbox-row { display: flex; align-items: center; gap: 10px; margin: 6px 0 14px; }
.checkbox-row input { width: auto; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 16px; margin-bottom: 24px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.stat .num { font-size: 1.8rem; font-weight: 800; }
.stat .lbl { color: var(--muted); font-size: .85rem; }
.code-pill { background: var(--bg-soft); border: 1px dashed var(--border); padding: 3px 9px; border-radius: 8px; font-family: monospace; font-size: .85rem; }

@media (max-width: 760px) {
  .admin-layout { grid-template-columns: 1fr; }
  .sidebar { display: flex; flex-wrap: wrap; gap: 6px; }
  .sidebar .brand { width: 100%; }
  .nav-link { margin-bottom: 0; }
  .form-row { grid-template-columns: 1fr; }
}
