:root {
  color-scheme: dark;
  --bg: #080908;
  --surface: #111211;
  --surface-soft: #181918;
  --surface-raised: #202120;
  --ink: #f4f3f0;
  --muted: #9f9e9a;
  --faint: #696a67;
  --line: rgba(255, 255, 255, .13);
  --line-strong: rgba(255, 255, 255, .24);
  --accent: #dc8d86;
  --accent-deep: #bd6561;
  --cool: #839ba5;
  --success: #83a890;
  --danger: #e39a82;
  --shadow: 0 24px 80px rgba(0, 0, 0, .34);
  --body: "Avenir Next", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: "SFMono-Regular", "Menlo", "Courier New", monospace;
  font-family: var(--body);
  background: var(--bg);
  color: var(--ink);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; background: var(--bg); }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink); }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { border: 0; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.site-header {
  position: sticky;
  z-index: 30;
  top: 0;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(20px, 3vw, 46px);
  border-bottom: 1px solid rgba(255,255,255,.07);
  background: rgba(8,9,8,.72);
  backdrop-filter: blur(20px);
}
.brand { display: inline-flex; align-items: center; gap: 9px; }
.brand-mark { display: grid; place-items: center; width: 28px; height: 28px; border: 1px solid rgba(255,255,255,.8); border-radius: 9px 2px 9px 2px; font-weight: 700; }
.brand-name { font-size: 19px; font-weight: 700; letter-spacing: -.04em; }
.brand-edition { color: var(--muted); font-size: 12px; font-weight: 500; }
.site-header nav { display: flex; align-items: center; gap: clamp(18px, 3vw, 42px); }
.site-header nav a, .link-button { color: rgba(255,255,255,.58); font-size: 13px; transition: color .2s ease; }
.site-header nav a:hover, .link-button:hover { color: #fff; }
.nav-cta { padding: 11px 18px; border-radius: 5px; background: #fff; color: #111 !important; font-weight: 600; }
.link-button { padding: 8px 0; background: transparent; cursor: pointer; }
.header-status { color: var(--muted); font-size: 11px; }
.header-status i { display: inline-block; width: 7px; height: 7px; margin-right: 8px; border-radius: 50%; background: var(--success); }

.landing { overflow: clip; }
.section { position: relative; padding: clamp(92px, 11vw, 170px) clamp(22px, 5vw, 76px); }
.section-head { max-width: 760px; }
.section-head h2, .page-heading h2 { margin: 13px 0 18px; font-size: clamp(38px, 5vw, 70px); line-height: 1.08; letter-spacing: -.055em; }
.section-head > p:last-child, .page-heading > p:last-child, .admin-card > p { color: var(--muted); line-height: 1.8; }
.section-head.compact { max-width: none; margin-bottom: 26px; }
.section-head.compact h2 { font-size: clamp(27px, 3vw, 38px); letter-spacing: -.04em; }
.eyebrow { color: var(--accent); font-size: 11px; font-weight: 600; letter-spacing: .08em; }

.button, body button:not(.tab):not(.link-button):not(.icon-button):not(.secondary-button):not(.table-action) { padding: 13px 18px; border-radius: 5px; background: #fff; color: #111; font-weight: 700; cursor: pointer; transition: transform .2s ease, background .2s ease; }
.button:hover, body button:not(.tab):not(.link-button):not(.icon-button):not(.secondary-button):not(.table-action):hover { transform: translateY(-1px); background: #eee; }
.secondary-button { padding: 11px 15px; border: 1px solid var(--line-strong); border-radius: 5px; background: rgba(255,255,255,.04); color: var(--ink); white-space: nowrap; cursor: pointer; }
.secondary-button:hover { border-color: rgba(255,255,255,.45); background: rgba(255,255,255,.08); }
.secondary-button:disabled { opacity: .42; cursor: not-allowed; }
.wide { width: 100%; }

.auth-panel, .admin-auth, .admin-card, .key-panel, .workspace-section, .metric-grid article { border: 1px solid var(--line); background: rgba(18,19,18,.78); box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.auth-panel, .admin-auth, .admin-card { padding: clamp(24px, 3vw, 36px); }
.tabs { display: flex; gap: 6px; margin: 25px 0; padding: 4px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.035); }
.tab { flex: 1; padding: 10px 15px; border-radius: 999px; background: transparent; color: var(--muted); cursor: pointer; }
.tab.active { background: rgba(255,255,255,.13); color: #fff; }
label { display: block; margin: 16px 0; color: var(--muted); font-size: 12px; }
input, select, textarea { display: block; width: 100%; margin-top: 8px; padding: 13px; border: 1px solid var(--line); border-radius: 5px; outline: none; background: rgba(255,255,255,.045); color: var(--ink); }
input:focus, select:focus, textarea:focus { border-color: rgba(255,255,255,.5); background: rgba(255,255,255,.07); }
input::placeholder, textarea::placeholder { color: #686967; }
.form-msg { min-height: 20px; color: var(--danger); font-size: 12px; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

footer { display: flex; justify-content: space-between; padding: 32px clamp(22px,5vw,76px) 48px; border-top: 1px solid var(--line); color: var(--faint); font-size: 11px; }

/* User workspace */
.app-shell { width: min(1400px, calc(100% - 64px)); margin: 56px auto 100px; display: grid; grid-template-columns: 240px minmax(0,1fr); gap: clamp(42px,6vw,90px); }
.side { position: sticky; top: 104px; align-self: start; }
.side h1, .admin-auth h1 { margin: 12px 0; font-size: clamp(32px,3.6vw,50px); line-height: 1.04; letter-spacing: -.055em; }
.side > p:not(.eyebrow):not(.side-note) { color: var(--muted); font-size: 12px; word-break: break-all; }
.side nav { display: flex; flex-direction: column; gap: 5px; margin-top: 38px; }
.side nav a { display: grid; grid-template-columns: 34px 1fr; padding: 13px 14px; border-radius: 6px; color: var(--muted); font-size: 13px; }
.side nav a span { color: var(--faint); font: 9px var(--mono); }
.side nav a.active, .side nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.side-note { margin-top: 68px; color: var(--faint); font: 9px/1.8 var(--mono); }
.workspace { min-width: 0; }
.dashboard-heading { display: grid; grid-template-columns: 1fr .8fr; gap: 40px; align-items: end; }
.dashboard-heading > p { color: var(--muted); line-height: 1.8; }
.metric-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 14px; margin-top: 24px; }
.metric-grid article { position: relative; min-height: 188px; padding: 27px; border-radius: 12px; overflow: hidden; }
.metric-grid article:first-child { background: linear-gradient(135deg, rgba(220,141,134,.26), rgba(30,31,30,.95) 60%); }
.metric-grid span, .key-panel span { color: var(--muted); font-size: 11px; }
.metric-grid strong { display: block; margin: 25px 0 17px; font-size: clamp(38px,5vw,60px); line-height: 1; letter-spacing: -.055em; }
.metric-grid small { color: var(--muted); }
.metric-grid b { position: absolute; top: 27px; right: 27px; color: var(--faint); font: 8px var(--mono); }
.key-panel { display: grid; grid-template-columns: .8fr 1.2fr; gap: 34px; align-items: end; margin-top: 14px; padding: 28px; border-radius: 12px; }
.key-panel h3 { margin: 7px 0; font-size: 24px; }
.key-panel p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.7; }
.key-row { display: flex; gap: 8px; }
.key-row code { flex: 1; min-width: 0; overflow: auto; padding: 14px; border: 1px solid var(--line); border-radius: 5px; background: rgba(0,0,0,.25); font: 11px var(--mono); white-space: nowrap; }
.workspace-section { margin-top: 28px; padding: clamp(24px,3vw,36px); border-radius: 12px; scroll-margin-top: 96px; }
.inline-form { display: flex; gap: 9px; }
.inline-form input { margin: 0; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { padding: 15px 10px; border-bottom: 1px solid var(--line); text-align: left; }
th { color: var(--muted); font-size: 10px; font-weight: 500; }
tbody tr:hover { background: rgba(255,255,255,.025); }
.pill { padding: 4px 8px; border: 1px solid var(--line); border-radius: 999px; }
.pill.recharge, .amount.recharge { color: var(--success); }
.pill.charge, .amount.charge { color: var(--danger); }

/* Shared admin primitives */
.admin-shell { width: min(1680px, calc(100% - 64px)); margin: 46px auto 90px; }
.admin-auth { max-width: 470px; margin: 90px auto; border-radius: 14px; }
.admin-grid { display: grid; grid-template-columns: 360px 1fr; gap: 18px; }
.admin-card { border-radius: 12px; }
.admin-card h2, .admin-card h3 { letter-spacing: -.03em; }
.admin-card h3 { margin: 8px 0; font-size: 24px; }
.wide-card { min-width: 0; }
.admin-card table input { min-width: 86px; margin: 0; padding: 9px; }
.admin-card table .name { min-width: 230px; }
.admin-card table small { display: block; margin-top: 7px; color: var(--muted); font: 9px var(--mono); }
.code-result { margin-top: 25px; padding: 18px; border: 1px solid rgba(220,141,134,.5); border-radius: 7px; background: rgba(220,141,134,.08); }
.code-result span { display: block; color: var(--muted); font-size: 11px; }
.code-result code { display: block; margin: 14px 0; color: #f1afa7; font: 13px var(--mono); word-break: break-all; }

@media (max-width: 900px) {
  .app-shell, .admin-grid { grid-template-columns: 1fr; }
  .app-shell, .admin-shell { width: calc(100% - 36px); }
  .side { position: static; }
  .side nav { flex-direction: row; overflow: auto; }
  .side nav a { min-width: 145px; }
  .side-note { display: none; }
  .dashboard-heading, .key-panel { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .site-header { min-height: 66px; padding: 0 16px; }
  .site-header nav a:not(.nav-cta), .header-status { display: none; }
  .brand-edition { display: none; }
  .nav-cta { padding: 9px 13px; }
  .section { padding: 78px 18px; }
  .metric-grid { grid-template-columns: 1fr; }
  .key-row, .inline-form { flex-direction: column; }
  footer { flex-direction: column; gap: 12px; padding-left: 18px; padding-right: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
