:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --text: #1b1f2a;
  --muted: #6b7385;
  --line: #e4e7ef;
  --brand: #3b5bfd;
  --brand-2: #6a3bfd;
  --brand-soft: #eef1ff;
  --ok: #12a150;
  --ok-soft: #e6f6ed;
  --warn: #c27a00;
  --warn-soft: #fff4dc;
  --err: #d93a3a;
  --err-soft: #fdeaea;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 30, 60, .05), 0 4px 16px rgba(20, 30, 60, .05);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, sans-serif; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6em; }
h1 { font-size: 26px; } h2 { font-size: 20px; } h3 { font-size: 16px; }
.container { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mt { margin-top: 16px; } .mb { margin-bottom: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* top nav */
.topbar { background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar .container { display: flex; align-items: center; gap: 20px; height: 60px; }
.logo { font-weight: 800; font-size: 19px; color: var(--text); letter-spacing: -.3px; }
.logo span { background: linear-gradient(135deg, var(--brand), var(--brand-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.nav { display: flex; gap: 18px; align-items: center; }
.nav a { color: var(--text); }
.nav a.active { color: var(--brand); font-weight: 600; }
.topbar .right-nav { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.inline { display: inline; margin: 0; }
.linkbtn { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; padding: 0; }
.linkbtn:hover { color: var(--text); }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 16px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; text-decoration: none !important; white-space: nowrap; }
.btn:hover { border-color: #cdd2df; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--err); border-color: #f2c9c9; }
.btn.danger:hover { background: var(--err-soft); }
.btn.sm { padding: 4px 10px; font-size: 13px; border-radius: 7px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card + .card { margin-top: 16px; }
.card h2 { font-size: 17px; }
.grid { display: grid; gap: 16px; }
.grid.c2 { grid-template-columns: repeat(2, 1fr); }
.grid.c3 { grid-template-columns: repeat(3, 1fr); }
.grid.c4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .grid.c3, .grid.c4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .grid.c2, .grid.c3, .grid.c4 { grid-template-columns: 1fr; } }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 4px; letter-spacing: -.5px; }

/* hero */
.hero { background: radial-gradient(1200px 400px at 20% -10%, #dfe5ff, transparent), radial-gradient(800px 400px at 90% 0%, #efe3ff, transparent); padding: 64px 0 48px; }
.hero h1 { font-size: 40px; letter-spacing: -1px; max-width: 720px; }
.hero p { color: var(--muted); font-size: 17px; max-width: 720px; }
@media (max-width: 600px) { .hero h1 { font-size: 30px; } .hero { padding: 40px 0 32px; } }
.notice { background: var(--warn-soft); border: 1px solid #f3dfb0; color: #6b4b00; padding: 10px 14px; border-radius: 10px; }

/* product cards */
.products { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.pcard { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; box-shadow: var(--shadow); transition: transform .12s, box-shadow .12s; }
.pcard:hover { transform: translateY(-2px); box-shadow: 0 8px 28px rgba(20, 30, 60, .09); }
.pcard .cat { font-size: 12px; color: var(--brand); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.pcard h3 { margin: 6px 0 10px; font-size: 17px; }
.pcard .desc { color: var(--muted); font-size: 13.5px; white-space: pre-line; flex: 1; margin-bottom: 14px; max-height: 9.5em; overflow: hidden; }
.price { font-size: 26px; font-weight: 800; letter-spacing: -.5px; }
.price small { font-size: 13px; font-weight: 500; color: var(--muted); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0 20px; }
.chip { padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font-size: 14px; }
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; text-decoration: none; }

/* forms */
label { display: block; font-weight: 500; margin-bottom: 6px; font-size: 14px; }
.field { margin-bottom: 14px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px; font: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
textarea { min-height: 90px; resize: vertical; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.check input { width: auto; }
.cycles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.cycle { position: relative; }
.cycle input { position: absolute; opacity: 0; }
.cycle span { display: block; border: 1.5px solid var(--line); border-radius: 10px; padding: 12px; cursor: pointer; background: #fff; }
.cycle span b { display: block; font-size: 18px; }
.cycle input:checked + span { border-color: var(--brand); background: var(--brand-soft); }
.hint { font-size: 13px; color: var(--muted); margin-top: 4px; }

/* auth */
.auth { max-width: 420px; margin: 56px auto; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: 14px; }
th { color: var(--muted); font-weight: 500; font-size: 13px; background: #fafbfd; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 8px 16px; }
.kv > div:nth-child(odd) { color: var(--muted); }
@media (max-width: 600px) { .kv { grid-template-columns: 1fr; } .kv > div:nth-child(odd) { margin-top: 8px; } }

/* badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #eef0f5; color: #555d70; white-space: nowrap; }
.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.info { background: var(--brand-soft); color: var(--brand); }

/* flash */
.flash { padding: 10px 14px; border-radius: 10px; margin: 16px 0 0; font-size: 14px; word-break: break-word; }
.flash.ok { background: var(--ok-soft); color: #0b6b36; border: 1px solid #c5e9d4; }
.flash.err { background: var(--err-soft); color: #9b2020; border: 1px solid #f3caca; }

/* member / admin shell */
.shell { display: grid; grid-template-columns: 220px 1fr; gap: 24px; padding: 24px 0 48px; }
.side { position: sticky; top: 84px; align-self: start; }
.side a { display: block; padding: 9px 12px; border-radius: 9px; color: var(--text); margin-bottom: 2px; }
.side a:hover { background: #eef0f6; text-decoration: none; }
.side a.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.side .group { font-size: 12px; color: var(--muted); padding: 14px 12px 4px; text-transform: uppercase; letter-spacing: .5px; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; gap: 12px; }
  .side { position: static; display: flex; gap: 4px; overflow-x: auto; padding-bottom: 4px; }
  .side a { white-space: nowrap; }
  .side .group { display: none; }
}
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 22px; }
.pager { display: flex; gap: 6px; margin-top: 16px; flex-wrap: wrap; }
.empty { text-align: center; color: var(--muted); padding: 32px 0; }
.admin-body .topbar { background: #141a2e; border-bottom-color: #141a2e; }
.admin-body .topbar .logo, .admin-body .topbar a, .admin-body .topbar .linkbtn { color: #e7eaf3; }
.addr { font-size: 15px; background: #f3f4f8; padding: 12px; border-radius: 10px; word-break: break-all; }
.big { font-size: 30px; font-weight: 800; }
.vm { border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-top: 12px; }
footer { border-top: 1px solid var(--line); padding: 24px 0; color: var(--muted); font-size: 13px; margin-top: 40px; }
details summary { cursor: pointer; color: var(--muted); }
pre { background: #f3f4f8; padding: 12px; border-radius: 10px; overflow: auto; font-size: 12px; max-height: 420px; }
