/* ==========================================================================
   悦享生活 · 个人生活门户
   设计系统底座：令牌 → 布局 → 组件
   主色提取自 joife logo 渐变蓝 (#60A5FA → #1D4ED8)
   ========================================================================== */

/* ---------- 1. 设计令牌 ---------- */
:root {
  /* 品牌蓝阶 */
  --blue-50:  #eff6ff;
  --blue-100: #dbeafe;
  --blue-200: #bfdbfe;
  --blue-300: #93c5fd;
  --blue-400: #60a5fa;
  --blue-500: #3b82f6;
  --blue-600: #2563eb;
  --blue-700: #1d4ed8;
  --blue-800: #1e40af;
  --blue-900: #1e3a8a;

  /* 语义色 */
  --amber-50:  #fffbeb;
  --amber-500: #f59e0b;
  --amber-600: #d97706;
  --green-50:  #ecfdf5;
  --green-500: #10b981;
  --green-600: #059669;
  --rose-50:   #fff1f2;
  --rose-500:  #f43f5e;
  --rose-600:  #e11d48;
  --violet-500:#8b5cf6;
  --cyan-500:  #06b6d4;

  /* 中性色 */
  --ink:       #0f172a;
  --ink-soft:  #334155;
  --ink-mute:  #64748b;
  --ink-faint: #94a3b8;
  --line:      #e2e8f0;
  --line-soft: #f1f5f9;
  --bg:        #f5f7fb;
  --card:      #ffffff;

  /* 间距 (4px 基数) */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px; --sp-12: 48px;

  /* 圆角 */
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 20px; --r-full: 999px;

  /* 阴影 */
  --sh-xs: 0 1px 2px rgba(15,23,42,.05);
  --sh-sm: 0 2px 8px rgba(15,23,42,.06);
  --sh-md: 0 6px 20px rgba(37,99,235,.08);
  --sh-lg: 0 16px 40px rgba(37,99,235,.14);

  /* 动效 */
  --t-fast: 150ms cubic-bezier(.4,0,.2,1);
  --t-base: 250ms cubic-bezier(.4,0,.2,1);

  /* 布局 */
  --sidebar-w: 236px;
  --maxw: 1180px;
  --font: "PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont,
          "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ---------- 2. 基础重置 ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.7;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, p, figure { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
button { font-family: inherit; }
a { color: var(--blue-600); text-decoration: none; }
img { display: block; max-width: 100%; }

:focus-visible {
  outline: 2px solid var(--blue-500);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* 屏幕阅读器专用 */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- 3. 应用骨架 ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--card);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 30;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-5) var(--sp-5);
  border-bottom: 1px solid var(--line-soft);
}
.brand img { height: 34px; width: auto; }
.brand-sub {
  font-size: 11px;
  color: var(--ink-faint);
  letter-spacing: .14em;
  text-transform: uppercase;
  margin-top: 2px;
}

.nav { padding: var(--sp-4) var(--sp-3); overflow-y: auto; flex: 1; }
.nav-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-faint);
  letter-spacing: .1em;
  padding: var(--sp-3) var(--sp-3) var(--sp-2);
  text-transform: uppercase;
}
.nav a {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 10px var(--sp-3);
  border-radius: var(--r-md);
  color: var(--ink-soft);
  font-weight: 500;
  transition: background var(--t-fast), color var(--t-fast);
}
.nav a:hover { background: var(--blue-50); color: var(--blue-700); }
.nav a.active { background: var(--blue-600); color: #fff; box-shadow: var(--sh-sm); }
.nav a .ico { font-size: 17px; width: 22px; text-align: center; flex-shrink: 0; }
.nav a .badge {
  margin-left: auto;
  background: var(--blue-100);
  color: var(--blue-700);
  font-size: 11px;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: var(--r-full);
}
.nav a.active .badge { background: rgba(255,255,255,.25); color: #fff; }

.sidebar-foot {
  padding: var(--sp-4);
  border-top: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.sidebar-foot img { width: 34px; height: 34px; border-radius: 10px; }
.sidebar-foot .who { font-size: 13px; font-weight: 600; line-height: 1.3; }
.sidebar-foot .who small { display: block; color: var(--ink-faint); font-weight: 400; font-size: 11.5px; }

/* 主区域 */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255,255,255,.85);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
  padding: var(--sp-4) var(--sp-8);
  display: flex;
  align-items: center;
  gap: var(--sp-4);
}
.topbar h1 { font-size: 19px; font-weight: 700; letter-spacing: .01em; }
.topbar .crumb { font-size: 12.5px; color: var(--ink-faint); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: var(--sp-2); }

.view {
  padding: var(--sp-8);
  max-width: var(--maxw);
  width: 100%;
  flex: 1;
}

/* 站点页脚（含备案号） */
.site-foot {
  max-width: var(--maxw);
  width: 100%;
  margin-top: var(--sp-8);
  padding: var(--sp-6) var(--sp-8);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  flex-wrap: wrap;
  border-top: 1px solid var(--line);
  color: var(--ink-faint);
  font-size: 13px;
}
.foot-brand { font-weight: 600; color: var(--ink-mute); }
.foot-beian {
  color: var(--ink-mute);
  border: 1px solid var(--line);
  padding: 6px 12px;
  border-radius: var(--r-md);
  transition: all var(--t-fast);
}
.foot-beian:hover { color: var(--blue-700); border-color: var(--blue-300); background: var(--blue-50); }

/* 移动端底部导航 */
.tabbar { display: none; }

/* ---------- 4. 组件：按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast),
              color var(--t-fast), transform var(--t-fast);
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary { background: var(--blue-600); color: #fff; box-shadow: var(--sh-sm); }
.btn-primary:hover:not(:disabled) { background: var(--blue-700); box-shadow: var(--sh-md); }

.btn-ghost { background: var(--card); border-color: var(--line); color: var(--ink-soft); }
.btn-ghost:hover:not(:disabled) { background: var(--blue-50); border-color: var(--blue-200); color: var(--blue-700); }

.btn-danger { background: var(--card); border-color: #fecdd3; color: var(--rose-600); }
.btn-danger:hover:not(:disabled) { background: var(--rose-50); border-color: var(--rose-500); }

.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: var(--r-sm); }
.btn-icon { padding: 8px; width: 34px; height: 34px; }

/* ---------- 5. 组件：卡片 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
}
.card-pad { padding: var(--sp-6); }
.card-head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-5) var(--sp-6);
  border-bottom: 1px solid var(--line-soft);
}
.card-head h3 { font-size: 15.5px; font-weight: 700; }
.card-head .more { margin-left: auto; font-size: 13px; color: var(--blue-600); font-weight: 600; }
.card-body { padding: var(--sp-6); }

/* ---------- 6. 组件：表单 ---------- */
.field { margin-bottom: var(--sp-4); }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
.input, .textarea, .select {
  width: 100%;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  font-size: 14.5px;
  font-family: inherit;
  color: var(--ink);
  background: var(--card);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px rgba(59,130,246,.16);
}
.textarea { resize: vertical; min-height: 88px; line-height: 1.65; }
.select { cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8.5 1.5 4h9z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center; padding-right: 34px;
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }

/* ---------- 7. 组件：徽标 / 标签 ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-size: 12px;
  font-weight: 600;
  background: var(--blue-50);
  color: var(--blue-700);
}
.chip-amber  { background: var(--amber-50);  color: var(--amber-600); }
.chip-green  { background: var(--green-50);  color: var(--green-600); }
.chip-rose   { background: var(--rose-50);   color: var(--rose-600); }
.chip-violet { background: #f5f3ff;           color: #6d28d9; }
.chip-grey   { background: var(--line-soft);  color: var(--ink-mute); }

/* ---------- 8. 组件：空状态 ---------- */
.empty {
  text-align: center;
  padding: var(--sp-12) var(--sp-6);
  color: var(--ink-mute);
}
.empty .emo { font-size: 40px; margin-bottom: var(--sp-3); opacity: .85; }
.empty p { font-size: 14px; }
.empty .btn { margin-top: var(--sp-5); }

/* ---------- 9. 组件：列表行 ---------- */
.row {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-6);
  border-bottom: 1px solid var(--line-soft);
  transition: background var(--t-fast);
}
.row:last-child { border-bottom: 0; }
.row:hover { background: #fafbff; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; font-size: 14.5px; }
.row-meta { font-size: 12.5px; color: var(--ink-faint); margin-top: 2px; }
.row-actions { display: flex; gap: 6px; opacity: 0; transition: opacity var(--t-fast); }
.row:hover .row-actions, .row:focus-within .row-actions { opacity: 1; }

/* ---------- 10. 组件：吐司 ---------- */
.toast-host {
  position: fixed;
  bottom: var(--sp-8);
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  align-items: center;
  pointer-events: none;
}
.toast {
  background: var(--ink);
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--r-full);
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--sh-lg);
  animation: toast-in .25s cubic-bezier(.2,.9,.3,1.2);
}
.toast.ok { background: var(--green-600); }
.toast.err { background: var(--rose-600); }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.94); } }

/* ---------- 11. 工具类 ---------- */
.muted { color: var(--ink-mute); }
.faint { color: var(--ink-faint); }
.small { font-size: 12.5px; }
.stack   { display: flex; flex-direction: column; gap: var(--sp-6); }
.stack-sm{ display: flex; flex-direction: column; gap: var(--sp-3); }
.row-flex { display: flex; align-items: center; gap: var(--sp-3); }
.grow { flex: 1; }
.right { margin-left: auto; }
.tnum { font-variant-numeric: tabular-nums; }

/* ---------- 12. 响应式 ---------- */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .topbar { padding: var(--sp-4); }
  .view { padding: var(--sp-4); }
  .site-foot {
    padding: var(--sp-5) var(--sp-4) calc(76px + env(safe-area-inset-bottom));
    margin-top: var(--sp-4);
  }

  .tabbar {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 40;
    background: rgba(255,255,255,.94);
    backdrop-filter: saturate(180%) blur(14px);
    border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .tabbar a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 2px;
    border-radius: var(--r-md);
    color: var(--ink-mute);
    font-size: 10.5px;
    font-weight: 600;
  }
  .tabbar a .ico { font-size: 19px; line-height: 1; }
  .tabbar a.active { color: var(--blue-600); background: var(--blue-50); }
}

@media (max-width: 560px) {
  .field-row { grid-template-columns: 1fr; }
  .row-actions { opacity: 1; }
  .row { padding: var(--sp-4); }
  .card-body, .card-pad { padding: var(--sp-4); }
}

/* ---------- 13. 动效偏好 ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* ---------- 14. 打印 ---------- */
@media print {
  .sidebar, .topbar, .tabbar, .row-actions { display: none !important; }
  .view { padding: 0; max-width: none; }
  .card { box-shadow: none; break-inside: avoid; }
}