/* Sam Todo —— 移动优先样式（CSP: style-src 'self'，全部在此文件） */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  color: #1f2937;
  background: #f6f7f9;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ---------- 登录页 ---------- */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, #eef2ff 0%, #ffffff 45%, #f9fafb 100%);
}
.login-card {
  width: 100%;
  max-width: 340px;
  background: #fff;
  border: 1px solid #eef0f3;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(17, 24, 39, .06);
  padding: 28px 24px;
}
.login-logo { font-size: 26px; font-weight: 700; color: #4f46e5; text-align: center; }
.login-sub { font-size: 13px; color: #9ca3af; text-align: center; margin: 6px 0 20px; }
.login-hint { font-size: 12px; color: #9ca3af; text-align: center; margin-top: 16px; }

/* ---------- 应用布局 ---------- */
.app-body { display: flex; flex-direction: column; min-height: 100vh; }
.app-content { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.sidebar { display: none; }
.app-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top));
  background: #fff;
  border-bottom: 1px solid #eef0f3;
}
.app-title { font-size: 18px; font-weight: 700; color: #4f46e5; }
.app-user { display: flex; align-items: center; gap: 10px; font-size: 13px; color: #6b7280; }
.app-username { font-weight: 500; color: #374151; }
.link-btn { background: none; border: none; color: #9ca3af; font-size: 13px; padding: 6px; }

.app-main {
  flex: 1;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px 96px;
}

.top-banner {
  background: #fffbeb; color: #b45309; font-size: 13px;
  padding: 8px 16px; text-align: center; border-bottom: 1px solid #fde68a;
}

/* ---------- 底部导航 ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex;
  background: #fff;
  border-top: 1px solid #eef0f3;
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-tab {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 8px 4px 6px;
  color: #9ca3af;
  font-size: 11px;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}
.nav-icon { font-size: 20px; line-height: 1.2; }
.nav-label { margin-top: 2px; }
.nav-tab-on { color: #4f46e5; }
.nav-badge {
  position: absolute; top: 4px; right: calc(50% - 18px);
  background: #ef4444; color: #fff; font-size: 10px;
  min-width: 16px; height: 16px; line-height: 16px; text-align: center;
  border-radius: 8px; padding: 0 4px;
}

/* ---------- 通用 ---------- */
.page-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.page-head h1 { font-size: 20px; font-weight: 700; margin: 0; flex: 1; }
.back { color: #6b7280; font-size: 15px; padding: 8px 0; }
.spacer { flex: 1; }
.muted { color: #9ca3af; font-size: 12px; }
.code { color: #4f46e5; font-weight: 500; }

.card {
  display: block;
  background: #fff;
  border: 1px solid #eef0f3;
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
}
.card:active { background: #fafbfc; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.card-date { font-size: 14px; font-weight: 600; }
.card-date.big { font-size: 16px; }
.card-preview { font-size: 13px; color: #6b7280; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tag-hint { font-size: 12px; }
.content-text { font-size: 14px; line-height: 1.7; white-space: pre-wrap; word-break: break-word; }

.empty { text-align: center; color: #9ca3af; font-size: 13px; padding: 48px 0; }
.section-title { font-size: 13px; font-weight: 600; color: #6b7280; margin: 18px 0 8px; }
.section-title.danger { color: #ef4444; }

/* ---------- 按钮 ---------- */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center;
  background: #4f46e5; color: #fff;
  border: none; border-radius: 10px;
  padding: 10px 16px; font-size: 14px; font-weight: 500;
  min-height: 44px;
}
.btn-primary:active { background: #4338ca; }
.btn-ghost {
  display: inline-flex; align-items: center; justify-content: center;
  background: #f3f4f6; color: #374151;
  border: none; border-radius: 10px;
  padding: 8px 14px; font-size: 13px; min-height: 40px;
}
.btn-danger { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; border-radius: 10px; padding: 11px 16px; font-size: 14px; min-height: 44px; }
.btn-success { background: #16a34a; color: #fff; border: none; border-radius: 10px; padding: 11px 16px; font-size: 14px; min-height: 44px; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 10px; margin-top: 4px; }
.grow { flex: 1; }
.inline-form { display: inline; }
.inline-form.grow { flex: 1; }
.check-btn {
  background: #eef2ff; color: #4f46e5;
  border: none; border-radius: 9999px;
  width: 34px; height: 34px; font-size: 16px; font-weight: 600;
  flex-shrink: 0;
}
.check-btn:active { background: #e0e7ff; }

/* ---------- 表单 ---------- */
.form { padding: 16px; }
.form-sub { font-size: 15px; font-weight: 600; margin: 0 0 12px; }
.field-label { display: block; font-size: 12px; color: #6b7280; margin: 12px 0 6px; }
.field {
  width: 100%;
  border: 1px solid #e5e7eb; border-radius: 10px;
  padding: 11px 12px; font-size: 14px;
  background: #fff; color: #1f2937;
  -webkit-appearance: none;
}
.field:focus { outline: none; border-color: #4f46e5; box-shadow: 0 0 0 3px rgba(79, 70, 229, .12); }
.textarea { resize: vertical; min-height: 96px; line-height: 1.6; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quick-row { display: flex; gap: 8px; margin: 14px 0; }

/* ---------- 筛选 pill ---------- */
.filters { display: flex; gap: 8px; margin-bottom: 12px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.pill {
  display: inline-flex; align-items: center;
  background: #f3f4f6; color: #6b7280;
  border-radius: 9999px; padding: 8px 14px;
  font-size: 13px; white-space: nowrap; min-height: 34px;
}
.pill-on { background: #4f46e5; color: #fff; }

/* ---------- 任务 ---------- */
.task-row { display: flex; align-items: center; gap: 10px; }
.task-main { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.task-body { flex: 1; min-width: 0; }
.task-title { font-size: 14px; font-weight: 500; line-height: 1.4; }
.task-title.done { text-decoration: line-through; color: #9ca3af; }
.task-title-view { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.task-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 12px; color: #6b7280; margin-top: 4px; }
.task-meta.big { margin-top: 0; }
.overdue { color: #ef4444; font-size: 12px; font-weight: 500; }

/* ---------- 徽标 / 优先级点 ---------- */
.badge { font-size: 11px; padding: 2px 8px; border-radius: 9999px; }
.badge[data-status="doing"]   { color: #2563eb; background: #2563eb1a; }
.badge[data-status="done"]    { color: #16a34a; background: #16a34a1a; }
.badge[data-status="shelved"] { color: #9ca3af; background: #9ca3af1a; }
.dot { width: 9px; height: 9px; border-radius: 9999px; flex-shrink: 0; }
.dot[data-p="P1"] { background: #ef4444; }
.dot[data-p="P2"] { background: #f59e0b; }
.dot[data-p="P3"] { background: #3b82f6; }
.dot[data-p="P4"] { background: #9ca3af; }

/* ---------- 进度条 ---------- */
.progress { height: 6px; background: #f3f4f6; border-radius: 9999px; overflow: hidden; margin-top: 12px; }
.progress-fill { height: 100%; border-radius: 9999px; background: #4f46e5; width: 0; }

/* ---------- 关联 ---------- */
.reftag {
  color: #4f46e5; background: #eef2ff;
  padding: 1px 7px; border-radius: 6px; font-weight: 500;
  cursor: pointer; word-break: break-all;
}
.ref-box { background: #f8f9ff; border: 1px solid #e0e7ff; border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; }
.ref-title { font-size: 12px; font-weight: 600; color: #4f46e5; margin-bottom: 8px; }
.ref-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 0; font-size: 13px;
  border-bottom: 1px solid #eef0f3;
}
.ref-item:last-child { border-bottom: none; }
.note-block { margin-top: 12px; padding-top: 12px; border-top: 1px solid #eef0f3; }

/* ---------- # 自动补全 ---------- */
.autocomplete {
  position: fixed;
  z-index: 60;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(17, 24, 39, .14);
  max-height: 260px;
  overflow-y: auto;
  display: none;
  padding: 4px 0;
}
.autocomplete.open { display: block; }
.ac-item {
  padding: 10px 12px;
  font-size: 14px;
  color: #374151;
  cursor: pointer;
  word-break: break-all;
}
.ac-item:hover, .ac-item.ac-active { background: #eef2ff; color: #4f46e5; }

/* ---------- 跟进记录时间线 ---------- */
.diary-day .card-date { margin-bottom: 10px; }
.timeline { padding-top: 2px; }
.tl-item {
  display: flex;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid #f3f4f6;
}
.tl-item:last-child { border-bottom: none; }
.tl-time {
  flex-shrink: 0;
  width: 46px;
  font-size: 12px;
  color: #9ca3af;
  padding-top: 2px;
  font-variant-numeric: tabular-nums;
}
.tl-body { flex: 1; min-width: 0; }
.tl-task {
  font-size: 13px;
  font-weight: 600;
  color: #4f46e5;
  margin-right: 6px;
}
.tl-content {
  font-size: 14px;
  color: #374151;
  margin-top: 2px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.6;
}

/* ---------- 提醒卡片 ---------- */
.remind-card { display: flex; align-items: center; gap: 10px; }
.remind-card.danger { border-color: #fecaca; }
.remind-card .task-body { flex: 1; }

/* ---------- 报告 ---------- */
.report-actions { display: flex; justify-content: flex-end; gap: 8px; margin: 14px 0 8px; }
.report-md {
  background: #111827; color: #e5e7eb;
  border-radius: 12px; padding: 16px;
  font-size: 13px; line-height: 1.7;
  white-space: pre-wrap; word-break: break-word;
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ---------- 筛选 / 分页 ---------- */
.filter-bar { display: flex; gap: 8px; margin-bottom: 12px; }
.filter-select { flex: 1; min-width: 0; }
.summary-line { font-size: 13px; color: #6b7280; margin-bottom: 10px; }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 16px 0 4px; }
.pagination-info { font-size: 12px; color: #9ca3af; }
.pagination-btns { display: flex; gap: 8px; }
.pill-disabled { opacity: .45; pointer-events: none; }

/* ---------- Flash / Toast ---------- */
.flash { padding: 10px 14px; border-radius: 10px; font-size: 13px; margin-bottom: 12px; }
.flash-ok { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.flash-err { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
#toast {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%);
  background: #111827; color: #fff; padding: 10px 18px;
  border-radius: 8px; font-size: 14px; z-index: 99;
  opacity: 0; transition: opacity .2s; pointer-events: none;
}
#toast.show { opacity: 1; }

/* ---------- 桌面端（≥1024px）：左侧栏导航，隐藏移动端顶栏/底栏 ---------- */
@media (min-width: 1024px) {
  .app-body { flex-direction: row; }
  .app-header { display: none; }
  .bottom-nav { display: none; }
  .app-main { max-width: 860px; padding: 32px 40px 48px; }

  .sidebar {
    display: flex; flex-direction: column;
    width: 232px; flex-shrink: 0;
    background: #fff; border-right: 1px solid #eef0f3;
    position: sticky; top: 0; height: 100vh;
  }
  .sidebar-logo { font-size: 20px; font-weight: 700; color: #4f46e5; padding: 24px 22px 18px; }
  .sidebar-nav { flex: 1; padding: 8px 12px; display: flex; flex-direction: column; gap: 4px; }
  .side-item {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 12px; border-radius: 8px; font-size: 14px; color: #6b7280;
    transition: background .12s, color .12s;
  }
  .side-item:hover { background: #f6f7f9; color: #374151; }
  .side-item-on { background: #eef2ff; color: #4f46e5; font-weight: 600; }
  .side-item-on:hover { background: #e0e7ff; color: #4f46e5; }
  .side-icon { font-size: 16px; line-height: 1; }
  .side-label { flex: 1; }
  .side-badge {
    background: #ef4444; color: #fff; font-size: 11px;
    min-width: 18px; height: 18px; line-height: 18px; text-align: center;
    border-radius: 9px; padding: 0 5px;
  }
  .sidebar-foot { padding: 14px 20px; border-top: 1px solid #eef0f3; }
  .sidebar-user { font-size: 14px; font-weight: 600; color: #374151; margin-bottom: 6px; }

  /* 桌面 hover 反馈 */
  .card { transition: border-color .12s, box-shadow .12s; }
  .card:hover { border-color: #e0e7ff; box-shadow: 0 2px 8px rgba(17,24,39,.05); }
  .btn-primary:hover { background: #4338ca; }
  .btn-ghost:hover { background: #e5e7eb; }
  .btn-danger:hover { background: #fee2e2; }
  .btn-success:hover { background: #15803d; }
  .pill:hover { background: #e5e7eb; }
  .pill-on:hover { background: #4338ca; }
  .check-btn:hover { background: #e0e7ff; }
  .ref-item:hover { background: #f0f4ff; }
}
