/* nfentik 用户中心 · 白色商务（Clean Business） */
:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --panel-2: #fafbfc;
  --ink: #14181f;
  --muted: #6b7280;
  --line: #e6e8ec;
  --line-strong: #d7dae0;
  --primary: #1f2937;
  --primary-dark: #111827;
  --accent: #4f46e5;
  --accent-soft: #eef2ff;
  --danger: #e5484d;
  --ok: #16a34a;
  --warn: #d97706;
  --radius: 10px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(17, 24, 39, .04), 0 6px 18px rgba(17, 24, 39, .05);
  --shadow-sm: 0 1px 3px rgba(17, 24, 39, .05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.btn {
  border: 1px solid transparent; border-radius: var(--radius-sm); padding: 8px 14px;
  font: inherit; font-weight: 500; cursor: pointer; background: #eceef1; color: var(--ink);
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.btn:hover { filter: brightness(0.98); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(79, 70, 229, .25); }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.ghost { background: #fff; border-color: var(--line-strong); color: var(--ink); }
.btn.ghost:hover { background: var(--panel-2); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.full { width: 100%; }
.btn.small { padding: 5px 10px; font-size: 12px; border-radius: 6px; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow-sm); margin-bottom: 16px;
}
.card h2 { font-size: 16px; margin: 0; font-weight: 600; letter-spacing: .1px; }

/* ---- login ---- */
.user-login {
  min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: linear-gradient(160deg, #eef1f6 0%, #e7ecf5 45%, #eef2ff 100%);
}
.login-card {
  width: min(400px, 100%); background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 30px;
  box-shadow: 0 24px 60px -24px rgba(17, 24, 39, .35), 0 2px 8px rgba(17, 24, 39, .06); animation: rise .32s ease;
}
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.login-logo {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  background: var(--primary); color: #fff; font-weight: 700; font-size: 20px;
}
.login-brand strong { display: block; font-size: 16px; }
.login-sub { color: var(--muted); font-size: 12px; }
.login-card h2 { margin: 0 0 6px; font-size: 22px; }
.login-hint { margin: 0 0 18px; color: var(--muted); font-size: 13px; }
.login-label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 6px; }
.login-field { position: relative; margin-bottom: 16px; }
.login-field input {
  width: 100%; padding: 11px 68px 11px 12px; border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); font: inherit; outline: none; background: var(--panel-2);
}
.login-field input:focus { border-color: var(--accent); background: #fff; box-shadow: 0 0 0 4px rgba(79,70,229,.15); }
.login-eye {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  border: none; background: transparent; color: var(--accent); font-size: 12px;
  font-weight: 600; cursor: pointer; padding: 6px 8px; border-radius: 7px;
}
.login-submit { padding: 11px; font-size: 15px; font-weight: 600; border-radius: var(--radius-sm); }
.login-error { margin: 10px 0 0; text-align: center; }
.error { color: var(--danger); font-size: 13px; min-height: 18px; }

/* ---- main ---- */
.user-main { max-width: 860px; margin: 0 auto; padding: 20px 16px 44px; }
.user-topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.brand { display: flex; align-items: center; gap: 10px; }
.logo {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  background: var(--primary); color: #fff; font-weight: 700; font-size: 18px;
}
.brand strong { display: block; font-size: 15px; }
.brand small { color: var(--muted); font-size: 11px; }

.user-alert {
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px;
  font-size: 13px; border: 1px solid transparent;
}
.user-alert.warn { background: #fef3c7; border-color: #fde68a; color: #b45309; }
.user-alert.danger { background: #fee2e2; border-color: #fecaca; color: #b91c1c; }
.user-alert.info { background: var(--accent-soft); border-color: #dbe0ff; color: #3730a3; }

.plan-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 10px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.plan-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.plan-item { display: flex; flex-direction: column; gap: 4px; }
.plan-item .label { color: var(--muted); font-size: 12px; }
.plan-item strong { font-size: 15px; word-break: break-word; }
.entitlement-grid { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }

.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; background: #eef0f3; color: #4b5563; }
.pill.active { background: #dcfce7; color: #15803d; }
.pill.expiring { background: #fef3c7; color: #b45309; }
.pill.expired { background: #fee2e2; color: #b91c1c; }
.pill.exhausted { background: #ffe4e6; color: #be123c; }
.pill.disabled { background: #eef0f3; color: #64748b; }

.quota { margin-top: 16px; }
.quota-head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
.quota-bar { height: 8px; border-radius: 999px; background: #eceef1; overflow: hidden; }
.quota-fill { height: 100%; width: 0; background: linear-gradient(90deg, #6366f1, #4f46e5); transition: width .3s ease; }

.note-field { margin-top: 18px; }
.field label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 6px; }
.note-view { display: flex; align-items: center; gap: 10px; }
.note-view #user-note { flex: 1; }
.note-edit textarea {
  width: 100%; padding: 9px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); font: inherit; background: #fff;
}
.note-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }

.editor {
  width: 100%; min-height: 180px; padding: 12px; border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px; background: var(--panel-2); color: var(--ink); white-space: pre; resize: vertical;
}

.url-field { margin-top: 14px; }
.url-row { display: flex; gap: 8px; align-items: center; }
.url-row input {
  flex: 1; min-width: 0; padding: 9px 10px; border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); font-size: 13px; background: var(--panel-2); color: inherit;
}
.url-row .btn { flex: 0 0 auto; }

.sample-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.sample label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 6px; }
.response-sample {
  margin: 0 0 8px; padding: 10px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: var(--panel-2);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px; white-space: pre-wrap; word-break: break-all;
}
.response-sample:last-child { margin-bottom: 0; }

.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; box-shadow: var(--shadow-sm); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 11px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 13px; }
th { background: var(--panel-2); font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: .02em; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--panel-2); }
.clamp { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pager { display: flex; align-items: center; gap: 12px; margin-top: 12px; justify-content: flex-end; }

.danger-zone { border-color: #fecaca; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(17, 24, 39, .45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; z-index: 100;
}
.modal-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px; width: 100%; max-width: 460px;
  box-shadow: var(--shadow);
}
.modal-card h2 { margin: 0 0 8px; font-size: 18px; }
.modal-card p { margin: 0 0 16px; }
.modal-token {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 18px;
}
.modal-token code { flex: 1; word-break: break-all; font-size: 13px; color: var(--ink); }
.modal-token .btn { flex: 0 0 auto; }
.modal-actions { display: flex; justify-content: flex-end; }

@media (max-width: 720px) {
  body { font-size: 15px; }
  .plan-grid { grid-template-columns: 1fr; }
  .user-main { padding: 14px 12px 32px; }
  .card { padding: 15px; }
  .table-wrap table { min-width: 720px; }
  .sample-grid { grid-template-columns: 1fr; }
  .login-field input, .note-edit textarea, .editor { font-size: 16px; }
  .pager { justify-content: space-between; }
  .pager .btn { flex: 1; }
}

/* ---- polish ---- */
.user-main { max-width: 900px; }
.user-topbar { padding-bottom: 14px; border-bottom: 1px solid var(--line); }
* { scrollbar-width: thin; scrollbar-color: #d5d8de transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d5d8de; border-radius: 999px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #c2c6ce; background-clip: content-box; }

/* ---- toasts ---- */
.toast-host {
  position: fixed; top: 18px; left: 50%; transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; gap: 10px;
  width: min(440px, calc(100vw - 28px)); pointer-events: none;
}
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 10px;
  background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--accent);
  border-radius: 10px; padding: 12px 12px 12px 14px; font-size: 13.5px; color: var(--ink);
  box-shadow: 0 12px 30px -12px rgba(17, 24, 39, .35), 0 2px 6px rgba(17, 24, 39, .06);
  animation: toast-in .22s ease;
}
.toast .toast-dot { flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; background: var(--accent); }
.toast .toast-msg { flex: 1; word-break: break-word; line-height: 1.5; }
.toast .toast-x { flex: 0 0 auto; border: none; background: transparent; color: var(--muted); font-size: 16px; line-height: 1; cursor: pointer; padding: 0 2px; }
.toast .toast-x:hover { color: var(--ink); }
.toast.success { border-left-color: var(--ok); }
.toast.success .toast-dot { background: var(--ok); }
.toast.error { border-left-color: var(--danger); }
.toast.error .toast-dot { background: var(--danger); }
.toast.warn { border-left-color: var(--warn); }
.toast.warn .toast-dot { background: var(--warn); }
.toast.leaving { animation: toast-out .18s ease forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-10px); } }

/* ---- account login and recharge ---- */
.login-tabs { display: flex; gap: 6px; margin: 0 0 18px; }
.login-tab {
  flex: 1; padding: 8px 6px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel); color: var(--muted); font-size: 13px; cursor: pointer;
}
.login-tab.active { border-color: var(--accent); color: var(--accent); background: rgba(79,70,229,.08); font-weight: 600; }
.login-panel { animation: fade-in .18s ease; }
@keyframes fade-in { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 18px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
#account-token-view { word-break: break-all; }
#redeem-code { text-transform: uppercase; }

@media (max-width: 720px) {
  .grid-2 { grid-template-columns: 1fr; }
}
