:root {
  color-scheme: light;
  --ink: #3d2a27;
  --muted: #876e67;
  --accent: #d95851;
  --accent-dark: #b6433d;
  --paper: #fffdfa;
  --warm: #fff4ed;
  --line: rgba(118, 75, 65, .16);
  --danger: #b83a36;
  --shadow: 0 18px 50px rgba(100, 57, 48, .14);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 5%, rgba(255, 205, 184, .58), transparent 30rem),
    radial-gradient(circle at 92% 92%, rgba(255, 229, 157, .4), transparent 27rem),
    var(--warm);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

.shell { width: min(100% - 30px, 510px); margin: 0 auto; padding: max(28px, env(safe-area-inset-top)) 0 38px; }
.panel { padding: 26px; border: 1px solid var(--line); border-radius: 25px; background: rgba(255, 253, 250, .94); box-shadow: var(--shadow); backdrop-filter: blur(10px); }
.brand { display: flex; align-items: center; gap: 13px; margin-bottom: 24px; }
.brand img { width: 52px; height: 52px; border-radius: 17px; box-shadow: 0 9px 21px rgba(200, 82, 74, .25); }
.brand h1 { margin: 0; font-size: 22px; letter-spacing: .02em; }
.brand p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
h2 { margin: 0 0 8px; font-size: 24px; }
.intro { margin: 0 0 22px; color: var(--muted); font-size: 14px; line-height: 1.65; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 18px; padding: 5px; background: #f8e8df; border-radius: 15px; }
.tabs button { min-height: 42px; border: 0; border-radius: 11px; color: #7a5d55; background: transparent; font: inherit; font-weight: 700; cursor: pointer; }
.tabs button.active { color: var(--accent-dark); background: #fffdfa; box-shadow: 0 2px 8px rgba(117, 75, 65, .12); }
form { display: grid; gap: 14px; }
label { display: grid; gap: 7px; color: #664d47; font-size: 13px; font-weight: 700; }
input, select { width: 100%; min-height: 48px; padding: 0 13px; border: 1px solid #e5c9bf; border-radius: 13px; outline: none; color: var(--ink); background: #fff; font: inherit; }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(217, 88, 81, .14); }
button { font: inherit; }
.primary, .secondary, .danger { min-height: 48px; padding: 0 17px; border: 0; border-radius: 13px; font-weight: 800; cursor: pointer; }
.primary { color: #fff; background: linear-gradient(135deg, #df675e, #cc4944); box-shadow: 0 9px 18px rgba(203, 73, 68, .24); }
.primary:hover { background: linear-gradient(135deg, #e27267, #bd3c38); }
.secondary { color: #81574e; background: #f9e7de; }
.danger { color: #fff; background: var(--danger); }
button:disabled { cursor: wait; opacity: .62; }
.notice { min-height: 20px; margin: 3px 0 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.notice.error { color: var(--danger); }
.notice.ok { color: #28815c; }
.hint { margin: 17px 0 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.privacy-panel h3 { margin: 24px 0 7px; font-size: 16px; }
.privacy-panel h3 + p { margin: 0; color: #664d47; font-size: 14px; line-height: 1.75; }
.privacy-panel a { color: var(--accent-dark); font-weight: 700; }
.hidden { display: none !important; }
.admin-shell { width: min(100% - 30px, 1060px); }
.admin-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.admin-header .brand { margin: 0; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 18px 0; }
.stat { padding: 15px; border-radius: 16px; background: #fff4ed; border: 1px solid var(--line); }
.stat strong { display: block; margin-top: 6px; font-size: 24px; }
.stat span { color: var(--muted); font-size: 12px; }
.admin-grid { display: grid; grid-template-columns: minmax(240px, 360px) 1fr; gap: 18px; align-items: start; }
.setting-card, .account-card { padding: 20px; border: 1px solid var(--line); border-radius: 20px; background: rgba(255, 253, 250, .92); box-shadow: 0 10px 25px rgba(100, 57, 48, .08); }
.setting-card h2, .account-card h2 { margin: 0 0 14px; font-size: 18px; }
.checkbox { display: flex; align-items: center; gap: 9px; font-size: 13px; color: #664d47; font-weight: 700; }
.checkbox input { width: 18px; min-height: 18px; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; }
.toolbar select { width: auto; min-height: 40px; }
.search-label { margin: 0 0 12px; }
.search-label input { min-height: 42px; }
.compact-hint { margin: -4px 0 1px; }
.account-list { display: grid; gap: 10px; }
.account { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 9px; align-items: center; padding: 14px; border: 1px solid var(--line); border-radius: 15px; background: #fff; }
.account strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account small { display: block; margin-top: 4px; color: var(--muted); line-height: 1.5; }
.tag { display: inline-flex; margin-left: 6px; padding: 2px 7px; border-radius: 999px; font-size: 11px; font-weight: 800; color: #796057; background: #f7e9df; }
.tag.active { color: #197251; background: #def2e7; }
.tag.disabled { color: #a0312f; background: #fbe2e1; }
.account-actions { display: grid; gap: 7px; justify-items: stretch; }
.small-button { min-height: 36px; padding: 0 11px; border: 0; border-radius: 10px; color: var(--danger); background: #ffe9e8; font-weight: 800; cursor: pointer; }
.small-button.freeze { color: #9a6820; background: #fff0cf; }
.small-button.restore { color: #197251; background: #def2e7; }
.small-button.delete { color: var(--danger); background: #ffe9e8; }
.empty { padding: 22px 8px; color: var(--muted); text-align: center; }
.portal-shell { width: min(100% - 30px, 620px); }
.portal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.portal-header .brand { margin-bottom: 15px; }
.portal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.activate-form { margin-top: 15px; padding: 14px; border: 1px solid var(--line); border-radius: 15px; background: #fffaf7; }
.button-link { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.section-title { margin: 25px 0 3px; font-size: 18px; }
.small-intro { margin-bottom: 13px; }
.one-time-code { display: grid; gap: 10px; padding: 16px; border: 1px solid #e8c08d; border-radius: 16px; background: #fff5db; }
.one-time-code code { display: block; overflow-wrap: anywhere; padding: 12px; border-radius: 10px; color: #6d4925; background: #fffdf4; font: 800 17px/1.4 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .04em; }
.code-list { display: grid; gap: 9px; }
.code-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.code-row strong { display: block; }
.code-row small { display: block; margin-top: 4px; color: var(--muted); }
.code-row .tag.revoked { color: #a0312f; background: #fbe2e1; }
.portal-help { margin-top: 18px; padding: 14px 15px; border-radius: 15px; color: #664d47; background: #f9e7de; font-size: 13px; line-height: 1.6; }
.portal-help p { margin: 5px 0 0; }
.turnstile { min-height: 0; }

@media (max-width: 760px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-grid { grid-template-columns: 1fr; }
  .admin-header { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 520px) {
  .portal-header { flex-direction: column; }
  .portal-actions { grid-template-columns: 1fr; }
  .code-row { align-items: flex-start; }
}
