/* Ampel Technologies brand tokens — see the ampel-brand-style skill for the source palette. */
:root {
  --nacht: #252831;
  --neon: #05fc7d;
  --tech: #1a4b5a;
  --mos: #c8d2ca;
  --roest: #dccccd;
  --creme: #f3eeee;
  --paper: #fbfaf9;
  --line: #e4e1de;
  --ink: #252831;
  --sub: #6b7177;

  --ok-bg: #e4f7ec;
  --ok-text: #146c43;
  --warn-bg: #fff3d6;
  --warn-text: #8a5a00;
  --danger-bg: #fbe4e4;
  --danger-text: #8f1d1d;

  --radius: 12px;
  --radius-sm: 7px;
  --shadow-card: 0 1px 2px rgba(37, 40, 49, 0.04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--creme);
}

body {
  font: 400 15px/1.5 Asap, "Calibri", "Trebuchet MS", system-ui, sans-serif;
  color: var(--ink);
}

h1, h2, h3, .brand-title, .panel-title, button, .btn {
  font-family: Poppins, "Trebuchet MS", system-ui, sans-serif;
}

a { color: var(--tech); }
a:hover { color: var(--nacht); }

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ─────────────────────────────────────────────────────────────── */

.topbar {
  background: var(--nacht);
  color: #fff;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand-block { display: flex; gap: 14px; align-items: center; }
.brand-logo { width: 40px; height: auto; display: block; }
.brand-title { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.2; }
.brand-subtitle { font-size: 13px; color: var(--mos); margin-top: 2px; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px 4px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--mos);
  margin-left: 16px;
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--sub); flex: none; }
.status-pill.online .status-dot { background: var(--neon); box-shadow: 0 0 0 3px rgba(5, 252, 125, 0.18); }
.status-pill.offline .status-dot { background: #e2685f; }
.status-pill.online { color: #d7ffe9; }
.status-pill.offline { color: #ffd9d5; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.accent-strip { height: 4px; background: var(--neon); flex: none; }

/* ── Buttons ────────────────────────────────────────────────────────────── */

button, .btn {
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  padding: 9px 16px;
  transition: filter 0.12s ease, transform 0.05s ease;
  white-space: nowrap;
}
button:active { transform: translateY(1px); }

.btn-primary, #download-template {
  background: var(--neon);
  color: var(--nacht);
  border-color: var(--neon);
}
.btn-primary:hover, #download-template:hover { filter: brightness(0.94); }
.btn-primary:disabled { background: var(--mos); border-color: var(--mos); color: #7a8079; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.28);
  color: #fff;
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.08); }

.btn-outline {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}
.btn-outline:hover { border-color: var(--tech); }

.btn-large {
  padding: 14px 28px;
  font-size: 15.5px;
  border-radius: var(--radius-sm);
}

.btn-accept {
  background: var(--tech);
  color: #fff;
  border-color: var(--tech);
  padding: 5px 10px;
  font-size: 12.5px;
  border-radius: 999px;
}
.btn-accept:hover { filter: brightness(1.15); }

/* ── Layout ─────────────────────────────────────────────────────────────── */

.content-grid {
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  gap: 20px;
  flex: 1;
}

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}

.stage-panel, .debug-panel { padding: 22px; min-width: 0; }

.panel-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.section-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--tech);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  margin-right: 10px;
  flex: none;
}

.panel-title { font-size: 19px; font-weight: 600; color: var(--nacht); letter-spacing: -0.01em; }
.panel-hint { font-size: 13.5px; color: var(--sub); margin: 4px 0 16px 36px; max-width: 76ch; }

/* ── Inputs (drag & drop) ───────────────────────────────────────────────── */

.inputs-grid { display: grid; gap: 12px; grid-template-columns: repeat(3, 1fr); }
@media (max-width: 1000px) { .inputs-grid { grid-template-columns: 1fr; } }

.dropzone {
  position: relative;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.dropzone:hover { border-color: var(--mos); }
.dropzone.drag-over { border-color: var(--neon); background: #f0fff7; }
.dropzone.filled { border-style: solid; border-color: var(--mos); }

.dropzone-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dropzone-title { font-weight: 700; font-size: 14.5px; }
.dropzone-meta { font-size: 12px; color: var(--sub); }

.dropzone input[type='file'] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.dropzone-body {
  border: 1px dashed transparent;
  border-radius: var(--radius-sm);
  padding: 10px 8px;
  text-align: center;
  font-size: 13px;
  color: var(--sub);
}
.dropzone-icon { font-size: 20px; line-height: 1; margin-bottom: 4px; }

.upload-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--ok-bg);
  color: var(--ok-text);
  align-self: flex-start;
}
.upload-status.pending { background: var(--paper); color: var(--sub); border: 1px dashed var(--line); }

.static-defaults-note {
  margin-top: 4px;
  font-size: 13px;
  color: var(--sub);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Callouts / feedback ────────────────────────────────────────────────── */

.callout {
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13.5px;
  border-left: 3px solid var(--line);
  background: #fff;
}
.callout.info { border-left-color: var(--tech); background: #eef5f7; color: var(--tech); }
.callout.warn { border-left-color: #d99a2b; background: var(--warn-bg); color: var(--warn-text); }
.callout.error { border-left-color: #c0392b; background: var(--danger-bg); color: var(--danger-text); }
.callout.success { border-left-color: var(--neon); background: var(--ok-bg); color: var(--ok-text); }
.callout .callout-detail {
  margin-top: 6px;
  font-size: 12px;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  color: inherit;
  opacity: 0.85;
  white-space: pre-wrap;
  word-break: break-word;
}
.callout summary { cursor: pointer; font-weight: 600; }

.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 0 0 16px 36px; font-size: 12.5px; color: var(--sub); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }

/* ── Preview table ──────────────────────────────────────────────────────── */

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); max-width: 100%; background: #fff; }
.table-wrap table { width: max-content; min-width: 100%; border-collapse: collapse; }
.preview-table-wrap { max-height: 68vh; }
.preview-table-wrap table { min-width: 1600px; }

.table-wrap th {
  background: var(--nacht);
  color: #fff;
  font-weight: 600;
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: left;
  padding: 10px 10px;
  white-space: nowrap;
}
.table-wrap td {
  border-bottom: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
  font-size: 13.5px;
}
.table-wrap tbody tr:nth-child(even) { background: #faf9f8; }

.pn-code { font-variant-numeric: tabular-nums; font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-size: 12.5px; }

.resolution-row.row-existing { background: var(--mos) !important; color: #52564f; }
.resolution-row.row-unresolved td { background: #fffaf4; }
.resolution-row.row-highlight { outline: 2px solid var(--tech); outline-offset: -2px; }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.status-badge.badge-existing { background: var(--mos); color: #3c4038; }
.status-badge.badge-create { background: #e4eef2; color: var(--tech); }
.status-badge.badge-resolved { background: var(--ok-bg); color: var(--ok-text); }
.status-badge.badge-suggested { background: var(--warn-bg); color: var(--warn-text); }
.status-badge.badge-unresolved { background: var(--danger-bg); color: var(--danger-text); }

.resolution-cell { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.resolution-select {
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 13px;
  background: #fff;
  color: var(--ink);
  min-width: 170px;
}
.resolution-select:hover { border-color: var(--mos); }
.resolution-select:focus-visible { outline: 2px solid var(--tech); outline-offset: 1px; }
.resolution-select.select-suggested { background: var(--warn-bg); border-color: #d99a2b; color: var(--warn-text); }
.resolution-select.select-unresolved { background: var(--danger-bg); border-color: #c0392b; color: var(--danger-text); }
.resolution-select.select-resolved { background: var(--ok-bg); border-color: #4caf7d; color: var(--ok-text); }
.resolution-select.select-create { background: #e4eef2; border-color: var(--tech); color: var(--tech); }
.resolution-select:disabled {
  background: #f3f2f0;
  border-color: var(--line);
  color: var(--sub);
  cursor: not-allowed;
  opacity: 0.75;
}

.suppliers-table-wrap table { min-width: 640px; }
.panel-title-row .status-badge { margin-left: auto; }

.row-remove-cell { width: 40px; min-width: 40px; text-align: center; }
.row-remove-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 6px 7px;
  color: var(--sub);
}
.row-remove-btn:hover { background: var(--danger-bg); border-color: #c0392b; color: var(--danger-text); }

.muted { color: var(--sub); }
.state-box {
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  padding: 24px;
  text-align: center;
  color: var(--sub);
  font-size: 13.5px;
  background: #fff;
}

/* ── Missing manufacturers ─────────────────────────────────────────────── */

.chip-list { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--danger-bg);
  color: var(--danger-text);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 600;
}
.chip::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ── Final action ───────────────────────────────────────────────────────── */

.final-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  background: var(--nacht);
  border-color: var(--nacht);
}
.final-action .panel-title { color: #fff; }
.final-action .panel-hint { color: var(--mos); margin-bottom: 0; }
.final-action-text { flex: 1 1 320px; min-width: 0; }

/* ── Debug panel ────────────────────────────────────────────────────────── */

.debug-panel summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 13.5px;
  color: var(--sub);
  list-style: none;
}
.debug-panel summary::-webkit-details-marker { display: none; }
.debug-panel summary::before { content: '\25B8'; display: inline-block; margin-right: 8px; transition: transform 0.12s ease; }
.debug-panel[open] summary::before { transform: rotate(90deg); }

.debug-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 14px; }
@media (max-width: 1000px) { .debug-grid { grid-template-columns: 1fr; } }

.section-title { font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--sub); margin-bottom: 8px; }
.kv-list, .artifact-list { display: grid; gap: 6px; }
.kv-item, .artifact-card, .run-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  background: #fff;
  font-size: 12.5px;
  overflow-wrap: anywhere;
}
.kv-item .label { display: block; font-size: 11px; color: var(--sub); text-transform: uppercase; letter-spacing: 0.02em; }
.kv-item .value { font-weight: 700; }
.diagnostics-box { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px; min-height: 100px; max-height: 340px; overflow: auto; background: #fff; display: grid; gap: 6px; }

/* ── Footer ─────────────────────────────────────────────────────────────── */

.app-footer {
  border-top: 1px solid var(--line);
  padding: 14px 24px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--sub);
}

/* ── Loading overlay ────────────────────────────────────────────────────── */

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(37, 40, 49, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.loading-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 26px 34px;
  background: var(--nacht);
  border-radius: var(--radius);
}
.loading-text { font-size: 15px; font-weight: 600; color: #fff; letter-spacing: 0.01em; }
.loading-spinner { position: relative; width: 44px; height: 44px; }
.loading-spinner span {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--neon);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }

@media (max-width: 1000px) {
  .topbar { flex-direction: column; align-items: flex-start; }
  .toolbar { width: 100%; }
}
