:root {
  --ink: #172033;
  --muted: #687086;
  --line: #dfe3ec;
  --surface: #fff;
  --brand: #5b5bd6;
  --brand-dark: #4646b7;
  --danger: #c93f55;
  --card-radius: 30px;
  --card-shadow: 0 2px 8px rgb(28 32 93 / 24%);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; color: var(--ink); font-family: Inter, "PingFang SC", "Microsoft YaHei", sans-serif; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.profile-page {
  min-height: 100dvh;
  padding: 48px 18px;
  background: linear-gradient(135deg, #f9f8f5, #dfe4ec 48%, #f7f4ef);
  background-position: center;
  background-size: cover;
}
.profile { width: min(100%, 560px); margin: 0 auto; text-align: center; }
.avatar { display: block; width: 96px; height: 96px; margin: 0 auto 16px; object-fit: cover; border: 3px solid rgb(255 255 255 / 90%); border-radius: 50%; box-shadow: 0 4px 18px rgb(28 32 93 / 20%); }
.profile-name { margin: 0; font-size: 22px; }
.profile-intro { margin: 8px 0 28px; color: #222; font-size: 14px; }
.link-list { display: grid; gap: 16px; }
.link-card { display: grid; grid-template-columns: 32px 1fr 32px; align-items: center; width: 100%; min-height: 62px; padding: 10px 18px; color: #000; font: inherit; text-decoration: none; cursor: pointer; background: #fff; border: 2px solid #fff; border-radius: var(--card-radius); box-shadow: var(--card-shadow); transition: transform 150ms ease, box-shadow 150ms ease; }
.link-card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgb(28 32 93 / 25%); }
.link-card:active { transform: scale(.98); }
.link-title { font-weight: 600; }
.link-arrow { font-size: 24px; line-height: 1; }
.section-title { margin: 6px 0; font-size: 16px; font-weight: 600; }
.modal[hidden], [hidden] { display: none !important; }
.modal { position: fixed; z-index: 10; inset: 0; display: grid; place-items: center; padding: 24px; }
.modal-backdrop { position: absolute; inset: 0; width: 100%; border: 0; background: rgb(0 0 0 / 58%); }
.qr-dialog { position: relative; z-index: 1; width: min(100%, 340px); padding: 28px 24px 24px; text-align: center; background: #fff; border-radius: 24px; box-shadow: 0 18px 50px rgb(0 0 0 / 30%); }
.qr-dialog h2 { margin: 0 0 18px; font-size: 20px; }
.qr-dialog img { display: block; width: 100%; border-radius: 12px; }
.qr-dialog p { margin: 16px 0 0; color: #666; font-size: 13px; }
.close-button { position: absolute; top: 8px; right: 12px; padding: 4px 8px; color: #666; font-size: 26px; cursor: pointer; background: transparent; border: 0; }
body.modal-open { overflow: hidden; }

.admin-body { min-height: 100vh; padding: 32px; background: #f3f5f9; }
.admin-locked { overflow: hidden; }
.admin-locked > :not(.auth-gate) { visibility: hidden; }
.auth-gate { position: fixed; z-index: 100; inset: 0; display: grid; place-items: center; padding: 20px; background: #eef1f7; }
.auth-card { display: grid; width: min(100%, 390px); gap: 18px; padding: 30px; background: #fff; border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 18px 60px rgb(37 44 70 / 14%); }
.auth-card h1, .auth-card p { margin: 0; }
.auth-card > p:not(.eyebrow):not(.auth-error) { color: var(--muted); }
.auth-error { min-height: 20px; color: var(--danger); font-size: 13px; }
.admin-header { display: flex; align-items: center; justify-content: space-between; width: min(100%, 1120px); margin: 0 auto 24px; gap: 24px; }
.admin-header h1 { margin: 3px 0 6px; font-size: clamp(26px, 4vw, 38px); }
.admin-header p, .danger-panel p { margin: 0; color: var(--muted); }
.eyebrow { color: var(--brand) !important; font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.header-actions { display: flex; flex-shrink: 0; gap: 10px; }
.admin-layout { display: grid; width: min(100%, 1120px); margin: 0 auto; gap: 20px; }
.admin-panel { padding: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 8px 32px rgb(37 44 70 / 6%); }
.stats-panel { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.stats-panel h2 { margin: 3px 0 7px; }
.stats-note { margin: 0; color: var(--muted); font-size: 13px; }
.ip-count-card { display: grid; grid-template-columns: auto auto auto; align-items: center; gap: 14px; min-width: 310px; padding: 14px 16px; background: #f8f9fc; border: 1px solid var(--line); border-radius: 14px; }
.ip-count-card span { color: var(--muted); font-size: 13px; font-weight: 700; }
.ip-count-card strong { min-width: 64px; font-size: 30px; text-align: right; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.panel-heading h2, .danger-panel h2 { margin: 3px 0 0; font-size: 20px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.full-field { grid-column: 1 / -1; }
label { display: grid; gap: 7px; color: #4a5266; font-size: 13px; font-weight: 700; }
input, textarea, select { width: 100%; padding: 11px 12px; color: var(--ink); background: #fff; border: 1px solid #cfd5e1; border-radius: 10px; outline: none; }
input:focus, textarea:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgb(91 91 214 / 12%); }
textarea { resize: vertical; }
input[type="file"] { padding: 8px; color: var(--muted); background: #f8f9fc; }
[data-upload-status] { color: var(--brand); font-size: 12px; font-weight: 600; }
.primary-button, .secondary-button, .danger-button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 0 16px; font-weight: 750; text-decoration: none; cursor: pointer; border-radius: 10px; }
.primary-button { color: #fff; background: var(--brand); border: 1px solid var(--brand); }
.primary-button:hover { background: var(--brand-dark); }
.secondary-button { color: var(--ink); background: #fff; border: 1px solid var(--line); }
.danger-button { color: #fff; background: var(--danger); border: 1px solid var(--danger); }
.admin-link-list { display: grid; gap: 12px; }
.link-editor { display: grid; grid-template-columns: 24px 1fr auto; align-items: center; gap: 14px; padding: 14px; background: #f8f9fc; border: 1px solid var(--line); border-radius: 14px; }
.drag-handle { color: #a0a6b5; font-weight: 800; letter-spacing: -3px; }
.link-fields { display: grid; grid-template-columns: 150px minmax(160px, 1fr) minmax(200px, 1.4fr) 90px auto; align-items: end; gap: 10px; }
.switch-field { display: flex; align-items: center; min-height: 41px; white-space: nowrap; }
.switch-field input { width: 18px; height: 18px; }
.row-actions { display: flex; gap: 5px; }
.row-actions button { width: 34px; height: 34px; color: #596176; cursor: pointer; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.row-actions button:disabled { cursor: not-allowed; opacity: .35; }
.row-actions .delete-icon { color: var(--danger); font-size: 20px; }
.danger-panel { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.empty-state { padding: 28px; color: var(--muted); text-align: center; border: 1px dashed var(--line); border-radius: 14px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 20; padding: 13px 18px; color: #fff; pointer-events: none; opacity: 0; background: #20283b; border-radius: 10px; box-shadow: 0 8px 30px rgb(0 0 0 / 20%); transform: translateY(12px); transition: .2s ease; }
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast.is-error { background: var(--danger); }

@media (max-width: 900px) {
  .link-fields { grid-template-columns: 1fr 1fr; }
  .admin-header { align-items: flex-start; }
}
@media (max-width: 640px) {
  .profile-page { padding-top: 32px; }
  .avatar { width: 84px; height: 84px; }
  .admin-body { padding: 20px 14px; }
  .admin-header { display: grid; }
  .header-actions { width: 100%; }
  .header-actions > * { flex: 1; }
  .admin-panel { padding: 18px; }
  .form-grid, .link-fields { grid-template-columns: 1fr; }
  .full-field { grid-column: auto; }
  .link-editor { grid-template-columns: 1fr; }
  .drag-handle { display: none; }
  .row-actions { justify-content: flex-end; }
  .danger-panel { align-items: flex-start; flex-direction: column; }
}
