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

:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --border: #dde1e7;
  --text: #1a1d23;
  --text-muted: #6b7280;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --secondary: #4b5563;
  --secondary-hover: #374151;
  --success: #16a34a;
  --warning-bg: #fff3cd;
  --warning-strong: #ffcf40;
  --error: #dc2626;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 15px;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

header { margin-bottom: 2rem; }
header h1 { font-size: 1.75rem; font-weight: 700; }
header .subtitle { color: var(--text-muted); margin-top: .25rem; }

/* Card */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}

.card h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: .6rem;
}

.card h3 {
  font-size: .95rem;
  font-weight: 600;
  margin: 1.5rem 0 .75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: .75rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* Form */
.form-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  align-items: start;
  gap: .5rem 1rem;
  margin-bottom: 1rem;
}

.form-row label { font-weight: 500; padding-top: .55rem; }

input[type="text"] {
  width: 100%;
  padding: .5rem .75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .95rem;
  color: var(--text);
  outline: none;
  transition: border-color .15s;
}
input[type="text"]:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }

/* Dropzone */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 1.5rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
  user-select: none;
}
.dropzone:hover, .dropzone:focus { border-color: var(--primary); color: var(--primary); outline: none; }
.dropzone.drag-over { border-color: var(--primary); background: #eff6ff; color: var(--primary); }
.dropzone.has-file { border-color: var(--success); color: var(--success); background: #f0fdf4; }
.dropzone svg { opacity: .6; }

/* Buttons */
.btn-row {
  display: flex;
  gap: .75rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}

.btn {
  padding: .55rem 1.2rem;
  border-radius: 6px;
  font-size: .9rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: background .15s, opacity .15s;
}
.btn:disabled { opacity: .4; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }

.btn-secondary { background: #e5e7eb; color: var(--secondary); }
.btn-secondary:hover:not(:disabled) { background: #d1d5db; }

/* File list */
.file-list {
  list-style: none;
  margin-top: .75rem;
  display: flex;
  flex-direction: column;
  gap: .4rem;
}
.file-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .4rem .75rem;
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .875rem;
}
.file-list .file-name { font-weight: 500; }
.file-list .file-size { color: var(--text-muted); margin-left: .5rem; }
.file-list .btn-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1;
  padding: 0 .25rem;
  transition: color .15s;
}
.file-list .btn-remove:hover { color: var(--error); }

/* Status box */
.status-box {
  margin-top: 1rem;
  padding: .7rem 1rem;
  border-radius: 6px;
  font-size: .9rem;
}
.status-box.success { background: #f0fdf4; border: 1px solid #bbf7d0; color: var(--success); }
.status-box.error   { background: #fef2f2; border: 1px solid #fecaca; color: var(--error); }

/* Results meta */
.results-meta {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: .5rem;
}
.meta-chip {
  padding: .3rem .75rem;
  border-radius: 20px;
  font-size: .85rem;
  font-weight: 500;
}
.meta-chip.total  { background: #eff6ff; color: var(--primary); }
.meta-chip.warn   { background: var(--warning-bg); color: #92400e; }
.meta-chip.ok     { background: #f0fdf4; color: var(--success); }

/* Tables */
.table-wrapper { overflow-x: auto; }

table {
  border-collapse: collapse;
  width: 100%;
  font-size: .875rem;
}
th, td {
  border: 1px solid var(--border);
  padding: .45rem .75rem;
  text-align: left;
  white-space: nowrap;
}
thead th {
  background: #f9fafb;
  font-weight: 600;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}
thead th:hover { background: #f3f4f6; }
thead th.sort-asc::after  { content: " ▲"; font-size: .7em; }
thead th.sort-desc::after { content: " ▼"; font-size: .7em; }

tbody tr:hover td { background: #f9fafb; }

/* Unmatched rows */
tr.row--unmatched td { background: var(--warning-bg); }
tr.row--unmatched:hover td { background: #fde68a; }
td.cell--unmatched { background: var(--warning-strong) !important; font-weight: 600; }

.export-row { margin-top: 1.5rem; }

/* Unmatched debug */
.warn-heading { color: #92400e; }

#unmatched-debug-table td.hint-spaces  { color: #b45309; }
#unmatched-debug-table td.hint-case    { color: #6d28d9; }
#unmatched-debug-table td.hint-fuzzy   { color: #0369a1; }
#unmatched-debug-table td.hint-missing { color: var(--error); }

#unmatched-debug-table td.suggestion { font-family: monospace; font-weight: 600; }
#unmatched-debug-table td.serial-csv { font-family: monospace; }

/* Customer cost table */
#customer-cost-table .col-expand { width: 32px; text-align: center; }

tr.customer-row { cursor: pointer; }
tr.customer-row:hover td { background: #eff6ff; }
tr.customer-row td.col-expand { color: var(--primary); font-size: .8rem; transition: transform .2s; }
tr.customer-row.open td.col-expand { transform: rotate(90deg); display: inline-block; }

tr.location-sub-row td { background: #f9fafb; font-size: .85rem; }
tr.location-sub-row td:first-child { border-left: 3px solid var(--primary); }
tr.location-sub-row:hover td { background: #f0f7ff; }
tr.location-sub-row.hidden { display: none; }

tr.customer-row td.total-eur,
tr.location-sub-row td.total-eur { color: #065f46; font-weight: 600; }
tr.customer-row td.total-usd,
tr.location-sub-row td.total-usd { color: #1e40af; font-weight: 600; }
tr.customer-row td.no-price { color: var(--text-muted); font-style: italic; font-weight: 400; }

#customer-cost-table tfoot td { font-weight: 700; background: #f9fafb; border-top: 2px solid var(--border); }

/* Price editor */
.price-editor {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 1rem;
  overflow: hidden;
}
.price-editor > summary {
  padding: .65rem 1rem;
  font-weight: 500;
  font-size: .9rem;
  cursor: pointer;
  background: #f9fafb;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.price-editor > summary::before {
  content: '▶';
  font-size: .7rem;
  transition: transform .2s;
  color: var(--text-muted);
}
.price-editor[open] > summary::before { transform: rotate(90deg); }
.price-editor-body { padding: .75rem 1rem 1rem; }

#price-table input[type="text"],
#price-table input[type="number"] {
  width: 100%;
  padding: .3rem .5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: .875rem;
}
#price-table input:focus { border-color: var(--primary); outline: none; }

.btn-remove-row {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1.1rem;
  padding: 0 .25rem;
  transition: color .15s;
}
.btn-remove-row:hover { color: var(--error); }

/* Location table cost highlight */
#location-table td.cost-eur { color: #065f46; font-weight: 600; }
#location-table td.cost-usd { color: #1e40af; font-weight: 600; }
#location-table tfoot td { font-weight: 700; background: #f9fafb; border-top: 2px solid var(--border); }

/* Spinner */
.spinner {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,.75);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  z-index: 100;
  backdrop-filter: blur(2px);
}
.spinner p { color: var(--text-muted); font-size: .95rem; }
.spinner-inner {
  width: 48px;
  height: 48px;
  border: 4px solid #e5e7eb;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Utility */
.hidden { display: none !important; }

@media (max-width: 600px) {
  .form-row { grid-template-columns: 1fr; }
  .form-row label { padding-top: 0; }
}
