/* ALL-FlashTool 用户中心 */
:root {
  --bg: #f0f2f5;
  --surface: #fff;
  --surface-2: #f8fafc;
  --border: #e5e9ef;
  --text: #111827;
  --text-2: #4b5563;
  --muted: #9ca3af;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --ok: #059669;
  --ok-bg: #ecfdf5;
  --warn: #d97706;
  --warn-bg: #fffbeb;
  --err: #dc2626;
  --err-bg: #fef2f2;
  --sidebar-w: 196px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: #0b1220;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ---- OS 随机壁纸（全局） ---- */
.panel-photo-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background: #0b1220;
}

.panel-photo-bg-fallback {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 20% 10%, rgba(147, 197, 253, 0.35) 0%, transparent 55%),
    radial-gradient(ellipse 70% 55% at 85% 20%, rgba(196, 181, 253, 0.28) 0%, transparent 50%),
    linear-gradient(160deg, #1e3a5f 0%, #0f172a 45%, #1e1b4b 100%);
}

.panel-photo-bg-blur,
.panel-photo-bg-main {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0;
  border: 0;
  transition: opacity 0.28s ease;
  image-rendering: auto;
}

/* 模糊层用 background，与主图共享一次下载；选中 URL 后立刻显示 */
.panel-photo-bg.is-pending .panel-photo-bg-blur,
.panel-photo-bg.is-ready .panel-photo-bg-blur {
  opacity: 1;
}

.panel-photo-bg.is-ready .panel-photo-bg-main {
  opacity: 1;
}

.panel-photo-bg-blur {
  background-color: #0b1220;
  background-position: center center;
  background-repeat: no-repeat;
  background-size: cover;
  transform: scale(1.12);
  filter: blur(26px) saturate(1.12) brightness(0.72);
  -webkit-filter: blur(26px) saturate(1.12) brightness(0.72);
  will-change: opacity;
}

/* 主图：JS 按自然尺寸切换 cover / contain，避免小图被强行拉伸发糊 */
.panel-photo-bg-main {
  object-position: center center;
  filter: none;
  z-index: 1;
}

.panel-photo-bg-main.fit-cover {
  object-fit: cover;
}

.panel-photo-bg-main.fit-contain {
  object-fit: contain;
}

/* 横竖构图焦点：竖图偏中上，横图居中 */
.panel-photo-bg-main.pos-portrait {
  object-position: center 28%;
}

.panel-photo-bg-main.pos-landscape {
  object-position: center center;
}

.panel-photo-bg-main.pos-center {
  object-position: center center;
}

.panel-photo-bg[data-orient="portrait"] .panel-photo-bg-veil {
  background:
    linear-gradient(180deg, rgba(8, 15, 30, 0.22) 0%, rgba(8, 15, 30, 0.1) 40%, rgba(8, 15, 30, 0.5) 100%),
    radial-gradient(ellipse 80% 60% at 50% 35%, transparent 25%, rgba(8, 15, 30, 0.4) 100%);
}

.panel-photo-bg[data-orient="landscape"] .panel-photo-bg-veil {
  background:
    linear-gradient(180deg, rgba(8, 15, 30, 0.3) 0%, rgba(8, 15, 30, 0.08) 45%, rgba(8, 15, 30, 0.42) 100%),
    radial-gradient(ellipse 90% 70% at 50% 50%, transparent 35%, rgba(8, 15, 30, 0.32) 100%);
}

.panel-photo-bg-veil {
  position: absolute;
  inset: 0;
  z-index: 2;
  background:
    linear-gradient(180deg, rgba(8, 15, 30, 0.28) 0%, rgba(8, 15, 30, 0.12) 42%, rgba(8, 15, 30, 0.45) 100%),
    radial-gradient(ellipse 70% 55% at 50% 40%, transparent 30%, rgba(8, 15, 30, 0.35) 100%);
}

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 1040px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

/* ---- Login ---- */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  overflow: auto;
}

.login-screen-content {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 380px;
}

.login-brand {
  text-align: center;
  margin-bottom: 24px;
  animation: loginBrandEnter 0.8s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes loginBrandEnter {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.brand-title {
  margin: 0 0 4px;
  font-size: 1.625rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #fff;
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.45), 0 1px 2px rgba(0, 0, 0, 0.35);
}

.brand-tagline {
  margin: 0;
  color: rgba(255, 255, 255, 0.88);
  font-size: 0.875rem;
  letter-spacing: 0.12em;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.4);
}

.login-card.card {
  padding: 28px 24px;
  overflow: visible;
  background: rgba(255, 255, 255, 0.48);
  backdrop-filter: blur(28px) saturate(1.55);
  -webkit-backdrop-filter: blur(28px) saturate(1.55);
  border: 1px solid rgba(255, 255, 255, 0.62);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.25) inset,
    0 20px 56px rgba(0, 0, 0, 0.24),
    0 4px 16px rgba(0, 0, 0, 0.08);
  animation: loginCardEnter 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes loginCardEnter {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.card-head h2 {
  margin: 0 0 4px;
  font-size: 1.125rem;
  font-weight: 600;
}

.login-card .card-head h2 {
  margin: 0 0 20px;
}

.card-head .sub { margin: 0 0 20px; }

.login-card .btn-primary { width: 100%; }

/* ---- Shared ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.sub { margin: 0; color: var(--text-2); font-size: 0.8125rem; }

.field { margin-bottom: 16px; }

.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-2);
}

.field input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input::placeholder { color: var(--muted); }

.field input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.field-password {
  position: relative;
  z-index: 2;
  overflow: visible;
}

input[type="password"] {
  ime-mode: disabled;
  -ms-ime-mode: disabled;
}

.btn {
  appearance: none;
  border: none;
  border-radius: var(--radius);
  padding: 9px 16px;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }

.btn-ghost {
  background: rgba(255, 255, 255, 0.5);
  color: var(--text-2);
  border: 1px solid rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.btn-ghost:hover:not(:disabled) { background: rgba(255, 255, 255, 0.72); }

.btn-danger {
  background: var(--err-bg);
  color: var(--err);
  border: 1px solid #fecaca;
  padding: 4px 10px;
  font-size: 0.75rem;
}

.alert {
  border-radius: var(--radius);
  padding: 9px 12px;
  font-size: 0.8125rem;
  margin-bottom: 12px;
}

.alert-err { background: var(--err-bg); color: #991b1b; border: 1px solid #fecaca; }
.alert-warn { background: var(--warn-bg); color: #92400e; border: 1px solid #fde68a; }
.alert-ok { background: var(--ok-bg); color: #065f46; border: 1px solid #a7f3d0; }

.foot-note {
  margin: 18px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
}

/* ---- Avatar ---- */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  text-transform: uppercase;
  flex-shrink: 0;
}

.avatar-lg {
  width: 52px;
  height: 52px;
  font-size: 1.125rem;
}

.avatar-has-img {
  background: var(--surface-2);
  overflow: hidden;
  padding: 0;
}

.avatar-has-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.user-pill .avatar {
  width: 26px;
  height: 26px;
  font-size: 0.6875rem;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 3px 10px 3px 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-2);
}

/* ---- Dashboard layout（侧栏与面板分离，避免遮罩挡点击） ---- */
.dash-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  align-items: stretch;
  gap: 0;
}

.dash-layout > .sidebar {
  grid-column: 1;
  grid-row: 1;
  z-index: 2;
}

.dash-layout > .dash-shell.card {
  grid-column: 2;
  grid-row: 1;
  z-index: 1;
  min-width: 0;
}

.dash-layout > .sidebar-backdrop {
  grid-column: 1 / -1;
  grid-row: 1;
}

/* ---- Dashboard shell（毛玻璃） ---- */
.dash-shell.card {
  display: flex;
  flex-direction: column;
  min-height: 560px;
  background: rgba(255, 255, 255, 0.38);
  backdrop-filter: blur(28px) saturate(1.55);
  -webkit-backdrop-filter: blur(28px) saturate(1.55);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-left: none;
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.2) inset,
    0 16px 48px rgba(0, 0, 0, 0.22);
  overflow: hidden;
}

/* ---- Sidebar ---- */
.sidebar {
  display: flex;
  flex-direction: column;
  padding: 20px 10px;
  background: rgba(255, 255, 255, 0.42);
  border-right: 1px solid rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(18px) saturate(1.35);
  -webkit-backdrop-filter: blur(18px) saturate(1.35);
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}

.sidebar-brand {
  padding: 0 10px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.35);
  margin-bottom: 12px;
}

.sidebar-brand strong {
  display: block;
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.sidebar-brand span {
  font-size: 0.6875rem;
  color: var(--muted);
}

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

.nav-item {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-2);
  font-size: 0.8125rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.45);
  color: var(--text);
}

.nav-item.active {
  background: rgba(255, 255, 255, 0.72);
  color: var(--primary);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* ---- Main content ---- */
.dash-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.content-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 28px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.12);
}

.content-header-main {
  flex: 1;
  min-width: 0;
}

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  padding: 0;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  flex-shrink: 0;
}

.nav-toggle-bar {
  display: block;
  width: 18px;
  height: 2px;
  margin: 0 auto;
  border-radius: 1px;
  background: var(--text-2);
}

.sidebar-backdrop {
  display: none;
}

body.nav-open {
  overflow: hidden;
}

.content-header h1 {
  margin: 0 0 2px;
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.content-header p {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--text-2);
}

.content-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

#dashUser {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notice-list {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.notice-item {
  padding: 12px 14px;
  border-radius: var(--radius-lg);
  background: rgba(255, 251, 235, 0.62);
  border: 1px solid rgba(253, 230, 138, 0.75);
  backdrop-filter: blur(12px) saturate(1.2);
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
  font-size: 0.8125rem;
}

.notice-item strong {
  display: block;
  margin-bottom: 4px;
  font-size: 0.875rem;
}

.notice-item p {
  margin: 0;
  color: var(--text-2);
  line-height: 1.55;
}

.dash-pages {
  flex: 1;
  padding: 24px 28px 32px;
}

.page {
  display: none;
}

.page.active {
  display: block;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---- Overview page ---- */
.profile-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  margin-bottom: 20px;
  border-radius: var(--radius-lg);
  background: linear-gradient(
    105deg,
    rgba(239, 246, 255, 0.55) 0%,
    rgba(255, 255, 255, 0.38) 100%
  );
  border: 1px solid rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(14px) saturate(1.35);
  -webkit-backdrop-filter: blur(14px) saturate(1.35);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.35) inset;
}

.profile-info h2 {
  margin: 0 0 4px;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.profile-meta {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--text-2);
}

.tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--primary-light);
  color: var(--primary);
}

.stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(12px) saturate(1.25);
  -webkit-backdrop-filter: blur(12px) saturate(1.25);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.3) inset;
}

.stat-label {
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--muted);
}

.stat-value {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
}

.stat-value-sm {
  font-size: 0.8125rem;
  font-weight: 500;
}

/* ---- Usage stats ---- */
.usage-layout {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.usage-hero {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.usage-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(12px) saturate(1.25);
  -webkit-backdrop-filter: blur(12px) saturate(1.25);
}

.usage-card-highlight {
  background: linear-gradient(
    to bottom right,
    rgba(239, 246, 255, 0.55),
    rgba(255, 255, 255, 0.4)
  );
  border-color: rgba(37, 99, 235, 0.2);
}

.usage-label {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.03em;
}

.usage-value {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.usage-hint {
  font-size: 0.75rem;
  color: var(--text-2);
}

.usage-details {
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.38);
  border: 1px solid rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(12px) saturate(1.25);
  -webkit-backdrop-filter: blur(12px) saturate(1.25);
  overflow: hidden;
}

.usage-details-title {
  margin: 0;
  padding: 14px 18px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
  border-bottom: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.28);
}

.usage-detail-list {
  margin: 0;
}

.usage-detail-row {
  display: grid;
  grid-template-columns: 120px 1fr;
  align-items: center;
  gap: 12px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
}

.usage-detail-row:last-child {
  border-bottom: none;
}

.usage-detail-row dt {
  font-size: 0.8125rem;
  color: var(--muted);
  font-weight: 500;
}

.usage-detail-row dd {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  text-align: right;
}

.usage-ip {
  font-family: ui-monospace, "Cascadia Code", "Segoe UI Mono", monospace;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.usage-ip-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.usage-ip-region {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
}

/* ---- Features ---- */
.feature-list {
  display: grid;
  gap: 8px;
}

.feature-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.feature-item .meta strong {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 2px;
}

.feature-item .meta span {
  font-size: 0.8125rem;
  color: var(--text-2);
}

/* ---- Password form ---- */
.form-panel {
  max-width: 360px;
}
#pageWallpaper .form-panel {
  max-width: 480px;
}

.pwd-form .field:last-of-type {
  margin-bottom: 20px;
}

.title-hint {
  margin: 0 0 18px;
}

.wallpaper-preview-wrap {
  position: relative;
  width: 100%;
  max-width: 420px;
  /* 贴近桌面登录左侧栏比例（约 1:1），便于判断横竖图裁切效果 */
  aspect-ratio: 1 / 1.02;
  margin: 0 0 12px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: #0b1220;
  -webkit-user-select: none;
  user-select: none;
}
.wallpaper-preview-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.8125rem;
  padding: 16px;
  text-align: center;
  z-index: 1;
}
.wallpaper-preview-media {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  display: block;
  background: #0b1220;
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
}
.wallpaper-preview-media.is-portrait {
  object-position: center 28%;
}
.wallpaper-preview-shield {
  position: absolute;
  inset: 0;
  z-index: 2;
  cursor: default;
  background: transparent;
}
.wallpaper-preview-badge {
  position: absolute;
  left: 10px;
  bottom: 10px;
  z-index: 3;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  color: #fff;
  background: rgba(15, 23, 42, 0.72);
  pointer-events: none;
}
.wallpaper-meta {
  margin: 0 0 16px;
  font-size: 0.75rem;
  color: var(--muted);
}
.wallpaper-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}
.wallpaper-form .field {
  margin-bottom: 14px;
}

.field-hint {
  margin: 6px 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.title-preview {
  margin: 16px 0 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.title-preview-label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
}

.title-preview-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.title-preview-brand {
  font-size: 0.8125rem;
  font-weight: 700;
  background: linear-gradient(90deg, #2563eb, #2dd4bf);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.title-preview-ver {
  font-size: 0.75rem;
  color: var(--muted);
}

.title-preview-user {
  margin-left: 2px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-light);
  border: 1px solid rgba(37, 99, 235, 0.12);
}

.title-preview-user.hidden {
  display: none;
}

.title-color-field {
  margin-bottom: 4px;
}

.title-color-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 6px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.title-color-toolbar:focus-within {
  border-color: rgba(37, 99, 235, 0.4);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}

.title-color-toolbar:has(.title-color-hex.is-invalid) {
  border-color: rgba(220, 38, 38, 0.45);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.06);
}

.title-color-swatch {
  position: relative;
  display: block;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.1);
  transition: box-shadow 0.15s;
}

.title-color-swatch:hover {
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.1), 0 0 0 2px rgba(37, 99, 235, 0.16);
}

.title-color-swatch-fill {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--primary);
}

.title-color-swatch-fill[data-empty="1"] {
  background: linear-gradient(135deg, #e2e8f0 46%, #f8fafc 46%, #f8fafc 54%, #cbd5e1 54%);
}

.title-color-native {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  border: none;
  padding: 0;
}

.title-color-hex {
  flex: 1;
  min-width: 0;
  height: 32px;
  padding: 0 4px;
  border: none;
  background: transparent;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text);
  font-family: Consolas, "Cascadia Mono", "Courier New", monospace;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  outline: none;
}

.title-color-hex::placeholder {
  color: var(--muted);
  font-weight: 400;
  letter-spacing: 0.03em;
}

.title-color-hex.is-invalid {
  color: var(--err);
}

.title-color-reset {
  flex-shrink: 0;
  height: 28px;
  padding: 0 10px;
  border: none;
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.title-color-reset:hover {
  background: #eef2ff;
  color: var(--primary);
}

.title-color-presets {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  margin-top: 10px;
  max-width: 240px;
}

.title-color-preset {
  width: 100%;
  aspect-ratio: 1;
  max-width: 32px;
  max-height: 32px;
  justify-self: center;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.1);
  transition: transform 0.1s, box-shadow 0.1s, border-color 0.1s;
}

.title-color-preset:hover {
  transform: scale(1.06);
}

.title-color-preset.is-active {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.25);
}

.title-color-preset.is-light {
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.14);
}

.btn-sm {
  padding: 6px 10px;
  font-size: 0.75rem;
}

/* ---- Badges ---- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-err { background: var(--err-bg); color: var(--err); }

/* ---- Tables ---- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

th, td {
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  background: var(--surface-2);
  color: var(--text-2);
  font-weight: 600;
  font-size: 0.75rem;
}

tr:last-child td { border-bottom: none; }

tbody tr:hover td { background: #fafbfc; }

.col-action { width: 88px; text-align: center; }
td.col-action { text-align: center; }

.cell-ip {
  font-family: ui-monospace, "Cascadia Code", "Segoe UI Mono", monospace;
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.empty-cell {
  padding: 40px 16px !important;
  text-align: center !important;
  color: var(--muted) !important;
  font-size: 0.8125rem !important;
  background: transparent !important;
}

.empty-text {
  margin: 0;
  padding: 32px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 0.8125rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  html, body {
    background: #0b1220;
  }

  .app-shell {
    max-width: none;
    margin: 0;
    padding: 0;
  }

  .login-screen {
    padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  }

  .login-screen-content {
    max-width: none;
  }

  .login-card.card {
    padding: 22px 18px;
  }

  .brand-title {
    font-size: 1.375rem;
  }

  .field input {
    font-size: 16px;
    min-height: 44px;
  }

  .btn {
    min-height: 44px;
    padding: 11px 16px;
  }

  .dash-layout {
    display: block;
  }

  .dash-layout > .sidebar,
  .dash-layout > .dash-shell.card {
    grid-column: auto;
    grid-row: auto;
  }

  .dash-shell.card {
    min-height: 100dvh;
    border: none;
    border-radius: 0;
    box-shadow: none;
    background: rgba(255, 255, 255, 0.42);
    backdrop-filter: blur(26px) saturate(1.45);
    -webkit-backdrop-filter: blur(26px) saturate(1.45);
  }

  /*
   * 遮罩只盖侧栏右侧内容区，绝不覆盖抽屉本身（从根上避免点不到菜单）
   * --drawer-w 与侧栏宽度一致
   */
  .sidebar-backdrop {
    --drawer-w: min(288px, 86vw);
    display: block;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: var(--drawer-w);
    width: auto;
    height: auto;
    inset: auto;
    z-index: 210;
    background: rgba(15, 23, 42, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }

  .sidebar-backdrop:not(.hidden) {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar {
    --drawer-w: min(288px, 86vw);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 230;
    width: var(--drawer-w);
    max-width: 100%;
    padding: max(12px, env(safe-area-inset-top)) 10px max(16px, env(safe-area-inset-bottom));
    border-right: 1px solid rgba(226, 232, 240, 0.95);
    border-bottom: none;
    border-radius: 0;
    background: #f8fafc;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: 8px 0 28px rgba(15, 23, 42, 0.2);
    transform: translate3d(-105%, 0, 0);
    transition: transform 0.25s ease;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    pointer-events: auto;
    touch-action: manipulation;
    isolation: isolate;
  }

  .sidebar.open {
    transform: translate3d(0, 0, 0);
  }

  .sidebar .nav-item {
    position: relative;
    z-index: 2;
    pointer-events: auto;
    -webkit-tap-highlight-color: rgba(37, 99, 235, 0.12);
  }

  .sidebar-brand {
    display: block;
    padding-top: 8px;
  }

  .sidebar-nav {
    flex-direction: column;
    flex-wrap: nowrap;
    overflow: visible;
    gap: 4px;
  }

  .nav-item {
    flex-shrink: unset;
    white-space: normal;
    padding: 12px 14px;
    font-size: 0.875rem;
    min-height: 44px;
  }

  .nav-item.active {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    background: rgba(255, 255, 255, 0.75);
  }

  .nav-toggle {
    display: flex;
  }

  .content-header {
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding: max(14px, env(safe-area-inset-top)) 14px 12px;
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(255, 255, 255, 0.45);
    backdrop-filter: blur(20px) saturate(1.35);
    -webkit-backdrop-filter: blur(20px) saturate(1.35);
  }

  .content-header-main {
    order: 2;
    flex: 1 1 calc(100% - 52px);
  }

  .content-header h1 {
    font-size: 1.0625rem;
  }

  .content-header-actions {
    order: 3;
    width: 100%;
    justify-content: space-between;
  }

  #dashUser {
    max-width: none;
    flex: 1;
  }

  .dash-pages {
    padding: 16px 14px max(28px, env(safe-area-inset-bottom));
  }

  .profile-banner {
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    padding: 16px;
  }

  .profile-info h2 {
    font-size: 1.125rem;
    word-break: break-all;
  }

  .stats {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .stat {
    padding: 12px;
  }

  .usage-hero {
    grid-template-columns: 1fr;
  }

  .usage-detail-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .usage-detail-row dd {
    text-align: left;
  }

  .usage-ip-cell {
    align-items: flex-start;
  }

  .form-panel {
    max-width: none;
  }

  .title-color-presets {
    max-width: none;
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .title-color-preset {
    max-width: none;
    width: 100%;
  }

  .title-preview-bar {
    flex-wrap: wrap;
  }

  .notify-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
  }

  .feature-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .table-responsive-cards {
    overflow: visible;
    border: none;
    background: transparent;
  }

  .table-responsive-cards table {
    display: block;
  }

  .table-responsive-cards thead {
    display: none;
  }

  .table-responsive-cards tbody {
    display: block;
  }

  .table-responsive-cards tr {
    display: block;
    margin-bottom: 10px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
  }

  .table-responsive-cards tr:last-child {
    margin-bottom: 0;
  }

  .table-responsive-cards td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 7px 0;
    border-bottom: none;
    text-align: right;
  }

  .table-responsive-cards td::before {
    content: attr(data-label);
    flex-shrink: 0;
    color: var(--muted);
    font-weight: 600;
    font-size: 0.75rem;
    text-align: left;
  }

  .table-responsive-cards td.col-action {
    justify-content: flex-end;
    padding-top: 10px;
    margin-top: 4px;
    border-top: 1px solid var(--border);
  }

  .table-responsive-cards td.col-action::before {
    display: none;
  }

  .table-responsive-cards tbody tr:hover td {
    background: transparent;
  }

  .table-responsive-cards .cell-ip {
    white-space: normal;
    word-break: break-all;
  }

  .table-responsive-cards .empty-cell {
    display: block !important;
    text-align: center !important;
    padding: 32px 12px !important;
  }

  .table-responsive-cards .empty-cell::before {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .panel-photo-bg-blur,
  .panel-photo-bg-main,
  .login-brand,
  .login-card.card {
    animation: none;
    transition: none;
  }
}

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

  .content-header-main {
    flex-basis: 100%;
  }

  .nav-toggle {
    order: 0;
  }
}

@media (min-width: 769px) {
  .sidebar-backdrop {
    display: none !important;
  }
}

.notify-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  background: var(--surface-2);
}

.notify-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.notify-row-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.notify-row-text strong {
  font-size: 15px;
  color: var(--text);
}

.notify-row-text span {
  font-size: 13px;
  color: var(--muted);
}

.toggle-switch {
  position: relative;
  display: inline-flex;
  width: 46px;
  height: 26px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  cursor: pointer;
  background: #cbd5e1;
  border-radius: 999px;
  transition: background 0.2s ease;
}

.toggle-slider::before {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s ease;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.18);
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--primary);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

.toggle-switch input:disabled + .toggle-slider {
  opacity: 0.55;
  cursor: not-allowed;
}

.notify-meta {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 14px;
}

.notify-label {
  color: var(--muted);
  margin-right: 8px;
}

.notify-preview {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 10px;
  background: rgba(37, 99, 235, 0.06);
  border: 1px solid rgba(37, 99, 235, 0.12);
}

.notify-preview-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.notify-preview-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

/* ---- Login key page ---- */
.login-key-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-key-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 20px;
}

.login-key-status {
  font-size: 0.8125rem;
  color: var(--text-2);
}

.login-key-timer-value {
  font-size: 0.8125rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--primary);
  letter-spacing: 0.02em;
}

.login-key-progress {
  height: 3px;
  margin-top: 12px;
  border-radius: 999px;
  background: #e5e7eb;
  overflow: hidden;
}

.login-key-progress-bar {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: var(--primary);
  transition: width 0.25s linear;
}

.login-key-panel[data-state="expired"] .login-key-timer-value {
  color: var(--warn);
}

.login-key-display {
  display: flex;
  align-items: center;
  gap: 10px;
}

.login-key-value {
  flex: 1;
  min-width: 0;
  display: block;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-family: ui-monospace, "Cascadia Code", "Segoe UI Mono", Consolas, monospace;
  font-size: 0.9375rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text);
  word-break: break-all;
  user-select: all;
}

.login-key-panel .btn-login-key {
  align-self: flex-start;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
}

.login-key-panel .btn-login-key:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: #d1d5db;
}

.login-key-panel .btn-login-key:disabled,
.login-key-panel .btn-login-key[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
  filter: grayscale(0.2);
  background: #fff;
  color: var(--muted);
}

.login-key-panel[data-state="used"] .login-key-status,
.login-key-panel[data-state="expired"] .login-key-status {
  color: var(--warn);
  font-weight: 600;
}
