/* ============================================
   雅安中院内部协作政务办公平台 - Apple 风格
   ============================================ */

:root {
  /* Apple 系统色（Light） */
  --bg-base: #fbfbfd;
  --bg-elev: #ffffff;
  --bg-group: #f5f5f7;
  --bg-elev-2: rgba(255, 255, 255, 0.72);
  --bg-glass: rgba(255, 255, 255, 0.68);

  --fg-primary: #1d1d1f;
  --fg-secondary: #6e6e73;
  --fg-tertiary: #86868b;
  --fg-quaternary: #aeaeb2;

  --line: rgba(0, 0, 0, 0.08);
  --line-strong: rgba(0, 0, 0, 0.16);

  --blue: #0071e3;
  --blue-hover: #0077ed;
  --blue-active: #006edb;
  --green: #34c759;
  --red: #ff3b30;
  --orange: #ff9500;
  --yellow: #ffcc00;
  --indigo: #5856d6;
  --teal: #5ac8fa;

  --shadow-1: 0 1px 2px rgba(0,0,0,0.04), 0 1px 1px rgba(0,0,0,0.04);
  --shadow-2: 0 4px 14px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
  --shadow-3: 0 16px 40px rgba(0,0,0,0.10), 0 4px 12px rgba(0,0,0,0.06);
  --shadow-4: 0 32px 80px rgba(0,0,0,0.18), 0 8px 24px rgba(0,0,0,0.10);

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --r-2xl: 28px;

  /* Apple 弹簧 */
  --ease-spring: cubic-bezier(0.32, 0.72, 0.0, 1.0);
  --ease-out: cubic-bezier(0.2, 0.0, 0.0, 1.0);
  --ease-in-out: cubic-bezier(0.4, 0.0, 0.2, 1.0);

  --dur-fast: 180ms;
  --dur-base: 280ms;
  --dur-slow: 480ms;

  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
               "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--fg-primary);
  background: var(--bg-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "tnum";
  letter-spacing: -0.01em;
}

/* ========== 登录页 ========== */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, #f5f5f7 0%, #e8eaf0 100%);
  position: relative; overflow: hidden;
}
.login-wrap::before, .login-wrap::after {
  content: ""; position: absolute; border-radius: 50%; filter: blur(80px); opacity: 0.4; pointer-events: none;
  animation: floatBlob 18s ease-in-out infinite alternate;
}
.login-wrap::before { width: 480px; height: 480px; background: #c0e0ff; top: -120px; left: -120px; }
.login-wrap::after  { width: 360px; height: 360px; background: #ffd4c0; bottom: -100px; right: -80px; animation-delay: -6s; }
@keyframes floatBlob { from { transform: translate(0,0) scale(1); } to { transform: translate(40px, -30px) scale(1.1); } }

.login-box {
  position: relative; z-index: 1;
  width: 380px; padding: 40px 32px;
  background: var(--bg-glass);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255,255,255,0.6);
  border-radius: var(--r-2xl);
  box-shadow: var(--shadow-3);
  animation: boxIn 600ms var(--ease-spring) both;
}
@keyframes boxIn {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0)    scale(1.00); }
}
.login-title {
  font-family: var(--font-display);
  font-size: 22px; font-weight: 600;
  text-align: center; letter-spacing: -0.02em;
}
.login-sub {
  text-align: center; color: var(--fg-tertiary);
  font-size: 11px; letter-spacing: 0.08em; margin-top: 4px; margin-bottom: 28px;
  font-family: ui-monospace, "SF Mono", monospace;
}
.login-form .form-item { margin-bottom: 16px; }
.login-form .form-item label {
  display: block; font-size: 12px; color: var(--fg-secondary);
  margin-bottom: 6px; font-weight: 500;
}
.login-form input {
  width: 100%; padding: 11px 14px;
  background: rgba(255,255,255,0.7);
  border: 1px solid var(--line); border-radius: var(--r-md);
  font-size: 14px; color: var(--fg-primary);
  transition: all var(--dur-fast) var(--ease-out);
  outline: none; -webkit-appearance: none; appearance: none;
}
.login-form input:focus {
  background: #fff; border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(0,113,227,0.15);
}
.login-tip { font-size: 11px; color: var(--fg-tertiary); margin-top: 10px; line-height: 1.6; }

/* ========== 按钮 ========== */
.btn-primary, .btn-default, .btn-link, .btn-link.danger {
  font-family: var(--font-sans); font-size: 14px; font-weight: 500;
  border: none; outline: none; cursor: pointer; -webkit-appearance: none; appearance: none;
  transition: transform 100ms var(--ease-out), background var(--dur-fast) var(--ease-out), color var(--dur-fast);
  letter-spacing: -0.01em;
}
.btn-primary { padding: 10px 20px; background: var(--blue); color: #fff; border-radius: 980px; }
.btn-primary:hover { background: var(--blue-hover); }
.btn-primary:active { background: var(--blue-active); transform: scale(0.97); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-default { padding: 9px 18px; background: rgba(0,0,0,0.05); color: var(--fg-primary); border-radius: 980px; }
.btn-default:hover { background: rgba(0,0,0,0.08); }
.btn-default:active { transform: scale(0.97); }

.btn-link { padding: 4px 8px; background: transparent; color: var(--blue); border-radius: 6px; font-size: 13px; }
.btn-link:hover { background: rgba(0,113,227,0.08); }
.btn-link:active { transform: scale(0.96); }
.btn-link.danger { color: var(--red); }
.btn-link.danger:hover { background: rgba(255,59,48,0.08); }

/* ========== 主布局 ========== */
.layout { display: flex; flex-direction: column; height: 100vh; }
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 20px; height: 52px;
  background: var(--bg-glass);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--line);
  position: relative; z-index: 10;
  flex-shrink: 0;
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.topbar-left .logo {
  width: 28px; height: 28px; display: grid; place-items: center;
  background: linear-gradient(135deg, #1d1d1f, #434347);
  color: #fff; border-radius: 8px; font-size: 16px;
}
.topbar-left .sysname {
  font-family: var(--font-display); font-size: 15px; font-weight: 600; letter-spacing: -0.01em;
}
.topbar-right { display: flex; align-items: center; gap: 14px; }
.user-info { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--fg-secondary); }
.user-info .dept { color: var(--fg-tertiary); }
.role-tag {
  display: inline-block; padding: 2px 8px;
  background: rgba(0,113,227,0.1); color: var(--blue);
  font-size: 11px; font-weight: 500; border-radius: 980px;
}

.main { display: flex; flex: 1; min-height: 0; }
.sidebar {
  width: 220px; padding: 14px 10px;
  background: var(--bg-group);
  border-right: 1px solid var(--line);
  overflow-y: auto; flex-shrink: 0;
}
.menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--r-md);
  cursor: pointer; color: var(--fg-primary);
  font-size: 14px; font-weight: 500;
  transition: all var(--dur-fast) var(--ease-out);
  user-select: none;
}
.menu-item .icon { font-size: 18px; width: 20px; text-align: center; }
.menu-item:hover { background: rgba(0,0,0,0.05); }
.menu-item.active {
  background: #fff; box-shadow: var(--shadow-1);
  color: var(--blue);
}
.menu-item:active { transform: scale(0.98); }

.workspace {
  flex: 1; overflow-y: auto; padding: 24px 28px;
  background: var(--bg-base);
}
.page-title {
  font-family: var(--font-display);
  font-size: 28px; font-weight: 700; letter-spacing: -0.025em;
  margin: 0 0 18px 0;
}
.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.page-head .page-title { margin: 0; }

/* ========== 统计卡 ========== */
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px; margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 18px 20px;
  border-left: 4px solid var(--fg-primary);
  transition: all var(--dur-base) var(--ease-spring);
  box-shadow: var(--shadow-1);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); }
.stat-card.blue { border-left-color: var(--blue); }
.stat-card.green { border-left-color: var(--green); }
.stat-card.orange { border-left-color: var(--orange); }
.stat-card.red { border-left-color: var(--red); }
.stat-num {
  font-family: var(--font-display);
  font-size: 32px; font-weight: 700; letter-spacing: -0.03em;
  line-height: 1.1; margin-bottom: 6px;
  font-feature-settings: "tnum";
}
.stat-label { color: var(--fg-secondary); font-size: 13px; }

/* ========== 数据表 ========== */
.block { margin-top: 28px; }
.block h3, .task-view h4 {
  font-family: var(--font-display);
  font-size: 18px; font-weight: 600; letter-spacing: -0.02em;
  margin: 0 0 12px 0;
}
.t {
  width: 100%; border-collapse: collapse; background: var(--bg-elev);
  border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden;
  font-variant-numeric: tabular-nums;
}
.t thead th {
  text-align: left; font-weight: 500; color: var(--fg-secondary);
  font-size: 12px; padding: 10px 14px;
  background: var(--bg-group); border-bottom: 1px solid var(--line);
  letter-spacing: 0.02em; text-transform: uppercase;
}
.t tbody td {
  padding: 11px 14px; font-size: 13px;
  border-bottom: 1px solid var(--line); color: var(--fg-primary);
}
.t tbody tr:last-child td { border-bottom: none; }
.t tbody tr { transition: background var(--dur-fast) var(--ease-out); }
.t tbody tr:hover { background: rgba(0,0,0,0.025); }
.t a { color: var(--blue); cursor: pointer; text-decoration: none; }
.t a:hover { text-decoration: underline; }
.t .empty { text-align: center; color: var(--fg-tertiary); padding: 40px; }
.t.inner th, .t.inner td { padding: 8px 12px; font-size: 12px; }

.filters {
  display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap;
}
.filters select, .filters input {
  padding: 8px 12px; font-size: 13px; font-family: var(--font-sans);
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--r-md);
  color: var(--fg-primary); outline: none; -webkit-appearance: none; appearance: none;
  transition: all var(--dur-fast) var(--ease-out);
}
.filters input { flex: 1; min-width: 180px; }
.filters select:focus, .filters input:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(0,113,227,0.12); }
.filters button {
  padding: 8px 16px; background: rgba(0,0,0,0.05); color: var(--fg-primary);
  border: none; border-radius: var(--r-md); cursor: pointer; font-size: 13px;
  font-family: var(--font-sans); transition: all var(--dur-fast) var(--ease-out);
}
.filters button:hover { background: rgba(0,0,0,0.08); }
.filters button:active { transform: scale(0.97); }

/* ========== 标签/状态 ========== */
.tag, .pill {
  display: inline-block; padding: 2px 8px; font-size: 11px; font-weight: 500;
  border-radius: 980px; line-height: 1.5; white-space: nowrap;
}
.tag { background: var(--bg-group); color: var(--fg-secondary); }
.st-PENDING_DISPATCH, .st-PENDING_RECEIVE, .st-PENDING_ASSIGN { background: rgba(255,204,0,0.15); color: #b06f00; }
.st-IN_PROGRESS, .st-PROCESSING { background: rgba(0,113,227,0.12); color: var(--blue); }
.st-COMPLETED { background: rgba(52,199,89,0.15); color: #248a3d; }
.st-ARCHIVED { background: rgba(0,0,0,0.06); color: var(--fg-tertiary); }
.st-CANCELED, .st-CANCELLED { background: rgba(255,59,48,0.12); color: var(--red); }
.st-DRAFT { background: var(--bg-group); color: var(--fg-secondary); }
.st-PENDING_DEPT_REVIEW, .st-PENDING_SUMMARY, .st-PENDING_LEADER { background: rgba(88,86,214,0.12); color: var(--indigo); }

.pri-NORMAL { background: rgba(0,0,0,0.05); color: var(--fg-secondary); }
.pri-IMPORTANT { background: rgba(0,113,227,0.12); color: var(--blue); }
.pri-URGENT { background: rgba(255,149,0,0.15); color: #b15c00; }
.pri-CRITICAL { background: rgba(255,59,48,0.12); color: var(--red); }
.pill.small { font-size: 10px; padding: 1px 6px; }
.pill.active { background: rgba(52,199,89,0.15); color: #248a3d; }
.overdue { color: var(--red); font-size: 11px; margin-left: 4px; font-weight: 500; }

/* ========== 抽屉（Sheet） ========== */
.drawer-mask {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,0.4);
  display: flex; justify-content: center; align-items: flex-start;
  padding: 60px 20px 20px;
  animation: maskIn 220ms var(--ease-out);
  overflow-y: auto;
}
@keyframes maskIn { from { opacity: 0; } to { opacity: 1; } }
.drawer, .modal {
  background: var(--bg-elev); border-radius: var(--r-2xl);
  width: 540px; max-width: 100%;
  box-shadow: var(--shadow-4);
  display: flex; flex-direction: column;
  max-height: calc(100vh - 80px);
  overflow: hidden;
  animation: sheetIn 480ms var(--ease-spring) both;
  border: 1px solid var(--line);
}
.modal { width: 420px; }
.drawer.big { width: 900px; }
@keyframes sheetIn {
  from { opacity: 0; transform: translateY(40px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0)    scale(1.00); }
}
.drawer-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
  font-family: var(--font-display); font-size: 16px; font-weight: 600;
  letter-spacing: -0.01em;
}
.drawer-head small { font-family: var(--font-sans); font-weight: 400; color: var(--fg-tertiary); font-size: 12px; }
.drawer-head .close {
  width: 28px; height: 28px; display: grid; place-items: center;
  border-radius: 50%; cursor: pointer; font-size: 18px; color: var(--fg-secondary);
  transition: all var(--dur-fast) var(--ease-out);
}
.drawer-head .close:hover { background: rgba(0,0,0,0.06); color: var(--fg-primary); }
.drawer-head .close:active { transform: scale(0.9); }
.drawer-body { padding: 18px 20px; overflow-y: auto; }

.form-item { margin-bottom: 14px; }
.form-item label { display: block; font-size: 12px; color: var(--fg-secondary); margin-bottom: 6px; font-weight: 500; }
.form-item input, .form-item select, .form-item textarea {
  width: 100%; padding: 9px 12px; font-size: 13px; font-family: var(--font-sans);
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--r-md);
  color: var(--fg-primary); outline: none; -webkit-appearance: none; appearance: none;
  transition: all var(--dur-fast) var(--ease-out);
}
.form-item input:focus, .form-item select:focus, .form-item textarea:focus {
  border-color: var(--blue); box-shadow: 0 0 0 4px rgba(0,113,227,0.12);
}
.form-item textarea { resize: vertical; min-height: 60px; line-height: 1.6; }
.form-item pre { font-family: var(--font-sans); white-space: pre-wrap; margin: 0; font-size: 13px; }

.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

.dept-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.dept-chip {
  padding: 5px 12px; background: var(--bg-group); border: 1px solid var(--line);
  border-radius: 980px; cursor: pointer; font-size: 12px;
  transition: all var(--dur-fast) var(--ease-out); user-select: none;
}
.dept-chip:hover { background: rgba(0,0,0,0.06); }
.dept-chip:active { transform: scale(0.96); }
.dept-chip.on { background: var(--blue); color: #fff; border-color: var(--blue); }
.dept-chip input { display: none; }

/* ========== 任务详情 ========== */
.task-view .row {
  display: flex; gap: 10px; padding: 7px 0;
  border-bottom: 1px solid var(--line);
}
.task-view .row label {
  flex: 0 0 90px; font-size: 12px; color: var(--fg-secondary); padding-top: 2px;
}
.task-view .row span, .task-view .row pre { flex: 1; font-size: 13px; }

.timeline { padding: 4px 0 4px 8px; }
.tl-item {
  position: relative; padding: 6px 0 6px 18px;
  border-left: 2px solid var(--line);
  margin-left: 4px;
}
.tl-item .tl-dot {
  position: absolute; left: -5px; top: 12px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--blue); border: 2px solid var(--bg-elev);
}
.tl-item .small { font-size: 12px; }
.muted { color: var(--fg-tertiary); }
pre.small { font-size: 12px; white-space: pre-wrap; word-break: break-all; margin: 0; }

code.small { font-size: 11px; color: var(--fg-secondary); word-break: break-all; }

/* ========== 减弱动效 ========== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 200ms !important;
    transition-duration: 100ms !important;
  }
}
