/* =====================================================================
   Mixu — "Bàn cắt chìa" design system

   Ý tưởng: sản phẩm ở đây là CHÌA KHOÁ. Chìa thật được cắt từ đồng thau
   trên máy thép. Nên toàn bộ giao diện là bề mặt kim loại phay: nền
   gunmetal, tấm thép dập nổi, nhãn khắc chìm, và đồng thau (brass) là
   màu tương tác duy nhất.

   Ba màu trạng thái mang nghĩa vật liệu:
     patina  #45C7A4  key đang sống
     thép nguội #7FA8CC  key phôi, chưa kích hoạt
     gỉ sét  #DE5B48  hết hạn / khoá

   Mọi token khoá trong :root và [data-theme="light"].
   ===================================================================== */

:root {
  /* ---------- Nền & tấm (dark, mặc định) ---------- */
  --bg:         #0f1317;
  --bg-2:       #0a0d10;
  --surface:    #171c22;
  --surface-2:  #1d242b;
  --surface-3:  #262e37;
  --surface-4:  #313b46;

  --line:       #2c353f;
  --line-soft:  #212932;

  /* Cạnh vát: sáng ở mép trên, tối ở mép dưới — tạo cảm giác dập nổi */
  --bevel-hi:   rgba(255, 255, 255, .075);
  --bevel-lo:   rgba(0, 0, 0, .5);
  --sheen:      rgba(255, 255, 255, .07);
  --sheen-2:    rgba(255, 255, 255, .035);
  --well:       inset 0 2px 5px rgba(0, 0, 0, .38), inset 0 -1px 0 var(--bevel-hi);
  --brushed:    rgba(255, 255, 255, .016);
  --engrave:    0 1px 0 rgba(255, 255, 255, .05);

  --text:       #e7eaee;
  --text-dim:   #a1abb6;
  --text-mute:  #6f7a86;

  /* ---------- Đồng thau: màu tương tác ----------
     Tách hai vai trò. `--brass*` là MỰC: chữ, biểu tượng, liên kết — đổi
     theo nền để luôn đọc được. `--brass-face*` là BỀ MẶT kim loại: nút,
     chốt, con dấu — giữ nguyên sắc vàng ở cả hai giao diện, nếu không
     đồng thau sẽ hoá nâu bùn trên nền sáng. */
  --brass:      #d9a94e;
  --brass-hi:   #f6dda6;
  --brass-mid:  #c3913a;
  --brass-lo:   #8d641d;
  --brass-bg:   rgba(217, 169, 78, .15);
  --brass-bg2:  rgba(217, 169, 78, .07);
  --brass-glow: rgba(217, 169, 78, .38);

  --brass-face-1: #f8e2ae;
  --brass-face-2: #dcac4f;
  --brass-face-3: #c08f2c;
  --brass-edge:   #8d641d;
  --brass-ink:    #2b1d05;
  --brass-line:   #d9a94e;

  /* alias giữ tương thích với code cũ */
  --accent:     var(--brass);
  --accent-2:   var(--brass-hi);
  --accent-lo:  var(--brass-lo);
  --accent-bg:  var(--brass-bg);
  --accent-bg2: var(--brass-bg2);
  --accent-glow: var(--brass-glow);

  --ok:    #45c7a4;
  --ok-bg: rgba(69, 199, 164, .11);
  --ok-ln: rgba(69, 199, 164, .3);
  --warn:    #7fa8cc;   /* phôi nguội — chưa kích hoạt */
  --warn-bg: rgba(127, 168, 204, .11);
  --warn-ln: rgba(127, 168, 204, .3);
  --bad:    #de5b48;
  --bad-bg: rgba(222, 91, 72, .11);
  --bad-ln: rgba(222, 91, 72, .32);
  --idle:  #6f7a86;

  --sh-1: 0 1px 2px rgba(0, 0, 0, .45);
  --sh-2: 0 2px 5px rgba(0, 0, 0, .4), 0 10px 20px -10px rgba(0, 0, 0, .6);
  --sh-3: 0 3px 8px rgba(0, 0, 0, .4), 0 20px 40px -18px rgba(0, 0, 0, .7);
  --sh-4: 0 8px 18px rgba(0, 0, 0, .45), 0 36px 64px -22px rgba(0, 0, 0, .8);

  /* Phi-lê nhỏ và đều như chi tiết máy */
  --r-sm: 5px;
  --r:    8px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-pill: 999px;

  --ease: cubic-bezier(.2, .6, .3, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-spring: cubic-bezier(.3, 1.5, .55, 1);

  --f-body: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --f-display: "IBM Plex Sans Condensed", "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;

  color-scheme: dark;
}

[data-theme="light"] {
  --bg:         #e6eaef;
  --bg-2:       #dde2e9;
  --surface:    #ffffff;
  --surface-2:  #f4f6f9;
  --surface-3:  #e9edf2;
  --surface-4:  #d8dfe7;

  --line:       #c6cfd9;
  --line-soft:  #dde3ea;

  --bevel-hi:   rgba(255, 255, 255, .95);
  --bevel-lo:   rgba(23, 33, 45, .14);
  --sheen:      rgba(255, 255, 255, .9);
  --sheen-2:    rgba(255, 255, 255, .55);
  --well:       inset 0 2px 4px rgba(23, 33, 45, .09), inset 0 -1px 0 rgba(255, 255, 255, .8);
  --brushed:    rgba(23, 33, 45, .014);
  --engrave:    0 1px 0 rgba(255, 255, 255, .75);

  --text:       #151b21;
  --text-dim:   #4d5964;
  --text-mute:  #7b8894;

  --brass:      #9a6a12;
  --brass-hi:   #c8952f;
  --brass-mid:  #855807;
  --brass-lo:   #664303;
  --brass-bg:   rgba(154, 106, 18, .13);
  --brass-bg2:  rgba(154, 106, 18, .055);
  --brass-glow: rgba(176, 126, 30, .38);

  --brass-face-1: #fbe9be;
  --brass-face-2: #dfb055;
  --brass-face-3: #b9862a;
  --brass-edge:   #8a5f10;
  --brass-ink:    #33230a;
  --brass-line:   #bc8a2b;

  --ok:    #10826a;
  --ok-bg: rgba(16, 130, 106, .1);
  --ok-ln: rgba(16, 130, 106, .26);
  --warn:    #3a6c99;
  --warn-bg: rgba(58, 108, 153, .1);
  --warn-ln: rgba(58, 108, 153, .24);
  --bad:    #bf3d2a;
  --bad-bg: rgba(191, 61, 42, .1);
  --bad-ln: rgba(191, 61, 42, .26);
  --idle:  #7b8894;

  --sh-1: 0 1px 2px rgba(23, 33, 45, .09);
  --sh-2: 0 1px 3px rgba(23, 33, 45, .07), 0 6px 14px -8px rgba(23, 33, 45, .18);
  --sh-3: 0 2px 6px rgba(23, 33, 45, .07), 0 16px 32px -16px rgba(23, 33, 45, .24);
  --sh-4: 0 6px 18px rgba(23, 33, 45, .1), 0 28px 56px -20px rgba(23, 33, 45, .3);

  color-scheme: light;
}

/* Theo hệ thống khi người dùng chưa chọn thủ công */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg:         #e6eaef;
    --bg-2:       #dde2e9;
    --surface:    #ffffff;
    --surface-2:  #f4f6f9;
    --surface-3:  #e9edf2;
    --surface-4:  #d8dfe7;
    --line:       #c6cfd9;
    --line-soft:  #dde3ea;
    --bevel-hi:   rgba(255, 255, 255, .95);
    --bevel-lo:   rgba(23, 33, 45, .14);
    --sheen:      rgba(255, 255, 255, .9);
    --sheen-2:    rgba(255, 255, 255, .55);
    --well:       inset 0 2px 4px rgba(23, 33, 45, .09), inset 0 -1px 0 rgba(255, 255, 255, .8);
    --brushed:    rgba(23, 33, 45, .014);
    --engrave:    0 1px 0 rgba(255, 255, 255, .75);
    --text:       #151b21;
    --text-dim:   #4d5964;
    --text-mute:  #7b8894;
    --brass:      #9a6a12;
    --brass-hi:   #c8952f;
    --brass-mid:  #855807;
    --brass-lo:   #664303;
    --brass-bg:   rgba(154, 106, 18, .13);
    --brass-bg2:  rgba(154, 106, 18, .055);
    --brass-glow: rgba(176, 126, 30, .38);
    --brass-face-1: #fbe9be;
    --brass-face-2: #dfb055;
    --brass-face-3: #b9862a;
    --brass-edge:   #8a5f10;
    --brass-ink:    #33230a;
    --brass-line:   #bc8a2b;
    --ok:    #10826a;
    --ok-bg: rgba(16, 130, 106, .1);
    --ok-ln: rgba(16, 130, 106, .26);
    --warn:    #3a6c99;
    --warn-bg: rgba(58, 108, 153, .1);
    --warn-ln: rgba(58, 108, 153, .24);
    --bad:    #bf3d2a;
    --bad-bg: rgba(191, 61, 42, .1);
    --bad-ln: rgba(191, 61, 42, .26);
    --idle:  #7b8894;
    --sh-1: 0 1px 2px rgba(23, 33, 45, .09);
    --sh-2: 0 1px 3px rgba(23, 33, 45, .07), 0 6px 14px -8px rgba(23, 33, 45, .18);
    --sh-3: 0 2px 6px rgba(23, 33, 45, .07), 0 16px 32px -16px rgba(23, 33, 45, .24);
    --sh-4: 0 6px 18px rgba(23, 33, 45, .1), 0 28px 56px -20px rgba(23, 33, 45, .3);
    color-scheme: light;
  }
}

/* =====================================================================
   Reset & nền
   ===================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scrollbar-color: var(--surface-4) transparent;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;   /* thanh địa chỉ trên mobile không làm nhảy layout */
  font-family: var(--f-body);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Ánh sáng xưởng: đèn đồng thau trên trái, ánh patina dưới phải, và
   một lớp phay ngang rất mờ phủ toàn trang. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(1180px 680px at 12% -14%, var(--brass-bg2), transparent 62%),
    radial-gradient(900px 620px at 102% 108%, rgba(69, 199, 164, .05), transparent 60%),
    repeating-linear-gradient(0deg, var(--brushed) 0 1px, transparent 1px 4px),
    var(--bg);
}

h1, h2, h3, h4 {
  margin: 0;
  font-family: var(--f-display);
  font-weight: 600;
  letter-spacing: -.005em;
  line-height: 1.2;
  color: var(--text);
}
h1 { font-size: 1.7rem; }
h2 { font-size: 1.14rem; }
h3 { font-size: 1rem; }
p  { margin: 0 0 .8em; color: var(--text-dim); }

a {
  color: var(--brass);
  text-decoration: none;
  transition: color .15s var(--ease);
}
a:hover { color: var(--brass-hi); }
[data-theme="light"] a:hover { color: var(--brass-lo); }

code, .mono, pre, kbd {
  font-family: var(--f-mono);
  font-size: .86em;
  font-feature-settings: "zero" 1;
}

:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
  border-radius: 3px;
}

::selection { background: var(--brass-bg); color: var(--text); }

::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--surface-4);
  border: 3.5px solid transparent;
  background-clip: padding-box;
  border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover { background: var(--brass-mid); background-clip: padding-box; }

/* Nhãn khắc chìm — dùng lại ở sidebar, bảng, stat, task */
.nav-label,
.stat-k,
.tbl th,
.brand-text span {
  font-family: var(--f-display);
  text-transform: uppercase;
  letter-spacing: .11em;
  font-weight: 600;
  text-shadow: var(--engrave);
}

/* =====================================================================
   Bố cục
   ===================================================================== */

.app { display: flex; min-height: 100vh; min-height: 100dvh; }

/* ---------- Thanh bên: tấm thép phay dọc ---------- */

.sidebar {
  position: sticky;
  top: 0;
  flex: 0 0 252px;
  height: 100vh;
  height: 100dvh;
  padding: 18px 12px 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background:
    repeating-linear-gradient(90deg, var(--brushed) 0 1px, transparent 1px 3px),
    linear-gradient(180deg, var(--surface-2), var(--surface) 42%, var(--bg-2));
  border-right: 1px solid var(--line);
  box-shadow: inset -1px 0 0 var(--bevel-lo);
  z-index: 30;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px 20px;
  text-decoration: none;
  color: inherit;
}

/* Bảng tên đồng thau: khối 3D thật bằng CSS (mặt trước + cạnh dày) */
.brand-mark {
  width: 38px; height: 38px;
  flex: none;
  position: relative;
  border-radius: 9px;
  display: grid; place-items: center;
  font-family: var(--f-display);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--brass-ink);
  user-select: none;
  background: linear-gradient(150deg, var(--brass-face-1), var(--brass-face-2) 42%, var(--brass-face-3) 78%, var(--brass-edge));
  box-shadow:
    inset 0 1.5px 0 rgba(255, 255, 255, .55),
    inset 0 -2px 4px rgba(70, 44, 0, .45),
    2px 3px 0 -1px var(--brass-edge),
    3px 5px 0 -2px rgba(80, 52, 4, .9),
    0 10px 22px -10px var(--brass-glow);
  text-shadow: 0 1px 0 rgba(255, 245, 214, .5);
  transform: perspective(420px) rotateY(-14deg) rotateX(6deg);
  transform-style: preserve-3d;
  transition: transform .45s var(--ease-spring), box-shadow .35s var(--ease);
}
.brand:hover .brand-mark,
.gk-head:hover .brand-mark {
  transform: perspective(420px) rotateY(12deg) rotateX(-4deg) translateY(-1px);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-text strong {
  font-family: var(--f-display);
  font-size: 1.06rem; font-weight: 600; letter-spacing: .005em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.brand-text span {
  font-size: .66rem;
  color: var(--brass);
}

.nav-label {
  padding: 15px 10px 7px;
  font-size: .625rem;
  color: var(--text-mute);
}

/* Mục điều hướng: rãnh khắc, gạch đồng ở mép trái khi đang mở */
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  border-radius: var(--r-sm);
  color: var(--text-dim);
  font-size: .925rem; font-weight: 500;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.nav-item::before {
  content: "";
  position: absolute;
  left: 0; top: 50%;
  width: 2px; height: 0;
  border-radius: 0 2px 2px 0;
  background: var(--brass-line);
  transform: translateY(-50%);
  transition: height .22s var(--ease-out);
}
.nav-item svg { width: 17px; height: 17px; flex: none; opacity: .72; transition: opacity .15s, color .15s; }
.nav-item:hover { color: var(--text); background: var(--surface-3); }
.nav-item:hover::before { height: 40%; }
.nav-item:hover svg { opacity: 1; }
.nav-item.is-active {
  color: var(--text);
  background: linear-gradient(90deg, var(--brass-bg), transparent 88%);
  box-shadow: inset 0 1px 0 var(--bevel-hi);
}
.nav-item.is-active::before { height: 62%; box-shadow: 0 0 10px var(--brass-glow); }
.nav-item.is-active svg { opacity: 1; color: var(--brass); }

.sidebar-foot {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
  box-shadow: 0 -1px 0 var(--bevel-hi);
}

.who {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px;
  border-radius: var(--r-sm);
  margin-bottom: 3px;
}
.who-av {
  width: 34px; height: 34px; flex: none;
  border-radius: 7px;
  display: grid; place-items: center;
  font-family: var(--f-mono);
  font-size: .76rem; font-weight: 600;
  letter-spacing: .02em;
  color: var(--text-dim);
  background: linear-gradient(165deg, var(--surface-4), var(--surface-2));
  box-shadow:
    inset 0 1px 0 var(--bevel-hi),
    inset 0 -1px 2px var(--bevel-lo),
    1px 2px 0 -1px var(--bevel-lo);
}
.who-meta { min-width: 0; line-height: 1.35; }
.who-meta b {
  display: block; font-size: .875rem; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.who-meta span { font-size: .72rem; color: var(--text-mute); font-family: var(--f-mono); }

/* ---------- Khu chính ---------- */

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  padding: 13px 26px;
  background:
    repeating-linear-gradient(0deg, var(--brushed) 0 1px, transparent 1px 3px),
    linear-gradient(180deg, var(--surface-2), var(--surface));
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 var(--bevel-lo), var(--sh-1);
}
/* Sợi đồng mảnh chạy dưới thanh tiêu đề */
.topbar::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
  background: linear-gradient(90deg, var(--brass-line) 0%, transparent 38%);
  opacity: .6;
}
.topbar h1 { font-size: 1.22rem; letter-spacing: .002em; }
.topbar .sub { font-size: .78rem; color: var(--text-mute); margin-top: 1px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.content {
  padding: 24px 26px 60px;
  max-width: 1400px;
  width: 100%;
}

.menu-btn { display: none; }

/* Màn phủ khi mở menu trên mobile (do JS chèn) */
.sidebar-scrim {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(6, 9, 12, .6);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none;
  transition: opacity .25s var(--ease);
}
.sidebar-scrim.is-on { opacity: 1; pointer-events: auto; }

/* =====================================================================
   Tấm (panel)
   ===================================================================== */

.panel {
  position: relative;
  background: linear-gradient(180deg, var(--surface-2), var(--surface) 34%);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow:
    inset 0 1px 0 var(--bevel-hi),
    inset 0 -1px 0 var(--bevel-lo),
    var(--sh-2);
  animation: plate-in .4s var(--ease-out) backwards;
}
.panel::before {
  content: "";
  position: absolute; inset: 0 0 auto; height: 1px;
  background: linear-gradient(90deg, transparent, var(--sheen) 22%, var(--sheen) 78%, transparent);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  pointer-events: none;
}

.panel-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-soft);
  box-shadow: 0 1px 0 var(--bevel-hi);
}
.panel-head h2 { font-size: 1.06rem; }
.panel-head h2 code { font-size: .82em; color: var(--brass); }
.panel-head .hint { font-size: .77rem; color: var(--text-mute); }
.panel-head .spacer { margin-left: auto; }
.panel-body { padding: 18px; }
.panel-foot {
  padding: 13px 18px;
  border-top: 1px solid var(--line-soft);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: linear-gradient(180deg, transparent, var(--bevel-lo));
  box-shadow: inset 0 1px 0 var(--bevel-hi);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}

@keyframes plate-in {
  from { opacity: 0; transform: translateY(7px); }
  to   { opacity: 1; transform: none; }
}

.grid { display: grid; gap: 15px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.split { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; }

/* =====================================================================
   Đồng hồ số (stat) — nắp màu ở mép trên mã hoá trạng thái
   ===================================================================== */

.stat {
  position: relative;
  overflow: hidden;
  padding: 15px 17px 16px;
  border-radius: var(--r);
  background: linear-gradient(180deg, var(--surface-2), var(--surface) 40%);
  border: 1px solid var(--line);
  box-shadow:
    inset 0 1px 0 var(--bevel-hi),
    inset 0 -1px 0 var(--bevel-lo),
    var(--sh-1);
  transition: transform .28s var(--ease), box-shadow .28s var(--ease), border-color .28s var(--ease);
}
.stat::before {
  content: "";
  position: absolute; inset: 0 0 auto; height: 2px;
  background: var(--brass-line);
  opacity: .9;
}
.stat:has(.dot.ok)::before   { background: var(--ok); }
.stat:has(.dot.warn)::before { background: var(--warn); }
.stat:has(.dot.bad)::before  { background: var(--bad); }
.stat:hover {
  transform: translateY(-2px);
  border-color: var(--surface-4);
  box-shadow:
    inset 0 1px 0 var(--bevel-hi),
    inset 0 -1px 0 var(--bevel-lo),
    var(--sh-3);
}
.stat-k {
  display: flex; align-items: center; gap: 8px;
  font-size: .68rem;
  color: var(--text-mute);
}
.stat-k svg { width: 13px; height: 13px; }
.stat-v {
  margin-top: 9px;
  font-family: var(--f-mono);
  font-size: 1.85rem; font-weight: 500; letter-spacing: -.035em;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
  color: var(--text);
}
.stat-sub { font-size: .755rem; color: var(--text-mute); margin-top: 5px; }

.dot { width: 7px; height: 7px; border-radius: 99px; flex: none; }
.dot.ok   { background: var(--ok);   box-shadow: 0 0 7px var(--ok); }
.dot.warn { background: var(--warn); box-shadow: 0 0 7px var(--warn); }
.dot.bad  { background: var(--bad);  box-shadow: 0 0 7px var(--bad); }
.dot.idle { background: var(--idle); }

/* =====================================================================
   Nút — phím máy có hành trình thật
   ===================================================================== */

.btn {
  position: relative;
  overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 15px;
  font: inherit;
  font-family: var(--f-body);
  font-size: .875rem; font-weight: 600;
  color: var(--text);
  background: linear-gradient(180deg, var(--surface-3), var(--surface-2));
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  box-shadow:
    inset 0 1px 0 var(--bevel-hi),
    inset 0 -1px 0 var(--bevel-lo),
    0 2px 0 -1px var(--bevel-lo),
    var(--sh-1);
  cursor: pointer;
  white-space: nowrap;
  transition:
    transform .1s var(--ease),
    box-shadow .1s var(--ease),
    background .14s var(--ease),
    border-color .14s var(--ease),
    color .14s var(--ease);
}
.btn:hover {
  background: linear-gradient(180deg, var(--surface-4), var(--surface-3));
  border-color: var(--surface-4);
}
.btn:active {
  transform: translateY(1.5px);
  box-shadow: inset 0 2px 5px var(--bevel-lo);
}
.btn svg { width: 16px; height: 16px; flex: none; }
.btn[disabled] { opacity: .45; pointer-events: none; }

/* Nút chính: tấm đồng thau đánh bóng */
.btn-primary {
  color: var(--brass-ink);
  background: linear-gradient(180deg, var(--brass-face-1) 0%, var(--brass-face-2) 46%, var(--brass-face-3) 100%);
  border-color: var(--brass-edge);
  text-shadow: 0 1px 0 rgba(255, 246, 220, .45);
  box-shadow:
    inset 0 1.5px 0 rgba(255, 255, 255, .6),
    inset 0 -2px 3px rgba(90, 60, 0, .35),
    0 2px 0 -1px var(--brass-edge),
    0 8px 18px -8px var(--brass-glow);
}
.btn-primary:hover {
  background: linear-gradient(180deg, #fff3d5 0%, var(--brass-face-1) 46%, var(--brass-face-2) 100%);
  border-color: var(--brass-edge);
}
.btn-primary:active {
  box-shadow: inset 0 2px 6px rgba(80, 52, 0, .45);
}
.btn-primary svg { opacity: .85; }

.btn-ghost {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--text-dim);
}
.btn-ghost:hover {
  background: var(--surface-3);
  border-color: var(--line);
  color: var(--text);
  box-shadow: inset 0 1px 0 var(--bevel-hi), var(--sh-1);
}
.btn-ghost:active { box-shadow: inset 0 2px 4px var(--bevel-lo); }

.btn-danger {
  color: var(--bad);
  border-color: var(--bad-ln);
  background: linear-gradient(180deg, var(--bad-bg), transparent);
  box-shadow: inset 0 1px 0 var(--bevel-hi), var(--sh-1);
}
.btn-danger:hover {
  color: #fff;
  background: linear-gradient(180deg, #e8705d, #b93c2a);
  border-color: #a8341f;
  text-shadow: 0 1px 0 rgba(0, 0, 0, .25);
}

.btn-sm { padding: 6px 11px; font-size: .81rem; }
.btn-sm svg { width: 14px; height: 14px; }
.btn-icon { padding: 7px; aspect-ratio: 1; }
.btn-sm.btn-icon { padding: 6px; }
.btn-block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* Gợn sóng khi bấm */
.btn .ripple {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  background: rgba(255, 255, 255, .3);
  transform: scale(0);
  animation: ripple .55s var(--ease-out);
}
.btn-primary .ripple { background: rgba(255, 250, 235, .5); }
@keyframes ripple { to { transform: scale(2.6); opacity: 0; } }

/* Nút chọn nhanh */
.quick-pick { display: inline-flex; gap: 4px; margin-top: 7px; flex-wrap: wrap; }
.quick-pick button {
  font: inherit;
  font-family: var(--f-mono);
  font-size: .74rem;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  border: 1px solid var(--line);
  color: var(--text-dim);
  cursor: pointer;
  transition: background .13s var(--ease), color .13s var(--ease), border-color .13s var(--ease);
}
.quick-pick button:hover {
  background: var(--brass-bg);
  border-color: var(--brass-mid);
  color: var(--brass);
}
.quick-pick button:active { transform: translateY(1px); }

.input-group { display: flex; gap: 7px; align-items: stretch; }
.input-group .input { flex: 1 1 auto; min-width: 0; }
.input-group .btn { flex: 0 0 auto; }

/* =====================================================================
   Biểu mẫu — ô nhập là rãnh khoét vào tấm
   ===================================================================== */

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 15px; }
.field > label {
  font-size: .8rem; font-weight: 600; color: var(--text-dim);
  font-family: var(--f-display);
  letter-spacing: .015em;
}
.field .help { font-size: .765rem; color: var(--text-mute); line-height: 1.5; }
.field .help code { color: var(--brass); }
.field .help b { color: var(--text-dim); font-weight: 600; }
.field .help svg { vertical-align: -2px; }

.input, .select, textarea.input {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  font-family: var(--f-body);
  font-size: .885rem;
  color: var(--text);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  box-shadow: var(--well);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease), background .15s var(--ease);
}
[data-theme="light"] .input,
[data-theme="light"] .select,
[data-theme="light"] textarea.input { background: var(--surface-2); }
.input.mono, input.mono { font-family: var(--f-mono); letter-spacing: .01em; }
.input::placeholder { color: var(--text-mute); opacity: .75; }
.input:hover, .select:hover, textarea.input:hover { border-color: var(--surface-4); }
.input:focus, .select:focus, textarea.input:focus {
  outline: none;
  border-color: var(--brass);
  box-shadow: var(--well), 0 0 0 3px var(--brass-bg);
}
.input:disabled, .select:disabled { opacity: .55; cursor: not-allowed; }
textarea.input { resize: vertical; min-height: 80px; }
.input-sm { padding: 7px 11px; font-size: .83rem; }

/* Danh sách key vừa tạo: mỗi dòng một key, không tự ngắt dòng để copy
   ra là dán được ngay, dòng thưa cho dễ đọc từng key. */
textarea.keydump {
  font-family: var(--f-mono);
  font-size: .855rem;
  line-height: 1.85;
  letter-spacing: .03em;
  white-space: pre;
  overflow: auto;
  color: var(--brass);
}

.select {
  appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a1abb6' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
[data-theme="light"] .select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%234d5964' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}

.field-row { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field-row.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* Công tắc gạt */
.switch { display: inline-flex; align-items: center; gap: 11px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track {
  width: 44px; height: 24px; flex: none;
  border-radius: var(--r-pill);
  background: var(--bg-2);
  border: 1px solid var(--line);
  box-shadow: var(--well);
  position: relative;
  transition: background .2s var(--ease), border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.switch-track::after {
  content: "";
  position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: linear-gradient(180deg, #fdfdfd, #b9c1cb);
  box-shadow: 0 2px 3px rgba(0, 0, 0, .4), inset 0 1px 0 #fff;
  transition: transform .24s var(--ease-spring), background .2s var(--ease);
}
.switch input:checked + .switch-track {
  background: linear-gradient(180deg, var(--brass-face-3), var(--brass-edge));
  border-color: var(--brass-edge);
  box-shadow: inset 0 1px 3px rgba(60, 40, 0, .5);
}
.switch input:checked + .switch-track::after {
  transform: translateX(20px);
  background: linear-gradient(180deg, #fff6e0, var(--brass-face-1));
}
.switch input:focus-visible + .switch-track { box-shadow: var(--well), 0 0 0 3px var(--brass-bg); }
.switch-label { font-size: .875rem; color: var(--text-dim); }

/* =====================================================================
   Bảng dữ liệu
   ===================================================================== */

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

table.tbl { width: 100%; border-collapse: collapse; font-size: .875rem; }
.tbl th {
  padding: 9px 14px;
  text-align: left;
  font-size: .655rem;
  color: var(--text-mute);
  background: linear-gradient(180deg, var(--surface-3), var(--surface-2));
  border-bottom: 1px solid var(--line);
  box-shadow: inset 0 1px 0 var(--bevel-hi);
  white-space: nowrap;
}
.tbl td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
.tbl tbody tr { transition: background .13s var(--ease); }
.tbl tbody tr:hover { background: var(--brass-bg2); }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl .num { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.tbl .actions { display: flex; gap: 5px; justify-content: flex-end; flex-wrap: nowrap; }
.tbl tr.is-picked > td {
  background: var(--brass-bg2);
  box-shadow: inset 2px 0 0 var(--brass);
}

/* Mã key: con dấu dập chìm */
.key-cell { display: flex; align-items: center; gap: 8px; max-width: 300px; }
.key-cell code {
  padding: 3px 9px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: var(--well);
  letter-spacing: .015em;
  font-size: .82rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; max-width: 210px;
}
[data-theme="light"] .key-cell code { background: var(--surface-3); }

.empty { padding: 50px 24px; text-align: center; }
.empty-mark {
  width: 54px; height: 54px; margin: 0 auto 14px;
  border-radius: 12px;
  background: linear-gradient(160deg, var(--surface-4), var(--surface-2) 65%);
  box-shadow:
    inset 0 1.5px 0 var(--bevel-hi),
    inset 0 -2px 4px var(--bevel-lo),
    2px 2px 0 -1px var(--surface-3),
    4px 4px 0 -1px var(--surface-2),
    5px 6px 0 -2px var(--bevel-lo),
    var(--sh-3);
  display: grid; place-items: center;
  color: var(--brass);
  transform: perspective(400px) rotateY(-18deg) rotateX(9deg);
  transition: transform .45s var(--ease-spring);
}
.empty:hover .empty-mark { transform: perspective(400px) rotateY(10deg) rotateX(-3deg); }
.empty h3 { margin-bottom: 6px; }
.empty p { max-width: 400px; margin: 0 auto; font-size: .875rem; }

/* =====================================================================
   Huy hiệu trạng thái
   ===================================================================== */

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 10px;
  font-size: .73rem; font-weight: 600;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--surface-3);
  color: var(--text-dim);
  white-space: nowrap;
  line-height: 1.6;
  box-shadow: inset 0 1px 0 var(--bevel-hi);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge.no-dot::before { display: none; }
.badge.active   { color: var(--ok);   border-color: var(--ok-ln);   background: var(--ok-bg); }
.badge.pending  { color: var(--warn); border-color: var(--warn-ln); background: var(--warn-bg); }
.badge.expired,
.badge.banned   { color: var(--bad);  border-color: var(--bad-ln);  background: var(--bad-bg); }
.badge.disabled { color: var(--text-mute); }
.badge.role-admin  { color: var(--brass); border-color: var(--brass-bg); background: var(--brass-bg2); }
.badge.role-seller { color: var(--text-dim); }

/* =====================================================================
   Thông báo trong trang + toast
   ===================================================================== */

.flash-stack { display: flex; flex-direction: column; gap: 9px; margin-bottom: 18px; }
.flash {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 11px 14px;
  font-size: .875rem;
  border-radius: var(--r);
  border: 1px solid var(--line);
  border-left-width: 3px;
  background: var(--surface-2);
  box-shadow: inset 0 1px 0 var(--bevel-hi), var(--sh-1);
  animation: flash-in .32s var(--ease-out);
}
.flash svg { width: 18px; height: 18px; flex: none; margin-top: 2px; }
.flash > div { color: var(--text); }
.flash.success { color: var(--ok);    border-color: var(--ok-ln);   border-left-color: var(--ok);    background: var(--ok-bg); }
.flash.error   { color: var(--bad);   border-color: var(--bad-ln);  border-left-color: var(--bad);   background: var(--bad-bg); }
.flash.info    { color: var(--brass); border-color: var(--brass-bg); border-left-color: var(--brass); background: var(--brass-bg2); }
.flash.is-leaving { animation: flash-out .28s var(--ease) forwards; }
@keyframes flash-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: none; }
}
@keyframes flash-out {
  to { opacity: 0; transform: translateY(-6px); max-height: 0; padding-top: 0; padding-bottom: 0; margin: 0; }
}

.toast-stack {
  position: fixed; z-index: 100;
  right: 18px; bottom: 18px;
  display: flex; flex-direction: column-reverse; gap: 9px;
  max-width: 360px; width: calc(100vw - 36px);
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 13px;
  border-radius: var(--r);
  background: linear-gradient(180deg, var(--surface-3), var(--surface));
  border: 1px solid var(--line);
  border-left: 3px solid var(--brass);
  box-shadow: inset 0 1px 0 var(--bevel-hi), var(--sh-4);
  font-size: .855rem;
  color: var(--text);
  animation: toast-in .32s var(--ease-spring);
}
.toast.is-leaving { animation: toast-out .26s var(--ease) forwards; }
.toast.success { border-left-color: var(--ok); }
.toast.success > svg { color: var(--ok); }
.toast.error   { border-left-color: var(--bad); }
.toast.error > svg { color: var(--bad); }
.toast.info    { border-left-color: var(--brass); }
.toast.info > svg { color: var(--brass); }
.toast svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.toast .toast-msg { flex: 1; line-height: 1.45; }
.toast .toast-close {
  background: transparent; border: none; color: var(--text-mute);
  cursor: pointer; padding: 0 3px; font-size: 1.15rem; line-height: 1.2;
  border-radius: 4px; transition: color .12s var(--ease), background .12s var(--ease);
}
.toast .toast-close:hover { color: var(--text); background: var(--surface-4); }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(18px) scale(.97); }
  to   { opacity: 1; transform: none; }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateX(18px) scale(.97); }
}

/* =====================================================================
   Vật thể 3D — chìa khoá đồng thau dựng thời gian thực trên canvas
   ===================================================================== */

.forge {
  position: relative;
  display: block;
  margin: 0 auto;
  width: 100%;
  max-width: 260px;
  aspect-ratio: 1 / .74;
}
.forge canvas {
  position: relative;
  display: block;
  width: 100%; height: 100%;
  z-index: 1;
}
/* Quầng đèn phía sau + bóng đổ dưới chân chìa */
.forge::before {
  content: "";
  position: absolute; inset: 12% 14%;
  border-radius: 50%;
  background: radial-gradient(circle at 44% 40%, var(--brass-glow), rgba(217, 169, 78, .07) 45%, transparent 70%);
  opacity: .55;
  filter: blur(10px);
}
.forge::after {
  content: "";
  position: absolute;
  left: 24%; right: 24%; bottom: 4%;
  height: 8px;
  border-radius: 50%;
  background: radial-gradient(50% 50% at 50% 50%, rgba(0, 0, 0, .5), transparent 72%);
  filter: blur(3px);
}
[data-theme="light"] .forge::after {
  background: radial-gradient(50% 50% at 50% 50%, rgba(23, 33, 45, .22), transparent 72%);
}

/* Chỗ đặt trên trang đăng nhập: logo phẳng nhường chỗ cho chìa 3D */
.auth-logo.has-forge {
  width: 100%;
  height: auto;
  max-width: 232px;
  background: none;
  box-shadow: none;
  transform: none;
  font-size: 0;
  margin: -4px auto 4px;
  border-radius: 0;
}
.auth-logo.has-forge .forge { max-width: 232px; }

/* Chỗ đặt trên trang nhận key */
.gk-forge { margin: -2px auto 4px; }
.gk-forge .forge { max-width: 196px; }

/* =====================================================================
   Đăng nhập / đăng ký
   ===================================================================== */

.auth-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid; place-items: center;
  padding: 32px 18px;
}
.auth-card {
  position: relative;
  width: 100%; max-width: 396px;
  padding: 30px 30px 26px;
  border-radius: var(--r-xl);
  background: linear-gradient(180deg, var(--surface-2), var(--surface) 30%);
  border: 1px solid var(--line);
  box-shadow:
    inset 0 1.5px 0 var(--bevel-hi),
    inset 0 -1px 0 var(--bevel-lo),
    var(--sh-4);
  animation: card-in .5s var(--ease-out);
}
.auth-card::before {
  content: "";
  position: absolute; inset: 0 0 auto; height: 1px;
  background: linear-gradient(90deg, transparent, var(--brass-line) 30%, var(--brass-line) 70%, transparent);
  opacity: .55;
  border-radius: var(--r-xl) var(--r-xl) 0 0;
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

/* Logo dự phòng khi chưa có 3D (JS tắt / đang tải) */
.auth-logo {
  width: 56px; height: 56px;
  margin: 0 auto 16px;
  display: grid; place-items: center;
  border-radius: 13px;
  background: linear-gradient(150deg, var(--brass-face-1), var(--brass-face-2) 42%, var(--brass-face-3) 78%, var(--brass-edge));
  color: var(--brass-ink);
  font-family: var(--f-display);
  font-size: 1.65rem; font-weight: 700; line-height: 1;
  text-shadow: 0 1px 0 rgba(255, 245, 214, .5);
  transform: perspective(500px) rotateY(-14deg) rotateX(7deg);
  box-shadow:
    inset 0 1.5px 0 rgba(255, 255, 255, .55),
    inset 0 -2px 5px rgba(70, 44, 0, .45),
    3px 4px 0 -1px var(--brass-edge),
    0 14px 26px -12px var(--brass-glow);
}

.auth-card h1 {
  font-size: 1.5rem; text-align: center;
  margin: 0 0 5px;
}
.auth-card .subtitle {
  text-align: center;
  font-size: .84rem;
  color: var(--text-mute);
  margin: 0 0 24px;
}
.auth-card .field { margin-bottom: 11px; }
.auth-card .input { padding: 11px 13px; }
.auth-card .btn-block { margin-top: 8px; padding: 11px 15px; }

.auth-foot {
  margin-top: 20px; padding-top: 16px;
  border-top: 1px solid var(--line-soft);
  box-shadow: 0 -1px 0 var(--bevel-hi);
  text-align: center; font-size: .82rem; color: var(--text-mute);
}
.auth-foot a { color: var(--brass); font-weight: 600; }
.auth-foot a:hover { text-decoration: underline; }

/* =====================================================================
   Trang nhận key công khai
   ===================================================================== */

.gk-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid; place-items: center;
  padding: 30px 16px;
}
.gk-card {
  position: relative;
  width: 100%; max-width: 520px;
  border-radius: var(--r-xl);
  background: linear-gradient(180deg, var(--surface-2), var(--surface) 26%);
  border: 1px solid var(--line);
  box-shadow:
    inset 0 1.5px 0 var(--bevel-hi),
    inset 0 -1px 0 var(--bevel-lo),
    var(--sh-4);
  overflow: hidden;
  animation: card-in .5s var(--ease-out);
}
.gk-card::before {
  content: "";
  position: absolute; inset: 0 0 auto; height: 1px;
  background: linear-gradient(90deg, transparent, var(--brass-line) 30%, var(--brass-line) 70%, transparent);
  opacity: .55;
}
.gk-head {
  padding: 22px 26px 22px; text-align: center;
  border-bottom: 1px solid var(--line-soft);
  box-shadow: 0 1px 0 var(--bevel-hi);
}
.gk-head .brand { justify-content: center; padding: 0 0 14px; }
.gk-head h1 { font-size: 1.55rem; }
.gk-body { padding: 22px 26px 26px; }

/* Thanh bước — ray thép, chốt đồng khi xong */
.steps { display: flex; align-items: center; gap: 0; margin-bottom: 20px; }
.step { display: flex; align-items: center; flex: 1; }
.step:last-child { flex: none; }
.step-dot {
  width: 32px; height: 32px; flex: none;
  border-radius: 8px;
  display: grid; place-items: center;
  font-family: var(--f-mono);
  font-size: .8rem; font-weight: 600;
  color: var(--text-mute);
  background: linear-gradient(165deg, var(--surface-3), var(--surface-2));
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 var(--bevel-hi), inset 0 -2px 3px var(--bevel-lo);
  transition: all .35s var(--ease-spring);
}
.step-line {
  flex: 1; height: 3px; margin: 0 7px;
  background: var(--bg-2);
  box-shadow: var(--well);
  border-radius: 3px;
  overflow: hidden;
}
.step.done .step-dot {
  color: var(--brass-ink);
  background: linear-gradient(165deg, var(--brass-face-1), var(--brass-face-2) 50%, var(--brass-face-3));
  border-color: var(--brass-edge);
  box-shadow:
    inset 0 1.5px 0 rgba(255, 255, 255, .55),
    inset 0 -2px 3px rgba(80, 52, 0, .4),
    0 4px 10px -3px var(--brass-glow);
}
.step.done .step-line {
  background: linear-gradient(90deg, var(--brass-face-3), var(--brass-face-2));
  box-shadow: none;
  animation: line-fill .5s var(--ease) backwards;
}
.step.now .step-dot {
  color: var(--brass);
  border-color: var(--brass);
  box-shadow: 0 0 0 3px var(--brass-bg), inset 0 1px 0 var(--bevel-hi);
  animation: chip-pulse 2.2s ease-in-out infinite;
}
@keyframes line-fill {
  from { transform: scaleX(0); transform-origin: left; }
  to   { transform: scaleX(1); transform-origin: left; }
}
@keyframes chip-pulse {
  0%, 100% { box-shadow: 0 0 0 3px var(--brass-bg), inset 0 1px 0 var(--bevel-hi); }
  50%      { box-shadow: 0 0 0 7px transparent, inset 0 1px 0 var(--bevel-hi); }
}

/* Chọn game */
.gk-games { display: flex; flex-direction: column; gap: 8px; margin: 2px 0 4px; }
.gk-game {
  display: flex; align-items: center; gap: 13px;
  padding: 12px 14px;
  border-radius: var(--r);
  text-decoration: none; color: var(--text);
  background: linear-gradient(180deg, var(--surface-3), var(--surface-2));
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 var(--bevel-hi), var(--sh-1);
  transition: transform .2s var(--ease), border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.gk-game:hover {
  transform: translateY(-2px);
  border-color: var(--brass-mid);
  box-shadow: inset 0 1px 0 var(--bevel-hi), var(--sh-3);
}
.gk-game-ic {
  width: 40px; height: 40px; flex: none;
  border-radius: 9px;
  display: grid; place-items: center;
  color: var(--brass);
  background: linear-gradient(160deg, var(--surface-4), var(--surface-2));
  box-shadow:
    inset 0 1px 0 var(--bevel-hi),
    inset 0 -2px 3px var(--bevel-lo),
    2px 2px 0 -1px var(--bevel-lo);
  transform: perspective(300px) rotateY(-12deg);
  transition: transform .4s var(--ease-spring);
}
.gk-game:hover .gk-game-ic { transform: perspective(300px) rotateY(10deg); }
.gk-game-t { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.gk-game-t b { font-weight: 600; font-size: .94rem; }
.gk-game-t span {
  font-size: .72rem; color: var(--text-mute);
  font-family: var(--f-mono);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* Số bước / hạn phải vượt cho game này — cho người chơi biết giá trước khi chọn */
.gk-game-meta {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}
.gk-game-n {
  flex: none;
  padding: 2px 9px;
  border-radius: var(--r-pill);
  font-family: var(--f-mono);
  font-size: .705rem;
  color: var(--brass);
  background: var(--brass-bg2);
  border: 1px solid var(--brass-bg);
  white-space: nowrap;
}
.gk-game-go { flex: none; color: var(--text-mute); transition: transform .2s var(--ease), color .2s var(--ease); }
.gk-game:hover .gk-game-go { color: var(--brass); transform: translateX(2px); }

.gk-pick {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  padding: 9px 13px;
  margin: 0 0 16px;
  border-radius: var(--r);
  background: var(--bg-2);
  box-shadow: var(--well);
  font-size: .88rem;
}
[data-theme="light"] .gk-pick { background: var(--surface-3); }
.gk-pick > svg { color: var(--brass); flex: none; }
.gk-pick a { margin-left: auto; }
.gk-pick a:hover { text-decoration: underline; }

/* Ô hiện key — dập nổi, viền đồng đứt nét */
.key-out {
  display: flex; align-items: center; gap: 10px;
  padding: 15px 16px;
  margin: 4px 0 16px;
  border-radius: var(--r);
  background: var(--bg-2);
  border: 1px dashed var(--brass-face-3);
  box-shadow: var(--well), 0 0 0 3px var(--brass-bg2);
  animation: stamp .45s var(--ease-spring);
}
[data-theme="light"] .key-out { background: var(--surface-3); }
.key-out code {
  flex: 1;
  font-size: 1.1rem; font-weight: 600; letter-spacing: .06em;
  word-break: break-all;
  color: var(--brass);
  text-shadow: var(--engrave);
}
@keyframes stamp {
  0%   { opacity: 0; transform: scale(1.06); }
  60%  { opacity: 1; }
  100% { opacity: 1; transform: none; }
}

/* Bảng thông số */
.meta-list {
  display: flex; flex-direction: column;
  margin: 16px 0;
  border-radius: var(--r);
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 var(--bevel-hi);
}
.meta-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 10px 14px;
  font-size: .855rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line-soft);
}
.meta-row:last-child { border-bottom: none; }
.meta-row span { color: var(--text-mute); }
.meta-row b { font-weight: 600; font-family: var(--f-mono); font-size: .95em; text-align: right; }

/* =====================================================================
   Nhiệm vụ trước khi vượt link
   ===================================================================== */

/* =====================================================================
   Chuỗi dịch vụ rút gọn
   ===================================================================== */

.chain { display: flex; flex-direction: column; gap: 8px; }
.chain-row {
  display: grid;
  grid-template-columns: 32px minmax(140px, .9fr) minmax(0, 1.7fr) 34px;
  gap: 8px;
  align-items: center;
  padding: 9px;
  border-radius: var(--r);
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  box-shadow: inset 0 1px 0 var(--bevel-hi);
  animation: rise .25s var(--ease-out);
}
.chain-idx {
  display: grid; place-items: center;
  width: 32px; height: 32px;
  border-radius: 7px;
  font-family: var(--f-mono);
  font-size: .8rem; font-weight: 600;
  color: var(--brass);
  background: linear-gradient(165deg, var(--surface-4), var(--surface-2));
  box-shadow: inset 0 1px 0 var(--bevel-hi), inset 0 -2px 3px var(--bevel-lo);
}
.chain-row .input, .chain-row .select { padding: 8px 11px; font-size: .84rem; }
.chain-row .select { padding-right: 30px; }

@keyframes rise {
  from { opacity: 0; transform: translateY(-5px); }
  to   { opacity: 1; transform: none; }
}

/* =====================================================================
   Số bước & hạn giờ riêng theo game — lưới gọn, tự xuống 1 cột trên mobile
   ===================================================================== */

.gsteps {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
}

.gstep {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r);
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  box-shadow: inset 0 1px 0 var(--bevel-hi);
  cursor: default;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.gstep:hover { border-color: var(--line); }
.gstep:focus-within {
  border-color: var(--brass);
  box-shadow: inset 0 1px 0 var(--bevel-hi), 0 0 0 3px var(--brass-bg);
}
/* Game đang đặt riêng: vạch đồng mép trái, quét mắt là thấy ngay */
.gstep.is-set {
  box-shadow: inset 2px 0 0 var(--brass-line), inset 0 1px 0 var(--bevel-hi);
}
.gstep.is-set:focus-within {
  box-shadow: inset 2px 0 0 var(--brass-line), inset 0 1px 0 var(--bevel-hi), 0 0 0 3px var(--brass-bg);
}

.gstep-ic {
  display: grid; place-items: center;
  width: 28px; height: 28px;
  border-radius: 6px;
  color: var(--brass);
  background: linear-gradient(165deg, var(--surface-4), var(--surface-2));
  box-shadow: inset 0 1px 0 var(--bevel-hi), inset 0 -1px 2px var(--bevel-lo);
}

.gstep-t { min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.gstep-t b {
  font-size: .865rem; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.gstep-t span {
  font-family: var(--f-mono);
  font-size: .685rem; color: var(--text-mute);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.gstep-n {
  padding: 6px 8px;
  text-align: center;
  font-family: var(--f-mono);
  font-size: .875rem;
  appearance: textfield;
  -moz-appearance: textfield;
}
.gstep .input.gstep-n {
  width: 58px;
  min-width: 58px;
  max-width: 58px;
  flex: none;
}
.gstep .input.gstep-n--h {
  width: 68px;
  min-width: 68px;
  max-width: 68px;
}
.gstep-n::-webkit-outer-spin-button,
.gstep-n::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.gstep-n::placeholder { opacity: .5; }
/* Cả hàng đã sáng viền khi focus rồi, ô số không cần sáng thêm lần nữa */
.gstep-n:focus { box-shadow: var(--well); }

.gstep-field {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.gstep-u { font-size: .7rem; color: var(--text-mute); white-space: nowrap; }

/* =====================================================================
   Nút đổi sáng/tối
   ===================================================================== */

.theme-btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; flex: none;
  border-radius: var(--r-sm);
  background: linear-gradient(180deg, var(--surface-3), var(--surface-2));
  border: 1px solid var(--line);
  color: var(--text-dim);
  cursor: pointer;
  box-shadow: inset 0 1px 0 var(--bevel-hi), 0 2px 0 -1px var(--bevel-lo);
  transition: color .18s var(--ease), background .18s var(--ease), transform .1s var(--ease), box-shadow .1s var(--ease);
}
.theme-btn:hover { color: var(--brass); background: linear-gradient(180deg, var(--surface-4), var(--surface-3)); }
.theme-btn:active { transform: translateY(1.5px); box-shadow: inset 0 2px 4px var(--bevel-lo); }
.theme-btn svg { width: 17px; height: 17px; }
.theme-btn .icon-sun,
.theme-btn .icon-moon { display: flex; transition: transform .35s var(--ease-spring); }
.theme-btn .icon-sun { display: none; }
[data-theme="light"] .theme-btn .icon-sun { display: flex; }
[data-theme="light"] .theme-btn .icon-moon { display: none; }
.theme-btn.is-spinning .icon-sun,
.theme-btn.is-spinning .icon-moon { transform: rotate(180deg) scale(.8); }

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .theme-btn .icon-sun { display: flex; }
  :root:not([data-theme]) .theme-btn .icon-moon { display: none; }
}

/* =====================================================================
   Tiện dụng
   ===================================================================== */

.stack   { display: flex; flex-direction: column; gap: 16px; }
.row     { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.spacer  { margin-left: auto; }
.dim     { color: var(--text-dim); }
.mute    { color: var(--text-mute); }
.sm      { font-size: .82rem; }
.xs      { font-size: .745rem; }
.nowrap  { white-space: nowrap; }
.center  { text-align: center; }
.right   { text-align: right; }
.mb0     { margin-bottom: 0; }
.mt-sm   { margin-top: 10px; }
.mt      { margin-top: 18px; }
.hr {
  height: 1px; border: 0; margin: 18px 0;
  background: var(--line-soft);
  box-shadow: 0 1px 0 var(--bevel-hi);
}
.tnum    { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.pos { color: var(--ok);  font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.neg { color: var(--bad); font-family: var(--f-mono); font-variant-numeric: tabular-nums; }

/* Nút copy */
.copy {
  display: inline-grid; place-items: center;
  width: 28px; height: 28px; flex: none;
  border-radius: 5px;
  color: var(--text-mute);
  background: linear-gradient(180deg, var(--surface-3), var(--surface-2));
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 var(--bevel-hi);
  cursor: pointer;
  transition: color .14s var(--ease), background .14s var(--ease), transform .1s var(--ease);
}
.copy:hover { color: var(--brass); background: linear-gradient(180deg, var(--surface-4), var(--surface-3)); }
.copy:active { transform: translateY(1px); }
.copy svg { width: 13px; height: 13px; }
.copy.done {
  color: var(--ok);
  border-color: var(--ok-ln);
  background: var(--ok-bg);
}

/* Thanh mức dùng thiết bị */
.bar {
  height: 5px; border-radius: var(--r-pill);
  background: var(--bg-2);
  box-shadow: var(--well);
  overflow: hidden;
}
[data-theme="light"] .bar { background: var(--surface-4); }
.bar > i {
  display: block; height: 100%; border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--brass-face-3), var(--brass-face-2));
  box-shadow: 0 0 6px var(--brass-glow);
  transition: width .6s var(--ease);
}
.bar.full > i {
  background: linear-gradient(90deg, #a5382a, var(--bad));
  box-shadow: none;
}

/* Khung chờ */
.skeleton {
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-4) 37%, var(--surface-3) 63%);
  background-size: 400% 100%;
  animation: skeleton 1.3s ease infinite;
  border-radius: 4px;
  color: transparent;
}
@keyframes skeleton {
  0%   { background-position: 100% 0; }
  100% { background-position: 0 0; }
}

/* =====================================================================
   Đáp ứng màn hình
   ===================================================================== */

@media (max-width: 1100px) {
  .grid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.split { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 900px) {
  .sidebar {
    position: fixed; z-index: 60;
    left: 0; top: 0;
    width: 262px; flex-basis: 262px;
    transform: translateX(-100%);
    transition: transform .28s var(--ease-out);
    box-shadow: var(--sh-4);
  }
  .sidebar.open { transform: none; }
  .menu-btn { display: inline-flex; }
  .content { padding: 18px 15px calc(54px + env(safe-area-inset-bottom)); }
  .topbar { padding: 11px 14px; gap: 10px; flex-wrap: wrap; }
  .topbar h1 { font-size: 1.1rem; }
  .grid.c3, .grid.c2 { grid-template-columns: minmax(0, 1fr); }
  .field-row, .field-row.c3 { grid-template-columns: minmax(0, 1fr); }
  .chain-row { grid-template-columns: 32px 1fr 34px; }
  .chain-row .chain-token { grid-column: 2 / -1; }
  .toast-stack { right: 12px; bottom: 12px; left: 12px; width: auto; max-width: none; }
  .panel-head, .panel-body, .panel-foot { padding-left: 15px; padding-right: 15px; }
  .tbl th { padding-left: 12px; padding-right: 12px; }
  .tbl td { padding-left: 12px; padding-right: 12px; }
}

/* Trên mobile thanh tiêu đề xuống 2 hàng: tiêu đề trên, nút hành động dưới */
@media (max-width: 720px) {
  .topbar > div:not(.topbar-actions) { flex: 1 1 auto; min-width: 0; }
  .theme-btn { order: 3; }
  .topbar-actions {
    order: 4;
    flex: 1 0 100%;
    margin-left: 0;
    overflow-x: auto;
    padding-bottom: 1px;
    scrollbar-width: none;
  }
  .topbar-actions::-webkit-scrollbar { display: none; }
  .topbar-actions .btn { flex: 1 1 auto; }
  /* Vùng chạm đủ lớn cho ngón tay */
  .btn { padding: 10px 15px; }
  .btn-sm { padding: 8px 12px; }
  .btn-icon { padding: 9px; }
  .btn-sm.btn-icon { padding: 8px; }
  .copy { width: 32px; height: 32px; }
  .gk-head, .gk-body { padding-left: 18px; padding-right: 18px; }
  .gk-shell { padding: 18px 12px; }
  .auth-shell { padding: 24px 14px; }
  .auth-card { padding: 26px 20px 22px; }
  .key-cell { max-width: none; }
}

@media (max-width: 560px) {
  body { font-size: 14.5px; }
  .grid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { padding: 13px 14px 14px; }
  .stat-v { font-size: 1.5rem; }
  .stat-sub { font-size: .715rem; }
  .gk-head h1 { font-size: 1.3rem; }
  .steps { margin-bottom: 16px; }
  .step-dot { width: 28px; height: 28px; font-size: .74rem; }
  .step-line { margin: 0 5px; }
  .key-out code { font-size: .97rem; }
  .gk-forge .forge { max-width: 132px; }
  .auth-logo.has-forge { max-width: 168px; }
  .auth-logo.has-forge .forge { max-width: 168px; }
  .meta-row { font-size: .82rem; padding: 9px 12px; }
  .gstep { grid-template-columns: 26px minmax(0, 1fr); gap: 8px; padding: 7px 9px; }
  .gstep-ic { grid-row: 1 / span 3; align-self: start; }
  .gstep-t { grid-column: 2; }
  .gstep-field { grid-column: 2; justify-content: flex-end; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* =====================================================================
   Mixu UI refresh — rõ thứ bậc, thao tác nhanh, bảng đọc tốt trên mobile
   Giữ nguyên class cũ để không ảnh hưởng logic PHP; đây là lớp giao diện
   mới đặt sau design system cũ nên có thể rollback gọn một block.
   ===================================================================== */

:root {
  --bg: #0b1020;
  --bg-2: #070b16;
  --surface: #111827;
  --surface-2: #151f32;
  --surface-3: #1d2a41;
  --surface-4: #2a3a58;
  --line: rgba(148, 163, 184, .18);
  --line-soft: rgba(148, 163, 184, .11);
  --bevel-hi: rgba(255, 255, 255, .06);
  --bevel-lo: rgba(0, 0, 0, .34);
  --sheen: rgba(255, 255, 255, .07);
  --sheen-2: rgba(255, 255, 255, .03);
  --well: inset 0 1px 2px rgba(0, 0, 0, .2);
  --brushed: transparent;
  --engrave: none;
  --text: #edf2ff;
  --text-dim: #a9b6ce;
  --text-mute: #71809a;
  --brass: #9d8cff;
  --brass-hi: #c4b5fd;
  --brass-mid: #7c6bf0;
  --brass-lo: #5b4bc3;
  --brass-bg: rgba(139, 124, 246, .16);
  --brass-bg2: rgba(139, 124, 246, .08);
  --brass-glow: rgba(139, 124, 246, .35);
  --brass-face-1: #c4b5fd;
  --brass-face-2: #9180f4;
  --brass-face-3: #6f5de0;
  --brass-edge: #5c4bc4;
  --brass-ink: #171229;
  --brass-line: #9d8cff;
  --ok: #34d399;
  --ok-bg: rgba(52, 211, 153, .11);
  --ok-ln: rgba(52, 211, 153, .28);
  --warn: #fbbf24;
  --warn-bg: rgba(251, 191, 36, .11);
  --warn-ln: rgba(251, 191, 36, .28);
  --bad: #fb7185;
  --bad-bg: rgba(251, 113, 133, .11);
  --bad-ln: rgba(251, 113, 133, .3);
  --idle: #71809a;
  --sh-1: 0 1px 2px rgba(0, 0, 0, .2);
  --sh-2: 0 12px 30px rgba(0, 0, 0, .18);
  --sh-3: 0 18px 44px rgba(0, 0, 0, .24);
  --sh-4: 0 24px 70px rgba(0, 0, 0, .32);
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --r-xl: 22px;
}

[data-theme="light"] {
  --bg: #f4f6fb;
  --bg-2: #e9edf5;
  --surface: #ffffff;
  --surface-2: #fbfcff;
  --surface-3: #f0f3f9;
  --surface-4: #e2e8f2;
  --line: rgba(71, 85, 105, .17);
  --line-soft: rgba(71, 85, 105, .1);
  --bevel-hi: rgba(255, 255, 255, .92);
  --bevel-lo: rgba(71, 85, 105, .12);
  --well: inset 0 1px 2px rgba(71, 85, 105, .08);
  --text: #172033;
  --text-dim: #586780;
  --text-mute: #8490a5;
  --brass: #6554d8;
  --brass-hi: #7c6bf0;
  --brass-mid: #5747c7;
  --brass-lo: #4538a2;
  --brass-bg: rgba(101, 84, 216, .11);
  --brass-bg2: rgba(101, 84, 216, .06);
  --brass-glow: rgba(101, 84, 216, .24);
  --brass-face-1: #a69afb;
  --brass-face-2: #8273e8;
  --brass-face-3: #6858d0;
  --brass-edge: #5646bf;
  --brass-ink: #fff;
  --brass-line: #6d5bdd;
  --sh-1: 0 1px 2px rgba(71, 85, 105, .08);
  --sh-2: 0 12px 30px rgba(71, 85, 105, .09);
  --sh-3: 0 18px 44px rgba(71, 85, 105, .13);
  --sh-4: 0 24px 70px rgba(71, 85, 105, .16);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg: #f4f6fb;
    --bg-2: #e9edf5;
    --surface: #ffffff;
    --surface-2: #fbfcff;
    --surface-3: #f0f3f9;
    --surface-4: #e2e8f2;
    --line: rgba(71, 85, 105, .17);
    --line-soft: rgba(71, 85, 105, .1);
    --bevel-hi: rgba(255, 255, 255, .92);
    --bevel-lo: rgba(71, 85, 105, .12);
    --well: inset 0 1px 2px rgba(71, 85, 105, .08);
    --text: #172033;
    --text-dim: #586780;
    --text-mute: #8490a5;
    --brass: #6554d8;
    --brass-hi: #7c6bf0;
    --brass-mid: #5747c7;
    --brass-lo: #4538a2;
    --brass-bg: rgba(101, 84, 216, .11);
    --brass-bg2: rgba(101, 84, 216, .06);
    --brass-glow: rgba(101, 84, 216, .24);
    --brass-face-1: #a69afb;
    --brass-face-2: #8273e8;
    --brass-face-3: #6858d0;
    --brass-edge: #5646bf;
    --brass-ink: #fff;
    --brass-line: #6d5bdd;
    --sh-1: 0 1px 2px rgba(71, 85, 105, .08);
    --sh-2: 0 12px 30px rgba(71, 85, 105, .09);
    --sh-3: 0 18px 44px rgba(71, 85, 105, .13);
    --sh-4: 0 24px 70px rgba(71, 85, 105, .16);
  }
}

html { scroll-behavior: smooth; }
body {
  background:
    radial-gradient(circle at 82% -10%, rgba(139, 124, 246, .12), transparent 32rem),
    var(--bg);
  font-size: 15px;
}
body::before { display: none; }
.app { background: transparent; }

.sidebar {
  flex-basis: 248px;
  padding: 20px 14px 16px;
  background: rgba(12, 18, 34, .86);
  border-right: 1px solid var(--line);
  box-shadow: 14px 0 40px rgba(0, 0, 0, .12);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
[data-theme="light"] .sidebar { background: rgba(255, 255, 255, .88); }
.brand { padding: 4px 8px 24px; }
.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  transform: none;
  background: linear-gradient(145deg, #c4b5fd, #7564e8);
  box-shadow: 0 10px 24px rgba(139, 124, 246, .28);
}
.brand:hover .brand-mark { transform: translateY(-2px); }
.brand-text strong { font-size: 1.02rem; }
.brand-text span { color: var(--brass-hi); }
.nav-label { padding: 18px 10px 8px; letter-spacing: .14em; }
.nav-item {
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text-dim);
}
.nav-item::before { width: 3px; background: var(--brass); }
.nav-item:hover { background: rgba(139, 124, 246, .09); color: var(--text); }
.nav-item.is-active {
  background: linear-gradient(90deg, rgba(139, 124, 246, .18), rgba(139, 124, 246, .04));
  color: var(--text);
  box-shadow: none;
}
.nav-item.is-active svg { color: var(--brass-hi); }
.sidebar-foot { border-top-color: var(--line-soft); box-shadow: none; }
.who { background: rgba(255, 255, 255, .025); }
[data-theme="light"] .who { background: rgba(101, 84, 216, .04); }
.who-av { border-radius: 10px; background: var(--brass-bg); color: var(--brass-hi); box-shadow: none; }

.topbar {
  padding: 16px 28px;
  background: rgba(17, 24, 39, .78);
  border-bottom-color: var(--line);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .08);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
[data-theme="light"] .topbar { background: rgba(255, 255, 255, .82); }
.topbar::after { background: linear-gradient(90deg, var(--brass), transparent 42%); opacity: .8; }
.topbar h1 { font-size: 1.28rem; letter-spacing: -.02em; }
.topbar .sub { margin-top: 3px; }
.content { max-width: 1560px; padding: 28px 28px 72px; }
.menu-btn { border-radius: 10px; }

.panel {
  overflow: hidden;
  background: rgba(17, 24, 39, .78);
  border-color: var(--line);
  border-radius: 16px;
  box-shadow: var(--sh-2);
  animation: none;
}
[data-theme="light"] .panel { background: rgba(255, 255, 255, .9); }
.panel::before { display: none; }
.panel-head { padding: 18px 20px; border-bottom-color: var(--line-soft); box-shadow: none; }
.panel-head h2 { font-size: 1.02rem; letter-spacing: -.015em; }
.panel-head .hint { font-size: .78rem; }
.panel-body { padding: 20px; }
.panel-foot { padding: 15px 20px; background: rgba(255, 255, 255, .018); box-shadow: none; border-top-color: var(--line-soft); }

.stat {
  padding: 18px 19px;
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(29, 42, 65, .9), rgba(17, 24, 39, .88));
  border-color: var(--line);
  box-shadow: var(--sh-1);
}
[data-theme="light"] .stat { background: linear-gradient(145deg, #fff, #f4f6fb); }
.stat::before { height: 3px; background: linear-gradient(90deg, var(--brass), transparent); }
.stat:hover { transform: translateY(-3px); border-color: rgba(157, 140, 255, .42); box-shadow: var(--sh-2); }
.stat-k { font-size: .7rem; letter-spacing: .08em; }
.stat-v { margin-top: 12px; font-size: 2rem; font-weight: 600; letter-spacing: -.06em; }
.stat-sub { margin-top: 7px; }

.btn {
  min-height: 38px;
  padding: 9px 14px;
  border-radius: 9px;
  background: var(--surface-3);
  border-color: var(--line);
  box-shadow: none;
}
.btn:hover { background: var(--surface-4); border-color: rgba(157, 140, 255, .42); }
.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, #a99bff, #6f5de0);
  border-color: #7564e8;
  text-shadow: none;
  box-shadow: 0 8px 18px rgba(111, 93, 224, .22);
}
.btn-primary:hover { color: #fff; background: linear-gradient(135deg, #bcb2ff, #7c6bf0); border-color: #8d7ff4; }
.btn-ghost { background: transparent; box-shadow: none; }
.btn-danger { background: var(--bad-bg); box-shadow: none; }
.btn-danger:hover { background: var(--bad); border-color: var(--bad); }
.btn-sm { min-height: 34px; padding: 7px 11px; }
.btn-icon { min-height: 34px; }

.input, .select, textarea.input {
  min-height: 42px;
  border-radius: 9px;
  background: rgba(7, 11, 22, .62);
  border-color: var(--line);
  box-shadow: none;
}
[data-theme="light"] .input,
[data-theme="light"] .select,
[data-theme="light"] textarea.input { background: #f8faff; }
.input:hover, .select:hover, textarea.input:hover { border-color: rgba(157, 140, 255, .42); }
.input:focus, .select:focus, textarea.input:focus { border-color: var(--brass); box-shadow: 0 0 0 3px var(--brass-bg); }
.input-sm { min-height: 36px; }

.tbl { font-size: .88rem; }
.tbl th { padding: 12px 16px; background: rgba(29, 42, 65, .72); color: var(--text-mute); letter-spacing: .1em; border-bottom-color: var(--line); box-shadow: none; }
[data-theme="light"] .tbl th { background: #f2f5fb; }
.tbl td { padding: 14px 16px; border-bottom-color: var(--line-soft); }
.tbl tbody tr:hover { background: rgba(139, 124, 246, .055); }
.key-cell code { border-radius: 7px; background: rgba(7, 11, 22, .7); border-color: var(--line); padding: 5px 9px; }
[data-theme="light"] .key-cell code { background: #eef1f8; }
.copy { border-radius: 8px; background: var(--surface-3); border-color: var(--line); box-shadow: none; }
.badge { padding: 3px 9px; border-radius: 7px; box-shadow: none; }
.bar { height: 6px; box-shadow: none; background: var(--surface-4); }

.empty { padding: 64px 24px; }
.empty-mark { border-radius: 16px; transform: none; box-shadow: var(--sh-2); }
.empty:hover .empty-mark { transform: translateY(-2px); }

/* Thanh lọc và phân trang của License */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.license-list-head { display: flex; flex-direction: column; align-items: stretch; gap: 18px; }
.list-heading { min-width: 0; }
.eyebrow { display: flex; align-items: center; gap: 7px; color: var(--text-mute); font-size: .68rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.eyebrow-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brass); box-shadow: 0 0 10px var(--brass-glow); }
.list-title-row { display: flex; align-items: center; gap: 10px; margin-top: 7px; }
.list-title-row h2 { margin: 0; }
.count-pill { display: inline-flex; align-items: center; min-height: 24px; padding: 2px 8px; border-radius: 999px; color: var(--brass-hi); background: var(--brass-bg); font-family: var(--f-mono); font-size: .7rem; }
.list-meta { margin-top: 5px; color: var(--text-mute); font-size: .78rem; }
.filter-bar { display: grid; grid-template-columns: minmax(190px, 1.5fr) minmax(130px, 1fr) minmax(145px, 1fr) minmax(120px, .85fr) auto; gap: 9px; align-items: center; width: 100%; }
.filter-bar:not(.has-actions) { grid-template-columns: minmax(190px, 1.5fr) minmax(130px, 1fr) minmax(145px, 1fr) minmax(120px, .85fr); }
.filter-search, .filter-select { position: relative; display: block; min-width: 0; }
.filter-search > svg { position: absolute; left: 12px; top: 50%; z-index: 1; transform: translateY(-50%); color: var(--text-mute); pointer-events: none; }
.filter-search .input { width: 100%; padding-left: 36px; }
.filter-select .select { width: 100%; padding-right: 32px; }
.filter-actions { display: flex; align-items: center; justify-content: flex-end; gap: 7px; }
.filter-summary { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; padding: 11px 20px; border-bottom: 1px solid var(--line-soft); background: rgba(139, 124, 246, .035); }
.filter-summary-label { display: inline-flex; align-items: center; gap: 5px; color: var(--text-mute); font-size: .75rem; font-weight: 600; }
.filter-chip { display: inline-flex; align-items: center; gap: 4px; min-height: 26px; padding: 3px 9px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-3); color: var(--text-dim); font-size: .73rem; }
.filter-chip-link { text-decoration: none; transition: border-color .16s ease, background .16s ease, color .16s ease; }
.filter-chip-link:hover { color: var(--text); border-color: var(--brass); background: var(--brass-bg); }
.filter-chip-link svg { flex: none; color: var(--text-mute); }
.filter-chip b { color: var(--text); font-weight: 600; }
.bulk-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 20px 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 11px; background: rgba(139, 124, 246, .045); }
.bulk-selection { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 7px; color: var(--text-mute); font-size: .76rem; }
.bulk-select-all { display: inline-flex; align-items: center; gap: 7px; color: var(--text-dim); font-size: .76rem; font-weight: 600; cursor: pointer; }
.bulk-select-all input { width: 16px; height: 16px; margin: 0; accent-color: var(--brass); cursor: pointer; }
.bulk-selection-count { min-width: 1.2em; color: var(--text); font-family: var(--f-mono); font-weight: 700; text-align: right; }
.bulk-actions { display: flex; align-items: center; gap: 7px; }
.bulk-bar .btn:disabled { opacity: .48; cursor: not-allowed; }
.license-table { min-width: 860px; }
.license-table .select-col { width: 44px; min-width: 44px; padding-left: 13px; padding-right: 8px; text-align: center; }
.license-table .select-col input { width: 16px; height: 16px; margin: 0; accent-color: var(--brass); cursor: pointer; }
.license-table .row-actions { min-width: 180px; }
.license-table .row-actions > .row-quick-form { order: 1; }
.license-table .row-actions > .row-menu { order: 3; }
.row-quick-form { display: flex; margin: 0; }
.row-delete-form { display: flex; margin: 0; order: 4; }
.row-delete-action { color: var(--bad); }
.row-delete-action:hover { color: #fff; border-color: var(--bad); background: var(--bad-bg); }
.row-menu { position: relative; }
.row-menu > summary { list-style: none; cursor: pointer; }
.row-menu > summary::-webkit-details-marker { display: none; }
.row-menu[open] > summary { color: var(--brass-hi); border-color: var(--brass); background: var(--brass-bg); }
.row-menu-scrim {
  position: fixed;
  z-index: 80;
  inset: 0;
  background: rgba(5, 9, 17, .58);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .16s var(--ease);
}
.row-menu-scrim.is-on { opacity: 1; pointer-events: auto; }
.row-menu-pop {
  position: fixed;
  z-index: 90;
  top: 50%;
  right: auto;
  bottom: auto;
  left: 50%;
  width: min(560px, calc(100vw - 24px));
  max-height: min(720px, calc(100vh - 32px));
  max-height: min(720px, calc(100dvh - 32px));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-2);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .42), var(--sh-4);
  transform: translate(-50%, -50%);
  transform-origin: center;
}
.row-menu-pop form { margin: 0; }
.row-menu-link { text-decoration: none; }
.row-menu-form { padding: 8px 9px 9px; }
.row-menu-form + .row-menu-form { border-top: 1px solid var(--line-soft); }
.row-menu-form-title { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: .79rem; font-weight: 600; }
.row-menu-form-title svg { flex: none; color: var(--text-mute); }
.row-menu-form-help { margin-top: 4px; color: var(--text-mute); font-size: .7rem; }
.row-menu-adjust-mode {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  margin-top: 8px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-3);
}
.row-menu-adjust-mode button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 38px;
  padding: 6px 7px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--text-dim);
  background: transparent;
  font: inherit;
  font-size: .73rem;
  font-weight: 700;
  cursor: pointer;
  transition: color .13s var(--ease), background .13s var(--ease), border-color .13s var(--ease), transform .13s var(--ease);
}
.row-menu-adjust-mode button b {
  display: inline-grid;
  place-items: center;
  width: 23px;
  height: 23px;
  border: 1px solid currentColor;
  border-radius: 6px;
  font-family: var(--f-mono);
  font-size: 1.05rem;
  line-height: 1;
}
.row-menu-adjust-mode button:hover { color: var(--text); border-color: var(--brass-mid); background: var(--brass-bg); }
.row-menu-adjust-mode button:active { transform: translateY(1px); }
.row-menu-adjust-mode button[data-sign="1"].is-active { color: var(--ok); border-color: var(--ok-ln); background: var(--ok-bg); box-shadow: inset 0 0 0 1px rgba(43, 210, 157, .08); }
.row-menu-adjust-mode button[data-sign="-1"].is-active { color: var(--bad); border-color: var(--bad-ln); background: var(--bad-bg); box-shadow: inset 0 0 0 1px rgba(239, 105, 122, .08); }
.row-menu-form-row { display: flex; align-items: center; gap: 6px; margin-top: 7px; }
.row-menu-number { width: 112px; min-width: 0; min-height: 34px; padding: 6px 8px; font-family: var(--f-mono); }
.row-menu-unit { color: var(--text-mute); font-size: .73rem; white-space: nowrap; }
.row-menu-form-row .btn { margin-left: auto; flex: none; }
.row-menu-picks { margin-top: 6px; }
.row-menu-picks button { min-width: 30px; padding: 3px 7px; }
.row-menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 35px;
  padding: 7px 9px;
  border: 0;
  border-radius: 7px;
  color: var(--text-dim);
  background: transparent;
  font: inherit;
  font-size: .79rem;
  text-align: left;
  cursor: pointer;
}
.row-menu-item:hover { color: var(--text); background: var(--brass-bg); }
.row-menu-item svg { flex: none; color: var(--text-mute); }
.pagination-foot { justify-content: space-between; }
.pagination-summary { display: flex; align-items: baseline; gap: 10px; color: var(--text-dim); }
.pagination { display: flex; align-items: center; gap: 5px; }
.pager-size-form { display: flex; align-items: center; gap: 8px; margin: 0; }
.pager-size-form label { color: var(--text-mute); font-size: .74rem; white-space: nowrap; }
.pager-size-form .select { width: auto; min-width: 112px; min-height: 34px; padding-top: 5px; padding-bottom: 5px; }
.page-number, .page-arrow { display: inline-grid; place-items: center; min-width: 34px; height: 34px; padding: 0 8px; border: 1px solid var(--line); border-radius: 8px; color: var(--text-dim); background: var(--surface-3); font-family: var(--f-mono); font-size: .76rem; text-decoration: none; }
.page-number:hover, .page-arrow:hover { color: var(--text); border-color: var(--brass); background: var(--brass-bg); }
.page-number.is-current { color: #fff; border-color: var(--brass); background: var(--brass-mid); box-shadow: 0 5px 14px var(--brass-glow); }
.page-ellipsis { min-width: 20px; color: var(--text-mute); text-align: center; }
.page-arrow.is-disabled { opacity: .35; pointer-events: none; }

@media (max-width: 1180px) {
  .filter-bar { grid-template-columns: minmax(210px, 1.4fr) repeat(3, minmax(110px, 1fr)) auto; }
  .filter-bar:not(.has-actions) { grid-template-columns: minmax(210px, 1.4fr) repeat(3, minmax(110px, 1fr)); }
}

@media (max-width: 900px) {
  .sidebar { background: #0e1628; }
  .topbar { padding: 14px 18px; }
  .content { padding: 22px 18px 60px; }
  .filter-bar { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .filter-search, .filter-actions { grid-column: 1 / -1; }
  .filter-source { grid-column: auto; }
  .filter-actions { justify-content: flex-start; }
}

@media (max-width: 720px) {
  .content { padding: 16px 12px 48px; }
  .topbar { padding: 12px 13px; }
  .topbar-actions { gap: 6px; }
  .panel-head, .panel-body, .panel-foot { padding-left: 15px; padding-right: 15px; }
  .filter-summary { padding-left: 15px; padding-right: 15px; }
  .bulk-bar { margin-left: 15px; margin-right: 15px; }
  .filter-bar { grid-template-columns: 1fr 1fr; gap: 8px; }
  .filter-search, .filter-actions { grid-column: 1 / -1; }
  .filter-select .select { min-height: 40px; }
  .filter-actions { justify-content: stretch; }
  .filter-actions .btn { flex: 1; }
  .filter-clear-label { display: inline; }
  .license-table-wrap { overflow: visible; }
  .license-table { min-width: 0; display: block; }
  .license-table thead { display: none; }
  .license-table tbody { display: grid; gap: 10px; }
  .license-table tbody tr { display: grid; gap: 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 13px; background: rgba(29, 42, 65, .45); }
  [data-theme="light"] .license-table tbody tr { background: #fbfcff; }
  .license-table tbody tr:hover { background: rgba(139, 124, 246, .08); }
  .license-table td { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; padding: 8px 0; border-bottom: 0; text-align: right; }
  .license-table td > * { min-width: 0; }
  .license-table td .key-cell { min-width: 0; }
  .license-table td .xs, .license-table td .mono { overflow-wrap: anywhere; word-break: break-word; }
  .license-table td .key-cell code { min-width: 0; overflow-wrap: anywhere; word-break: break-word; }
  .license-table td::before { content: attr(data-label); flex: 0 0 auto; color: var(--text-mute); font-size: .71rem; font-weight: 600; letter-spacing: .06em; text-align: left; text-transform: uppercase; }
  .license-table td:first-child { display: block; padding-top: 0; padding-bottom: 10px; text-align: left; }
  .license-table td:first-child::before { display: none; }
  .license-table td:nth-child(2) > *, .license-table td:nth-child(3) > *, .license-table td:nth-child(4) > *, .license-table td:nth-child(5) > * { max-width: 68%; }
  .license-table td.actions { display: flex; justify-content: flex-start; align-items: center; gap: 6px; margin-top: 5px; padding-top: 11px; border-top: 1px solid var(--line-soft); }
  .license-table td.actions::before { display: none; }
  .license-table .row-actions { min-width: 0; }
  .pagination-foot { align-items: stretch; flex-direction: column; }
  .pagination-summary { justify-content: space-between; }
  .pagination { justify-content: center; }
  .pager-size-form { justify-content: space-between; }
  .pager-size-form .select { flex: 1; }
  .page-number, .page-arrow { min-width: 32px; height: 32px; }
}

@media (max-width: 420px) {
  .filter-bar { grid-template-columns: 1fr; }
  .filter-source { grid-column: 1 / -1; }
  .list-title-row { align-items: flex-start; flex-direction: column; gap: 5px; }
  .filter-clear-label { display: none; }
}

.delete-confirm-dialog {
  width: min(600px, calc(100vw - 36px));
  max-height: calc(100dvh - 36px);
  margin: auto;
  padding: 26px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  color: var(--text);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  box-shadow: var(--sh-4);
}
.delete-confirm-dialog::backdrop {
  background: rgba(4, 7, 14, .66);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.delete-confirm-dialog p { margin: 0; color: var(--text); font-size: 1rem; }
.delete-confirm-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }

@media (max-width: 560px) {
  .delete-confirm-dialog { padding: 22px 18px; }
}
