:root {
  --th-red: #c8102e;
  --th-red-dark: #a20d25;
  --th-cream: #f8f3ee;
  --th-soft: #fffaf6;
  --th-brown: #6b3e26;
  --th-text: #2f241f;
  --th-muted: #7a6a61;
  --th-border: #eadfd6;
  --th-card: #ffffff;
  --shadow: 0 10px 24px rgba(107, 62, 38, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, Arial, Helvetica, sans-serif;
  color: var(--th-text);
  background:
    radial-gradient(circle at top right, rgba(200, 16, 46, 0.06), transparent 30%),
    linear-gradient(180deg, #fffdfb 0%, var(--th-cream) 100%);
}

.container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 28px 20px 40px;
}

.hero {
  background: linear-gradient(135deg, #fff 0%, #fff7f1 100%);
  border: 1px solid var(--th-border);
  border-radius: 28px;
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 22px;
}

.hero-top {
  background: linear-gradient(135deg, var(--th-red) 0%, #d71f3e 100%);
  color: #fff;
  padding: 28px 28px 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.2px;
  margin-bottom: 14px;
}

h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.1;
}

.hero-top p {
  margin: 12px 0 0;
  max-width: 850px;
  line-height: 1.6;
  color: rgba(255,255,255,0.92);
  font-size: 15px;
}

.hero-body {
  padding: 22px 28px 28px;
}

.upload-panel {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  margin-bottom: 14px;
}

.file-input-wrap {
  display: flex;
  align-items: center;
  background: var(--th-soft);
  border: 1px dashed #d8c7bb;
  border-radius: 16px;
  padding: 14px;
  min-height: 58px;
}

input[type="file"] {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--th-text);
  font-size: 14px;
}

input[type="file"]::file-selector-button {
  margin-right: 14px;
  border: none;
  border-radius: 12px;
  background: #f1e3d6;
  color: var(--th-brown);
  font-weight: 700;
  padding: 10px 14px;
  cursor: pointer;
}

button {
  border: none;
  border-radius: 16px;
  padding: 0 22px;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  transition: 0.2s ease;
  min-height: 58px;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.primary-btn {
  background: var(--th-red);
  color: #fff;
  box-shadow: 0 10px 20px rgba(200, 16, 46, 0.18);
}

.primary-btn:hover:not(:disabled) {
  background: var(--th-red-dark);
}

.secondary-btn {
  min-height: 44px;
  background: #fff;
  border: 1px solid var(--th-border);
  color: var(--th-brown);
  padding: 0 16px;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.status {
  background: #fffaf8;
  border: 1px solid var(--th-border);
  border-left: 5px solid var(--th-red);
  color: var(--th-muted);
  border-radius: 16px;
  padding: 14px 16px;
  min-height: 54px;
  display: flex;
  align-items: center;
  line-height: 1.5;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--th-card);
  border: 1px solid var(--th-border);
  border-radius: 20px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.stat-label {
  color: var(--th-muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--th-text);
}

.content-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 18px;
}

.card {
  background: var(--th-card);
  border: 1px solid var(--th-border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  padding: 20px 22px;
  border-bottom: 1px solid var(--th-border);
  background: linear-gradient(180deg, #fff, #fffaf7);
}

.card-header h2 {
  margin: 0;
  font-size: 22px;
}

.card-header p {
  margin: 6px 0 0;
  color: var(--th-muted);
  font-size: 14px;
  line-height: 1.5;
}

.card-body {
  padding: 18px;
}

.category-list {
  display: grid;
  gap: 14px;
}

.category {
  border: 1px solid var(--th-border);
  border-radius: 20px;
  background: #fffdfa;
  overflow: hidden;
}

.category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  background: linear-gradient(90deg, #fff8f3 0%, #fff 100%);
  border-bottom: 1px solid var(--th-border);
}

.category-name {
  font-size: 18px;
  font-weight: 800;
  color: var(--th-brown);
}

.category-total {
  font-size: 18px;
  font-weight: 800;
  color: var(--th-red);
  background: #fff1f3;
  border: 1px solid #f3c8d0;
  border-radius: 999px;
  padding: 8px 12px;
  white-space: nowrap;
}

.items {
  padding: 8px 18px 16px;
  display: grid;
  gap: 8px;
}

.item {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 0;
  border-bottom: 1px dashed #e7d8cf;
  font-size: 14px;
}

.item:last-child {
  border-bottom: none;
}

.item-name {
  color: var(--th-text);
  line-height: 1.45;
}

.item-price {
  color: var(--th-brown);
  font-weight: 700;
  white-space: nowrap;
}

.empty-state {
  text-align: center;
  color: var(--th-muted);
  padding: 28px 10px;
  line-height: 1.7;
}

.tip-box {
  background: #fffbf7;
  border: 1px solid var(--th-border);
  color: var(--th-muted);
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 14px;
  line-height: 1.6;
  font-size: 14px;
}

pre {
  margin: 0;
  padding: 16px;
  border-radius: 18px;
  background: #fffaf7;
  border: 1px solid var(--th-border);
  color: #5a4b43;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 720px;
  overflow: auto;
}

.footer-note {
  margin-top: 18px;
  color: var(--th-muted);
  font-size: 13px;
  text-align: center;
}

@media (max-width: 1080px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .content-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .container {
    padding: 16px 12px 28px;
  }

  .hero-top,
  .hero-body {
    padding-left: 18px;
    padding-right: 18px;
  }

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

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .category-header,
  .item {
    align-items: flex-start;
    flex-direction: column;
  }

  .category-total,
  .item-price {
    white-space: normal;
  }
}