*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  background: #d8d8d8;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.app {
  width: 100%;
  max-width: 680px;
}

/* ── Card ── */
.card {
  background: #f2f2f2;
  border-radius: 12px;
  padding: 36px 40px 32px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.12);
}

.card.wide {
  max-width: 820px;
  width: 100%;
}

/* ── Screen visibility ── */
.screen { display: none; }
.screen.active { display: block; }

/* ── Header ── */
.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 32px;
}

.card-header h1 {
  font-size: 28px;
  font-weight: 700;
  color: #111;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #0057A8;
  font-size: 13px;
  font-weight: 600;
}

/* ── Upload ── */
.upload-area {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.upload-label {
  font-size: 13px;
  color: #444;
  font-weight: 500;
}

.file-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.file-input-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 6px;
  padding: 9px 14px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.file-input-wrap:hover { border-color: #4A9EE8; }

.file-input-wrap span {
  font-size: 13px;
  color: #555;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-input-wrap input[type="file"] { display: none; }

.file-hint {
  font-size: 11px;
  color: #999;
  margin-top: 2px;
}

.error-msg {
  color: #c0392b;
  font-size: 13px;
  margin-top: 8px;
}

/* ── Buttons ── */
.btn {
  padding: 10px 22px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  white-space: nowrap;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary { background: #4A9EE8; color: #fff; }
.btn-primary:hover:not(:disabled) { background: #3a8ed8; }

.btn-danger { background: #E85A5A; color: #fff; }
.btn-danger:hover { background: #d44a4a; }

.btn-upload-new {
  background: #8B6914;
  color: #fff;
  width: 100%;
  margin-top: 14px;
  text-align: center;
}
.btn-upload-new:hover { background: #7a5c10; }

/* ── Preview ── */
.preview-area {
  display: flex;
  justify-content: center;
  margin-bottom: 28px;
}

.preview-area img {
  max-width: 100%;
  max-height: 300px;
  border-radius: 8px;
  object-fit: contain;
  border: 1px solid #ccc;
}

.btn-row {
  display: flex;
  gap: 16px;
  justify-content: center;
}

.btn-row .btn { min-width: 120px; }

/* ── Spinner ── */
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
  vertical-align: middle;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Results ── */
.results-body {
  display: flex;
  gap: 32px;
  align-items: flex-start;
}

.results-left {
  flex: 0 0 auto;
  width: 240px;
}

.results-left img {
  width: 100%;
  border-radius: 8px;
  border: 1px solid #ccc;
  object-fit: contain;
}

.results-right {
  flex: 1;
  min-width: 0;
}

.result-label {
  font-size: 13px;
  color: #333;
  margin-bottom: 12px;
}

.result-label strong {
  color: #0057A8;
}

.chart-wrap {
  height: 180px;
  margin-bottom: 16px;
}

.chart-title {
  font-size: 12px;
  color: #555;
  margin-bottom: 8px;
  font-weight: 500;
}

.bar-wrap {
  height: 200px;
}

.mock-badge {
  background: #fff3cd;
  border: 1px solid #ffc107;
  color: #856404;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 4px;
  margin-bottom: 10px;
  display: inline-block;
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .card { padding: 24px 20px; }
  .results-body { flex-direction: column; }
  .results-left { width: 100%; }
}
