/* ============================================================
   File Collector — Global v2.3
   统一设计系统 · 4px 网格 · 单一色彩体系
   ============================================================ */

:root {
  /* 品牌色 */
  --c-primary: #2563eb;
  --c-primary-hover: #1d4ed8;
  --c-primary-light: #eff6ff;
  --c-primary-border: #bfdbfe;

  /* 语义色 */
  --c-success: #16a34a;
  --c-success-light: #f0fdf4;
  --c-success-border: #bbf7d0;
  --c-warning: #d97706;
  --c-warning-light: #fffbeb;
  --c-warning-border: #fde68a;
  --c-danger: #dc2626;
  --c-danger-light: #fef2f2;
  --c-danger-border: #fecaca;
  --c-purple: #7c3aed;
  --c-purple-light: #f5f0ff;
  --c-purple-border: #e2d8f5;
  --c-info: #06b6d4;

  /* 中性灰 */
  --c-gray-50: #f9fafb;
  --c-gray-100: #f3f4f6;
  --c-gray-200: #e5e7eb;
  --c-gray-300: #d1d5db;
  --c-gray-400: #9ca3af;
  --c-gray-500: #6b7280;
  --c-gray-600: #4b5563;
  --c-gray-700: #374151;
  --c-gray-900: #111827;

  /* 旧变量兼容 */
  --c-bg: #f5f6f8;
  --c-white: #fff;
  --c-border: #e5e7eb;
  --c-text: #374151;
  --c-text-soft: #6b7280;
  --c-text-muted: #9ca3af;
  --c-bg-hover: #f3f4f6;

  /* 排版 */
  --fs-xs: .7rem;
  --fs-sm: .8rem;
  --fs-base: .9rem;
  --fs-md: 1rem;
  --fs-lg: 1.15rem;
  --fs-xl: 1.35rem;

  /* 圆角 */
  --br-sm: 4px;
  --br-md: 8px;
  --br-lg: 12px;
  --radius: 8px;
  --radius-sm: 8px;

  /* 阴影 */
  --shadow-sm: 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08);

  /* 安全区域 */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Helvetica Neue", sans-serif;
  --header-h: 44px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  overflow-y: scroll;
}

body {
  font-family: var(--font);
  color: var(--c-text);
  background: var(--c-bg);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  padding-bottom: var(--safe-bottom);
}

a { color: var(--c-primary); text-decoration: none; -webkit-touch-callout: none; }
a:hover { opacity: .85; }
a:active { opacity: .6; }

/* ============================================================
   Header
   ============================================================ */
.header {
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: .5px solid var(--c-border);
  height: var(--header-h);
  position: sticky; top: 0; z-index: 100;
  padding: 0 env(safe-area-inset-right, 0px) 0 env(safe-area-inset-left, 0px);
}
.header-inner {
  max-width: 960px; margin: 0 auto; height: 100%;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
}
.header-brand {
  font-size: var(--fs-md); font-weight: 700;
  color: var(--c-text); display: flex; align-items: center; gap: 8px;
  text-decoration: none; letter-spacing: -.3px;
}
.header-brand img {
  width: 26px; height: 26px; border-radius: 0;
  flex-shrink: 0; object-fit: contain;
}
.header-nav { display: flex; align-items: center; gap: 6px; }
.header-nav .header-user {
  font-size: var(--fs-sm); color: var(--c-text);
  font-weight: 500; max-width: 140px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.header-nav-sep {
  color: var(--c-border); font-size: .85rem;
  user-select: none;
}
.header-nav-link {
  font-size: var(--fs-sm); text-decoration: none;
  padding: 4px 8px; border-radius: var(--br-md);
  font-weight: 400; color: var(--c-text-soft);
  background: transparent; transition: all .15s;
}
.header-nav-link:hover { background: var(--c-bg-hover); color: var(--c-text); }
.header-nav-link.active { color: var(--c-primary) !important; background: var(--c-primary-light) !important; }
.header-nav-link:active { background: rgba(0,0,0,.06); }
.header-nav-logout { color: var(--c-text-soft); background: transparent; border: 1px solid transparent; }
.header-nav-logout:hover { background: var(--c-primary-light); border-color: var(--c-primary); color: var(--c-primary); }

/* ============================================================
   Main Content
   ============================================================ */
.main {
  flex: 1; padding: 12px 16px;
  max-width: 960px; width: 100%; margin: 0 auto;
}
.main-inner { width: 100%; }

/* ============================================================
   Footer
   ============================================================ */
.footer {
  text-align: center; padding: 12px 16px calc(12px + var(--safe-bottom));
  font-size: var(--fs-xs); color: var(--c-text-muted);
}

.is-admin .footer {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  background: rgba(255,255,255,.88);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: .5px solid var(--c-border);
}
.is-admin .main { padding-bottom: 50px; }

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--c-white); border-radius: var(--br-md);
  margin-bottom: 12px; overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 14px 16px; display: flex; align-items: center;
  justify-content: space-between; gap: 10px;
  border-bottom: .5px solid var(--c-border);
}
.card-header h2, .card-header h3 {
  font-size: var(--fs-base); font-weight: 600; letter-spacing: -.2px;
}
.card-body { padding: 16px; }
.card-footer {
  padding: 12px 16px; border-top: .5px solid var(--c-border);
  background: var(--c-gray-50); text-align: center;
}

/* ============================================================
   Stats Grid
   ============================================================ */
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
.stat-card {
  background: var(--c-white); border-radius: var(--br-md);
  padding: 16px 14px; text-align: center;
  box-shadow: var(--shadow-sm); transition: transform .15s;
}
.stat-card:active { transform: scale(.97); }
.stat-value {
  font-size: 1.6rem; font-weight: 800; line-height: 1.2;
  letter-spacing: -.5px; color: var(--c-primary);
}
.stat-label { font-size: var(--fs-xs); color: var(--c-text-soft); margin-top: 4px; }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 4px; padding: 10px 18px; font-size: var(--fs-base);
  font-weight: 500; font-family: var(--font);
  border-radius: var(--br-md); border: none;
  cursor: pointer; line-height: 1.4; white-space: nowrap;
  text-decoration: none; background: var(--c-gray-100);
  color: var(--c-text); transition: all .15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.96); opacity: .8; }
.btn:disabled { opacity: .4; pointer-events: none; }

.btn-primary { background: var(--c-primary); color: #fff; }
.btn-danger { background: var(--c-danger); color: #fff; }
.btn-success { background: var(--c-success); color: #fff; }
.btn-warning { background: var(--c-warning); color: #fff; }
.btn-info { background: var(--c-info); color: #fff; }
.btn-purple { background: var(--c-purple); color: #fff; }
.btn-secondary { background: var(--c-gray-200); color: var(--c-gray-700); }
.btn-secondary:hover { background: var(--c-gray-300); }

.btn-outline { background: transparent; border: 1px solid var(--c-border); color: var(--c-text); }
.btn-outline:hover { background: var(--c-primary-light); border-color: var(--c-primary); color: var(--c-primary); }
.btn-outline:active { transform: scale(.96); opacity: .8; }
.btn-outline-primary { background: transparent; border: 1px solid var(--c-primary); color: var(--c-primary); }
.btn-outline-danger { background: transparent; border: 1px solid var(--c-danger); color: var(--c-danger); }

.btn-link { background: transparent; border: none; border-radius: var(--br-sm); color: var(--c-primary); cursor: pointer; text-decoration: none; transition: all .15s; }
.btn-link:hover { background: var(--c-primary-light); }
.btn-link:active { transform: scale(.96); opacity: .8; }

.btn-sm { padding: 5px 14px; font-size: var(--fs-sm); border-radius: var(--br-sm); }
.btn-xs { padding: 4px 10px; font-size: var(--fs-xs); border-radius: var(--br-sm); }

.btn-more {
  background: transparent; color: var(--c-primary);
  border: 1px solid var(--c-primary);
  font-size: var(--fs-sm); padding: 4px 10px;
  border-radius: var(--br-md); cursor: pointer;
  transition: all .15s; white-space: nowrap; flex-shrink: 0;
}
.btn-more:hover { background: var(--c-primary-light); }
.btn-more.active { background: var(--c-primary); color: #fff; }
.btn-block { display: flex; width: 100%; }
.text-center { text-align: center; }
.btn-icon {
  width: 36px; height: 36px; padding: 0;
  border-radius: 50%; font-size: var(--fs-lg);
}

/* ============================================================
   Forms
   ============================================================ */
.form-group { margin-bottom: 14px; }
.form-label {
  display: block; font-size: var(--fs-sm); font-weight: 600;
  margin-bottom: 6px; color: var(--c-text); letter-spacing: -.1px;
}
.form-hint { font-size: var(--fs-xs); color: var(--c-text-muted); margin-top: 4px; }

.form-input, .form-select, .form-textarea {
  width: 100%; padding: 10px 14px; font-size: var(--fs-base);
  font-family: var(--font); color: var(--c-text);
  background: #f7f8fa; border: 1px solid var(--c-gray-200);
  border-radius: var(--br-md); outline: none;
  line-height: 1.5; transition: all .15s; -webkit-appearance: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  background: var(--c-white); border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.form-input::placeholder { color: var(--c-gray-400); }
.form-textarea { resize: vertical; min-height: 72px; }

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M5 6L0 0h10z' fill='%239ca3af'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
  padding-right: 36px;
}

.form-check {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; font-size: var(--fs-base);
}
.form-check input[type="checkbox"] {
  width: 20px; height: 20px; accent-color: var(--c-primary); cursor: pointer;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }

/* Compact Card */
.card-compact { margin-bottom: 10px; }
.card-compact .card-header { padding: 10px 14px; }
.card-compact .card-header h3 { font-size: var(--fs-base); }
.card-compact .card-body { padding: 12px 14px; }
.card-compact .form-group { margin-bottom: 10px; }
.card-compact .form-label { font-size: var(--fs-xs); margin-bottom: 4px; }
.card-compact .form-hint { font-size: var(--fs-xs); margin-top: 4px; }
.card-compact .info-row { padding: 8px 0; font-size: var(--fs-sm); }
.card-compact .info-row .info-label { font-size: var(--fs-sm); }
.card-compact .info-row .info-value { font-size: var(--fs-xs); }
.form-input-sm { padding: 8px 12px; font-size: var(--fs-sm); }
.form-textarea-sm { min-height: 52px; font-size: var(--fs-sm); }

/* Toggle Switch */
.toggle-switch {
  display: inline-flex; align-items: center; gap: 10px;
  cursor: pointer; font-size: var(--fs-base); user-select: none;
}
.toggle-switch input[type="checkbox"] { display: none; }
.toggle-slider {
  position: relative; width: 44px; height: 24px;
  background: #cbd5e1; border-radius: 12px;
  transition: background .25s; flex-shrink: 0;
}
.toggle-slider::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 20px; height: 20px; background: #fff;
  border-radius: 50%; transition: transform .25s;
  box-shadow: 0 1px 3px rgba(0,0,0,.18);
}
.toggle-switch input:checked + .toggle-slider { background: var(--c-primary); }
.toggle-switch input:checked + .toggle-slider::after { transform: translateX(20px); }
.toggle-text { color: var(--c-text); }

/* ============================================================
   Modal
   ============================================================ */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 1200; padding: 20px;
}
.modal-content {
  background: #fff; border-radius: var(--br-lg);
  max-width: 480px; width: 100%; max-height: 80vh;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.modal-sm { max-width: 360px; }
.modal-lg { max-width: 600px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--c-border);
}
.modal-header h3 { margin: 0; font-size: var(--fs-lg); color: var(--c-text); }
.modal-close {
  background: none; border: none; font-size: 24px;
  cursor: pointer; color: var(--c-text-soft); padding: 0;
  width: 32px; height: 32px; display: flex;
  align-items: center; justify-content: center;
  border-radius: 50%; transition: background .2s;
}
.modal-close:hover { background: var(--c-bg-hover); }
.modal-body {
  padding: 20px; overflow-y: auto; flex: 1; min-height: 0;
}
.modal-body p { line-height: 1.8; margin: 0 0 12px 0; color: var(--c-text); }
.modal-body code {
  background: var(--c-bg-hover); padding: 2px 8px;
  border-radius: var(--br-sm); font-family: monospace; color: var(--c-primary);
}
.modal-body .form-group { margin-bottom: 12px; }
.modal-body .form-hint { font-size: var(--fs-xs); color: var(--c-text-muted); margin-top: 4px; }
.modal-image-container { margin-top: 16px; border-radius: var(--br-md); overflow: hidden; background: #f8f9fa; }
.modal-image { width: 100%; height: auto; display: block; }
.modal-footer {
  padding: 16px 20px; border-top: 1px solid var(--c-border);
  text-align: right; flex-shrink: 0;
  display: flex; gap: 8px; justify-content: flex-end;
}

@media (max-width: 640px) {
  .modal-overlay { padding: 10px; }
  .modal-content { border-radius: var(--br-md); max-width: calc(100vw - 20px); }
  .modal-body { padding: 16px; }
  .modal-header { padding: 12px 16px; }
  .modal-footer { padding: 12px 16px; }
}

/* ============================================================
   Tables
   ============================================================ */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; width: 100%; }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
thead th {
  background: var(--c-gray-50); padding: 10px 14px;
  text-align: left; font-weight: 600; font-size: var(--fs-xs);
  color: var(--c-text-soft); text-transform: uppercase;
  letter-spacing: .3px; white-space: nowrap;
  border-bottom: 1px solid var(--c-border);
}
tbody td {
  padding: 12px 14px; border-bottom: .5px solid var(--c-gray-100);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:active { background: #f7f8fa; }

/* Dashboard Recent Uploads */
.dash-records { table-layout: fixed; min-width: 0; }
.dash-records th, .dash-records td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-records th:nth-child(2), .dash-records td:nth-child(2) { width: 65px; }
.dash-records th:nth-child(3), .dash-records td:nth-child(3) { width: 80px; }
.dash-records th:nth-child(4), .dash-records td:nth-child(4) { width: 45px; text-align: center; }
.dash-records th:nth-child(5), .dash-records td:nth-child(5) { width: 100px; }
.dash-records td:first-child { max-width: none; }
.dash-records td:first-child a {
  display: block; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; font-weight: 500;
}

@media (max-width: 768px) {
  .dash-records th:nth-child(3), .dash-records td:nth-child(3),
  .dash-records th:nth-child(4), .dash-records td:nth-child(4) { display: none; }
}
@media (max-width: 480px) {
  .dash-records th:nth-child(5), .dash-records td:nth-child(5) { display: none; }
}

.dash-records--full {
  table-layout: fixed; width: 100%; min-width: 640px; border-collapse: collapse;
}
.dash-records--full th, .dash-records--full td {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 8px 6px;
}
.dash-records--full .col-chk { width: 38px; text-align: center; }
.dash-records--full .col-chk input { width: 15px; height: 15px; cursor: pointer; accent-color: var(--c-primary); }
.dash-records--full .col-name a {
  display: block; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; font-weight: 500; text-decoration: none; color: var(--c-primary);
}
.dash-records--full .col-name a:hover { text-decoration: underline; }
.dash-records--full .col-size { width: 68px; }
.dash-records--full .col-src  { width: 92px; }
.dash-records--full .col-dl   { width: 50px; text-align: center; }
.dash-records--full .col-ip   { width: 138px; }
.dash-records--full .col-time { width: 140px; }
.dash-records--full .col-meta { color: var(--c-text-soft); font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-records--full .col-meta-dim { color: var(--c-text-muted); font-size: var(--fs-sm); }
.dash-records--full .col-act { width: 140px; text-align: center; }

.btn-record-del {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border: none; border-radius: 50%;
  background: transparent; color: var(--c-gray-400);
  font-size: var(--fs-md); cursor: pointer; transition: all .15s; line-height: 1;
}
.btn-record-del:hover { background: var(--c-danger-light); color: var(--c-danger); }

@media (max-width: 900px) {
  .dash-records--full th:nth-child(6), .dash-records--full td:nth-child(6),
  .dash-records--full th:nth-child(5), .dash-records--full td:nth-child(5) { display: none; }
}
@media (max-width: 768px) {
  .dash-records--full th:nth-child(4), .dash-records--full td:nth-child(4),
  .dash-records--full th:nth-child(3), .dash-records--full td:nth-child(3) { display: none; }
}
@media (max-width: 640px) {
  .dash-records--full th:nth-child(6), .dash-records--full td:nth-child(6) { display: none; }
}

/* Records PC/Mobile switch */
.records-table-pc { display: block; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.records-cards-mobile { display: none; }
.records-mobile-header {
  display: none; justify-content: space-between;
  padding: 8px 14px; font-size: var(--fs-sm);
  color: var(--c-gray-400); border-bottom: 1px solid var(--c-gray-200);
}

@media (max-width: 640px) {
  .records-table-pc { display: none; }
  .records-cards-mobile { display: block; }
  .records-mobile-header { display: flex; }
  .card-header { flex-wrap: wrap; gap: 8px; }
  .card-header h3 { font-size: var(--fs-base); margin: 0; }
  .card-header .btn-sm { font-size: var(--fs-xs); padding: 4px 12px; flex-shrink: 0; }
}

.record-card {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-bottom: .5px solid var(--c-gray-100);
  background: var(--c-white); transition: background .12s;
}
.record-card:last-child { border-bottom: none; }
.record-card:active { background: #f7f8fa; }
.record-card-left { flex-shrink: 0; padding-top: 2px; }
.record-card-check { display: flex; align-items: center; }
.record-card-check input { width: 17px; height: 17px; cursor: pointer; accent-color: var(--c-primary); }
.record-card-body { flex: 1; min-width: 0; overflow: hidden; }
.record-card-name {
  display: block; font-size: var(--fs-base); font-weight: 400;
  color: #121820; text-decoration: none; line-height: 1.45;
  word-break: break-word; margin-bottom: 6px;
}
.record-card-name:hover { text-decoration: underline; }
.record-card-meta {
  display: flex; flex-wrap: wrap; gap: 4px 12px;
  font-size: var(--fs-xs); color: var(--c-text-soft); line-height: 1.6;
}
.record-card-meta span:not(:last-child)::after { content: "·"; margin-left: 12px; color: #d0d0d8; }
.record-card-right { flex-shrink: 0; display: flex; align-items: flex-start; padding-top: 2px; }

/* Links Table */
.links-table { table-layout: fixed; width: 100%; }
.links-table th, .links-table td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.links-table tbody td { padding: 8px 10px; }
.links-table .col-title  { width: 120px; }
.links-table .col-limit  { width: 100px; }
.links-table .col-expire { width: 130px; }
.links-table .col-status { width: 64px; }
.links-table .col-time   { width: 145px; }
.links-table .col-act    { width: 190px; }

@media (max-width: 768px) {
  .links-table .col-limit, .links-table .col-time { display: none; }
  .links-table .col-title { width: 110px; }
  .links-table .col-act   { width: 170px; }
}
@media (max-width: 480px) {
  .links-table .col-expire { display: none; }
  .links-table .col-title  { width: 90px; }
  .links-table .col-status { width: 56px; }
  .links-table .col-act    { width: 100px; }
}

/* ============================================================
   Badges
   ============================================================ */
.badge {
  display: inline-block; padding: 2px 8px;
  font-size: var(--fs-xs); font-weight: 500;
  border-radius: 10px; background: var(--c-gray-100);
  color: var(--c-text-soft); letter-spacing: .1px;
}
.badge-success { background: var(--c-success-light); color: #065f46; }
.badge-danger  { background: var(--c-danger-light); color: #991b1b; }
.badge-warning { background: var(--c-warning-light); color: #92400e; }
.badge-info    { background: var(--c-primary-light); color: #1e40af; }

/* ============================================================
   Alerts
   ============================================================ */
.alert {
  padding: 10px 14px; border-radius: var(--br-md);
  font-size: var(--fs-sm); margin-bottom: 10px;
  display: flex; align-items: center; gap: 8px;
}
.alert-success { background: var(--c-success-light); color: #065f46; }
.alert-error   { background: var(--c-danger-light); color: #991b1b; }
.alert-warning { background: var(--c-warning-light); color: #92400e; }
.alert-info    { background: var(--c-primary-light); color: #1e40af; }
.flash-container { margin-bottom: 12px; }

/* ============================================================
   Empty State
   ============================================================ */
.empty-state {
  text-align: center; padding: 36px 16px; color: var(--c-text-muted);
}
.empty-state h3 { font-size: var(--fs-md); font-weight: 600; color: var(--c-text-soft); margin-bottom: 4px; }
.empty-state p { font-size: var(--fs-sm); }

/* ============================================================
   Pagination (global)
   ============================================================ */
.pagination {
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.pagination .page-info { font-size: var(--fs-sm); color: var(--c-text-soft); padding: 0 6px; }

/* ============================================================
   Admin Sidebar
   ============================================================ */
.admin-layout { display: flex; flex-direction: column; gap: 0; }
.sidebar-nav {
  display: flex; border-radius: var(--br-md);
  background: var(--c-white); margin-bottom: 12px;
  overflow: hidden; box-shadow: var(--shadow-sm);
}
.sidebar-nav a {
  flex: 1; text-align: center; padding: 12px 4px;
  font-size: var(--fs-sm); color: var(--c-text-soft);
  text-decoration: none; white-space: nowrap; font-weight: 500;
  transition: all .15s; position: relative;
}
.sidebar-nav a::after {
  content: ''; position: absolute; bottom: 0; left: 16px; right: 16px;
  height: 2.5px; background: transparent;
  border-radius: 2px; transition: background .15s;
}
.sidebar-nav a:active { background: #f7f8fa; }
.sidebar-nav a.active { color: var(--c-primary); font-weight: 600; }
.sidebar-nav a.active::after { background: var(--c-primary); }

@media (max-width: 480px) {
  .sidebar-nav a { font-size: var(--fs-xs); padding: 10px 4px; }
  .sidebar-nav a::after { left: 10px; right: 10px; }
}
.admin-content { flex: 1; min-width: 0; width: 100%; }

/* ============================================================
   Quick Actions
   ============================================================ */
.quick-actions { display: flex; gap: 12px; margin-bottom: 16px; border-radius: var(--br-md); }
.quick-action-btn {
  flex: 1; display: flex; align-items: center; justify-content: center;
  gap: 8px; padding: 12px 16px; background: var(--c-white);
  border-radius: var(--br-md); text-decoration: none;
  color: var(--c-text); font-size: var(--fs-base); font-weight: 500;
  box-shadow: var(--shadow-sm); transition: all .2s;
}
.quick-action-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.quick-action-btn:active { transform: translateY(0); }
.quick-action-icon { width: 20px; height: 20px; flex-shrink: 0; }
.quick-action-text { white-space: nowrap; }

/* ============================================================
   Action Group
   ============================================================ */
.action-group { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.action-group form { display: inline-flex; margin: 0; }

@media (max-width: 480px) {
  .action-group { flex-direction: column; width: 100%; gap: 4px; }
  .action-group .btn,
  .action-group form .btn { width: 100%; text-align: center; font-size: var(--fs-xs); padding: 6px 14px; border-radius: var(--br-sm); }
  .action-group form { width: 100%; display: flex; }
}

/* ============================================================
   Toggle Section
   ============================================================ */
.toggle-section { margin-bottom: 12px; }
.toggle-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--c-white);
  border-radius: var(--br-md); cursor: pointer;
  font-size: var(--fs-base); font-weight: 500;
  user-select: none; box-shadow: var(--shadow-sm);
}
.toggle-header:active { background: #f7f8fa; }
.toggle-body {
  display: none; padding: 16px; background: var(--c-white);
  border-radius: 0 0 var(--br-md) var(--br-md);
  margin-top: -4px; box-shadow: var(--shadow-sm);
}
.toggle-section.open .toggle-body { display: block; }
.toggle-section.open .toggle-header { border-radius: var(--br-md) var(--br-md) 0 0; }

/* ============================================================
   Settings Grid
   ============================================================ */
.settings-grid { display: flex; flex-direction: column; gap: 12px; }

/* ============================================================
   Info Row
   ============================================================ */
.info-row {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 10px 0; border-bottom: .5px solid var(--c-gray-100);
  font-size: var(--fs-sm);
}
.info-row:last-child { border-bottom: none; }
.info-row .info-label { color: var(--c-text-soft); flex-shrink: 0; }
.info-row .info-value { font-family: "SF Mono", "Consolas", monospace; font-size: var(--fs-sm); min-width: 0; word-break: break-all; text-align: right; }

/* ============================================================
   WeChat Warning
   ============================================================ */
.wechat-warn {
  background: var(--c-warning-light); border-bottom: 1px solid var(--c-warning-border);
  text-align: center; padding: 8px 16px;
  font-size: var(--fs-sm); color: #92400e; font-weight: 500;
}

/* ============================================================
   Auth Page
   ============================================================ */
.auth-page {
  min-height: 100vh; min-height: 100dvh;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.auth-layout .main { padding: 0; }
.auth-layout .main-inner { max-width: none; margin: 0; width: 100%; }
.auth-card {
  background: var(--c-white); border-radius: 20px;
  padding: 36px 28px; width: 100%; max-width: 440px;
  box-shadow: 0 4px 24px rgba(0,0,0,.06);
  animation: authFadeIn .4s cubic-bezier(.22,.61,.36,1);
}
@keyframes authFadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.auth-card h1 {
  font-size: 1.3rem; font-weight: 700; margin-bottom: 2px;
  text-align: center; letter-spacing: -.3px;
}
.auth-card .auth-subtitle {
  font-size: var(--fs-sm); color: var(--c-text-soft);
  margin-bottom: 24px; text-align: center;
}

/* Auth Split Layout */
.auth-split { display: flex; flex-direction: row; max-width: 760px; padding: 0; overflow: hidden; }
.auth-brand {
  flex: 0 0 300px;
  background: linear-gradient(160deg, var(--c-primary-light) 0%, #e0e7ff 60%, #f0f4ff 100%);
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 48px 32px;
  text-align: center; position: relative; overflow: hidden;
}
.auth-brand::before {
  content: ''; position: absolute; width: 200px; height: 200px;
  border-radius: 50%; background: rgba(37,99,235,.06);
  top: -60px; right: -40px; pointer-events: none;
}
.auth-brand::after {
  content: ''; position: absolute; width: 120px; height: 120px;
  border-radius: 50%; background: rgba(124,58,237,.05);
  bottom: -30px; left: -20px; pointer-events: none;
}
.auth-brand .auth-logo { margin-bottom: 20px; position: relative; z-index: 1; }
.auth-brand .auth-logo img {
  width: 72px; height: 72px; border-radius: 18px;
  box-shadow: 0 8px 24px rgba(37,99,235,.18);
}
.auth-brand h1 { font-size: 1.2rem; font-weight: 700; margin-bottom: 4px; position: relative; z-index: 1; }
.auth-brand .auth-subtitle { font-size: var(--fs-sm); color: var(--c-text-soft); margin: 0; position: relative; z-index: 1; }
.auth-form {
  flex: 1; padding: 40px 36px; display: flex;
  flex-direction: column; justify-content: center; min-width: 0;
}
.auth-form .form-group { margin-bottom: 16px; }
.auth-form .btn-block { margin-top: 4px; }

@media (max-width: 640px) {
  .auth-page { padding: 24px 16px; min-height: 100vh; min-height: 100dvh; background: #f5f5f7; align-items: center; justify-content: center; }
  .auth-card { max-width: 420px; padding: 32px 24px; overflow: visible; background: #fff; border-radius: 16px; box-shadow: 0 2px 16px rgba(0,0,0,0.06); }
  .auth-card .auth-logo { margin-bottom: 14px; }
  .auth-card .auth-logo img { width: 56px; height: 56px; border-radius: 14px; }
  .auth-card h1 { font-size: 1.3rem; font-weight: 600; color: #1a1a1a; margin-bottom: 4px; }
  .auth-card .auth-subtitle { font-size: var(--fs-sm); color: #999; margin-bottom: 24px; }
  .auth-card .form-group { margin-bottom: 16px; }
  .auth-card .form-label { font-size: var(--fs-sm); margin-bottom: 6px; color: #333; font-weight: 500; }
  .auth-card .form-input {
    padding: 12px 16px; font-size: var(--fs-base); border-radius: var(--br-md);
    background: #f5f5f5; border: 1px solid transparent; color: #1a1a1a;
  }
  .auth-card .form-input::placeholder { color: #bbb; }
  .auth-card .form-input:focus { background: #fff; border-color: var(--c-primary); box-shadow: none; }
  .auth-card .btn-primary { padding: 13px 0; font-size: var(--fs-md); border-radius: var(--br-md); margin-top: 8px; background: var(--c-primary); border: none; font-weight: 500; }
  .auth-card .auth-extra { margin-top: 20px; font-size: var(--fs-sm); flex-wrap: wrap; }
  .auth-card .auth-extra a { color: var(--c-primary); }
  .auth-split { flex-direction: column; max-width: 100%; }
  .auth-brand { padding: 64px 28px 28px; background: #fff; text-align: center; position: relative; overflow: visible; }
  .auth-brand::before, .auth-brand::after { display: none; }
  .auth-dot { display: none; }
  .auth-brand .auth-logo { margin-bottom: 14px; }
  .auth-brand .auth-logo img { width: 64px; height: 64px; border-radius: 14px; box-shadow: none; image-rendering: -webkit-optimize-contrast; }
  .auth-brand h1 { font-size: 1.3rem; font-weight: 600; color: #1a1a1a; margin-bottom: 4px; }
  .auth-brand .auth-subtitle { font-size: var(--fs-sm); color: #999; margin: 0; }
  .auth-form { padding: 0 28px 36px; }
  .auth-form .form-group { margin-bottom: 16px; }
  .auth-form .form-label { font-size: var(--fs-sm); margin-bottom: 6px; color: #333; font-weight: 500; }
  .auth-form .form-input {
    padding: 12px 16px; font-size: var(--fs-base); border-radius: var(--br-md);
    background: #f5f5f5; border: 1px solid transparent; color: #1a1a1a;
  }
  .auth-form .form-input::placeholder { color: #bbb; }
  .auth-form .form-input:focus { background: #fff; border-color: var(--c-primary); box-shadow: none; }
  .auth-form .btn-primary { padding: 13px 0; font-size: var(--fs-md); border-radius: var(--br-md); margin-top: 8px; background: var(--c-primary); border: none; font-weight: 500; }
  .auth-extra { margin-top: 20px; font-size: var(--fs-sm); }
  .auth-extra a { color: var(--c-primary); }
}
.auth-tip {
  margin-top: 16px; padding: 10px 14px;
  background: var(--c-warning-light); border-radius: var(--br-md);
  font-size: var(--fs-sm); color: #92400e; text-align: center;
}

/* Password field */
.password-field { position: relative; }
.password-field .form-input { padding-right: 44px; }
.password-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: none; border: none; padding: 8px; cursor: pointer;
  color: var(--c-gray-400); display: flex;
  align-items: center; justify-content: center;
  border-radius: var(--br-md); transition: color .15s;
  -webkit-tap-highlight-color: transparent;
}
.password-toggle:hover { color: var(--c-gray-500); }
.password-toggle:active { color: var(--c-gray-700); background: var(--c-gray-100); }

/* Button loading */
.btn-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn-loading::after {
  content: ''; position: absolute; inset: 0; margin: auto;
  width: 18px; height: 18px; border: 2px solid transparent;
  border-top-color: currentColor; border-radius: 50%;
  animation: btnSpin .6s linear infinite;
}
.btn-primary.btn-loading::after { border-top-color: #fff; }
@keyframes btnSpin { to { transform: rotate(360deg); } }

.auth-extra {
  margin-top: 20px; text-align: center; font-size: var(--fs-sm);
  color: #86868b; display: flex; align-items: center; justify-content: center; gap: 8px;
}
.auth-extra a { color: var(--c-primary); font-weight: 500; }
.auth-extra a:hover { text-decoration: underline; }

/* ============================================================
   Error Page
   ============================================================ */
.error-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--c-bg);
}
.error-card {
  text-align: center;
  background: var(--c-white);
  border-radius: 20px;
  padding: 40px 28px;
  max-width: 360px;
  width: 100%;
  box-shadow: 0 4px 24px rgba(0,0,0,.06);
}
.error-code {
  font-size: 3.5rem;
  font-weight: 800;
  color: #e5e7eb;
  line-height: 1;
  margin-bottom: 8px;
  letter-spacing: -1px;
}
.error-card h2 { font-size: 1.1rem; font-weight: 600; margin-bottom: 8px; }
.error-card p { color: var(--c-text-soft); margin-bottom: 20px; font-size: .88rem; }

/* ============================================================
   Toast
   ============================================================ */
.toast {
  position: fixed;
  bottom: calc(24px + var(--safe-bottom));
  left: 50%; transform: translateX(-50%) translateY(60px);
  background: rgba(30,30,40,.92);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  color: #fff; padding: 10px 22px; border-radius: 20px;
  font-size: var(--fs-sm); font-weight: 500;
  z-index: 9999; opacity: 0;
  transition: all .25s cubic-bezier(.4,0,.2,1);
  pointer-events: none; white-space: nowrap; letter-spacing: .1px;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Flash Toast */
.flash-toast-overlay {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  z-index: 10000; display: flex; flex-direction: column; align-items: center;
  gap: 8px; pointer-events: none; max-width: calc(100vw - 32px);
}
.flash-toast-item {
  max-width: 480px; min-width: 200px;
  padding: 10px 14px 10px 16px; border-radius: 10px;
  font-size: var(--fs-sm); line-height: 1.4; color: #1e293b;
  background: #fff; box-shadow: 0 8px 32px rgba(0,0,0,.12), 0 2px 8px rgba(0,0,0,.08);
  pointer-events: auto;
  animation: flashToastIn .3s cubic-bezier(.22,.61,.36,1);
  word-break: break-word; display: flex; align-items: center; gap: 0;
  border-left: 3px solid transparent; cursor: default;
}
.flash-toast-icon { flex-shrink: 0; display: flex; align-items: center; justify-content: center; width: 18px; height: 18px; margin-right: 9px; }
.flash-toast-icon svg { display: block; width: 18px; height: 18px; }
.flash-toast-text { flex: 1; min-width: 0; text-align: left; }
.flash-toast-close {
  flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; margin-left: 8px;
  border-radius: var(--br-sm); cursor: pointer;
  color: #94a3b8; transition: color .15s, background .15s;
  background: transparent; border: none; padding: 0;
}
.flash-toast-close:hover { color: #64748b; background: #f1f5f9; }
.flash-toast-close svg { width: 14px; height: 14px; display: block; }
.flash-toast-overlay.flash-toast-out .flash-toast-item { animation: flashToastOut .25s ease forwards; }
@keyframes flashToastIn {
  from { opacity: 0; transform: translateY(-12px) scale(.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes flashToastOut {
  to { opacity: 0; transform: translateY(-8px) scale(.96); }
}
.flash-toast-success { border-left-color: var(--c-success); }
.flash-toast-success .flash-toast-icon { color: #059669; }
.flash-toast-error   { border-left-color: var(--c-danger); }
.flash-toast-error   .flash-toast-icon { color: var(--c-danger); }
.flash-toast-warning { border-left-color: var(--c-warning); }
.flash-toast-warning .flash-toast-icon { color: var(--c-warning); }
.flash-toast-info    { border-left-color: var(--c-primary); }
.flash-toast-info    .flash-toast-icon { color: var(--c-primary); }

@media (max-width: 640px) {
  .flash-toast-overlay { top: 12px; max-width: calc(100vw - 24px); }
  .flash-toast-item { max-width: none; width: 100%; padding: 9px 12px 9px 14px; font-size: var(--fs-sm); }
}

/* ============================================================
   Copy Row
   ============================================================ */
.copy-row { display: flex; align-items: center; gap: 6px; }
.copy-row code {
  font-family: "SF Mono", "Consolas", "Monaco", monospace;
  font-size: var(--fs-xs); background: #f7f8fa;
  padding: 2px 6px; border-radius: var(--br-sm);
  max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.copy-btn {
  padding: 4px 8px; font-size: var(--fs-xs);
  background: var(--c-primary-light); color: var(--c-primary);
  border: 1px solid var(--c-primary-border);
  border-radius: var(--br-sm); cursor: pointer; white-space: nowrap;
}
.copy-btn:active { background: #dbeafe; }

/* ============================================================
   Quick Links
   ============================================================ */
.quick-links { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
.quick-link {
  display: flex; align-items: center; gap: 10px;
  padding: 14px; background: var(--c-white);
  border-radius: var(--br-md); font-size: var(--fs-sm);
  color: var(--c-text); text-decoration: none;
  box-shadow: var(--shadow-sm); transition: transform .15s;
}
.quick-link:active { transform: scale(.97); }

@media (max-width: 480px) { .quick-links { grid-template-columns: 1fr; } }

/* ============================================================
   Responsive Global
   ============================================================ */
@media (max-width: 640px) {
  html { font-size: 15px; }
  .main { padding: 10px 12px; }
  .auth-layout .main { padding: 0; }
  .form-row { grid-template-columns: 1fr; }
  .header-nav-link { font-size: var(--fs-sm); padding: 4px 10px; }
}

@media (max-width: 480px) {
  html { font-size: 14px; }
  .main { padding: 8px 10px; }
  .auth-layout .main { padding: 0; }
  .card-header { padding: 12px 14px; }
  .card-body { padding: 12px; }
  .stats-grid { gap: 8px; }
  .stat-card { padding: 14px 10px; }
  .stat-value { font-size: 1.4rem; }
  .stat-label { font-size: var(--fs-xs); }
  .btn-sm { font-size: var(--fs-xs); padding: 4px 12px; }
  thead th, tbody td { padding: 8px 10px; font-size: var(--fs-sm); }
  .toggle-header { padding: 10px 14px; font-size: var(--fs-sm); }
  .toggle-body { padding: 12px; }
  .error-code { font-size: 3rem; }
  .form-input, .form-select, .form-textarea { padding: 9px 12px; font-size: var(--fs-sm); }
}

/* ============================================================
   Scrollbar
   ============================================================ */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d0d0d8; border-radius: 2px; }