/* ============================================================
   组件：卡片 / 按钮 / 表单 / chip / 进度 / 热力图 / 表格 / 浮层
   ============================================================ */

/* ---------------- 卡片 ---------------- */
.card {
  position: relative;
  background: linear-gradient(180deg, var(--bg-2), #0e141d);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
  padding: 16px;
  transition: border-color var(--dur) var(--ease);
}
.card:hover { border-color: var(--line-2); }

.card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.card-head h3 { font-size: var(--fs-body); font-weight: 600; }
.card-head .spacer { flex: 1; }
.card-title-hint { font-size: var(--fs-xs); color: var(--txt-3); }

.card--kpi::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  background: linear-gradient(90deg, var(--neon-cyan), var(--neon-violet));
  opacity: .85;
}
.card--focus { border-color: var(--line-glow); box-shadow: var(--shadow-card), var(--glow-cyan); }

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-2);
  background: var(--bg-3);
  color: var(--txt-1);
  font-size: var(--fs-sm);
  font-weight: 600;
  white-space: nowrap;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
              transform var(--dur) var(--ease), filter var(--dur) var(--ease);
}
.btn:hover { background: var(--bg-4); border-color: #31465d; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.btn-primary {
  background: linear-gradient(135deg, #22d3ee, #6d8cf7 55%, #8b5cf6);
  border: none;
  color: #04131a;
  box-shadow: 0 6px 18px -10px rgba(34, 211, 238, .9);
}
.btn-primary:hover { filter: brightness(1.08); background: linear-gradient(135deg, #22d3ee, #6d8cf7 55%, #8b5cf6); }

.btn-ghost { background: transparent; color: var(--txt-2); }
.btn-ghost:hover { background: var(--bg-3); color: var(--txt-1); }

.btn-danger { border-color: rgba(248, 113, 113, .35); color: var(--danger); background: rgba(248, 113, 113, .08); }
.btn-danger:hover { background: rgba(248, 113, 113, .16); border-color: rgba(248, 113, 113, .55); }

.btn-sm { height: 28px; padding: 0 11px; font-size: var(--fs-xs); }
.btn-block { width: 100%; }
.btn-icon { width: 30px; height: 30px; padding: 0; border-radius: var(--r-sm); }

/* ---------------- 分段控件 ---------------- */
.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
}
.segmented button {
  height: 26px;
  padding: 0 12px;
  border: none;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--txt-2);
  font-size: var(--fs-xs);
  font-weight: 600;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.segmented button:hover { color: var(--txt-1); }
.segmented button.active {
  background: rgba(34, 211, 238, .14);
  color: var(--neon-cyan);
  box-shadow: 0 0 0 1px rgba(34, 211, 238, .28) inset;
}

/* ---------------- 表单 ---------------- */
input, textarea, select {
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  color: var(--txt-1);
  border-radius: var(--r-md);
  padding: 9px 12px;
  font-family: inherit;
  font-size: var(--fs-body);
  font-variant-numeric: tabular-nums;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  width: 100%;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--neon-cyan);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, .14);
}
::placeholder { color: var(--txt-3); }
textarea { resize: vertical; min-height: 80px; line-height: 1.7; }
select { appearance: none; background-image: none; cursor: pointer; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label { font-size: var(--fs-xs); color: var(--txt-3); letter-spacing: .04em; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.search-box { position: relative; }
.search-box svg {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; fill: none; stroke: var(--txt-3);
  stroke-width: 1.8; stroke-linecap: round;
}
.search-box input { padding-left: 32px; height: 34px; }

/* ---------------- chip / 标签 ---------------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border-radius: var(--r-pill);
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  font-size: var(--fs-xs);
  color: var(--txt-2);
  white-space: nowrap;
}
.chip.is-on { background: rgba(34, 211, 238, .12); border-color: rgba(34, 211, 238, .45); color: var(--neon-cyan); }
button.chip { transition: border-color var(--dur), color var(--dur), background var(--dur); }
button.chip:hover { color: var(--txt-1); border-color: #31465d; }

.tag {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: 6px;
  background: rgba(139, 92, 246, .12);
  border: 1px solid rgba(139, 92, 246, .28);
  color: #b9a4fb;
  font-size: 11px;
}

.dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 7px; }
.dot.p1 { background: var(--neon-rose); box-shadow: 0 0 8px -1px var(--neon-rose); }
.dot.p2 { background: var(--neon-amber); }
.dot.p3 { background: var(--txt-3); }
.dot.ok { background: var(--ok); }

/* ---------------- 复选 ---------------- */
.check {
  appearance: none;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  border-radius: 6px;
  border: 1.5px solid var(--line-2);
  background: var(--bg-3);
  cursor: pointer;
  position: relative;
  transition: all var(--dur) var(--ease);
  padding: 0;
}
.check:hover { border-color: var(--neon-cyan); }
.check:checked {
  background: linear-gradient(135deg, var(--neon-cyan), var(--neon-violet));
  border-color: transparent;
}
.check:checked::after {
  content: "";
  position: absolute;
  left: 5px; top: 2px;
  width: 5px; height: 9px;
  border: solid #04131a;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* ---------------- 列表行 ---------------- */
.row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.row + .row { margin-top: 2px; }
.row:hover { background: var(--bg-3); }
.row.is-done .row-title { color: var(--txt-3); text-decoration: line-through; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-title {
  font-size: var(--fs-body);
  color: var(--txt-1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row-meta { display: flex; align-items: center; gap: 8px; font-size: var(--fs-xs); color: var(--txt-3); flex-wrap: wrap; }
.row-actions { display: flex; align-items: center; gap: 4px; opacity: 0; transition: opacity var(--dur); }
.row:hover .row-actions, .row:focus-within .row-actions { opacity: 1; }
@media (max-width: 900px) { .row-actions { opacity: 1; } }

.bar-priority { width: 3px; align-self: stretch; border-radius: 2px; flex: 0 0 3px; min-height: 22px; }
.bar-priority.p1 { background: var(--neon-rose); }
.bar-priority.p2 { background: var(--neon-amber); }
.bar-priority.p3 { background: var(--txt-3); }

.due { display: inline-flex; align-items: center; gap: 4px; }
.due.overdue { color: var(--danger); background: rgba(248, 113, 113, .12); border-radius: 5px; padding: 0 5px; }
.due.today { color: var(--neon-cyan); }

/* ---------------- 进度条 / 环 ---------------- */
.bar {
  position: relative;
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--bg-4);
  overflow: hidden;
}
.bar > i {
  display: block;
  height: 100%;
  border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--neon-cyan), var(--neon-violet));
  transition: width 420ms var(--ease);
}
.bar.warn > i { background: linear-gradient(90deg, var(--neon-amber), #f59e0b); }
.bar.ok > i { background: linear-gradient(90deg, var(--ok), #22d3ee); }
.bar.thin { height: 4px; }

.ring { display: block; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: var(--bg-4); }
.ring-bar { fill: none; stroke-linecap: round; transition: stroke-dashoffset 420ms var(--ease); }

.ring-wrap { position: relative; display: grid; place-items: center; }
.ring-center {
  position: absolute;
  display: grid;
  place-items: center;
  text-align: center;
  line-height: 1.1;
}
.ring-center b { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 1.125rem; }
.ring-center small { font-size: 10px; color: var(--txt-3); }

/* ---------------- 热力图 ---------------- */
.heatmap-wrap { overflow-x: auto; padding-bottom: 4px; }
.heatmap {
  display: grid;
  grid-template-rows: repeat(7, 12px);
  grid-auto-flow: column;
  grid-auto-columns: 12px;
  gap: 3px;
  width: max-content;
}
.hm {
  border-radius: 3px;
  background: var(--hm-0);
  transition: transform 120ms var(--ease);
  cursor: default;
}
.hm:hover { transform: scale(1.3); }
.hm.lv-1 { background: var(--hm-1); }
.hm.lv-2 { background: var(--hm-2); }
.hm.lv-3 { background: var(--hm-3); }
.hm.lv-4 { background: var(--hm-4); box-shadow: 0 0 8px -2px var(--neon-cyan); }
.hm.is-future { opacity: .25; }

.hm-legend { display: flex; align-items: center; gap: 4px; font-size: 10px; color: var(--txt-3); }
.hm-legend span.sw { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

/* ---------------- 表格 ---------------- */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}
.table th {
  text-align: left;
  padding: 8px 10px;
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--txt-3);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--txt-2);
}
.table tr:last-child td { border-bottom: none; }
.table td.num, .table th.num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ---------------- 空态 ---------------- */
.empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--txt-3);
  font-size: var(--fs-sm);
  border: 1px dashed var(--line-2);
  border-radius: var(--r-md);
}
.empty b { display: block; color: var(--txt-2); font-weight: 500; margin-bottom: 4px; }

/* ---------------- 浮层：drawer / modal / sheet ---------------- */
.overlay { position: relative; z-index: 60; }
.overlay:empty { display: none; }

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 4, 8, .66);
  backdrop-filter: blur(3px);
  animation: fadeIn 160ms var(--ease);
}

.drawer {
  position: fixed;
  top: 0; right: 0;
  width: min(400px, 100%);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg-1);
  border-left: 1px solid var(--line-2);
  box-shadow: var(--shadow-pop);
  animation: slideIn 200ms var(--ease);
}
.drawer-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.drawer-head h3 { font-size: var(--fs-body); }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px; }
.drawer-foot {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: var(--bg-1);
}
.drawer-foot .spacer { flex: 1; }

.modal {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(440px, calc(100vw - 28px));
  max-height: calc(100dvh - 48px);
  display: flex;
  flex-direction: column;
  background: var(--bg-1);
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop);
  animation: popIn 180ms var(--ease);
}
.modal-head { padding: 16px 18px 0; }
.modal-head h3 { font-size: var(--fs-body); }
.modal-body { padding: 16px 18px; overflow-y: auto; }
.modal-foot {
  display: flex; gap: 8px; justify-content: flex-end;
  padding: 12px 18px; border-top: 1px solid var(--line);
}
.modal-foot .spacer { flex: 1; }

@media (max-width: 900px) {
  .drawer {
    top: auto; bottom: 0; right: 0; left: 0;
    width: 100%;
    height: min(88dvh, 720px);
    border-left: none;
    border-top: 1px solid var(--line-2);
    border-radius: 18px 18px 0 0;
    animation: sheetIn 220ms var(--ease);
  }
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideIn { from { transform: translateX(24px); opacity: .4; } to { transform: none; opacity: 1; } }
@keyframes sheetIn { from { transform: translateY(24px); opacity: .4; } to { transform: none; opacity: 1; } }
@keyframes popIn { from { transform: translate(-50%, -48%) scale(.97); opacity: 0; } to { transform: translate(-50%, -50%) scale(1); opacity: 1; } }

/* ---------------- toast ---------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 12px);
  z-index: 90;
  padding: 9px 16px;
  border-radius: var(--r-pill);
  background: rgba(17, 24, 35, .96);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow-pop);
  font-size: var(--fs-sm);
  color: var(--txt-1);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms var(--ease), transform 180ms var(--ease);
  max-width: min(88vw, 480px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: rgba(248, 113, 113, .5); color: #fecaca; }
.toast.ok { border-color: rgba(52, 211, 153, .45); }

/* ---------------- 骨架屏 ---------------- */
.skeleton {
  border-radius: var(--r-md);
  background: linear-gradient(90deg, var(--bg-3) 25%, var(--bg-4) 37%, var(--bg-3) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* ---------------- markdown 预览 ---------------- */
.md {
  font-size: var(--fs-sm);
  line-height: 1.75;
  color: var(--txt-2);
  word-break: break-word;
}
.md h1 { font-size: 1.0625rem; color: var(--txt-1); margin: 0 0 12px; }
.md h2 {
  font-size: var(--fs-body);
  color: var(--neon-cyan);
  margin: 18px 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line);
}
.md h3 { font-size: var(--fs-sm); color: var(--txt-1); margin: 14px 0 6px; }
.md p { margin: 8px 0; }
.md ul, .md ol { margin: 6px 0; padding-left: 20px; list-style: revert; }
.md li { margin: 2px 0; }
.md strong { color: var(--txt-1); font-weight: 600; }
.md code {
  font-family: var(--font-mono);
  font-size: .92em;
  background: var(--bg-3);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--neon-lime);
}
.md blockquote {
  margin: 10px 0;
  padding: 8px 12px;
  border-left: 2px solid var(--line-2);
  background: rgba(255, 255, 255, .02);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  color: var(--txt-2);
}
.md table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: var(--fs-xs); }
.md th, .md td { border: 1px solid var(--line); padding: 6px 9px; text-align: left; }
.md th { background: var(--bg-3); color: var(--txt-2); font-weight: 600; }
.md tr:nth-child(even) td { background: rgba(255, 255, 255, .015); }

/* ---------------- 工具类 ---------------- */
.flex { display: flex; }
.items-center { align-items: center; }
.gap-4 { gap: 4px; }
.gap-6 { gap: 6px; }
.gap-8 { gap: 8px; }
.gap-10 { gap: 10px; }
.gap-12 { gap: 12px; }
.wrap { flex-wrap: wrap; }
.ml-auto { margin-left: auto; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.fs-xs { font-size: var(--fs-xs); }
.fs-sm { font-size: var(--fs-sm); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
