:root {
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #eef2f3;
  color: #172126;
  --panel: #ffffff;
  --line: #d8e1e5;
  --line-soft: #edf1f3;
  --muted: #62727a;
  --ink: #172126;
  --teal: #126d73;
  --blue: #2563eb;
  --green: #16803c;
  --cyan: #0e7490;
  --amber: #b45309;
  --red: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
}

button,
select,
input {
  font: inherit;
}

.app-shell {
  width: min(1360px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 20px 0 32px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgb(15 23 42 / 0.04);
}

.title-block h1,
.panel h2 {
  margin: 0;
  letter-spacing: 0;
}

.title-block h1 {
  font-size: 23px;
  line-height: 1.25;
}

.title-block p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.toolbar-status {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.toolbar-status span,
.sheet-list span {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border: 1px solid #cfdde2;
  border-radius: 999px;
  background: #f7fafb;
  color: #33464e;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

select,
input[type="file"] {
  height: 38px;
  border: 1px solid #cbd7dc;
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  padding: 0 12px;
}

input[type="file"] {
  display: flex;
  align-items: center;
  padding: 7px 10px;
}

button {
  height: 40px;
  border: 0;
  border-radius: 6px;
  background: var(--teal);
  color: #ffffff;
  padding: 0 18px;
  font-weight: 650;
  cursor: pointer;
  box-shadow: 0 1px 2px rgb(18 109 115 / 0.18);
}

button:disabled {
  cursor: wait;
  background: #8aa4aa;
  box-shadow: none;
}

.upload-panel {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  align-items: stretch;
  gap: 14px;
  margin-top: 14px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgb(15 23 42 / 0.04);
}

.file-field {
  position: relative;
  display: grid;
  align-content: center;
  gap: 8px;
  min-width: 0;
  min-height: 112px;
  padding: 16px;
  border: 1px dashed #b8c8cf;
  border-radius: 8px;
  background: #f8fbfb;
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    background 0.15s ease,
    box-shadow 0.15s ease;
}

.file-field:hover,
.file-field.drag-over {
  border-color: var(--teal);
  background: #effafa;
  box-shadow: inset 0 0 0 1px rgb(18 109 115 / 0.14);
}

.file-field.has-file {
  border-style: solid;
  border-color: #8fc3bd;
  background: #f2fbf8;
}

.file-field input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.file-label {
  color: #34464e;
  font-size: 13px;
  font-weight: 650;
}

.file-field strong {
  display: block;
  min-width: 0;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-field small {
  min-height: 16px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.metric,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgb(15 23 42 / 0.04);
}

.metric {
  min-height: 104px;
  padding: 14px 14px 12px;
  border-top-width: 3px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 9px;
  color: var(--ink);
  font-size: clamp(19px, 1.65vw, 26px);
  line-height: 1.08;
  word-break: break-word;
}

.metric small {
  display: block;
  margin-top: 8px;
  color: #7a8990;
  font-size: 12px;
}

.tone-neutral {
  border-top-color: #7c8b92;
}

.tone-blue {
  border-top-color: var(--blue);
}

.tone-green {
  border-top-color: var(--green);
}

.tone-cyan {
  border-top-color: var(--cyan);
}

.tone-douyin {
  border-top-color: #111827;
}

.tone-meituan {
  border-top-color: #f59e0b;
}

.tone-warning {
  border-top-color: var(--red);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.18fr) minmax(360px, 0.82fr);
  gap: 16px;
}

.panel {
  min-width: 0;
  padding: 16px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel h2 {
  font-size: 16px;
}

.status-line {
  min-height: 24px;
  color: #52646c;
  font-size: 14px;
}

.sheet-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.sheet-list span {
  border-color: #d7e1e5;
  background: #f8fbfb;
  color: #31444d;
}

.download-link,
.text-link {
  color: var(--teal);
  font-size: 14px;
  font-weight: 650;
  text-decoration: none;
}

.download-link.disabled,
.text-link.disabled {
  color: #a2adb2;
  pointer-events: none;
}

.stats-table {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 14px;
  margin-top: 14px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-soft);
  color: #243238;
  font-size: 14px;
}

.stat-row span:first-child {
  color: var(--muted);
}

.stat-row span:last-child {
  min-width: 88px;
  text-align: right;
  font-weight: 650;
}

.warning-list {
  max-height: 320px;
  overflow: auto;
  display: grid;
  gap: 8px;
  padding-right: 2px;
}

.warning-list.empty {
  color: var(--muted);
  font-size: 14px;
}

.warning-item {
  padding: 10px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 6px;
}

.warning-item strong {
  display: block;
  color: #7c3e0c;
  font-size: 13px;
}

.warning-item span {
  display: block;
  margin-top: 4px;
  color: #624022;
  font-size: 12px;
  line-height: 1.45;
  word-break: break-all;
}

.preview-panel {
  margin-top: 16px;
}

.preview-panel .panel-head span {
  color: var(--muted);
  font-size: 13px;
}

.preview-frame {
  position: relative;
  min-height: 300px;
  overflow: auto;
  border: 1px solid #d5dde1;
  border-radius: 6px;
  background: #ffffff;
}

.preview-table {
  display: none;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
}

.preview-table th,
.preview-table td {
  max-width: 260px;
  padding: 8px 10px;
  border-right: 1px solid #e6ecef;
  border-bottom: 1px solid #e6ecef;
  color: #243238;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #edf6f5;
  color: #1d373c;
  font-weight: 700;
}

.preview-table tr:nth-child(even) td {
  background: #f9fbfc;
}

.preview-frame.has-preview .preview-table {
  display: table;
}

.preview-frame.has-preview .preview-empty {
  display: none;
}

.preview-empty {
  display: grid;
  min-height: 300px;
  place-items: center;
  color: #7b8b93;
  font-size: 14px;
}

@media (max-width: 1240px) {
  .summary-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .app-shell {
    width: min(100vw - 20px, 760px);
    padding-top: 12px;
  }

  .toolbar,
  .upload-panel {
    align-items: stretch;
  }

  .toolbar {
    display: grid;
  }

  .toolbar-status {
    justify-content: flex-start;
  }

  .upload-panel {
    grid-template-columns: 1fr;
  }

  .file-field {
    min-height: 96px;
  }

  .summary-grid,
  .content-grid,
  .stats-table {
    grid-template-columns: 1fr;
  }
}

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

  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }
}
