/* ==========================================================================
   oid-server 设计系统
   --------------------------------------------------------------------------
   规范：
     间距  4 / 8 / 12 / 16 / 24 / 32   （8px 基准）
     圆角  8 / 12 / 16 / 20 / 999
     字号  11 / 12 / 13 / 14 / 16 / 20 / 24
     触控  所有可点元素 ≥ 44px
     对比  正文 ≥ 4.5:1（WCAG AA）
   ========================================================================== */

/* ---------- 设计令牌 ---------- */
:root {
  /* 品牌 */
  --c-primary:      #2563EB;
  --c-primary-dark: #1D4ED8;
  --c-primary-50:   #EFF6FF;
  --c-primary-100:  #DBEAFE;

  /* 语义 */
  --c-success:      #10B981;
  --c-success-50:   #ECFDF5;
  --c-warn:         #F59E0B;
  --c-warn-50:      #FFFBEB;
  --c-danger:       #EF4444;
  --c-danger-50:    #FEF2F2;
  --c-info:         #0EA5E9;

  /* 中性 */
  --c-bg:           #F8FAFC;
  --c-card:         #FFFFFF;
  --c-border:       #E2E8F0;
  --c-border-soft:  #F1F5F9;

  /* 文字 */
  --c-t1:           #0F172A;
  --c-t2:           #475569;
  --c-t3:           #64748B;
  --c-t-inv:        #FFFFFF;

  /* 头部渐变 */
  --g-head: #0F172A;

  /* 间距 */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px;
  --s-4: 16px; --s-5: 24px; --s-6: 32px;

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

  /* 阴影 */
  --sh-1: 0 1px 2px rgba(15, 23, 42, .04);
  --sh-2: 0 4px 12px rgba(15, 23, 42, .08);
  --sh-3: 0 8px 20px rgba(15, 23, 42, .12);

  /* 动效 */
  --ease: cubic-bezier(.4, 0, .2, 1);
}

/* ---------- 重置 ---------- */
*, *::before, *::after {
  margin: 0; padding: 0; box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--c-t1);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior-y: none;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { border: none; background: none; cursor: pointer; }
img { display: block; max-width: 100%; }
a { color: var(--c-primary); text-decoration: none; }

/* ---------- 排版 ---------- */
.t-xs   { font-size: 11px; }
.t-sm   { font-size: 12px; }
.t-base { font-size: 14px; }
.t-md   { font-size: 16px; }
.t-lg   { font-size: 20px; }
.t-xl   { font-size: 24px; }
.t-bold { font-weight: 600; }
.t-1    { color: var(--c-t1); }
.t-2    { color: var(--c-t2); }
.t-3    { color: var(--c-t3); }
.t-num  { font-variant-numeric: tabular-nums; }

/* ---------- 布局 ---------- */
.row     { display: flex; align-items: center; }
.row-top { display: flex; align-items: flex-start; }
.col     { display: flex; flex-direction: column; }
.gap-1 { gap: var(--s-1); } .gap-2 { gap: var(--s-2); }
.gap-3 { gap: var(--s-3); } .gap-4 { gap: var(--s-4); }
.flex-1 { flex: 1; min-width: 0; }
.center { display: flex; align-items: center; justify-content: center; }
.ellipsis {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: var(--s-4);
}
.card-flat {
  background: var(--c-card);
  border-radius: var(--r-lg);
  padding: var(--s-4);
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: 44px;
  padding: 0 var(--s-4);
  border-radius: var(--r-md);
  font-size: 15px;
  font-weight: 600;
  transition: all .16s var(--ease);
  user-select: none;
}
.btn:active { transform: scale(.975); }
.btn[disabled] { opacity: .5; pointer-events: none; }

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

.btn-success { background: var(--c-success); color: #fff; }
.btn-danger  { background: var(--c-danger);  color: #fff; }

.btn-ghost {
  background: var(--c-primary-50);
  color: var(--c-primary);
}
.btn-ghost:hover { background: var(--c-primary-100); }

.btn-outline {
  background: var(--c-card);
  border: 1px solid var(--c-border);
  color: var(--c-t2);
}
.btn-outline:hover { border-color: var(--c-primary); color: var(--c-primary); }

.btn-block { width: 100%; }
.btn-sm { min-height: 36px; font-size: 13px; padding: 0 var(--s-3); }
.btn-lg { min-height: 50px; font-size: 16px; }

/* ---------- 徽章 ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}
.badge-primary { background: var(--c-primary-50); color: var(--c-primary); }
.badge-success { background: var(--c-success-50); color: #047857; }
.badge-warn    { background: var(--c-warn-50);    color: #B45309; }
.badge-danger  { background: var(--c-danger-50);  color: #B91C1C; }
.badge-gray    { background: #F1F5F9; color: var(--c-t2); }

/* ---------- 输入框 ---------- */
.field {
  width: 100%;
  min-height: 46px;
  padding: 0 var(--s-4);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  background: var(--c-card);
  font-size: 15px;
  outline: none;
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
}
.field::placeholder { color: var(--c-t3); }
.field:focus {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px var(--c-primary-50);
}

/* ---------- 进度条 ---------- */
.bar {
  height: 6px;
  border-radius: var(--r-full);
  background: #E2E8F0;
  overflow: hidden;
}
.bar > i {
  display: block;
  height: 100%;
  border-radius: var(--r-full);
  background: var(--c-primary);
  transition: width .35s var(--ease);
}
.bar.is-warn   > i { background: var(--c-warn); }
.bar.is-danger > i { background: var(--c-danger); }
.bar.is-ok     > i { background: var(--c-success); }

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--s-5);
  background: rgba(15, 23, 42, .66);
}
.modal.show { display: flex; }
.modal-box {
  width: 100%;
  max-width: 340px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--c-card);
  border-radius: var(--r-xl);
  padding: var(--s-5);
  box-shadow: var(--sh-3);
  animation: modalIn .2s var(--ease);
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(.94) translateY(8px); }
  to   { opacity: 1; transform: scale(1)   translateY(0); }
}

/* ---------- 空状态 ---------- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-3);
  padding: 64px var(--s-5);
  text-align: center;
  color: var(--c-t3);
  font-size: 13px;
  line-height: 1.8;
}
.empty-icon {
  width: 56px; height: 56px;
  border-radius: var(--r-full);
  background: #F1F5F9;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  opacity: .7;
}

/* ---------- 加载骨架 ---------- */
.skeleton {
  background: #E2E8F0;
  border-radius: var(--r-sm);
}

/* ---------- 轻提示 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  padding: 11px 22px;
  border-radius: var(--r-full);
  background: rgba(15, 23, 42, .92);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  z-index: 2000;
  box-shadow: var(--sh-2);
  animation: toastIn .22s var(--ease);
  pointer-events: none;
  max-width: 86vw;
  text-align: center;
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- 分割线 ---------- */
.divider { height: 1px; background: var(--c-border-soft); }

/* ==========================================================================
   UI 规范补充：动效降级 + 焦点可见性 + 键盘导航
   ========================================================================== */

/* 焦点可见性（键盘导航） */
:focus-visible {
  outline: 2px solid var(--c-primary);
  outline-offset: 2px;
  border-radius: 4px;
}
.btn:focus-visible, .field:focus-visible, .nav-i:focus-visible {
  outline: 2px solid var(--c-primary);
  outline-offset: 2px;
}

/* 动效降级：用户偏好减少动效时全部静止 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .skeleton {
    background: #F1F5F9 !important;
    animation: none !important;
  }
  .modal-box { animation: none !important; }
  .toast { animation: none !important; }
}

/* 骨架屏加载态保持克制（真实加载，非占位装饰） */
.skeleton { background: #E2E8F0; animation: none; }

/* 弹窗动画用 transform/opacity（已合规），时长控制在 200ms */
.modal-box { animation-duration: .18s; }
