:root {
  --bg: #0e1020;
  --panel: #171a30;
  --panel-2: #1e2240;
  --line: rgba(255, 255, 255, 0.08);
  --text: #eef0ff;
  --muted: #9aa0c4;
  --primary: #6c5ce7;
  --primary-2: #8f7bff;
  --accent: #ffd166;
  --green: #2ecc71;
  --red: #ff6b6b;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: radial-gradient(120% 70% at 50% 0%, #1a1e3c, var(--bg) 60%);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
}
h1, h2, h3 { margin: 0 0 6px; }
h2 { font-size: 18px; }
h3 { font-size: 14px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); font-size: 13px; }
.small { font-size: 12px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.between { justify-content: space-between; }

/* login */
.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 360px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 18px; padding: 28px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}
.login-card h1 { font-size: 22px; }
.login-card p { color: var(--muted); font-size: 14px; }
.login-card input { width: 100%; margin: 8px 0 14px; }
.login-error { color: var(--red); font-size: 13px; min-height: 18px; margin-top: 10px; }
.demo-hint { margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--line); text-align: left; }
.demo-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 8px; }
.demo-item {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  width: 100%; margin: 6px 0; padding: 9px 12px; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 10px; color: var(--text);
  font: inherit; font-size: 13px; cursor: pointer; text-align: left;
}
.demo-item:hover { border-color: var(--primary-2); }
.demo-item code { color: var(--primary-2); font-size: 12px; white-space: nowrap; }
.demo-note { color: var(--muted); font-size: 12px; margin: 8px 0 0; }

input[type="text"], input[type="password"], input[type="number"], select {
  background: #101327; border: 1px solid var(--line); color: var(--text);
  padding: 10px 12px; border-radius: 10px; font-size: 14px; outline: none;
  width: 100%; font-family: inherit;
}
input:focus, select:focus { border-color: var(--primary-2); }

.btn {
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  padding: 10px 16px; border-radius: 10px; font-size: 14px; font-weight: 600;
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center;
  gap: 6px; transition: 0.15s; font-family: inherit;
}
.btn:hover { filter: brightness(1.12); }
.btn.primary { background: linear-gradient(90deg, var(--primary), var(--primary-2)); border: none; }
.btn.ghost { background: transparent; }
.btn.small { padding: 7px 11px; font-size: 12px; }
.btn.danger { color: var(--red); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 20px; border-bottom: 1px solid var(--line);
  background: rgba(14, 16, 32, 0.85); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 16px; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--green); box-shadow: 0 0 12px var(--green); }
.shop-tag { color: var(--accent); font-size: 13px; font-weight: 700; }
.shop-select {
  background: #101327; border: 1px solid var(--line); color: var(--text);
  padding: 8px 10px; border-radius: 10px; font-size: 13px; font-weight: 600; max-width: 190px;
}
.shop-banner {
  background: rgba(255, 107, 107, 0.14); border: 1px solid rgba(255, 107, 107, 0.5);
  color: #ffb3b3; font-size: 13px; font-weight: 600; padding: 10px 14px; border-radius: 12px; margin-bottom: 16px;
}

/* dashboard */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 16px;
}
.stat .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.stat .v { font-size: 26px; font-weight: 900; margin-top: 4px; }
.stat.gold .v { color: var(--accent); }
.stat.green .v { color: var(--green); }
.stat.red .v { color: var(--red); }
.stat.violet .v { color: #b9acff; }

/* shops */
.shops-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.shop-row {
  display: grid; grid-template-columns: 1.6fr 1fr 0.8fr auto; gap: 12px; align-items: center;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
}
.shop-row.inactive { opacity: 0.6; }
.shop-row .nm { font-weight: 800; }
.shop-row .cd { color: var(--muted); font-size: 12px; }
.shop-row .st { font-size: 12px; color: var(--muted); }
.shop-row .acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 800px) {
  .shop-row { grid-template-columns: 1fr; }
  .shop-row .acts { justify-content: flex-start; }
}
.role-badge {
  font-size: 11px; font-weight: 800; letter-spacing: 0.4px;
  padding: 3px 9px; border-radius: 999px; text-transform: uppercase;
  background: rgba(108, 92, 231, 0.25); color: #b9acff; border: 1px solid rgba(143, 123, 255, 0.5);
}
.role-badge.super { background: rgba(255, 179, 71, 0.2); color: #ffd166; border-color: rgba(255, 209, 102, 0.55); }
.top-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.switch { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.switch input { display: none; }
.switch .slider {
  width: 44px; height: 24px; border-radius: 999px; background: #3a3f63;
  position: relative; transition: 0.2s;
}
.switch .slider::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; transition: 0.2s;
}
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider::after { transform: translateX(20px); }
.switch-label { font-size: 13px; font-weight: 700; }

/* tabs */
.tabs { display: flex; gap: 4px; padding: 12px 20px 0; flex-wrap: wrap; }
.tab {
  background: transparent; border: 1px solid transparent; color: var(--muted);
  padding: 9px 16px; border-radius: 10px; cursor: pointer; font-size: 14px;
  font-weight: 600; font-family: inherit;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--panel-2); color: var(--text); border-color: var(--line); }

.content { padding: 20px; max-width: 1180px; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; }

.grid.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 820px) { .grid.two { grid-template-columns: 1fr; } }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 18px; margin-bottom: 16px;
}

/* mode */
.mode-grid { display: grid; gap: 10px; margin-top: 6px; }
.mode {
  text-align: left; background: var(--panel-2); border: 1px solid var(--line);
  color: var(--text); border-radius: 12px; padding: 12px 14px; cursor: pointer;
  display: flex; flex-direction: column; gap: 3px; font-family: inherit;
}
.mode:hover { border-color: var(--primary-2); }
.mode.active { border-color: var(--primary-2); background: linear-gradient(90deg, rgba(108,92,231,0.25), rgba(143,123,255,0.12)); }
.mode-title { font-weight: 800; font-size: 14px; }
.mode-desc { color: var(--muted); font-size: 12px; }

.force-box { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.force-options { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.force-chip {
  border: 2px solid transparent; border-radius: 999px; padding: 9px 14px;
  color: #fff; font-weight: 700; font-size: 13px; cursor: pointer; font-family: inherit;
  opacity: 0.6; transition: 0.15s;
}
.force-chip.active { opacity: 1; border-color: #fff; transform: scale(1.04); box-shadow: 0 6px 18px rgba(0,0,0,0.4); }
.force-chip .tag { font-weight: 500; opacity: 0.85; font-size: 11px; }

.pill { background: var(--primary); color: #fff; border-radius: 999px; padding: 2px 9px; font-size: 12px; }

.pending-list { display: flex; flex-direction: column; gap: 10px; min-height: 60px; }
.pending { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.pending .meta { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.pending .actions { display: flex; flex-wrap: wrap; gap: 6px; }
.pending .actions .btn { color: #fff; border: none; }

.feed { display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow: auto; }
.feed-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  font-size: 13px;
}
.feed-item .prize { font-weight: 700; }
.feed-item .when { color: var(--muted); font-size: 12px; }
.empty { color: var(--muted); font-size: 13px; padding: 12px; text-align: center; }

/* table */
.table-wrap { overflow-x: auto; margin-top: 12px; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; color: var(--muted); font-weight: 600; padding: 8px; border-bottom: 1px solid var(--line); }
.table td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table input[type="text"], .table input[type="number"], .table select { padding: 7px 9px; font-size: 13px; }
.table input[type="color"] { width: 44px; height: 34px; border: 1px solid var(--line); border-radius: 8px; background: transparent; padding: 2px; }
.swatch { width: 14px; height: 14px; border-radius: 4px; display: inline-block; margin-right: 6px; vertical-align: middle; }

/* qr */
.dynamic-card { border-color: rgba(108, 92, 231, 0.45); background: linear-gradient(180deg, rgba(108, 92, 231, 0.16), var(--panel) 60%); }
.dynamic-grid { display: grid; grid-template-columns: 220px 1fr; gap: 20px; align-items: center; margin-top: 14px; }
.dynamic-grid .qr-img { aspect-ratio: 1/1; }
.dynamic-info { min-width: 0; }
.dynamic-info .link { font-size: 12px; color: var(--muted); word-break: break-all; margin-bottom: 10px; }
.control-status {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 13px; font-size: 13px; margin-bottom: 12px; line-height: 1.5;
}
.control-status .dot-inline {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--green); margin-right: 7px; box-shadow: 0 0 8px var(--green); vertical-align: middle;
}
.control-status.paused .dot-inline { background: var(--red); box-shadow: 0 0 8px var(--red); }
@media (max-width: 700px) {
  .dynamic-grid { grid-template-columns: 1fr; }
  .dynamic-grid .qr-img { max-width: 260px; margin: 0 auto; }
}

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: end; }
.form-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.form-grid label.check { flex-direction: row; align-items: center; gap: 8px; }
.form-grid .btn { height: 42px; justify-content: center; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }

.session-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; margin-top: 12px; }
.session { background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.session .head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.session .name { font-weight: 800; }
.session .note { color: var(--muted); font-size: 12px; margin: 2px 0 8px; }
.session .qr-img { background: #fff; border-radius: 12px; width: 100%; aspect-ratio: 1/1; display: grid; place-items: center; overflow: hidden; }
.session .qr-img img { width: 100%; height: 100%; object-fit: contain; }
.session .link { font-size: 11px; color: var(--muted); word-break: break-all; margin: 8px 0; }
.session .actions { display: flex; flex-wrap: wrap; gap: 6px; }
.session.inactive { opacity: 0.55; }
.session .stats { font-size: 12px; color: var(--muted); margin-top: 8px; display: flex; gap: 12px; }

.save-status { margin-left: 10px; font-size: 13px; color: var(--green); }

/* toast */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  padding: 12px 20px; border-radius: 12px; font-size: 14px; z-index: 100;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}
