/* ============================================================
   需求收集进度 — 设计系统(Flat Design)
   主色 #0D9488 teal / 强调橙 #EA580C / 亮暗双主题
   ============================================================ */

/* ---------- 语义 Token ---------- */
:root {
  --bg: #F0FDFA;
  --surface: #FFFFFF;
  --surface-2: #F5FAF9;
  --text: #134E4A;
  --text-2: #475569;
  --text-3: #7C8A8A;
  --border: #D9F0EB;
  --border-strong: #B7E3DA;

  --primary: #0D9488;
  --primary-strong: #0F766E;
  --primary-soft: #CCFBF1;
  --on-primary: #FFFFFF;

  --accent: #EA580C;
  --accent-soft: #FFEDD5;
  --on-accent: #FFFFFF;

  --blue: #2563EB;
  --blue-soft: #DBEAFE;
  --danger: #DC2626;
  --danger-soft: #FEE2E2;
  --gray: #8FA3A1;
  --gray-soft: #EDF2F1;

  --ring: rgba(13, 148, 136, 0.45);
  --shadow-sm: 0 1px 2px rgba(19, 78, 74, 0.05);
  --shadow-md: 0 4px 16px rgba(19, 78, 74, 0.08);

  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  --header-h: 56px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #061F1D;
    --surface: #0B2F2C;
    --surface-2: #0F3733;
    --text: #E8FAF6;
    --text-2: #A9BCB9;
    --text-3: #7B948F;
    --border: #1B4742;
    --border-strong: #2A5B55;

    --primary: #2DD4BF;
    --primary-strong: #5EEAD4;
    --primary-soft: #11554E;
    --on-primary: #04211E;

    --accent: #FB923C;
    --accent-soft: #4A2A12;
    --on-accent: #1A0F06;

    --blue: #60A5FA;
    --blue-soft: #1E3A5F;
    --danger: #F87171;
    --danger-soft: #4A1D1D;
    --gray: #7B948F;
    --gray-soft: #16312E;

    --ring: rgba(45, 212, 191, 0.5);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.35);
  }
}

/* ---------- 基础 ---------- */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont,
    "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: contain;
  touch-action: manipulation;
  min-height: 100dvh;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, p { margin: 0; }

#app { min-height: 100dvh; }

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 6px;
}

::selection { background: var(--primary-soft); }

/* ---------- 通用组件 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 15px;
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.05s ease;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }

.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-strong); }

.btn-soft { background: var(--primary-soft); color: var(--primary-strong); }
.btn-soft:hover { background: var(--border-strong); }

.btn-accent { background: var(--accent); color: var(--on-accent); }
.btn-accent:hover { filter: brightness(1.06); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.06); }

.btn-ghost { color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); }

.btn-block { width: 100%; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  color: var(--text-2);
  transition: background-color 0.15s ease, color 0.15s ease;
  flex: none;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.danger { color: var(--danger); }
.icon-btn.danger:hover { background: var(--danger-soft); }

.icon { width: 22px; height: 22px; display: block; }

.skip-link {
  position: fixed;
  top: calc(8px + var(--safe-top));
  left: 8px;
  z-index: 1000;
  background: var(--primary);
  color: var(--on-primary);
  padding: 8px 14px;
  border-radius: 8px;
  font-weight: 600;
  transform: translateY(-150%);
  transition: transform 0.15s ease;
}
.skip-link:focus { transform: translateY(0); }

/* ---------- 头部 ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 8px;
  height: calc(var(--header-h) + var(--safe-top));
  padding: var(--safe-top) 16px 0;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid transparent;
}
.app-header.scrolled { border-bottom-color: var(--border); }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-right: auto;
  min-width: 0;
}
.brand .logo {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--primary);
  color: var(--on-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.brand .logo .icon { width: 20px; height: 20px; }
.brand h1 { font-size: 18px; font-weight: 700; letter-spacing: 0.2px; white-space: nowrap; }

.header-title {
  font-size: 17px;
  font-weight: 700;
  margin-right: auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.header-actions { display: flex; align-items: center; gap: 2px; flex: none; }

/* ---------- 内容区 ---------- */
.content {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 16px calc(32px + var(--safe-bottom));
}

.page-sub {
  color: var(--text-2);
  font-size: 14px;
  margin: 2px 4px 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

/* ---------- 任务卡片(首页) ---------- */
.task-list { display: flex; flex-direction: column; gap: 12px; }

.task-card {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 16px;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  text-align: left;
  width: 100%;
}
.task-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.task-card:active { transform: scale(0.995); }

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

.task-top { display: flex; align-items: flex-start; gap: 8px; }
.task-name {
  flex: 1;
  min-width: 0;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.task-meta {
  margin-top: 4px;
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.5;
}
.task-progress { margin-top: 12px; }

.progress {
  height: 8px;
  border-radius: 999px;
  background: var(--gray-soft);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--primary);
  transition: width 0.25s ease;
}
.progress-fill.done { background: var(--primary-strong); }

/* ---------- 空状态 ---------- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 64px 24px;
  gap: 8px;
}
.empty .empty-icon {
  width: 64px;
  height: 64px;
  color: var(--primary);
  opacity: 0.85;
  margin-bottom: 8px;
}
.empty h2 { font-size: 18px; font-weight: 700; }
.empty p { color: var(--text-2); font-size: 14px; max-width: 280px; }
.empty .btn { margin-top: 16px; }

/* ---------- 详情页:汇总 ---------- */
.summary { padding: 16px; margin-bottom: 12px; }

.summary-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 8px;
}
.summary-label .pct { font-weight: 700; color: var(--text); font-size: 14px; }

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 14px;
}
.stat {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 10px 8px;
  text-align: center;
}
.stat b { display: block; font-size: 20px; font-weight: 700; color: var(--primary-strong); }
.stat span { font-size: 12px; color: var(--text-2); }

.bulk-row { display: flex; gap: 8px; margin-bottom: 12px; }
.bulk-row .btn { flex: 1; }

/* ---------- 筛选 chips ---------- */
.chips {
  position: sticky;
  top: calc(var(--header-h) + var(--safe-top));
  z-index: 30;
  display: flex;
  gap: 8px;
  padding: 4px 0 10px;
  margin: 0 -16px 4px;
  padding-left: 16px;
  padding-right: 16px;
  background: var(--bg);
  overflow-x: auto;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.chip .count { color: var(--text-3); font-size: 12px; }
.chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
}
.chip.active .count { color: inherit; opacity: 0.8; }
.chip-toggle.active-blue { background: var(--blue-soft); border-color: var(--blue); color: var(--blue); }
.chip-toggle.active-teal { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-strong); }

/* ---------- 部门卡片 ---------- */
.dept-list { display: flex; flex-direction: column; gap: 10px; }

.dept-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  transition: border-color 0.15s ease;
}
.dept-card.complete { border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); }

.dept-top { display: flex; align-items: center; gap: 10px; }
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: none;
}
.status-dot.s-gray { background: var(--gray); }
.status-dot.s-blue { background: var(--blue); }
.status-dot.s-teal { background: var(--primary); }

.dept-name {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.pill {
  flex: none;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
}
.pill-gray { background: var(--gray-soft); color: var(--text-2); border-color: var(--border-strong); }
.pill-blue { background: var(--blue-soft); color: var(--blue); }
.pill-teal { background: var(--primary-soft); color: var(--primary-strong); }
.pill-teal.solid { background: var(--primary); color: var(--on-primary); }

.dept-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
}
.chips-group { display: flex; gap: 8px; min-width: 0; }

.stepper { display: flex; align-items: center; gap: 2px; flex: none; }
.step-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 20px;
  font-weight: 600;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease;
}
.step-btn:hover:not(:disabled) { background: var(--surface-2); }
.step-btn:disabled { opacity: 0.35; cursor: default; }
.step-val {
  min-width: 44px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  color: var(--primary-strong);
  border-radius: 10px;
}
.step-val:hover { background: var(--surface-2); }
.step-val.zero { color: var(--text-3); font-weight: 500; }

/* ---------- 安装横幅 ---------- */
.install-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--primary);
  color: var(--on-primary);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-md);
  animation: banner-in 0.25s ease;
}
@keyframes banner-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
.install-banner .banner-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.install-banner .icon { width: 20px; height: 20px; }
.banner-text { flex: 1; min-width: 0; }
.banner-text b { display: block; font-size: 14px; font-weight: 700; }
.banner-text > span:not(.banner-progress) { display: block; font-size: 12px; opacity: 0.85; }
.banner-progress { display: block; height: 3px; border-radius: 999px; background: rgba(255, 255, 255, 0.28); margin-top: 7px; overflow: hidden; }
.banner-progress-fill { display: block; height: 100%; border-radius: 999px; background: #fff; transition: width 0.2s ease; }

.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.install-banner .btn-accent { min-height: 36px; padding: 0 14px; font-size: 13px; }
.install-banner .icon-btn { color: inherit; opacity: 0.8; width: 36px; height: 36px; }
.install-banner .icon-btn:hover { background: rgba(255, 255, 255, 0.15); opacity: 1; }

/* ---------- 菜单(下拉) ---------- */
.menu-wrap { position: relative; }
.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 60;
  min-width: 168px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 6px;
  animation: menu-in 0.15s ease;
}
@keyframes menu-in {
  from { opacity: 0; transform: translateY(-4px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  text-align: left;
}
.menu button:hover { background: var(--surface-2); }
.menu button.danger { color: var(--danger); }
.menu .icon { width: 18px; height: 18px; color: var(--text-2); }
.menu button.danger .icon { color: var(--danger); }

/* ---------- Toast ---------- */
#toast-root {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(24px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
  padding: 0 16px;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 100%;
  background: var(--text);
  color: var(--bg);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 14px;
  box-shadow: var(--shadow-md);
  animation: toast-in 0.2s ease;
}
.toast .toast-msg { overflow-wrap: anywhere; }
.toast .toast-action {
  color: #fff;
  background: var(--primary);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  min-height: 36px;
  flex: none;
}
.toast .toast-action:hover { filter: brightness(1.1); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- 弹窗 ---------- */
.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(6, 31, 29, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  animation: fade-in 0.18s ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.dialog {
  width: 100%;
  max-width: 480px;
  max-height: 84dvh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding: 20px 20px calc(20px + var(--safe-bottom));
  animation: sheet-in 0.22s ease;
  box-shadow: var(--shadow-md);
}
@keyframes sheet-in {
  from { transform: translateY(40px); opacity: 0.6; }
  to { transform: translateY(0); opacity: 1; }
}

.dialog h2 { font-size: 17px; font-weight: 700; margin-bottom: 6px; }
.dialog .dialog-msg { color: var(--text-2); font-size: 14px; line-height: 1.6; }
.dialog .dialog-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}
.dialog .dialog-actions .btn { flex: 1; }

.dialog-field { margin-top: 14px; }
.dialog-field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 6px;
}
.dialog-field input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
}
.dialog-field input:focus {
  outline: 2px solid var(--ring);
  outline-offset: 0;
  border-color: var(--primary);
}
.dialog-field .hint { font-size: 12px; color: var(--text-3); margin-top: 6px; }

/* 桌面端弹窗居中 */
@media (min-width: 560px) {
  .dialog-backdrop { align-items: center; padding: 24px; }
  .dialog { border-radius: 20px; max-width: 400px; padding: 24px; }
}

/* ---------- 预缓存进度弹窗 ---------- */
.pd-track {
  height: 8px;
  border-radius: 999px;
  background: var(--gray-soft);
  overflow: hidden;
  margin-top: 14px;
}
.pd-bar {
  height: 100%;
  border-radius: 999px;
  background: var(--primary);
  transition: width 0.2s ease;
}
.pd-text { font-size: 13px; color: var(--text-2); margin-top: 8px; }

/* ---------- 安装引导步骤 ---------- */
.install-steps { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.install-step { display: flex; align-items: flex-start; gap: 10px; }
.install-step .num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  margin-top: 1px;
}
.install-step p { font-size: 14px; color: var(--text); line-height: 1.55; }
.install-step p b { font-weight: 700; }

/* ---------- 响应式(桌面) ---------- */
@media (min-width: 768px) {
  .content { padding-top: 24px; }
  .task-card { padding: 20px; }
  .summary { padding: 20px; }
  .dept-card { padding: 14px 16px; }
}

/* ---------- 动效降级 ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
