/* ============== 基础变量 ============== */
:root {
  --header-h: 56px;
  --bg: #f1f5f9;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --danger: #ef4444;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

a { color: inherit; }

/* ============== 应用骨架 ============== */
.app {
  height: 100vh;
  display: grid;
  grid-template-rows: var(--header-h) 1fr;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  background: white;
  border-bottom: 1px solid var(--border);
  z-index: 30;
  gap: 8px;
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.topbar h1 {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 50vw;
}

.icon-btn {
  background: transparent;
  border: 0;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { background: #f1f5f9; color: var(--text); }

.btn {
  border: 1px solid var(--border);
  background: white;
  color: var(--text);
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: inherit;
}
.btn:hover { background: #f8fafc; }
.btn-primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-sm { padding: 4px 10px; font-size: 12px; margin-left: 4px; }

.ws-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 10px;
  font-size: 11px;
  background: #f1f5f9;
  color: var(--muted);
}
.ws-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: #94a3b8; }
.ws-pill.online { color: #047857; background: #d1fae5; }
.ws-pill.online .dot { background: #10b981; }

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px 4px 4px;
  border-radius: 20px;
  cursor: pointer;
  border: 0;
  background: transparent;
  font-family: inherit;
}
.user-chip:hover { background: #f1f5f9; }
.user-chip .avatar { width: 28px; height: 28px; border-radius: 50%; }

.content {
  overflow: auto;
  position: relative;
}

/* ============== 项目列表 ============== */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.project-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  transition: box-shadow .15s, transform .15s, border-color .15s;
}
.project-card:hover {
  box-shadow: 0 8px 22px rgba(0, 0, 0, .08);
  transform: translateY(-2px);
  border-color: #c7d2fe;
}
.project-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.project-info { flex: 1; min-width: 0; }
.project-name {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.project-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.project-meta {
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: #94a3b8;
  align-items: center;
}

/* ============== 管理后台 ============== */
.admin-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.admin-tabs button {
  border: 0;
  background: transparent;
  padding: 10px 16px;
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  font-family: inherit;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.admin-tabs button.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 500;
}

.data-table-wrap {
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: auto;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}
.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: 0; }
.data-table tr:hover td { background: #fafbfc; }
.data-table tr.row-disabled td { opacity: .55; }

/* 用户管理 */
.user-toolbar {
  margin-bottom: 12px;
}
.bulk-bar {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 12px;
  padding: 4px 8px 4px 12px;
  background: #eef2ff;
  border-radius: 8px;
  flex-wrap: wrap;
}
.bulk-count {
  font-size: 12px;
  color: #4338ca;
  margin-right: 4px;
}
.bulk-count b { font-weight: 700; }

/* grid 表格输入弹窗 */
.ui-dialog:has(.grid-table-wrap) {
  max-width: 720px;
}
.grid-table-wrap {
  overflow-x: auto;
  max-height: 50vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.grid-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.grid-table th {
  background: #f8fafc;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  padding: 8px 6px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1;
}
.grid-table td {
  padding: 4px 4px;
  border-bottom: 1px solid #f1f5f9;
}
.grid-rownum {
  font-size: 11px;
  color: #cbd5e1;
  text-align: center;
}
.grid-input {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  padding: 7px 8px;
  font-size: 13px;
  outline: none;
  border-radius: 5px;
  font-family: inherit;
  color: var(--text);
}
.grid-input:focus {
  background: white;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, .15);
}
.grid-cb {
  margin: 0 auto;
  display: block;
  cursor: pointer;
  accent-color: var(--primary);
}
.grid-del {
  border: 0;
  background: transparent;
  color: #cbd5e1;
  cursor: pointer;
  font-size: 16px;
  width: 28px;
  height: 28px;
  border-radius: 4px;
}
.grid-del:hover { color: var(--danger); background: #fef2f2; }

html.is-mobile .ui-dialog:has(.grid-table-wrap) { max-width: 100%; }
html.is-mobile .grid-table th,
html.is-mobile .grid-table td { padding: 6px 4px; }
html.is-mobile .grid-input { padding: 6px; font-size: 12px; }

/* ============== 看板 / 列表 ============== */
.board-wrap {
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}
.board {
  display: flex;
  gap: 12px;
  padding: 14px;
  height: 100%;
  min-width: max-content;
}
.kanban-column {
  width: 300px;
  min-width: 300px;
  display: flex;
  flex-direction: column;
  background: #eef2f5;
  border-radius: 12px;
  max-height: 100%;
}
.kanban-column-header {
  padding: 10px 14px;
  font-weight: 600;
  font-size: 13px;
  color: #334155;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid;
}
.kanban-cards {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 60px;
}

.list-view {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}
.list-view.empty {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
}

/* 卡片 */
.kanban-card {
  background: white;
  border-radius: 10px;
  padding: 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  cursor: pointer;
  transition: box-shadow .15s, transform .15s;
  border-left: 3px solid #cbd5e1;
}
.kanban-card:hover { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08); }
.kanban-card.priority-low { border-left-color: #10b981; }
.kanban-card.priority-normal { border-left-color: #3b82f6; }
.kanban-card.priority-high { border-left-color: #f59e0b; }
.kanban-card.priority-urgent { border-left-color: #ef4444; }
.card-row1 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-code { font-family: ui-monospace, "SFMono-Regular", monospace; font-size: 11px; color: #94a3b8; }
.card-title {
  font-size: 14px; font-weight: 500;
  color: #1e293b;
  margin: 6px 0;
  line-height: 1.4;
  word-break: break-word;
}
.card-meta {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 8px; font-size: 12px; color: var(--muted); gap: 8px;
}
.card-due { display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.card-due.due-soon { color: #f59e0b; font-weight: 500; }
.card-due.overdue { color: #ef4444; font-weight: 600; }

.due-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 8px;
  line-height: 1.5;
  white-space: nowrap;
}
.badge-overdue { background: #fee2e2; color: #b91c1c; }
.badge-today { background: #fef3c7; color: #b45309; }
.badge-tomorrow { background: #fde68a; color: #92400e; }
.badge-after { background: #e0e7ff; color: #4338ca; }

.avatars { display: inline-flex; align-items: center; }
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; color: white; font-weight: 600; flex-shrink: 0;
}
.avatar-sm { width: 22px; height: 22px; font-size: 10px; }
.avatar-md { width: 28px; height: 28px; font-size: 12px; }
.avatar-lg { width: 36px; height: 36px; font-size: 14px; }
.avatars .avatar + .avatar { margin-left: -6px; border: 2px solid white; }
.avatar-more { background: #cbd5e1; color: #475569; }

.card-thumbs { display: flex; gap: 4px; margin-top: 8px; flex-wrap: wrap; }
.thumb-tag {
  font-size: 10px; padding: 2px 7px; border-radius: 4px;
  background: #f1f5f9; color: var(--muted);
  display: inline-flex; align-items: center; gap: 3px;
}
.thumb-tag.before { background: #fef3c7; color: #92400e; }
.thumb-tag.after { background: #d1fae5; color: #065f46; }

.sortable-ghost { opacity: .35; background: #c7d2fe !important; }
.sortable-chosen { cursor: grabbing; }
.sortable-drag { transform: rotate(1.5deg); box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18) !important; }

/* 列拖拽手柄 */
.col-drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 22px;
  font-size: 12px;
  color: #cbd5e1;
  cursor: grab;
  user-select: none;
  letter-spacing: -2px;
  flex-shrink: 0;
  border-radius: 4px;
  transition: color .15s, background .15s;
}
.col-drag-handle:hover { color: #475569; background: rgba(99, 102, 241, .08); }
.col-drag-handle:active { cursor: grabbing; color: var(--primary); }

/* 列拖拽中样式 */
.col-ghost {
  opacity: .4;
  background: #e0e7ff !important;
}
.col-chosen { cursor: grabbing; }
.col-drag {
  transform: rotate(1deg);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.2) !important;
  opacity: .95;
}

.kanban-cards::-webkit-scrollbar,
.content::-webkit-scrollbar {
  width: 8px; height: 8px;
}
.kanban-cards::-webkit-scrollbar-thumb,
.content::-webkit-scrollbar-thumb {
  background: #cbd5e1; border-radius: 4px;
}

/* 浮动新建按钮 */
.fab {
  position: fixed;
  right: 18px;
  bottom: calc(18px + var(--safe-bottom));
  width: 54px; height: 54px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-size: 28px;
  border: 0;
  box-shadow: 0 6px 16px rgba(99, 102, 241, .45);
  cursor: pointer;
  z-index: 25;
  display: none;
}
.fab:hover { background: var(--primary-dark); }

/* ============== 卡片详情 ============== */
.detail-mask {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .45);
  z-index: 35;
  display: flex; justify-content: center; align-items: center;
  opacity: 0;
  transition: opacity .18s;
}
.detail-mask.show { opacity: 1; }
.detail-panel {
  background: white;
  width: 100%;
  max-width: 800px;
  max-height: 92vh;
  border-radius: 14px;
  display: flex; flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .25);
  transform: translateY(8px);
  transition: transform .18s;
}
.detail-mask.show .detail-panel { transform: translateY(0); }

.detail-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
}
.detail-head .left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.detail-body {
  padding: 16px 18px;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 14px;
}
.detail-foot {
  padding: 12px 18px calc(12px + var(--safe-bottom));
  border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; gap: 10px;
  background: #fafbfc;
  border-radius: 0 0 14px 14px;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; font-weight: 500; color: var(--muted); }
.input, .textarea, .select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 14px;
  font-family: inherit;
  background: white;
  outline: none;
  color: var(--text);
}
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, .15);
}
.textarea { resize: vertical; min-height: 70px; }
.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.tag-button {
  border: 1px solid var(--border);
  background: white;
  padding: 8px 11px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-align: left;
  width: 100%;
  font-family: inherit;
  color: var(--text);
}
.tag-button:hover:not(:disabled) { background: #f8fafc; }
.tag-button:disabled { cursor: not-allowed; }
.tag-button .dot { width: 8px; height: 8px; border-radius: 50%; }

.assignee-display {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  min-height: 32px;
}
.assignee-display .placeholder { color: #94a3b8; font-size: 13px; }

.image-zones {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 600px) {
  .image-zones { grid-template-columns: 1fr; }
}
.image-zone {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 10px;
  background: #fafbfc;
}
.image-zone-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; font-weight: 600; color: #475569;
  margin-bottom: 8px;
}
.image-zone-head .dot { width: 8px; height: 8px; border-radius: 50%; }
.image-zone .upload-btn { font-size: 12px; color: var(--primary); cursor: pointer; }
.image-zone .upload-btn:hover { color: var(--primary-dark); }
.image-list {
  display: flex; flex-direction: column; gap: 6px;
  min-height: 80px;
}
.image-list .empty {
  text-align: center; font-size: 12px; color: #94a3b8;
  padding: 16px 0;
}

/* 上传进度 */
.upload-progress {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.upload-item {
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  transition: opacity .2s;
}
.upload-item.done { background: #ecfdf5; border-color: #a7f3d0; }
.upload-item.done .upload-fill { background: #10b981; }
.upload-item.failed { background: #fef2f2; border-color: #fecaca; }
.upload-item.failed .upload-fill { background: #ef4444; }
.upload-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.upload-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #475569;
}
.upload-pct {
  flex-shrink: 0;
  font-family: ui-monospace, monospace;
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}
.upload-item.done .upload-pct { color: #047857; }
.upload-item.failed .upload-pct { color: #b91c1c; }
.upload-track {
  height: 4px;
  background: #e2e8f0;
  border-radius: 2px;
  overflow: hidden;
}
.upload-fill {
  height: 100%;
  width: 0;
  background: var(--primary);
  border-radius: 2px;
  transition: width .15s linear;
}
.image-item {
  position: relative;
  background: white;
  border-radius: 8px;
  border: 1px solid var(--border);
  display: flex;
  gap: 8px;
  padding: 6px;
}
.image-item img {
  width: 70px; height: 70px;
  object-fit: cover;
  border-radius: 6px;
  cursor: zoom-in;
  flex-shrink: 0;
}
.image-item .info {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; justify-content: center;
}
.image-item .info .name {
  font-size: 12px; color: #475569;
  word-break: break-all; line-height: 1.3;
}
.image-item .info .meta { font-size: 11px; color: #94a3b8; margin-top: 2px; }
.image-item .del {
  position: absolute; top: 4px; right: 4px;
  width: 22px; height: 22px;
  border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, .95);
  color: var(--danger);
  cursor: pointer;
  font-size: 14px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .1);
}

/* 图片放大查看 */
.image-viewer {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, .92);
  z-index: 80;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  cursor: zoom-out;
}
.image-viewer img {
  max-width: 100%; max-height: 100%;
  object-fit: contain;
  border-radius: 6px;
}
.image-viewer .close-x {
  position: absolute; top: 14px; right: 14px;
  background: rgba(255, 255, 255, .15);
  color: white;
  width: 38px; height: 38px;
  border: 0; border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
}

/* ============== UI 组件库 ============== */
.ui-mask {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .5);
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  opacity: 0;
  transition: opacity .15s;
}
.ui-mask.show { opacity: 1; }
.ui-dialog {
  background: white;
  width: 100%;
  max-width: 420px;
  max-height: 86vh;
  border-radius: 12px;
  display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .3);
  transform: scale(.96);
  transition: transform .15s;
}
.ui-mask.show .ui-dialog { transform: scale(1); }
.ui-head { padding: 14px 18px 6px; }
.ui-head h3 { margin: 0; font-size: 15px; font-weight: 600; color: var(--text); }
.ui-body {
  padding: 8px 18px 14px;
  overflow-y: auto;
  flex: 1;
}
.ui-body p {
  margin: 0 0 10px;
  font-size: 14px;
  color: #475569;
  line-height: 1.5;
  white-space: pre-wrap;
}
.ui-body .ui-msg { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.ui-body-list {
  padding: 4px 8px 14px;
  max-height: 60vh;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ui-search { padding: 0 12px 8px; }
.ui-foot {
  padding: 10px 16px calc(10px + var(--safe-bottom));
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--border);
  background: #fafbfc;
}
.ui-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 14px;
  outline: none;
  font-family: inherit;
  color: var(--text);
  background: white;
}
.ui-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, .15);
}
.ui-btn {
  border: 1px solid var(--border);
  background: white;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  font-weight: 500;
  font-family: inherit;
}
.ui-btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.ui-btn-primary:hover { background: var(--primary-dark); }
.ui-btn-ghost { background: white; color: #475569; }
.ui-btn-ghost:hover { background: #f1f5f9; }
.ui-btn-danger { background: var(--danger); color: white; border-color: var(--danger); }
.ui-btn-danger:hover { background: #dc2626; }

.ui-option {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
  font-size: 14px;
}
.ui-option:hover { background: #f8fafc; }
.ui-option.selected { background: #eef2ff; }
.ui-option input[type="radio"],
.ui-option input[type="checkbox"] {
  margin: 0; width: 16px; height: 16px;
  cursor: pointer; accent-color: var(--primary);
}
.ui-option-dot { width: 10px; height: 10px; border-radius: 50%; background: #cbd5e1; flex-shrink: 0; }
.ui-option-label { flex: 1; }
.ui-option-hint { font-size: 11px; color: var(--muted); }

/* ============== Toast ============== */
#ui-toast {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 14px);
  right: 14px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.ui-toast-item {
  background: #1e293b;
  color: white;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, .18);
  min-width: 180px;
  max-width: 300px;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity .2s, transform .2s;
}
.ui-toast-item.show { opacity: 1; transform: translateY(0); }
.ui-toast-success { background: #059669; }
.ui-toast-error { background: #dc2626; }

/* ============== 用户菜单 / 板菜单 ============== */
.user-menu {
  position: absolute;
  top: 100%;
  right: 0;
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .1);
  width: 200px;
  padding: 6px;
  z-index: 50;
  margin-top: 4px;
}
.user-menu .header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.user-menu .header .name { font-size: 14px; font-weight: 600; }
.user-menu .header .username { font-size: 11px; color: var(--muted); margin-top: 2px; }
.user-menu button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 9px 12px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
}
.user-menu button:hover { background: #f1f5f9; }

/* ============== 移动端断点 ============== */
@media (max-width: 768px) {
  :root { --header-h: 52px; }
  .topbar { padding: 0 10px; }
  .topbar h1 { font-size: 15px; max-width: 40vw; }
  .desktop-only { display: none !important; }

  .board { padding: 10px; gap: 10px; }
  .kanban-column { width: 84vw; min-width: 84vw; }

  .list-view { grid-template-columns: 1fr; gap: 8px; }
  .project-grid { grid-template-columns: 1fr; }

  .fab { display: flex; align-items: center; justify-content: center; }

  /* 详情抽屉变底部上滑 */
  .detail-mask { align-items: flex-end; padding: 0; }
  .detail-panel {
    border-radius: 14px 14px 0 0;
    max-height: 92vh;
    transform: translateY(100%);
  }
  .detail-mask.show .detail-panel { transform: translateY(0); }

  .ui-dialog { max-width: 100%; border-radius: 14px; }

  /* 表格在手机端横滚 */
  .data-table-wrap { overflow-x: auto; }
  .data-table th, .data-table td { white-space: nowrap; padding: 10px 12px; }
}

@media (min-width: 769px) {
  .mobile-only { display: none !important; }
}

/* ============== 设备识别强制覆盖 ============== */
/* 通过 device.js 判定的 is-mobile，确保不论屏幕宽度都按移动端排版 */
html.is-mobile :root { --header-h: 52px; }
html.is-mobile .topbar { padding: 0 10px; }
html.is-mobile .topbar h1 { font-size: 15px; max-width: 40vw; }
html.is-mobile .desktop-only { display: none !important; }
html.is-desktop .mobile-only { display: none !important; }

html.is-mobile .board { padding: 10px; gap: 10px; flex-direction: column; min-width: 0; }
html.is-mobile .board-wrap { overflow-x: hidden; overflow-y: auto; }
html.is-mobile .kanban-column { width: 100%; min-width: 0; max-height: none; }
html.is-mobile .kanban-cards { max-height: 60vh; }

/* 手机端：列标题可点击折叠 */
html.is-mobile .kanban-column-header {
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: rgba(99, 102, 241, .08);
}
html.is-mobile .kanban-column-header:active { background: #e8edf3; }
html.is-mobile .kanban-column.collapsed { background: #e8edf3; }
html.is-mobile .kanban-column.collapsed .kanban-column-header {
  border-bottom-color: transparent !important;
}
.col-caret {
  font-size: 10px;
  color: #94a3b8;
  width: 12px;
  flex-shrink: 0;
}
.collapsed-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 500;
  color: #475569;
  background: #fef3c7;
  border: 1px solid #fde68a;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
}

html.is-mobile .list-view { grid-template-columns: 1fr; gap: 8px; }
html.is-mobile .project-grid { grid-template-columns: 1fr; }
html.is-mobile .fab { display: flex; align-items: center; justify-content: center; }

html.is-mobile .detail-mask { align-items: flex-end; padding: 0; }
html.is-mobile .detail-panel {
  border-radius: 14px 14px 0 0;
  max-height: 92vh;
  transform: translateY(100%);
}
html.is-mobile .detail-mask.show .detail-panel { transform: translateY(0); }
html.is-mobile .ui-dialog { max-width: 100%; border-radius: 14px; }
html.is-mobile .data-table-wrap { overflow-x: auto; }
html.is-mobile .data-table th,
html.is-mobile .data-table td { white-space: nowrap; padding: 10px 12px; }

html.is-mobile .field-grid { grid-template-columns: 1fr; }
html.is-mobile .image-zones { grid-template-columns: 1fr; }
html.is-mobile .topbar-right { gap: 4px; }
html.is-mobile .btn { padding: 6px 10px; font-size: 12px; }
html.is-mobile .topbar-right .user-chip .avatar { width: 30px; height: 30px; }

/* ============== 通讯录卡片 ============== */
.contact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}
html.is-mobile .contact-grid { grid-template-columns: 1fr; }

.contact-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  cursor: pointer;
  transition: box-shadow .15s, transform .15s, border-color .15s;
}
.contact-card:hover {
  box-shadow: 0 6px 16px rgba(0, 0, 0, .06);
  transform: translateY(-1px);
  border-color: #c7d2fe;
}
.contact-head {
  display: flex; align-items: center; gap: 12px;
}
.contact-main { min-width: 0; flex: 1; }
.contact-name {
  font-size: 15px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.contact-role { font-size: 12px; color: var(--muted); margin-top: 2px; }
.contact-rows {
  margin-top: 10px;
  display: flex; flex-direction: column; gap: 4px;
}
.contact-row {
  font-size: 12px;
  color: #475569;
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  word-break: break-all;
}
.contact-row:hover { color: var(--primary); }
.contact-notes {
  margin-top: 10px;
  padding: 8px 10px;
  background: #f8fafc;
  border-radius: 6px;
  font-size: 12px;
  color: #475569;
  line-height: 1.5;
  white-space: pre-wrap;
}

/* ============== 卡片详情：联系人区 ============== */
.contact-list {
  display: flex; flex-direction: column; gap: 6px;
}
.contact-list .empty {
  text-align: center;
  font-size: 12px;
  color: #94a3b8;
  padding: 14px 0;
}
.contact-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.contact-chip .chip-main {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 2px;
}
.contact-chip .chip-name {
  font-size: 13px; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.contact-chip .chip-meta {
  font-size: 11px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.contact-chip .chip-note {
  font-size: 11px;
  color: #b45309;
  background: #fef3c7;
  padding: 2px 6px;
  border-radius: 4px;
  margin-top: 2px;
  display: inline-block;
}
.contact-chip-actions {
  display: flex; gap: 2px;
}
.contact-chip-actions .icon-btn { width: 28px; height: 28px; font-size: 14px; }

.contact-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #f1f5f9;
  color: #475569;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 10px;
  margin-right: 4px;
  margin-bottom: 2px;
}
.contact-tag .dot {
  width: 6px; height: 6px; border-radius: 50%;
  flex-shrink: 0;
}
