:root {
  --bg: #faf8f3;
  --surface: #ffffff;
  --surface-hover: #fbf9f5;
  --ink: #1e293b;
  --ink-secondary: #475569;
  --ink-muted: #64748b;
  --primary: #0d9488;
  --primary-strong: #0f766e;
  --primary-deep: #115e56;
  --amber: #b45309;
  --amber-soft: #fef3c7;
  --red: #dc2626;
  --red-soft: #fef2f2;
  --green-soft: #ecfdf5;
  --border: #e8e4da;
  --border-soft: #f0ecdf;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(30,41,59,0.05), 0 1px 3px rgba(30,41,59,0.07);
  --shadow-md: 0 4px 14px rgba(30,41,59,0.10);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  font-size: 15px;
  padding-bottom: 80px;
  min-height: 100vh;
}
button, input { font-family: inherit; font-size: inherit; }
svg { display: inline-block; vertical-align: middle; }

/* ===== 页头 ===== */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, #ccfbf1, #99f6e4);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--primary-deep);
}
.brand h1 { font-size: 18px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
.brand p { font-size: 12px; color: var(--ink-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ghost-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--ink-secondary);
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 13px;
  white-space: nowrap;
  transition: background 0.2s, border-color 0.2s;
}
.ghost-btn:hover { background: var(--surface-hover); border-color: #d8d2c4; }

/* ===== 布局 ===== */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
@media (min-width: 768px) {
  .container { grid-template-columns: 1fr 1fr; gap: 20px; padding: 24px; }
  .left-col { display: flex; flex-direction: column; gap: 16px; }
  .right-col { position: sticky; top: 84px; align-self: start; }
}

/* ===== 操作区 ===== */
.action-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  border: 1px solid var(--border);
}
.action-buttons { display: flex; flex-wrap: wrap; gap: 10px; }
.action-btn {
  flex: 1 1 calc(33.333% - 8px);
  min-width: 104px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-hover);
  color: var(--ink);
  font-weight: 500;
  transition: transform 0.15s, box-shadow 0.2s;
  min-height: 44px;
}
.action-btn svg { width: 24px; height: 24px; color: var(--primary); }
.action-btn.primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-deep) 100%);
  border-color: var(--primary-deep);
  color: white;
  box-shadow: 0 4px 12px rgba(13,148,136,0.25);
}
.action-btn.primary svg { color: white; }
.action-btn:active { transform: scale(0.97); }

.steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 0;
  font-size: 13px;
  color: var(--ink-secondary);
  flex-wrap: wrap;
}
.step { display: flex; align-items: center; gap: 6px; }
.step-dot {
  width: 22px; height: 22px;
  background: linear-gradient(135deg, #ccfbf1, #99f6e4);
  color: var(--primary-deep);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}
.step-line { width: 24px; height: 1px; background: var(--border); }

/* ===== 空状态 ===== */
.empty-state {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  color: var(--ink-muted);
  box-shadow: var(--shadow);
}
.empty-state svg { width: 48px; height: 48px; color: var(--border); margin-bottom: 12px; display: block; }
.empty-state p { font-size: 14px; }

/* ===== 动态卡片 ===== */
.item-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  transition: box-shadow 0.2s, border-color 0.2s;
  position: relative;
}
.item-card.invalid { border-color: var(--red); box-shadow: 0 0 0 3px rgba(220,38,38,0.1), var(--shadow); }
.card-header { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.thumb {
  width: 48px; height: 48px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg);
  border: 1px solid var(--border);
}
.thumb-placeholder {
  width: 48px; height: 48px;
  border-radius: 8px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-muted);
  flex-shrink: 0;
  border: 1px solid var(--border);
}
.item-info { flex: 1; min-width: 0; }
.batch-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.batch-input {
  flex: 1 1 150px;
  min-width: 0;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: white;
  min-height: 44px;
}
.batch-input:focus { outline: 2px solid rgba(13,148,136,0.18); border-color: var(--primary); }
.retry-btn {
  background: #ccfbf1;
  color: var(--primary-deep);
  border: none;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  min-height: 44px;
}
.retry-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.delete-btn {
  background: transparent;
  border: none;
  color: var(--ink-muted);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 13px;
  min-height: 44px;
}
.delete-btn:active { background: #f8f8f6; }
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 500;
  white-space: nowrap;
}
.error-text { font-size: 13px; color: var(--red); margin-top: 4px; }

/* 内容网格 */
.content-grid { display: grid; grid-template-columns: 1fr; gap: 8px; margin: 12px 0; }
.info-row {
  background: var(--surface-hover);
  padding: 10px 12px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.info-label { font-size: 12px; color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.info-value { font-size: 15px; font-weight: 500; word-break: break-word; }
.info-value.strong { font-size: 16px; font-weight: 600; color: var(--ink); }

/* 有效期 */
.validity-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
}
.details-toggle {
  background: transparent;
  border: none;
  color: var(--primary);
  font-size: 13px;
  font-weight: 500;
  padding: 4px 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
}
.details-panel { display: none; margin-top: 8px; border-top: 1px solid var(--border); padding-top: 12px; }
.details-panel.open { display: block; }
.details-panel h4 { font-size: 13px; color: var(--ink-muted); margin: 8px 0 4px; }
.details-panel p { font-size: 14px; }
.source-link { display: inline-block; margin-right: 8px; color: var(--primary-strong); text-decoration: none; font-size: 13px; }
.source-link:hover { text-decoration: underline; }
.source-link.invalid { color: var(--ink-muted); pointer-events: none; }

/* 用量与项目 */
.inputs-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.input-group { display: flex; flex-direction: column; gap: 4px; }
.input-group label { font-size: 12px; color: var(--ink-muted); font-weight: 500; }
.input-with-unit { display: flex; align-items: center; gap: 6px; }
.input-with-unit input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  min-height: 44px;
}
.input-with-unit select {
  width: 70px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  min-height: 44px;
}
.project-candidates { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.suggestion-chip {
  background: #ccfbf1;
  color: var(--primary-deep);
  border: none;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  white-space: nowrap;
}
.amount-error { font-size: 13px; color: var(--red); margin-top: 4px; }

.item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.item-actions button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 13px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-secondary);
  min-height: 44px;
}
.item-actions button:hover { background: var(--surface-hover); }
.item-actions svg { width: 16px; height: 16px; }

/* ===== 预览卡片 ===== */
.preview-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 16px;
}
.preview-card h2 { font-size: 16px; margin-bottom: 12px; display: flex; align-items: center; gap: 6px; }
.preview-card h2 svg { width: 20px; height: 20px; color: var(--primary); }
.preview-text {
  background: #fbf9f3;
  border-radius: 8px;
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 80px;
  max-height: 240px;
  overflow-y: auto;
  color: var(--ink);
  border: 1px solid var(--border);
}
.global-row { display: flex; gap: 8px; margin-top: 12px; }
.global-row input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  min-height: 44px;
}
#apply-all-project {
  background: #ccfbf1;
  color: var(--primary-deep);
  border: none;
  padding: 0 16px;
  border-radius: 8px;
  font-weight: 500;
  white-space: nowrap;
  min-height: 44px;
}
.share-options {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-secondary);
}
.share-options input { width: 16px; height: 16px; accent-color: var(--primary); }
.notice-area { margin-top: 12px; }

/* ===== 底部固定栏 ===== */
.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  padding: 10px 16px calc(10px + var(--safe-bottom));
  display: flex;
  gap: 12px;
  z-index: 30;
  box-shadow: 0 -2px 10px rgba(30,41,59,0.05);
}
.bottom-btn {
  flex: 1;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-hover);
  color: var(--ink);
  font-weight: 600;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  transition: background 0.2s;
}
.bottom-btn.primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-deep) 100%);
  border-color: var(--primary-deep);
  color: white;
  box-shadow: 0 4px 12px rgba(13,148,136,0.25);
}
.bottom-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.bottom-btn svg { width: 20px; height: 20px; }

/* ===== 示例弹层 ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(30,41,59,0.4);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(2px);
}
.modal-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 20px;
  max-width: 480px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
}
.close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  background: transparent;
  border: none;
  color: var(--ink-muted);
  font-size: 24px;
  line-height: 1;
  padding: 4px;
}
.example-tag {
  display: inline-block;
  background: var(--amber-soft);
  color: var(--amber);
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 12px;
}
.example-content { font-size: 14px; }
.example-content p { margin-bottom: 8px; }
.example-content .label { font-weight: 600; color: var(--ink-secondary); }

/* ===== 状态类 ===== */
.status-badge.pending { background: var(--amber-soft); color: var(--amber); }
.status-badge.recognizing, .status-badge.looking-up { background: #e0f2fe; color: #0369a1; }
.status-badge.done { background: var(--green-soft); color: var(--primary-deep); }
.status-badge.error { background: var(--red-soft); color: var(--red); }
.validity-indicator.validity-valid { background: var(--green-soft); color: #047857; }
.validity-indicator.stopped, .validity-indicator.expired { background: var(--red-soft); color: var(--red); }
.validity-indicator.unknown, .validity-indicator.no_fixed_date, .validity-indicator.pending { background: var(--amber-soft); color: var(--amber); }

/* ===== 禁用/焦点 ===== */
:disabled { cursor: not-allowed; }
:focus-visible {
  outline: 2px solid rgba(13,148,136,0.4);
  outline-offset: 2px;
}
button:focus-visible, input:focus-visible { outline: 2px solid rgba(13,148,136,0.4); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
@media (max-width: 640px) {
  .action-btn { min-width: 90px; font-size: 13px; padding: 12px 6px; }
  .step { font-size: 12px; }
}
