:root {
  --paper: #f4f1e9;
  --paper-deep: #ebe7dc;
  --surface: #faf8f2;
  --surface-strong: #fffdf8;
  --ink: #1e2c26;
  --ink-soft: #3d4b44;
  --muted: #6f7970;
  --muted-light: #939b92;
  --line: rgba(30, 44, 38, 0.12);
  --line-strong: rgba(30, 44, 38, 0.22);
  --accent: #cc5d35;
  --accent-deep: #b44b26;
  --accent-soft: #f4e4dc;
  --sage: #4d695e;
  --sage-soft: #e5ece4;
  --font-sans: "Noto Sans CJK SC", "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --font-serif: "Noto Serif CJK SC", "Noto Serif SC", "Songti SC", "STSong", Georgia, serif;
  --shadow: 0 30px 70px -42px rgba(30, 44, 38, 0.42), 0 1px 0 rgba(255, 255, 255, 0.65) inset;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(ellipse 55% 38% at 92% 1%, rgba(204, 93, 53, 0.085), transparent 65%),
    radial-gradient(ellipse 42% 34% at 0% 38%, rgba(77, 105, 94, 0.06), transparent 70%),
    var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.brand { display: inline-flex; align-items: center; gap: 10px; }
.brand__mark {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%;
  background: var(--ink); color: #fcf8ef; transform: rotate(-10deg);
}
.brand__word { display: flex; flex-direction: column; gap: 1px; font-family: var(--font-serif); font-size: 18px; font-weight: 600; letter-spacing: .12em; line-height: 1.1; }
.brand__word small { color: var(--muted); font-family: var(--font-sans); font-size: 7px; letter-spacing: .24em; }

.eyebrow { color: var(--muted); font-size: 8px; letter-spacing: .2em; text-transform: uppercase; }

.auth-page { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; padding: 26px 18px; }
.auth-top { width: min(980px, 100%); display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.auth-top__note { color: var(--muted); font-size: 10px; letter-spacing: .08em; }
.auth-shell { width: min(440px, 100%); margin: auto; padding: 26px 0; }
.auth-card { padding: 34px 32px; border: 1px solid var(--line); border-radius: 24px; background: var(--surface); box-shadow: var(--shadow); }
.auth-card h1 { margin-top: 6px; font-family: var(--font-serif); font-size: 34px; font-weight: 500; letter-spacing: .06em; line-height: 1.25; }
.auth-card__sub { margin-top: 8px; color: var(--muted); font-size: 11px; line-height: 1.8; }
.auth-tabs { display: flex; gap: 4px; margin-top: 22px; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper-deep); }
.auth-tab { flex: 1; padding: 9px 8px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: 11px; }
.auth-tab.is-active { background: var(--surface-strong); color: var(--ink); box-shadow: 0 4px 14px -9px rgba(30,44,38,.35); }

.field { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.field label { color: var(--muted); font-size: 9.5px; letter-spacing: .08em; }
.field .control, .code-row .control { display: flex; align-items: center; gap: 9px; height: 48px; padding: 0 13px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-strong); color: var(--muted-light); transition: border-color .2s, box-shadow .2s; }
.field .control:focus-within, .code-row .control:focus-within { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(30,44,38,.05); }
.field input, .code-row input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 13px; }
.field input::placeholder, .code-row input::placeholder { color: var(--muted-light); }
.code-row { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px; }
.code-btn { height: 48px; padding: 0 13px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-strong); color: var(--ink-soft); font-size: 10px; white-space: nowrap; }
.code-btn:hover:not(:disabled) { border-color: var(--ink); color: var(--ink); }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 46px; padding: 10px 18px; border: 1px solid transparent; border-radius: 999px; font-size: 12px; font-weight: 500; transition: transform .2s, background .2s, border-color .2s, color .2s; }
.button--primary { border-color: var(--ink); background: var(--ink); color: #fcf8ef; box-shadow: 0 10px 22px -16px rgba(30,44,38,.9); }
.button--primary:hover { background: #2e4036; transform: translateY(-1px); }
.button--ghost { border-color: var(--line); background: transparent; color: var(--ink-soft); }
.button--ghost:hover { border-color: var(--line-strong); background: rgba(255,253,248,.65); }
.button--danger { border-color: var(--accent-deep); background: var(--accent-deep); color: #fff9f3; }
.button--compact { min-height: 34px; padding: 7px 12px; font-size: 10px; }
.submit { width: 100%; margin-top: 20px; }
.spinner { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.alert { margin-top: 16px; padding: 10px 12px; border: 1px solid rgba(180,75,38,.22); border-radius: 10px; background: var(--accent-soft); color: var(--accent-deep); font-size: 10.5px; line-height: 1.7; }
.notice { margin-top: 16px; padding: 10px 12px; border: 1px solid rgba(77,105,94,.18); border-radius: 10px; background: var(--sage-soft); color: var(--sage); font-size: 10.5px; line-height: 1.7; }
.hidden { display: none !important; }
.auth-switch { margin-top: 18px; color: var(--muted); font-size: 10.5px; text-align: center; }
.auth-switch button { padding: 0; border: 0; background: transparent; color: var(--accent-deep); text-decoration: underline; text-underline-offset: 3px; }
.auth-meta { margin-top: 14px; color: var(--muted-light); font-size: 8.5px; letter-spacing: .16em; text-align: center; }

.account-page, .admin-page { width: min(1100px, 100%); margin: 0 auto; padding: 0 22px 44px; }
.account-top, .admin-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 22px 0; border-bottom: 1px solid var(--line); }
.account-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; margin-top: 24px; align-items: start; }
.card { padding: 22px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: 0 20px 50px -44px rgba(30,44,38,.5); }
.card h2 { margin-top: 3px; font-family: var(--font-serif); font-size: 22px; font-weight: 500; }
.card__sub { margin-top: 6px; color: var(--muted); font-size: 10.5px; line-height: 1.8; }
.profile { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.avatar { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--sage); color: #fbf8ef; font-family: var(--font-serif); font-size: 18px; }
.profile strong { display: block; font-size: 14px; }
.profile span { color: var(--muted); font-size: 10px; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 999px; background: var(--sage-soft); color: var(--sage); font-size: 8.5px; }
.pill--off { background: var(--accent-soft); color: var(--accent-deep); }
.app-list { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.app-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-strong); font-size: 10.5px; }
.app-row small { color: var(--muted); font-size: 8.5px; }

.admin-hero { padding: 28px 0 18px; }
.admin-hero h1 { margin-top: 5px; font-family: var(--font-serif); font-size: 40px; font-weight: 500; letter-spacing: .05em; }
.admin-hero p { margin-top: 8px; color: var(--muted); font-size: 11px; line-height: 1.8; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; margin-bottom: 16px; }
.stat { padding: 15px 17px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.stat span { color: var(--muted); font-size: 9px; letter-spacing: .08em; }
.stat strong { display: block; margin-top: 3px; font-family: var(--font-serif); font-size: 26px; font-weight: 500; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; min-width: 840px; }
th { padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--paper-deep); color: var(--muted); font-size: 8.5px; font-weight: 500; letter-spacing: .08em; text-align: left; white-space: nowrap; }
td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: 10.5px; }
tr:last-child td { border-bottom: 0; }
.user-cell strong { display: block; font-size: 11.5px; }
.user-cell span { color: var(--muted); font-size: 9px; }
.apps-cell { display: flex; flex-wrap: wrap; gap: 4px; }
.app-toggle { padding: 3px 7px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-strong); color: var(--muted); font-size: 8px; }
.app-toggle.is-on { border-color: rgba(77,105,94,.25); background: var(--sage-soft); color: var(--sage); }
.app-toggle.is-off { border-color: rgba(180,75,38,.2); background: var(--accent-soft); color: var(--accent-deep); }
.actions { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
.actions .button { min-height: 28px; padding: 5px 8px; font-size: 8.5px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.form-grid .field { margin-top: 0; }
.audit { margin-top: 16px; }
.audit-item { display: flex; gap: 8px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 10px; }
.audit-item:first-child { border-top: 0; }
.audit-item time { margin-left: auto; color: var(--muted-light); font-size: 8.5px; white-space: nowrap; }

.footer { padding: 18px 0; color: var(--muted-light); font-size: 8.5px; text-align: center; letter-spacing: .08em; }

@media (max-width: 760px) {
  .auth-card { padding: 26px 20px; border-radius: 20px; }
  .auth-card h1 { font-size: 29px; }
  .auth-top { padding-inline: 2px; }
  .code-row { grid-template-columns: minmax(0,1fr) 94px; }
  .code-btn { padding: 0 8px; font-size: 9px; }
  .account-grid { grid-template-columns: 1fr; }
  .account-page, .admin-page { padding-inline: 16px; }
  .admin-hero h1 { font-size: 32px; }
  .stats { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .form-grid { grid-template-columns: 1fr; }
  .account-top, .admin-top { flex-wrap: wrap; }
  input, textarea, select { font-size: 16px !important; }
}
