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

[hidden] { display: none !important; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: #f5f6fa;
  color: #1a1a2e;
  min-height: 100vh;
  padding: 32px 16px;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  background-color: #ffffff;
  border-radius: 16px;
  padding: 40px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
}

h1 {
  font-size: 26px;
  font-weight: 700;
  color: #1a1a2e;
  margin-bottom: 28px;
  border-bottom: 2px solid #e8eaf0;
  padding-bottom: 14px;
}

/* ── Date ──────────────────────────────────────────── */
.date-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}
.date-row label {
  font-weight: 600;
  font-size: 14px;
  color: #444;
  white-space: nowrap;
}
.date-row input[type="date"] {
  padding: 9px 13px;
  border: 2px solid #d1d5e0;
  border-radius: 8px;
  font-size: 14px;
  color: #1a1a2e;
  background: #fff;
  outline: none;
}
.date-row input[type="date"]:focus { border-color: #4f46e5; }

/* ── Drop zone ─────────────────────────────────────── */
.drop-zone {
  border: 2px dashed #a5b4fc;
  border-radius: 14px;
  background-color: #f5f6ff;
  padding: 52px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s;
  margin-bottom: 20px;
}
.drop-zone:hover,
.drop-zone.drag-over {
  border-color: #4f46e5;
  background-color: #eef0ff;
}
.drop-icon { margin-bottom: 12px; }
.drop-title {
  font-size: 16px;
  font-weight: 600;
  color: #1a1a2e;
  margin-bottom: 6px;
}
.drop-sub {
  font-size: 13px;
  color: #9ca3af;
}

/* ── Thumbnails ────────────────────────────────────── */
.thumb-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
  align-items: flex-end;
}
.thumb-item {
  position: relative;
  width: 90px;
  height: 90px;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid #e8eaf0;
  background: #f0f1f8;
  flex-shrink: 0;
}
.thumb-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.thumb-remove {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(239,68,68,0.9);
  color: #fff;
  border: none;
  font-size: 13px;
  line-height: 20px;
  text-align: center;
  cursor: pointer;
  padding: 0;
}
.thumb-name {
  display: none;
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  font-size: 9px;
  color: #444;
  background: rgba(255,255,255,0.85);
  text-align: center;
  padding: 2px 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.thumb-no-preview {
  display: flex;
  align-items: center;
  justify-content: center;
}
.thumb-no-preview .thumb-name {
  display: flex;
  align-items: center;
  justify-content: center;
  position: static;
  font-size: 10px;
  background: none;
  color: #6b7280;
  padding: 6px;
  text-align: center;
  word-break: break-all;
  height: 100%;
}
.thumb-count {
  font-size: 12px;
  color: #6b7280;
  padding: 4px 0 0 2px;
  align-self: flex-end;
}

/* ── Submit ─────────────────────────────────────────── */
.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 14px;
  background-color: #4f46e5;
  color: #ffffff;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s, opacity 0.2s;
}
.btn-primary:hover:not(:disabled) { background-color: #4338ca; }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }

.spinner {
  width: 17px;
  height: 17px;
  border: 3px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Error ──────────────────────────────────────────── */
.error-box {
  margin-top: 18px;
  padding: 13px 16px;
  background-color: #fff0f0;
  border: 2px solid #f87171;
  border-radius: 10px;
  color: #b91c1c;
  font-size: 14px;
  font-weight: 500;
}

/* ── Progress ───────────────────────────────────────── */
.progress-wrap {
  margin-top: 24px;
}
.progress-bar-outer {
  height: 8px;
  background: #e8eaf0;
  border-radius: 99px;
  overflow: hidden;
}
.progress-bar-inner {
  height: 100%;
  background: linear-gradient(90deg, #4f46e5, #7c3aed);
  border-radius: 99px;
  transition: width 0.3s ease;
  width: 0%;
}
.progress-text {
  margin-top: 8px;
  font-size: 13px;
  color: #6b7280;
}

/* ── Results header ─────────────────────────────────── */
#resultsSection { margin-top: 36px; }
.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 10px;
}
.results-header h2 {
  font-size: 19px;
  font-weight: 700;
}
.export-row {
  display: flex;
  gap: 8px;
}
.btn-export {
  padding: 9px 18px;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn-xml { background-color: #0ea5e9; }
.btn-xml:hover { background-color: #0284c7; }
.btn-xls { background-color: #10b981; }
.btn-xls:hover { background-color: #059669; }

/* ── Meter cards ─────────────────────────────────────── */
.meter-card {
  display: flex;
  gap: 16px;
  border: 2px solid #e8eaf0;
  border-radius: 12px;
  margin-bottom: 12px;
  overflow: hidden;
  background: #fafbff;
  transition: border-color 0.2s;
}

.card-ok   { border-left: 5px solid #10b981; }
.card-warn { border-left: 5px solid #f59e0b; background: #fffef5; }
.card-error { border-left: 5px solid #ef4444; background: #fff8f8; }
.card-processing { opacity: 0.7; }

/* Thumbnail */
.card-thumb {
  width: 150px;
  min-width: 150px;
  background: #f0f1f8;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: zoom-in;
}
.card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.card-no-img {
  width: 100%;
  height: 100%;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: #9ca3af;
  text-align: center;
  padding: 8px;
  word-break: break-all;
}

/* Spinner inside card */
.card-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #d1d5e0;
  border-top-color: #4f46e5;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Card body */
.card-body {
  flex: 1;
  padding: 14px 16px 14px 4px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.card-filename {
  font-size: 12px;
  color: #9ca3af;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-loading {
  font-size: 13px;
  color: #6b7280;
  font-style: italic;
}

/* Status badge */
.card-status {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 5px;
  display: inline-block;
  align-self: flex-start;
}
.card-status-ok   { background: #d1fae5; color: #065f46; }
.card-status-warn { background: #fef3c7; color: #92400e; }
.card-status-err  { background: #fee2e2; color: #991b1b; }

/* Fields grid */
.card-fields {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

@media (max-width: 600px) {
  .meter-card { flex-direction: column; }
  .card-thumb { width: 100%; min-width: unset; height: 180px; cursor: default; }
  .card-body  { padding: 12px; }
  .card-fields { grid-template-columns: 1fr 1fr; }
}

/* Field label + input */
.fl {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.fl > span {
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.fi {
  padding: 7px 10px;
  border: 2px solid #d1d5e0;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 600;
  color: #1a1a2e;
  background: #fff;
  outline: none;
  width: 100%;
  font-family: inherit;
  transition: border-color 0.15s, background 0.15s;
}
.fi:focus { border-color: #4f46e5; }

/* Amber highlight when value is missing */
.fi-empty {
  border-color: #f59e0b;
  background-color: #fffbeb;
}
.fi-empty:focus { border-color: #d97706; }

.fsel {
  padding: 7px 10px;
  border: 2px solid #d1d5e0;
  border-radius: 7px;
  font-size: 14px;
  color: #1a1a2e;
  background: #fff;
  outline: none;
  width: 100%;
  font-family: inherit;
  cursor: pointer;
}
.fsel:focus { border-color: #4f46e5; }
