:root {
  color-scheme: light;
  --bg: #f3f3f3;
  --surface: #ffffff;
  --surface-2: #fafafa;
  --line: #e5e5e5;
  --line-strong: #d1d1d1;
  --text: #1a1a1a;
  --muted: #605e5c;
  --accent: #0f6cbd;
  --accent-hover: #115ea3;
  --accent-soft: #eaf3fc;
  --good: #0e700e;
  --danger: #c42b1c;
  --danger-soft: #fde7e9;
  --warn: #8a6116;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 8px 24px rgba(0, 0, 0, 0.04);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  font-family: "Noto Sans SC", "Segoe UI Variable", "Segoe UI", "Microsoft YaHei UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  min-height: 100%;
  margin: 0;
  color: var(--text);
  background: var(--bg);
}

button, input, textarea, select { font: inherit; color: inherit; }
button:not(:disabled) { cursor: pointer; }
button:disabled { cursor: wait; opacity: .55; }

.hidden { display: none !important; }

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

.muted { color: var(--muted); }

.material-symbols-outlined {
  font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24;
  font-size: 20px;
  line-height: 1;
  user-select: none;
  vertical-align: middle;
}
.mi-sm { font-size: 18px !important; }

/* —— Split login (GprX-like) —— */
.login-split {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #f5f5f5;
}
.login-hero {
  position: relative;
  background:
    radial-gradient(680px 420px at 18% 110%, rgba(180, 120, 60, 0.18), transparent 55%),
    #0b0b0b;
  color: #fff;
  overflow: hidden;
}
.login-hero-foot {
  position: absolute;
  left: 48px;
  right: 48px;
  bottom: 56px;
}
.login-eyebrow {
  margin: 0 0 14px;
  font-size: 12px;
  letter-spacing: 0.18em;
  color: rgba(255, 255, 255, 0.55);
  font-weight: 500;
}
.login-brand-name {
  margin: 0;
  font-family: Syne, "Noto Sans SC", sans-serif;
  font-size: clamp(48px, 7vw, 84px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 0.95;
}
.login-brand-sub {
  margin: 14px 0 0;
  font-size: 22px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.9);
}
.login-panel {
  display: grid;
  place-items: center;
  padding: 32px 24px;
  background: #f5f5f5;
}
.login-form {
  width: min(380px, 100%);
  display: grid;
  gap: 14px;
}
.login-form h2 {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  color: #111;
}
.login-desc {
  margin: -4px 0 4px;
  color: #777;
  font-size: 13px;
}
.login-form label {
  gap: 8px;
  font-size: 13px;
  color: #666;
  font-weight: 500;
}
.login-form input {
  width: 100%;
  height: 44px;
  border: 0;
  border-radius: 0;
  background: #e8f0fe;
  padding: 0 12px;
  box-shadow: none;
}
.login-form input:focus {
  outline: none;
  box-shadow: inset 0 0 0 2px #111;
  background: #eef4ff;
}
.login-submit {
  margin-top: 8px;
  height: 48px;
  border: 0;
  border-radius: 0;
  background: #111;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  transition: background .15s var(--ease), transform .12s var(--ease);
}
.login-submit:hover { background: #000; }
.login-submit:active { transform: scale(0.99); }
.login-foot {
  margin: 4px 0 0;
  color: #999;
  font-size: 12px;
  line-height: 1.5;
}
@media (max-width: 900px) {
  .login-split { grid-template-columns: 1fr; }
  .login-hero { min-height: 34vh; }
  .login-hero-foot { left: 28px; right: 28px; bottom: 28px; }
  .login-brand-name { font-size: 44px; }
}

/* —— Legacy login (unused) —— */
.login-shell {
  min-height: 100vh;
  display: none;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.login-brand strong {
  display: block;
  font-size: 15px;
  font-weight: 600;
}

.login-brand span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--accent);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -.04em;
  animation: markIn 520ms var(--ease-out);
}
.brand-mark .material-symbols-outlined {
  font-size: 22px;
  color: #fff;
}
.brand-mark.small {
  width: 32px;
  height: 32px;
  font-size: 14px;
  margin: 0;
}
.brand-mark.small .material-symbols-outlined {
  font-size: 18px;
}
@keyframes markIn {
  from { opacity: 0; transform: scale(0.86) rotate(-8deg); }
  to { opacity: 1; transform: scale(1) rotate(0); }
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

h1, h2, p { margin-top: 0; }

h1 {
  margin-bottom: 8px;
  font-size: 24px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
  font-weight: 600;
}

.login-card > .muted {
  margin-bottom: 22px;
  line-height: 1.5;
  font-size: 13px;
}

form { display: grid; gap: 14px; }

label {
  display: grid;
  gap: 6px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}

label small {
  color: var(--muted);
  font-weight: 400;
}

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  outline: none;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}

input, select {
  height: 36px;
  padding: 0 10px;
}

textarea {
  min-height: 96px;
  padding: 10px;
  resize: vertical;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.primary,
.secondary,
.danger,
.icon-button {
  border: 0;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background .15s var(--ease), transform .12s var(--ease), box-shadow .15s var(--ease);
}

.primary:active,
.secondary:active,
.danger:active,
.icon-button:active {
  transform: scale(0.98);
}

.primary {
  height: 36px;
  padding: 0 14px;
  color: #fff;
  background: var(--accent);
  font-weight: 600;
}

.primary:hover { background: var(--accent-hover); }

.primary.wide {
  width: 100%;
  height: 40px;
  margin-top: 4px;
}

.secondary {
  height: 36px;
  padding: 0 14px;
  color: var(--text);
  background: #f5f5f5;
  border: 1px solid var(--line);
  font-weight: 600;
}

.secondary:hover { background: #ebebeb; }

.danger {
  height: 36px;
  padding: 0 14px;
  color: #fff;
  background: var(--danger);
  font-weight: 600;
}

.danger:hover { filter: brightness(0.95); }

.icon-button {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  color: var(--text);
  background: transparent;
}

.icon-button:hover { background: rgba(0, 0, 0, 0.05); }
.icon-button .material-symbols-outlined { font-size: 20px; }

.form-error {
  min-height: 1.2em;
  margin: 0;
  color: var(--danger);
  font-size: 13px;
}

/* —— App shell —— */
.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 14px;
  border-bottom: 1px solid var(--line);
}

.brand strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
}

.brand span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: 10px 12px;
  text-align: left;
  color: var(--text);
  background: transparent;
  font-size: 14px;
  transition: background .15s var(--ease), color .15s var(--ease), transform .15s var(--ease);
}

.nav-item:hover { background: #f5f5f5; transform: translateX(2px); }

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--accent);
}

.nav-ico,
.nav-item > .material-symbols-outlined {
  width: auto;
  text-align: center;
  color: var(--muted);
  transition: color .15s var(--ease), transform .22s var(--ease-out);
}
.nav-item:hover > .material-symbols-outlined,
.nav-item:hover .nav-ico { color: var(--text); transform: scale(1.06); }
.nav-item.active > .material-symbols-outlined,
.nav-item.active .nav-ico {
  color: var(--accent);
  font-variation-settings: "FILL" 1, "wght" 500, "GRAD" 0, "opsz" 24;
  transform: scale(1.08);
}

.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line);
}

.operator {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.operator span,
#edit-user-avatar {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--accent);
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.operator strong,
.operator small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.operator strong { font-size: 13px; }
.operator small { color: var(--muted); font-size: 12px; }

.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px 14px;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(16px) saturate(1.15);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-title {
  display: flex;
  align-items: center;
  gap: 12px;
}
.view-icon {
  font-size: 28px;
  color: var(--accent);
  animation: iconPop 420ms var(--ease-out);
}
@keyframes iconPop {
  from { opacity: 0; transform: scale(0.7) translateY(4px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.topbar h1 {
  margin: 0;
  font-size: 22px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.connection-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #13a10e;
  box-shadow: 0 0 0 3px rgba(19, 161, 14, 0.15);
}

.view-panel {
  padding: 18px 22px 28px;
  display: grid;
  gap: 14px;
  animation: viewIn 380ms var(--ease-out);
}
.view-panel.swap {
  animation: viewIn 380ms var(--ease-out);
}
@keyframes viewIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: min(100%, 280px);
  max-width: 520px;
  height: 36px;
  padding: 0 6px 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
}
.search-box > .material-symbols-outlined {
  color: var(--muted);
  font-size: 20px;
}
.search-box button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.search-box input {
  flex: 1;
  height: 100%;
  border: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.search-box input:focus {
  border: 0;
  box-shadow: none;
}

.search-box button {
  height: 28px;
  padding: 0 12px;
  border: 0;
  border-radius: 4px;
  color: #fff;
  background: var(--accent);
  font-weight: 600;
  font-size: 13px;
}

.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.summary-strip > div {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.summary-strip span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}
.strip-label {
  display: inline-flex !important;
  align-items: center;
  gap: 4px;
  margin-bottom: 4px !important;
}

.summary-strip strong {
  font-size: 18px;
  font-weight: 600;
}

.summary-strip .good { color: var(--good); }

.table-shell {
  position: relative;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th, td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 13px;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-weight: 600;
  background: var(--surface-2);
  position: sticky;
  top: 0;
}

tbody tr:hover { background: #f7f7f7; }

.empty-state {
  padding: 48px 20px;
  text-align: center;
  color: var(--muted);
  display: grid;
  justify-items: center;
  gap: 6px;
  animation: rise 420ms var(--ease-out);
}
.empty-ico {
  font-size: 40px !important;
  color: var(--accent);
  opacity: 0.75;
  margin-bottom: 4px;
  animation: iconPop 480ms var(--ease-out);
}
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.empty-state strong {
  display: block;
  color: var(--text);
  margin-bottom: 0;
  font-size: 15px;
}

.panel-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 18px;
  box-shadow: none;
}

.panel-card.narrow { max-width: 720px; }

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.revision {
  color: var(--muted);
  font-size: 12px;
  font-family: ui-monospace, Consolas, monospace;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.quick-days {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.quick-days > span {
  color: var(--muted);
  font-size: 12px;
  margin-right: 4px;
}

.quick-days button {
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
}

.quick-days button.selected,
.quick-days button:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.check-row {
  display: flex !important;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

.check-row input {
  width: auto;
  height: auto;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: 8px;
  background: #f0f0f0;
}

.segmented button {
  height: 32px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
}

.segmented button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.audit-list {
  display: grid;
  gap: 8px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.status-pill.active,
.status-pill[class*="active"] {
  background: #dff6dd;
  color: var(--good);
}

.status-pill.banned,
.status-pill.expired {
  background: var(--danger-soft);
  color: var(--danger);
}

.user-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-cell > span {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--accent);
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.user-cell strong,
.user-cell small {
  display: block;
}

.user-cell small {
  color: var(--muted);
  font-size: 12px;
}

.rank {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 4px;
  background: #f0f0f0;
  font-size: 12px;
  font-weight: 600;
}

.rank.admin {
  background: #fde7e9;
  color: var(--danger);
}

.rank.beta {
  background: #fff4ce;
  color: var(--warn);
}

.rank.user {
  background: var(--accent-soft);
  color: var(--accent);
}

.row-action {
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.row-action .material-symbols-outlined { font-size: 16px; }

.row-action:hover {
  background: var(--accent-soft);
  border-color: #cfe4f6;
}

tbody tr {
  animation: rowIn 320ms var(--ease-out) both;
}
tbody tr:nth-child(1) { animation-delay: 20ms; }
tbody tr:nth-child(2) { animation-delay: 40ms; }
tbody tr:nth-child(3) { animation-delay: 60ms; }
tbody tr:nth-child(4) { animation-delay: 80ms; }
tbody tr:nth-child(5) { animation-delay: 100ms; }
@keyframes rowIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.audit-event {
  display: grid;
  grid-template-columns: 150px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  animation: rise 360ms var(--ease-out) both;
}

.audit-event time,
.audit-event code {
  color: var(--muted);
  font-size: 12px;
  font-family: ui-monospace, Consolas, monospace;
}

.audit-event strong,
.audit-event small {
  display: block;
}

.audit-event small {
  color: var(--muted);
  margin-top: 2px;
  font-size: 12px;
}

.identity-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.identity-card strong,
.identity-card small {
  display: block;
}

.identity-card small {
  color: var(--muted);
  font-size: 12px;
  word-break: break-all;
}

dialog {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0;
  max-width: min(92vw, 520px);
  width: 100%;
  background: var(--surface);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  color: var(--text);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.35);
}

.dialog-card {
  padding: 18px;
  gap: 14px;
}

.dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.dialog-actions.split {
  justify-content: space-between;
  align-items: center;
}

.dialog-actions.split > div {
  display: flex;
  gap: 8px;
}

.toast-region {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: grid;
  gap: 8px;
  z-index: 50;
  width: min(360px, calc(100vw - 24px));
}

.toast {
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 13px;
}

.toast.error {
  border-color: #f1aeb5;
  background: var(--danger-soft);
  color: var(--danger);
}

.mobile-nav {
  display: none;
}

.mobile-only { display: none !important; }

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
    padding-bottom: 64px;
  }

  .sidebar { display: none; }

  .mobile-nav {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    position: fixed;
    inset: auto 0 0 0;
    height: 60px;
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(14px);
    z-index: 20;
  }

  .mobile-nav.owner-mode {
    grid-template-columns: repeat(4, 1fr);
  }

  .mobile-nav .nav-item {
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    border-radius: 0;
    font-size: 11px;
    padding: 8px 4px;
  }

  .mobile-nav .nav-item small {
    font-size: 11px;
  }
  .mobile-nav .nav-item > .material-symbols-outlined {
    font-size: 22px;
  }

  .mobile-only { display: grid !important; }

  .summary-strip { grid-template-columns: 1fr; }
  .field-grid { grid-template-columns: 1fr; }
  .view-panel { padding: 14px; }
  .topbar { padding: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
