:root {
  --bg: #f6f9fc;
  --surface: #ffffff;
  --surface-soft: #eef6fb;
  --line: #d8e4ee;
  --text: #203244;
  --muted: #6b7c8f;
  --primary: #3978a8;
  --primary-deep: #245f89;
  --accent: #8ecae6;
  --ok: #2f9e7e;
  --warn: #cf8f2f;
  --danger: #c65d5d;
  --shadow: 0 12px 30px rgba(55, 87, 112, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
}

button,
select,
input {
  font: inherit;
}

.app-shell {
  max-width: 1480px;
  margin: 0 auto;
  padding: 22px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.2;
}

h2 {
  font-size: 20px;
}

h3 {
  font-size: 16px;
}

.top-actions,
.filters,
.tabs {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.file-button,
.ghost-button,
.tab {
  min-height: 38px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  padding: 9px 14px;
  border-radius: 8px;
  cursor: pointer;
}

.ghost-button.small {
  min-height: 32px;
  padding: 6px 10px;
}

.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
}

.file-button.secondary {
  background: #4f9f8d;
  border-color: #4f9f8d;
}

.file-button.compact {
  min-height: 34px;
  padding: 7px 12px;
}

.file-button input {
  display: none;
}

.ghost-button:hover,
.tab:hover {
  border-color: var(--primary);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.metric-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 15px 16px;
  box-shadow: var(--shadow);
}

.metric-card span {
  display: block;
  color: var(--muted);
  margin-bottom: 8px;
}

.metric-card strong {
  display: block;
  font-size: 24px;
  color: var(--primary-deep);
}

.tabs {
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.tab {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.tab.active {
  background: var(--surface-soft);
  color: var(--primary-deep);
  border-color: #b9d8eb;
  font-weight: 700;
}

.panel {
  display: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.panel.active {
  display: block;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.panel-header p {
  color: var(--muted);
  margin-top: 5px;
}

label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

select {
  height: 34px;
  min-width: 132px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0 10px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #e8f3fa;
  color: #24445f;
  font-weight: 700;
}

tbody tr:hover {
  background: #f7fbfd;
}

.num {
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.photo-cell {
  width: 78px;
}

.thumb {
  display: block;
  margin: 0 auto;
  width: 56px;
  height: 42px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #f4f8fb;
}

.status {
  display: inline-flex;
  align-items: center;
  min-width: 58px;
  justify-content: center;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 700;
}

.status.shipped,
.status.good {
  color: #166f59;
  background: #e3f5ef;
}

.status.pending,
.status.warn {
  color: #8a5d1f;
  background: #fff3d7;
}

.status.danger {
  color: #9a3f3f;
  background: #fde8e8;
}

.factory-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 14px;
}

.insight-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfdff;
}

.bars {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.bar-row span {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 5px;
}

.bar-track {
  height: 10px;
  background: #e6eef5;
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--primary));
}

.upload-note {
  border: 1px dashed #a7cce2;
  background: #f1f8fc;
  color: var(--primary-deep);
  border-radius: 8px;
  padding: 11px 12px;
  margin-bottom: 12px;
}

.data-status {
  border: 1px solid #b9d8eb;
  background: #eaf5fb;
  color: var(--primary-deep);
  border-radius: 8px;
  padding: 11px 12px;
  margin: -4px 0 12px;
  font-weight: 700;
}

.data-status.demo {
  border-color: #e1b96a;
  background: #fff8e8;
  color: #7d5818;
}

.data-status.empty {
  border-color: var(--line);
  background: #fff;
  color: var(--muted);
}

.price-lock {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  border: 1px solid #edd39a;
  background: #fff9ea;
  color: #7d5818;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.price-lock.unlocked {
  border-color: #a9d8c9;
  background: #eefaf6;
  color: #166f59;
}

.price-lock input {
  height: 32px;
  width: 120px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
}

.price-lock em {
  color: var(--danger);
  font-style: normal;
}

.price-lock.unlocked em {
  color: #166f59;
}

.masked-value {
  color: var(--muted);
  font-weight: 700;
}

.photo-note {
  margin-top: -6px;
  margin-bottom: 16px;
}

.photo-note.warning {
  border-color: #e1b96a;
  background: #fff8e8;
  color: #7d5818;
}

.merchant-detail {
  max-width: 340px;
  white-space: normal;
  line-height: 1.45;
}

.empty-state,
.empty-chart {
  color: var(--muted);
  text-align: center;
}

.empty-state {
  padding: 28px 12px;
}

.empty-chart {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 24px 12px;
  background: #f7fbfd;
}

@media (max-width: 900px) {
  .app-shell {
    padding: 14px;
  }

  .topbar,
  .panel-header {
    align-items: stretch;
    flex-direction: column;
  }

  .metric-grid,
  .factory-layout {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 23px;
  }
}
