/* GameProtector admin console — modern SaaS style, no build chain. */

/* Author rule .bulk-bar{display:flex} etc. would otherwise override the HTML
   hidden attribute; always honour [hidden]. */
[hidden] { display: none !important; }

:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e3e8f0;
  --text: #1c2434;
  --text-dim: #667085;
  --primary: #3b6ef6;
  --primary-d: #2f5ad0;
  --primary-soft: #eaf0ff;
  --ok: #12b76a;
  --ok-soft: #e7f8f0;
  --warn: #f79009;
  --warn-soft: #fef3e2;
  --err: #f04438;
  --err-soft: #feeceb;
  --shadow: 0 1px 3px rgba(16,24,40,.06), 0 1px 2px rgba(16,24,40,.04);
  --sidebar-bg: #111a32;
  --sidebar-text: #b8c2d9;
  --sidebar-active: #1e2c4f;
  --radius: 10px;
}
[data-theme="dark"] {
  --bg: #0d1220;
  --surface: #161d31;
  --surface-2: #1c2540;
  --border: #2a3454;
  --text: #e6ebf5;
  --text-dim: #93a0bd;
  --primary: #5b85ff;
  --primary-d: #4770ec;
  --primary-soft: #1d2a52;
  --ok-soft: #11301f;
  --warn-soft: #3a2a10;
  --err-soft: #3b1d1c;
  --shadow: 0 1px 3px rgba(0,0,0,.4);
  --sidebar-bg: #0a0f1d;
  --sidebar-text: #93a0bd;
  --sidebar-active: #1c2540;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
}

/* ---------- layout ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 228px; flex: 0 0 228px;
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 18px; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, #4f7dff, #7a4dff);
  color: #fff; font-weight: 700; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
}
.brand-mark.lg { width: 44px; height: 44px; font-size: 17px; border-radius: 10px; }
.brand-name { color: #fff; font-weight: 600; font-size: 15px; letter-spacing: .3px; }
.nav { padding: 6px 10px 20px; overflow-y: auto; }
.nav-group {
  color: #6b7896; font-size: 11px; letter-spacing: 1px;
  padding: 14px 12px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px;
  color: var(--sidebar-text); text-decoration: none;
  font-size: 13.5px; margin-bottom: 2px;
}
.nav-item:hover { background: var(--sidebar-active); color: #fff; }
.nav-item.active { background: var(--sidebar-active); color: #fff; font-weight: 600; }
.nav-ico { width: 18px; text-align: center; opacity: .9; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 60px; background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; position: sticky; top: 0; z-index: 10;
}
.page-title { font-size: 17px; margin: 0; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.user-chip { display: flex; align-items: center; gap: 8px; }
.user-name { font-weight: 600; }
.role-badge {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: var(--primary-soft); color: var(--primary-d);
}
[data-theme="dark"] .role-badge { color: #a9c0ff; }
.content { padding: 22px 24px 40px; }

/* ---------- cards / stats ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid var(--border);
}
.card-head h2 { margin: 0; font-size: 15px; }
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr));
  gap: 14px; margin-bottom: 16px;
}
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
}
.stat .n { font-size: 26px; font-weight: 700; line-height: 1.2; }
.stat .l { color: var(--text-dim); font-size: 12.5px; margin-top: 4px; }
.stat.is-total .n { color: var(--primary); }
.stat.is-used .n { color: var(--primary-d); }
.stat.is-expired .n { color: var(--warn); }
.stat.is-disabled .n { color: var(--text-dim); }
.stat.is-unused .n { color: var(--ok); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1100px) { .two-col { grid-template-columns: 1fr; } }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; font-weight: 600; color: var(--text-dim);
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  white-space: nowrap; background: var(--surface-2);
}
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:hover { background: var(--surface-2); }
.table tr.row-disabled { opacity: .65; }
.empty { text-align: center; color: var(--text-dim); padding: 28px 12px; }
.col-check { width: 36px; text-align: center; }

/* ---------- badges ---------- */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.badge-unused { background: var(--ok-soft); color: var(--ok); }
.badge-used { background: var(--primary-soft); color: var(--primary-d); }
.badge-expired { background: var(--warn-soft); color: var(--warn); }
.badge-disabled { background: var(--surface-2); color: var(--text-dim); border: 1px solid var(--border); }
.badge-type { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); }
.badge-muted { background: var(--surface-2); color: var(--text-dim); border: 1px solid var(--border); }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; }
.dot-on { background: var(--ok); } .dot-off { background: var(--err); }

/* ---------- controls ---------- */
.btn {
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); border-radius: 8px; padding: 8px 14px;
  font-size: 13.5px; cursor: pointer; transition: .12s;
  font-family: inherit;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); border-color: var(--primary-d); color: #fff; }
.btn-danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn-danger:hover { color: #fff; opacity: .9; }
.btn-danger-ghost { color: var(--err); }
.btn-danger-ghost:hover { border-color: var(--err); color: var(--err); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); border-color: transparent; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }
.btn-block { width: 100%; padding: 11px; font-size: 14.5px; margin-top: 8px; }
.btn-row { display: inline-flex; gap: 6px; }
.input, select.input {
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); border-radius: 8px; padding: 8px 10px;
  font-size: 13.5px; font-family: inherit; outline: none;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; padding: 14px 18px; align-items: center; }
.spacer { flex: 1; }
.selection-info { color: var(--text-dim); font-size: 12.5px; }
.bulk-bar {
  display: flex; gap: 8px; flex-wrap: wrap;
  padding: 0 18px 14px; border-bottom: 1px solid var(--border);
}
.pagination {
  display: flex; gap: 8px; align-items: center; justify-content: flex-end;
  padding: 14px 18px;
}
.pagination .pg-info { color: var(--text-dim); margin-right: auto; font-size: 12.5px; }

/* ---------- forms ---------- */
.form { padding: 16px 18px; display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 12.5px; color: var(--text-dim); font-weight: 600; }
.form-error {
  background: var(--err-soft); color: var(--err);
  padding: 9px 12px; border-radius: 8px; font-size: 13px;
}
.callout {
  background: var(--warn-soft); color: #8a5408; border-radius: 8px;
  padding: 10px 12px; font-size: 12.5px; line-height: 1.6;
}
[data-theme="dark"] .callout { color: #f3c98b; }
.plain-list { margin: 0; padding-left: 20px; color: var(--text-dim); line-height: 2; }

/* ---------- login ---------- */
.login-body {
  background: radial-gradient(1200px 500px at 50% -10%, #243b7a 0%, #0c1326 55%);
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
}
.login-card {
  width: 380px; max-width: calc(100vw - 32px);
  background: var(--surface); border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
  padding: 30px 28px 22px;
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.login-title { font-size: 18px; font-weight: 700; }
.login-sub { color: var(--text-dim); font-size: 12.5px; }
.login-foot { text-align: center; color: var(--text-dim); font-size: 11.5px; margin-top: 14px; }
.login-card .form { padding: 0; }

/* ---------- import page ---------- */
.dropzone {
  margin: 16px 18px; border: 2px dashed var(--border); border-radius: 12px;
  padding: 34px 18px; text-align: center; cursor: pointer;
  transition: .15s; background: var(--surface-2);
}
.dropzone:hover, .dropzone.drag { border-color: var(--primary); background: var(--primary-soft); }
.dz-title { font-weight: 600; font-size: 14.5px; }
.dz-sub { color: var(--text-dim); font-size: 12.5px; margin-top: 6px; }
.dz-file { margin-top: 12px; font-weight: 600; color: var(--primary); }
.preview-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 10px; padding: 0 18px 14px; }
.mini-stat {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 9px; padding: 12px; text-align: center;
}
.mini-stat b { display: block; font-size: 22px; }
.mini-stat span { font-size: 12px; color: var(--text-dim); }
.mini-stat.ok b { color: var(--ok); }
.mini-stat.warn b { color: var(--warn); }
.mini-stat.err b { color: var(--err); }
.suggestion { padding: 0 18px 16px; }
.sugg-title { font-size: 12.5px; font-weight: 600; color: var(--text-dim); margin-bottom: 8px; }
#suggestionList .badge { margin-right: 8px; font-size: 12.5px; }
.invalid-box { padding: 0 18px 18px; }
.invalid-box ul { margin: 6px 0 0; padding-left: 18px; max-height: 150px; overflow: auto; font-size: 12.5px; }
.invalid-box li { color: var(--err); }
.import-result { margin: 0 18px 18px; border-radius: 9px; padding: 14px; background: var(--ok-soft); color: var(--ok); font-size: 13.5px; line-height: 1.9; }
.import-result a { color: inherit; font-weight: 700; }

/* ---------- modal / toast ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(9,14,26,.55);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal {
  background: var(--surface); border-radius: 12px; width: 480px;
  max-width: calc(100vw - 32px); max-height: 88vh; overflow: auto;
  box-shadow: 0 24px 70px rgba(0,0,0,.35);
}
.modal.wide { width: 760px; }
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 15px 18px; border-bottom: 1px solid var(--border); font-weight: 600;
}
.modal-body { padding: 16px 18px; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.modal-x { cursor: pointer; color: var(--text-dim); font-size: 18px; background: none; border: 0; }
.toast-host { position: fixed; top: 18px; right: 18px; z-index: 80; display: flex; flex-direction: column; gap: 10px; }
.toast {
  padding: 11px 16px; border-radius: 9px; color: #fff; font-size: 13.5px;
  box-shadow: 0 8px 24px rgba(0,0,0,.22); min-width: 220px; max-width: 420px;
  animation: slideIn .18s ease;
}
.toast.ok { background: #0e9f61; }
.toast.err { background: #d9392c; }
.toast.info { background: #344054; }
@keyframes slideIn { from { transform: translateX(16px); opacity: 0; } to { transform: none; opacity: 1; } }

.settings-box { padding: 16px 18px; }
.kv { display: grid; grid-template-columns: 200px 1fr; gap: 10px 16px; font-size: 13.5px; }
.kv dt { color: var(--text-dim); } .kv dd { margin: 0; }
.json-detail { font-family: ui-monospace, Consolas, monospace; font-size: 12px; color: var(--text-dim); white-space: pre-wrap; word-break: break-all; }
.mono { font-family: ui-monospace, Consolas, monospace; }
.cid { display: block; font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; word-break: break-all; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; cursor: pointer; user-select: all; }
.cid:hover { border-color: var(--primary); }
