/* ========================================================================
   admin-gateway · admin.css
   共享样式: 严格按 design-ready.md §9 落地 token, 不引任何 UI 框架
   ======================================================================== */

:root {
  /* Surface */
  --bg: #faf9f7;
  --bg-app: #faf9f7;
  --bg-panel: #ffffff;
  --bg-subtle: #f4f2ed;
  --bg-muted: #ece9e2;
  --bg-elevated: #ffffff;

  /* Border */
  --border: #ebe8e1;
  --border-strong: #d8d4cb;
  --border-soft: #f1eee7;

  /* Text */
  --text: #1a1916;
  --text-strong: #0d0c0a;
  --text-muted: #74716b;
  --text-soft: #989590;
  --text-faint: #b3b0a8;

  /* Accent (赭石) */
  --accent: #c96442;
  --accent-strong: #b45a3b;
  --accent-soft: #f5d8cb;
  --accent-tint: #fbeee5;
  --accent-hover: #b45a3b;

  /* Semantic */
  --green: #1f7a3a;
  --green-bg: #e8f7ee;
  --green-border: #c6ead2;
  --blue: #2348b8;
  --blue-bg: #e8efff;
  --blue-border: #c8d6ff;
  --purple: #6c3aa6;
  --purple-bg: #f3ecf9;
  --purple-border: #e4d4f1;
  --red: #9c2a25;
  --red-bg: #fdecea;
  --red-border: #f5c6c2;
  --amber: #b26200;
  --amber-bg: #fff3e0;

  /* Radius */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-pill: 999px;

  /* Shadow */
  --shadow-xs: 0 1px 0 rgba(28, 27, 26, 0.04);
  --shadow-sm: 0 1px 2px rgba(28, 27, 26, 0.05), 0 1px 3px rgba(28, 27, 26, 0.04);
  --shadow-md: 0 6px 24px rgba(28, 27, 26, 0.07), 0 2px 6px rgba(28, 27, 26, 0.04);
  --shadow-lg: 0 24px 60px rgba(28, 27, 26, 0.16), 0 8px 16px rgba(28, 27, 26, 0.07);

  /* Typography */
  --serif: 'Source Serif Pro', 'Source Serif 4', 'Iowan Old Style', 'Apple Garamond', Georgia, 'Times New Roman', serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    --bg: #1a1917;
    --bg-app: #1a1917;
    --bg-panel: #222120;
    --bg-subtle: #272523;
    --bg-muted: #2e2c29;
    --bg-elevated: #2a2825;

    --border: #333128;
    --border-strong: #46433c;
    --border-soft: #2a2825;

    --text: #e8e4dc;
    --text-strong: #f2ede4;
    --text-muted: #9a9690;
    --text-soft: #6e6b65;
    --text-faint: #4e4b46;

    --accent: #d97a56;
    --accent-strong: #e8896a;
    --accent-soft: #3d2318;
    --accent-tint: #2e1a12;
    --accent-hover: #e8896a;

    --green: #4caf72;
    --green-bg: #0f2a18;
    --green-border: #1a4028;
    --blue: #6b8fe8;
    --blue-bg: #0f1a38;
    --blue-border: #1a2c58;
    --purple: #a87dd4;
    --purple-bg: #1e1030;
    --purple-border: #321a50;
    --red: #e06b65;
    --red-bg: #2a0e0c;
    --red-border: #451714;
    --amber: #e09a40;
    --amber-bg: #2a1a04;

    --shadow-xs: 0 1px 0 rgba(0, 0, 0, 0.2);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 3px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 6px 24px rgba(0, 0, 0, 0.4), 0 2px 6px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.6), 0 8px 16px rgba(0, 0, 0, 0.3);
  }
}

[data-theme="dark"] {
  --bg: #1a1917;
  --bg-app: #1a1917;
  --bg-panel: #222120;
  --bg-subtle: #272523;
  --bg-muted: #2e2c29;
  --bg-elevated: #2a2825;

  --border: #333128;
  --border-strong: #46433c;
  --border-soft: #2a2825;

  --text: #e8e4dc;
  --text-strong: #f2ede4;
  --text-muted: #9a9690;
  --text-soft: #6e6b65;
  --text-faint: #4e4b46;

  --accent: #d97a56;
  --accent-strong: #e8896a;
  --accent-soft: #3d2318;
  --accent-tint: #2e1a12;
  --accent-hover: #e8896a;

  --green: #4caf72;
  --green-bg: #0f2a18;
  --green-border: #1a4028;
  --blue: #6b8fe8;
  --blue-bg: #0f1a38;
  --blue-border: #1a2c58;
  --purple: #a87dd4;
  --purple-bg: #1e1030;
  --purple-border: #321a50;
  --red: #e06b65;
  --red-bg: #2a0e0c;
  --red-border: #451714;
  --amber: #e09a40;
  --amber-bg: #2a1a04;

  --shadow-xs: 0 1px 0 rgba(0, 0, 0, 0.2);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 3px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 6px 24px rgba(0, 0, 0, 0.4), 0 2px 6px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.6), 0 8px 16px rgba(0, 0, 0, 0.3);
}

/* ===== reset ===== */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--sans);
  font-size: 13.5px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== layout ===== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-header__brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 650;
  color: var(--text-strong);
  letter-spacing: -0.01em;
}

.app-header__brand .brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.app-header__user {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-muted);
}

.app-header__user .username {
  color: var(--text);
  font-weight: 500;
}

.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 28px 24px 64px;
  max-width: 1080px;
  width: 100%;
  margin: 0 auto;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-head__title {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--text-strong);
  margin: 0 0 4px;
}

.page-head__sub {
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 0;
}

/* ===== buttons ===== */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  font: 500 13px/1 var(--sans);
  color: var(--text);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
  white-space: nowrap;
}
.button:hover:not(:disabled) { border-color: var(--border-strong); box-shadow: var(--shadow-xs); transform: translateY(-1px); }
.button:active:not(:disabled) { transform: scale(0.96); }
.button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.button:disabled { opacity: 0.5; cursor: not-allowed; }

.button.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.button.primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
.button.danger {
  background: var(--bg-panel);
  border-color: var(--red-border);
  color: var(--red);
}
.button.danger:hover:not(:disabled) {
  background: var(--red-bg);
  border-color: var(--red);
}
.button.ghost {
  background: transparent;
  border-color: var(--border);
}
.button.icon-only { padding: 6px 10px; }
.button .spinner {
  width: 12px; height: 12px;
  border: 1.5px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: icon-spin 0.9s linear infinite;
}

/* ===== form fields ===== */
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.field .field-help {
  font-size: 11.5px;
  color: var(--text-faint);
  margin-top: 4px;
}
.field input,
.field textarea,
.field select {
  width: 100%;
  font: inherit;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  color: var(--text);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.field input::placeholder { color: var(--text-faint); }
.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}
.field .field-error {
  display: none;
  margin-top: 6px;
  font-size: 12px;
  color: var(--red);
}
.field.has-error input { border-color: var(--red); }
.field.has-error .field-error { display: block; }

/* ===== alert (login error banner) ===== */
.alert {
  background: var(--red-bg);
  border: 1px solid var(--red-border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 12.5px;
  color: var(--red);
  margin-bottom: 14px;
  display: none;
}
.alert.is-visible { display: block; animation: shake 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97); }
.alert.is-visible::before {
  content: "⚠";
  margin-right: 6px;
}

@keyframes shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-4px); }
  40%, 60% { transform: translateX(4px); }
}

/* ===== card / panel ===== */
.card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
}

/* ===== table ===== */
.users-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.users-table th, .users-table td {
  padding: 12px 14px;
  text-align: left;
  font-size: 13px;
  border-bottom: 1px solid var(--border-soft);
}
.users-table th {
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-subtle);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.users-table tbody tr:last-child td { border-bottom: none; }
.users-table tbody tr:hover { background: var(--bg-subtle); }
.users-table .col-id { width: 60px; color: var(--text-muted); font-family: var(--mono); font-size: 12.5px; }
.users-table .col-created { color: var(--text-muted); font-size: 12.5px; white-space: nowrap; }
.users-table .col-username { color: var(--text-strong); font-weight: 500; }
.users-table .col-actions { width: 160px; text-align: right; white-space: nowrap; }
.users-table .col-actions .button { padding: 4px 10px; font-size: 12px; }

/* ===== empty state ===== */
.empty-state {
  padding: 56px 24px;
  text-align: center;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-panel);
}
.empty-state svg {
  width: 96px; height: 72px;
  margin: 0 auto 12px;
  display: block;
  color: var(--text-faint);
  opacity: 0.85;
}
.empty-state__title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-strong);
  margin: 0 0 4px;
}
.empty-state__sub {
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 0;
}

/* ===== skeleton ===== */
.skeleton {
  display: block;
  background: linear-gradient(90deg, var(--bg-subtle) 0%, var(--bg-muted) 50%, var(--bg-subtle) 100%);
  background-size: 400px 100%;
  border-radius: 6px;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer {
  from { background-position: -400px 0; }
  to { background-position: 400px 0; }
}
.skeleton-row {
  display: flex; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--border-soft);
}
.skeleton-row .sk-col { height: 14px; }
.skeleton-row .sk-id { width: 40px; }
.skeleton-row .sk-username { flex: 1; }
.skeleton-row .sk-time { width: 140px; }
.skeleton-row .sk-actions { width: 140px; }

/* ===== modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(28, 27, 26, 0.42);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 16px;
}
.modal-overlay.is-visible {
  display: flex;
  animation: fade-in 160ms ease-out;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 22px;
  animation: pop-in 220ms cubic-bezier(0.21, 1.02, 0.73, 1);
}
@keyframes pop-in {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.modal__title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-strong);
  letter-spacing: -0.015em;
  margin: 0;
}
.modal__close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 28px; height: 28px;
  border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0;
  transition: background 120ms ease, color 120ms ease;
}
.modal__close:hover { background: var(--bg-subtle); color: var(--text-strong); }

.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

/* ===== toast ===== */
.toast-stack {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  align-items: center;
}
.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text);
  min-width: 200px;
  text-align: center;
  pointer-events: auto;
  animation: pop-in 220ms cubic-bezier(0.21, 1.02, 0.73, 1);
}
.toast.success { border-color: var(--green-border); background: var(--green-bg); color: var(--green); }
.toast.error { border-color: var(--red-border); background: var(--red-bg); color: var(--red); }
.toast.info { border-color: var(--blue-border); background: var(--blue-bg); color: var(--blue); }

/* ===== login page ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-md);
}
.login-card__brand {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 20px;
}
.login-card__brand .brand-mark {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 18px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.login-card__brand .brand-text {
  display: flex; flex-direction: column;
}
.login-card__brand .brand-name {
  font-size: 15px; font-weight: 650;
  color: var(--text-strong);
  letter-spacing: -0.01em;
}
.login-card__brand .brand-tag {
  font-size: 11.5px; color: var(--text-muted);
  letter-spacing: 0.04em; text-transform: uppercase;
}
.login-card__title {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-strong);
  letter-spacing: -0.015em;
  margin: 0 0 6px;
}
.login-card__sub {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 20px;
}
.login-card .button.primary { width: 100%; padding: 9px 14px; font-size: 13.5px; }
.login-card__foot {
  margin-top: 18px;
  font-size: 11.5px;
  color: var(--text-faint);
  text-align: center;
  line-height: 1.55;
}

/* ===== responsive ===== */
@media (max-width: 640px) {
  .app-header { padding: 10px 14px; }
  .app-header__user .username-text { display: none; }
  .app-main { padding: 18px 14px 48px; }
  .page-head { margin-bottom: 16px; }
  .page-head__title { font-size: 18px; }
  .users-table th, .users-table td { padding: 10px 10px; font-size: 12.5px; }
  .users-table .col-id { width: 44px; }
  .users-table .col-actions { width: 120px; }
  .login-card { padding: 24px; }
}

@media (max-width: 480px) {
  .users-table .col-created { display: none; }
}

/* ===== a11y ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}
