/* 客如云月报 — 最初版暖色账本 UI */
:root {
  --bg: #f7f5f2;
  --surface: #ffffff;
  --ink: #1c1917;
  --muted: #78716c;
  --faint: #a8a29e;
  --border: #e7e5e4;
  --border-strong: #d6d3d1;
  --accent: #e24b28;
  --accent-soft: #fde8e2;
  --accent-deep: #c2410c;
  --green: #16a34a;
  --green-soft: #dcfce7;
  --amber: #d97706;
  --amber-soft: #fef3c7;
  --red: #dc2626;
  --red-soft: #fee2e2;
  --blue: #2563eb;
  --blue-soft: #dbeafe;
  --teal: #0f766e;
  --shadow: 0 1px 2px rgba(28, 25, 23, 0.04), 0 8px 24px rgba(28, 25, 23, 0.06);
  --radius: 14px;
  --radius-sm: 10px;
  --font: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: var(--accent-deep); text-decoration: none; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(247, 245, 242, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(145deg, var(--accent), var(--accent-deep));
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 15px;
  box-shadow: 0 6px 16px rgba(226, 75, 40, 0.28);
}

.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-title { font-size: 16px; font-weight: 650; line-height: 1.2; }
.brand-sub { font-size: 11px; color: var(--muted); }

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.month-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-weight: 500;
}
.month-pill input {
  border: none;
  background: transparent;
  outline: none;
  font-weight: 600;
  width: 8.5em;
}
/* 键盘操作时让顶栏的账期 / 门店 / 已上传有可见焦点 */
.month-pill:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(226, 75, 40, 0.16);
}
.month-pill input:focus-visible,
.month-pill select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}
.month-pill select {
  border: none;
  background: transparent;
  outline: none;
  font-weight: 600;
  max-width: 9em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.store-pill select { width: 9em; }
.history-pill select { width: 8.5em; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: 10px;
  font-weight: 550;
  border: 1px solid transparent;
  transition: transform 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 6px 16px rgba(226, 75, 40, 0.22);
}
.btn-primary:hover { background: var(--accent-deep); }
.btn-ghost {
  background: var(--surface);
  border-color: var(--border);
}
.btn-ghost:hover { background: #fafaf9; border-color: var(--border-strong); }
.btn-soft {
  background: var(--accent-soft);
  color: var(--accent-deep);
}
.btn-sm { padding: 6px 10px; font-size: 12px; border-radius: 8px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 24px 64px;
}

.section { margin-bottom: 28px; }

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.section-title {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: 0.01em;
}
.section-desc {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* hero */
.hero {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 16px;
}
.hero-main {
  padding: 22px 24px;
  background:
    radial-gradient(circle at 100% 0%, rgba(226, 75, 40, 0.08), transparent 42%),
    var(--surface);
}
.hero h1 {
  margin: 0 0 8px;
  font-size: 26px;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.hero h1 em { font-style: normal; color: var(--accent); }
.hero p { margin: 0 0 18px; color: var(--muted); max-width: 36em; }

.dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 18px;
  background: #fafaf9;
}
.dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.dropzone-title { font-weight: 600; margin-bottom: 4px; }
.dropzone-hint { color: var(--muted); font-size: 12px; margin-bottom: 12px; }
.dropzone-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.file-input { display: none; }

.hero-side { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.hero-side h2 { margin: 0; font-size: 14px; font-weight: 650; }
.data-list { display: flex; flex-direction: column; gap: 8px; }
.data-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #fafaf9;
}
.data-item .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.data-item .dot.empty { background: var(--border-strong); }
.data-item .dot.ok {
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.15);
}
.data-item .meta { flex: 1; min-width: 0; }
.data-item .name { font-weight: 600; font-size: 13px; }
.data-item .count { color: var(--muted); font-size: 12px; }

/* KPI */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}
.kpi { padding: 18px 18px 16px; position: relative; overflow: hidden; }
.kpi::after {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--border);
}
.kpi.accent::after { background: var(--accent); }
.kpi.teal::after { background: var(--teal); }
.kpi.red::after { background: var(--red); }
.kpi.green::after { background: var(--green); }
.kpi.amber::after { background: var(--amber); }
.kpi.blue::after { background: var(--blue); }
.kpi-label { color: var(--muted); font-size: 12px; font-weight: 550; }
.kpi-value {
  margin-top: 6px;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}
.kpi-value.positive { color: var(--green); }
.kpi-value.negative { color: var(--red); }
.kpi-foot { margin-top: 6px; color: var(--muted); font-size: 12px; }
.kpi.highlight .kpi-value { animation: pop 0.55s ease; }
@keyframes pop {
  0% { transform: translateY(6px); opacity: 0.4; }
  100% { transform: none; opacity: 1; }
}

.two-col {
  display: grid;
  grid-template-columns: 0.95fr 1.05fr;
  gap: 16px;
  align-items: start;
}

.panel { padding: 18px 18px 16px; }
.panel-title { margin: 0 0 4px; font-size: 15px; font-weight: 650; }
.panel-sub { margin: 0 0 16px; color: var(--muted); font-size: 12px; }

.donut-wrap {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 16px;
  align-items: center;
}
.donut { width: 180px; height: 180px; }
.legend { display: flex; flex-direction: column; gap: 8px; }
.legend-row {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  gap: 8px;
  align-items: center;
  font-size: 13px;
}
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; }
.legend-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.legend-val {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 12px;
}

.advice-list { display: flex; flex-direction: column; gap: 10px; }
.advice-item {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #fff;
}
.advice-item.warn { border-color: #fcd9a8; background: #fffdf7; }
.advice-item.good { border-color: #bbf7d0; background: #f7fff9; }
.advice-item.risk { border-color: #fecaca; background: #fffbfb; }
.advice-item.info { border-color: var(--border); background: #fafaf9; }
.advice-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 700;
}
.advice-item.warn .advice-icon { background: var(--amber-soft); color: var(--amber); }
.advice-item.good .advice-icon { background: var(--green-soft); color: var(--green); }
.advice-item.risk .advice-icon { background: var(--red-soft); color: var(--red); }
.advice-item.info .advice-icon { background: #f5f5f4; color: var(--muted); }
.advice-title { font-weight: 650; font-size: 13px; margin-bottom: 2px; }
.advice-body { color: var(--muted); font-size: 12.5px; line-height: 1.55; }

.ratio-list { display: flex; flex-direction: column; gap: 12px; }
.ratio-row {
  display: grid;
  grid-template-columns: 88px 1fr 64px;
  gap: 10px;
  align-items: center;
}
.ratio-name { font-size: 12px; color: var(--muted); }
.ratio-track {
  height: 8px;
  border-radius: 999px;
  background: #f0eeec;
  overflow: hidden;
}
.ratio-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  width: 0;
  transition: width 0.6s ease;
}
.ratio-fill.green { background: var(--green); }
.ratio-fill.amber { background: var(--amber); }
.ratio-fill.blue { background: var(--blue); }
.ratio-fill.red { background: var(--red); }
.ratio-val {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  font-weight: 600;
}

/* table */
.table-wrap {
  overflow-x: auto !important;
  overflow-y: auto;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  -webkit-overflow-scrolling: touch;
}
table.data {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  min-width: 0;
}
table.data th,
table.data td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
table.data th {
  background: #fafaf9;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  position: sticky;
  top: 0;
}
table.data tr:last-child td { border-bottom: none; }
table.data td.num,
table.data th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
table.data tbody tr:hover td { background: #fafaf9; }
table.data .ellip,
table.data td:last-child { max-width: 0; }

.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: #f5f5f4;
  color: var(--muted);
}
.tag.red { background: var(--red-soft); color: var(--red); }
.tag.green { background: var(--green-soft); color: var(--green); }
.tag.amber { background: var(--amber-soft); color: var(--amber); }
.tag.blue { background: var(--blue-soft); color: var(--blue); }

.tabs {
  display: inline-flex;
  padding: 3px;
  background: #efece8;
  border-radius: 10px;
  gap: 2px;
}
.tab {
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.tab.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(28, 25, 23, 0.08);
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 8px 4px;
}
.pager-info {
  font-size: 12px;
  color: var(--muted);
  padding: 0 6px;
  font-variant-numeric: tabular-nums;
}

.empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.empty strong {
  display: block;
  color: var(--ink);
  margin-bottom: 4px;
}

.summary-line {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: #fafaf9;
  border: 1px solid var(--border);
  margin-bottom: 14px;
  font-size: 13px;
  line-height: 1.7;
}
.summary-line strong { color: var(--accent-deep); }

.report-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 12px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: #fff;
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 550;
  box-shadow: 0 12px 32px rgba(28, 25, 23, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 100;
  max-width: min(90vw, 480px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--red); }

.foot-note {
  margin-top: 28px;
  color: var(--faint);
  font-size: 12px;
  text-align: center;
}

.paste-box {
  width: 100%;
  min-height: 120px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  resize: vertical;
  outline: none;
  background: #fff;
}
.paste-panel { display: none; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.paste-panel.open { display: block; }
.paste-row { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }

/* print */
.print-only { display: none; }
.print-cover { display: none; }
.print-title {
  margin: 8px 0 6px;
  font-size: 13px;
  font-weight: 700;
}
.print-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
}
.print-table th,
.print-table td {
  font-size: 10px;
  line-height: 1.25;
  padding: 2px 4px;
  border-bottom: 1px solid #eee;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.print-table th {
  background: #fafaf9;
  font-weight: 650;
  color: #555;
}
.print-table .c-num { width: 28px; color: #aaa; }
.print-table .c-date { width: 56px; }
.print-table .c-amt { width: 72px; font-variant-numeric: tabular-nums; }
.print-table .c-note { width: 88px; color: #888; }
.print-table tr {
  break-inside: avoid;
  page-break-inside: avoid;
}

@media print {
  .topbar,
  .hero,
  .no-print,
  .toast,
  .pager,
  .tabs {
    display: none !important;
  }
  .screen-only,
  #detailTableWrap {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    overflow: hidden !important;
  }
  .print-only {
    display: block !important;
    visibility: visible !important;
    height: auto !important;
    overflow: visible !important;
  }
  body { background: #fff; font-size: 11px; }
  .main { padding: 0; max-width: none; }
  .card {
    box-shadow: none;
    border-color: #e5e5e5;
    break-inside: auto;
    border-radius: 8px;
  }
  .print-cover {
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 90vh;
    page-break-after: always;
    break-after: page;
    text-align: center;
    padding: 30px 16px;
  }
  .cover-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
  .cover-logo {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    background: var(--accent);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 24px;
    font-weight: 700;
  }
  .cover-name { font-size: 16px; font-weight: 700; text-align: left; }
  .cover-sub { font-size: 11px; color: #666; text-align: left; }
  .cover-title { font-size: 28px; margin: 6px 0 10px; letter-spacing: -0.02em; }
  .cover-store { font-size: 14px; color: #444; margin-bottom: 22px; }
  .cover-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 20px;
    width: min(480px, 92%);
    margin: 0 auto 28px;
    text-align: left;
  }
  .cover-grid .item {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid #eee;
    padding: 5px 0;
    font-size: 12px;
  }
  .cover-grid .item .v {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
  }
  .cover-foot { margin-top: auto; font-size: 10px; color: #888; }
  .section { margin-bottom: 10px; }
  .section-title {
    font-size: 13px;
    border-left: 3px solid #e24b28;
    padding-left: 6px;
    margin-top: 6px;
    break-after: avoid;
    page-break-after: avoid;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .section-head,
  .panel-title {
    break-after: avoid;
    page-break-after: avoid;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .section-desc { display: none; }
  .panel, .kpi { padding: 10px 12px; }
  .kpi-value { font-size: 18px !important; }
  .advice-body { font-size: 10px; line-height: 1.45; }
  .two-col { display: block !important; }
  .two-col > .card {
    margin-bottom: 8px;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .kpi-grid {
    break-inside: avoid;
    page-break-inside: avoid;
    margin-bottom: 8px;
    gap: 8px;
  }
  /* 每个模块从新页顶部开始 */
  .print-cover ~ .section {
    break-before: page;
    page-break-before: always;
  }
  .print-cover ~ .section:first-of-type {
    break-before: auto;
    page-break-before: auto;
  }
  .print-last {
    break-before: page;
    page-break-before: always;
  }
  .print-last .section-title { margin-top: 0; margin-bottom: 8px; }
  /* AI 经营诊断：打印时整块展开、去交互态，标题与正文保持可读字号 */
  #aiQuickSection,
  #aiStale {
    display: none !important;
  }
  .ai-panel {
    background: #fff !important;
    box-shadow: none !important;
    border-color: #e5e5e5 !important;
  }
  .ai-mark { background: #f1efec !important; color: #1f1b16 !important; }
  .ai-report.is-collapsed .ai-card-body { display: block !important; }
  .ai-grid { gap: 9px; }
  .ai-card {
    background: #fff !important;
    border-color: #e5e5e5 !important;
    box-shadow: none !important;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .ai-card-body { font-size: 10.5px; line-height: 1.65; }
  .ai-card-title { font-size: 11.5px; }
  .ai-card-no { background: #f1efec !important; color: #8a5a12 !important; }
  .ai-meta { font-size: 9.5px; border-top-color: #e5e5e5; }
}

@page { size: A4; margin: 12mm 10mm 14mm; }

@media (max-width: 920px) {
  .hero, .two-col { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .donut-wrap { grid-template-columns: 1fr; justify-items: center; }
}

@media (max-width: 560px) {
  .topbar-inner, .main { padding-left: 14px; padding-right: 14px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .hero h1 { font-size: 22px; }
  .kpi-value { font-size: 21px; }
}

/* 明细表：日期完整显示，略缩字号、加宽日期列 */
#detailTableWrap table.data {
  font-size: 11px;
}
#detailTableWrap table.data th,
#detailTableWrap table.data td {
  padding: 8px 8px;
  font-size: 11px;
}
#detailTableWrap table.data th:nth-child(1),
#detailTableWrap table.data td:nth-child(1) {
  width: 22%;
  min-width: 22%;
}
#detailTableWrap table.data th:nth-child(2),
#detailTableWrap table.data td:nth-child(2) {
  width: 12%;
}
#detailTableWrap table.data th:nth-child(3),
#detailTableWrap table.data td:nth-child(3) {
  width: 28%;
}
#detailTableWrap table.data th:nth-child(4),
#detailTableWrap table.data td:nth-child(4) {
  width: 18%;
}
#detailTableWrap table.data th:nth-child(5),
#detailTableWrap table.data td:nth-child(5) {
  width: 20%;
}

/* 敏感 / 对账表也略小字，避免截断 */
#detailTableWrap table.data td {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- 登录用户 / 门店权限 ---------- */
[hidden] { display: none !important; }

.user-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 8px;
  border-left: 1px solid var(--border);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-deep);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 12px;
}

.user-meta { display: flex; flex-direction: column; line-height: 1.15; }
.user-name {
  font-size: 12px;
  font-weight: 650;
  max-width: 9em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-role { font-size: 10px; color: var(--muted); }

.store-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.store-grid:empty { display: none; }

.store-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  background: var(--surface);
}
.store-card h3 { margin: 0 0 4px; font-size: 14px; }
.store-address { color: var(--muted); font-size: 12px; min-height: 18px; }
.store-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
  font-size: 11px;
  color: var(--muted);
}
.store-badge {
  background: var(--accent-soft);
  color: var(--accent-deep);
  border-radius: 999px;
  padding: 2px 8px;
  font-weight: 600;
}

@media (max-width: 920px) {
  .user-area { border-left: 0; padding-left: 0; }
}

@media (max-width: 560px) {
  .topbar-actions { gap: 6px; }
  .user-chip { padding: 3px 6px 3px 3px; }
  .user-meta { display: none; }
}

/* ---------- AI 经营诊断 ---------- */
.ai-panel {
  border-color: #f1dccd;
  background:
    radial-gradient(1200px 240px at 100% -10%, rgba(226, 75, 40, 0.06), transparent 60%),
    var(--surface);
}
.ai-title { display: flex; align-items: center; gap: 8px; }
.ai-mark {
  display: inline-grid;
  place-items: center;
  padding: 2px 7px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--accent), var(--amber));
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.6px;
}
.ai-head { align-items: flex-start; }
.ai-head .page-actions { width: auto; }

.ai-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 26px 16px 22px;
  text-align: center;
}
.ai-empty-mark {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-size: 20px;
}
.ai-empty-title { font-size: 15px; }
.ai-empty-desc {
  margin: 0;
  max-width: 520px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.65;
}
.ai-generate-btn {
  min-height: 46px;
  padding: 12px 26px;
  margin-top: 2px;
  border-radius: 12px;
  font-size: 14.5px;
}
.ai-generate-btn[disabled] { opacity: 0.72; cursor: not-allowed; box-shadow: none; transform: none; }
.ai-empty-hint { font-size: 11.5px; color: var(--faint); }

.ai-loading { display: flex; align-items: center; gap: 14px; padding: 22px 6px; }
.ai-loading strong { display: block; font-size: 13.5px; }
.ai-loading p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.ai-spinner {
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 3px solid var(--accent-soft);
  border-top-color: var(--accent);
  animation: ai-spin 0.8s linear infinite;
}
@keyframes ai-spin { to { transform: rotate(360deg); } }

.ai-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.ai-card {
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fffdfb;
}
.ai-card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.ai-card-no {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-size: 12px;
  font-weight: 700;
}
.ai-card-title { font-size: 13.5px; font-weight: 700; }
.ai-card-body {
  color: var(--ink);
  font-size: 12.5px;
  line-height: 1.7;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.ai-card-body p { margin: 0 0 6px; }
.ai-card-body p:last-child { margin-bottom: 0; }
.ai-card-body ul { margin: 0 0 6px; padding-left: 18px; }
.ai-card-body li { margin-bottom: 4px; }
.ai-card-body strong { font-weight: 650; }
.ai-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  color: var(--muted);
  font-size: 11.5px;
}

/* AI 诊断：头部操作、折叠、成本变更提醒、仪表盘快捷入口 */
.ai-head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ai-report.is-collapsed .ai-card-body { display: none; }
.ai-report.is-collapsed .ai-grid { gap: 10px; }
.ai-stale {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid #fcd9a8;
  border-radius: var(--radius-sm);
  background: #fffdf7;
  color: #8a5a12;
  font-size: 12.5px;
  line-height: 1.6;
}
.ai-stale-text { font-weight: 650; }
.ai-quick-card { display: grid; gap: 12px; }
.ai-quick-head { display: flex; align-items: center; gap: 10px; }
.ai-quick-text {
  margin: 0;
  color: var(--ink);
  font-size: 13.5px;
  line-height: 1.75;
  overflow-wrap: anywhere;
}
.ai-quick-text.is-empty { color: var(--muted); }
.ai-quick-foot { color: var(--muted); font-size: 11.5px; line-height: 1.6; }

@media (max-width: 767px) {
  .ai-quick-card .panel-head-row { flex-wrap: wrap; gap: 10px; }
  .ai-quick-card .page-actions { margin-left: 0; }
}

@media (max-width: 980px) {
  .ai-grid { grid-template-columns: 1fr; }
}

@media (max-width: 767px) {
  .ai-head { flex-wrap: wrap; gap: 8px; }
  .ai-head .page-actions { margin-left: 0; }
}

@media (max-width: 560px) {
  .ai-panel { padding: 14px 12px 12px; }
  .ai-empty { padding: 18px 4px; }
  .ai-empty-desc { font-size: 12.5px; }
  .ai-generate-btn { width: 100%; min-height: 48px; font-size: 15px; }
  .ai-card { padding: 12px 13px; }
  .ai-card-body { font-size: 13px; line-height: 1.75; }
  .ai-loading { align-items: flex-start; }
  .ai-meta { font-size: 11px; }
}

/* ---------- 手机端 / 微信内置浏览器 ---------- */
* { -webkit-tap-highlight-color: transparent; }
@media (max-width: 767px) {
  /* 输入框 ≥16px，避免 iOS 聚焦时页面自动放大 */
  input,
  select,
  textarea { font-size: 16px; }
  /* 底部安全区（iPhone 刘海屏 / 微信底部栏） */
  body { padding-bottom: env(safe-area-inset-bottom, 0px); }
}
