/* =========================================================================
   MCRX - giao dien panel quan tri va shop
   Mot file CSS, khong build step, khong node_modules. Mobile-first.
   ========================================================================= */

:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #0f172a;
  --ink-2: #475569;
  --ink-3: #8091a7;
  --line: #e2e8f0;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --brand-soft: #eff4ff;
  --ok: #0f8a4f;
  --ok-soft: #e7f7ee;
  --warn: #b45309;
  --warn-soft: #fff4e5;
  --err: #b42318;
  --err-soft: #feeceb;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px -16px rgba(15, 23, 42, .25);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .6rem; line-height: 1.25; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
p { margin: .4rem 0; }
small, .muted { color: var(--ink-3); }
code, .code, pre {
  font-family: var(--mono);
  font-size: .86em;
}
code { background: #f1f5f9; padding: .12em .35em; border-radius: 5px; word-break: break-all; }
pre {
  background: #0f172a; color: #e2e8f0; padding: .9rem 1rem; border-radius: 10px;
  overflow: auto; max-height: 420px;
}
pre code { background: none; padding: 0; color: inherit; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  padding: .5rem .85rem; border-radius: 9px; border: 1px solid var(--brand);
  background: var(--brand); color: #fff; font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--brand-dark); border-color: var(--brand-dark); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.small { padding: .3rem .6rem; font-size: .82rem; border-radius: 7px; }
.btn.ghost { background: transparent; color: var(--ink-2); border-color: var(--line); }
.btn.ghost:hover { background: #f1f5f9; color: var(--ink); text-decoration: none; }
.btn.danger { background: var(--err); border-color: var(--err); }
.btn.danger:hover { background: #8f1c13; }
.btn.ok { background: var(--ok); border-color: var(--ok); }
.btn.block { width: 100%; }
.inline { display: inline; }

/* ---------- forms ---------- */
label { display: block; font-weight: 600; font-size: .85rem; color: var(--ink-2); margin-bottom: .25rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url],
input[type=search], input[type=file], select, textarea {
  width: 100%; padding: .5rem .6rem; font: inherit; color: var(--ink);
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--brand-soft); border-color: var(--brand);
}
textarea { min-height: 90px; resize: vertical; }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--brand); }
.field { margin-bottom: .8rem; }
.field .hint { font-size: .78rem; color: var(--ink-3); margin-top: .2rem; }
.row { display: flex; gap: .8rem; flex-wrap: wrap; }
.row > * { flex: 1 1 180px; min-width: 0; }
.filters { display: flex; gap: .6rem; flex-wrap: wrap; align-items: end; margin-bottom: 1rem; }
.filters .field { margin: 0; }
.filters .field.wide { flex: 1 1 240px; }

/* ---------- layout admin ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 236px; flex: 0 0 236px; background: #0b1220; color: #cbd5e1;
  display: flex; flex-direction: column; padding: .9rem .7rem; position: sticky; top: 0;
  height: 100vh; height: 100dvh; overflow-y: auto;
  overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #334155 transparent;
}
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: #334155; border-radius: 999px; }
.sidebar::-webkit-scrollbar-thumb:hover { background: #475569; }
.sidebar .brand { font-weight: 800; font-size: 1.05rem; letter-spacing: .02em; padding: .3rem .5rem 1rem; }
.sidebar .brand a { color: #fff; }
.sidebar .brand .dot { color: var(--brand); margin: 0 .15rem; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar .group {
  margin: .9rem .5rem .25rem; font-size: .68rem; text-transform: uppercase;
  letter-spacing: .08em; color: #64748b; font-weight: 700;
}
.sidebar nav a {
  color: #cbd5e1; padding: .42rem .55rem; border-radius: 8px; font-size: .88rem;
}
.sidebar nav a:hover { background: #16213a; color: #fff; text-decoration: none; }
.sidebar nav a.on { background: var(--brand); color: #fff; font-weight: 600; }
.sidefoot { margin-top: auto; padding: .8rem .5rem 0; font-size: .8rem; }
.sidefoot a { color: #93c5fd; }

.main { flex: 1 1 auto; min-width: 0; padding: 0 1.1rem 3rem; }
.topbar {
  display: flex; align-items: center; gap: .8rem; padding: .9rem 0 1rem;
  border-bottom: 1px solid var(--line); margin-bottom: 1.1rem;
}
.topbar h1 { margin: 0; font-size: 1.15rem; flex: 1 1 auto; }
.whoami { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.burger { display: none; font-size: 1.3rem; cursor: pointer; padding: .1rem .35rem; }

@media (max-width: 900px) {
  .shell { display: block; }
  .sidebar {
    position: fixed; z-index: 40; left: 0; top: 0; transform: translateX(-100%);
    transition: transform .18s ease; height: 100vh; height: 100dvh; box-shadow: 0 0 40px rgba(0,0,0,.4);
  }
  .navtoggle:checked ~ .sidebar { transform: translateX(0); }
  .burger { display: inline-block; }
  .main { padding: 0 .8rem 2.5rem; }
}

/* ---------- cards / stats ---------- */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.1rem; box-shadow: var(--shadow); margin-bottom: 1rem;
}
.card.center { text-align: center; max-width: 520px; margin: 3rem auto; }
.card h2 { margin-top: 0; }
.card.flush { padding: 0; overflow: hidden; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .85rem 1rem; }
.stat .k { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 700; }
.stat .v { font-size: 1.55rem; font-weight: 800; margin-top: .15rem; }
.stat .s { font-size: .78rem; color: var(--ink-3); }
.stat.brand { background: linear-gradient(135deg, #1e3a8a, #2563eb); color: #fff; border: 0; }
.stat.brand .k, .stat.brand .s { color: #bfdbfe; }

/* ---------- tables ---------- */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
table { width: 100%; border-collapse: collapse; font-size: .86rem; }
th, td { text-align: left; padding: .55rem .7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #f8fafc; font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 700; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfdff; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.nowrap, th.nowrap { white-space: nowrap; }
.tablewrap.tall { max-height: 68vh; overflow-y: auto; }

.badge {
  display: inline-block; padding: .1rem .45rem; border-radius: 999px; font-size: .72rem;
  font-weight: 700; background: #eef2f7; color: var(--ink-2); border: 1px solid transparent;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.err { background: var(--err-soft); color: var(--err); }
.badge.brand { background: var(--brand-soft); color: var(--brand); }
.badge.muted { background: #f1f5f9; color: var(--ink-3); }

/* ---------- flash / messages ---------- */
.flash {
  padding: .65rem .85rem; border-radius: 9px; margin-bottom: 1rem; font-weight: 600;
  border: 1px solid transparent;
}
.flash.ok { background: var(--ok-soft); color: var(--ok); border-color: #b7ecd0; }
.flash.warn { background: var(--warn-soft); color: var(--warn); border-color: #ffe0b2; }
.flash.error { background: var(--err-soft); color: var(--err); border-color: #ffd0cc; }
.empty { padding: 2rem 1rem; text-align: center; color: var(--ink-3); }
.errorcode { font-size: 3rem; margin: 0; color: var(--ink-3); }

/* ---------- misc ---------- */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; font-size: .88rem; }
.kv dt { color: var(--ink-3); font-weight: 600; }
.kv dd { margin: 0; word-break: break-word; }
.pager { display: flex; gap: .5rem; align-items: center; margin: 1rem 0; }
.pill { display: inline-flex; gap: .3rem; align-items: center; padding: .18rem .55rem; border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-weight: 700; font-size: .76rem; }
.copybox { display: flex; gap: .5rem; align-items: center; }
.copybox input { font-family: var(--mono); font-size: .8rem; }
.product-thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: #fff; }
.tabs { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tabs a { padding: .35rem .7rem; border-radius: 999px; background: #eef2f7; color: var(--ink-2); font-weight: 600; font-size: .82rem; }
.tabs a.on { background: var(--brand); color: #fff; }
.notice { border-left: 3px solid var(--brand); background: var(--brand-soft); padding: .6rem .8rem; border-radius: 0 8px 8px 0; font-size: .87rem; }
.danger-zone { border: 1px solid #ffd0cc; background: #fffbfa; border-radius: var(--radius); padding: 1rem 1.1rem; }

/* =========================================================================
   SHOP
   ========================================================================= */
.shopbar { background: #0b1220; color: #e2e8f0; position: sticky; top: 0; z-index: 30; }
.shopbar .wrap { display: flex; align-items: center; gap: 1rem; padding: .7rem 1rem; max-width: 1080px; margin: 0 auto; }
.shopbar .logo { font-weight: 800; font-size: 1.1rem; color: #fff; letter-spacing: .02em; }
.shopbar .logo span { color: #60a5fa; }
.shopnav { display: flex; gap: .25rem; flex: 1 1 auto; flex-wrap: wrap; }
.shopnav a { color: #cbd5e1; padding: .35rem .6rem; border-radius: 8px; font-size: .9rem; }
.shopnav a:hover { background: #16213a; color: #fff; text-decoration: none; }
.shopnav a.on { background: #1e293b; color: #fff; }
.shopuser { display: flex; align-items: center; gap: .5rem; }
.shopuser .balance { background: #16213a; color: #93c5fd; font-weight: 700; padding: .25rem .6rem; border-radius: 999px; font-size: .85rem; }
.shopmain { min-height: 62vh; }
.shopmain .wrap { max-width: 1080px; margin: 0 auto; padding: 1.2rem 1rem 3rem; }
.shopfoot { border-top: 1px solid var(--line); color: var(--ink-3); font-size: .8rem; background: #fff; }
.shopfoot .wrap { max-width: 1080px; margin: 0 auto; padding: 1rem; display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.hero { background: linear-gradient(135deg, #0b1220, #1e3a8a 60%, #2563eb); color: #fff; border-radius: 16px; padding: 1.6rem 1.4rem; margin-bottom: 1.2rem; }
.hero h1 { font-size: 1.5rem; color: #fff; }
.hero p { color: #dbeafe; max-width: 60ch; }
.product-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.product { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.product img { width: 100%; height: 150px; object-fit: cover; background: #f1f5f9; }
.product .body { padding: .9rem 1rem; flex: 1 1 auto; }
.product h3 { margin: 0 0 .3rem; }
.product .desc { color: var(--ink-2); font-size: .86rem; min-height: 2.6em; }
.product .meta { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-top: .7rem; }
.price { font-weight: 800; font-size: 1.15rem; color: var(--ink); }
.stockline { font-size: .8rem; color: var(--ink-3); }
.buyform { padding: .8rem 1rem 1rem; border-top: 1px solid var(--line); display: flex; gap: .5rem; align-items: center; }
.buyform input[type=number] { width: 76px; }
.authcard { max-width: 420px; margin: 2rem auto; }
.wallettable td, .wallettable th { white-space: nowrap; }
.secret { font-family: var(--mono); font-size: .8rem; background: #f8fafc; border: 1px dashed var(--line); padding: .6rem .7rem; border-radius: 8px; word-break: break-all; }
.qr { display: block; margin: .8rem auto; width: 190px; height: 190px; image-rendering: pixelated; background: #fff; padding: .4rem; border: 1px solid var(--line); border-radius: 10px; }
.steps { counter-reset: step; padding-left: 0; list-style: none; }
.steps li { position: relative; padding-left: 2rem; margin-bottom: .7rem; }
.steps li::before {
  counter-increment: step; content: counter(step); position: absolute; left: 0; top: 0;
  width: 1.35rem; height: 1.35rem; border-radius: 999px; background: var(--brand); color: #fff;
  font-size: .75rem; font-weight: 700; display: grid; place-items: center;
}

@media (max-width: 640px) {
  .shopbar .wrap { flex-wrap: wrap; }
  .shopnav { order: 3; width: 100%; }
  .shopuser { margin-left: auto; }
  .product-grid { grid-template-columns: 1fr; }
}
