:root {
  /* Kesseböhmer brand greens (sampled from the logo) */
  --accent: #0a7257;
  --accent-strong: #002923;
  --accent-soft: rgba(10, 114, 87, 0.1);
  --accent-ring: rgba(10, 114, 87, 0.3);

  /* knowway accent */
  --knowway-yellow: #ffc629;

  --bg: #eef2f0;
  --surface: #ffffff;
  --border: #dde6e2;
  --text: #16241f;
  --muted: #5f6f69;

  --ok: #0a7257;
  --err: #d23b3b;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 18px 50px -24px rgba(0, 41, 35, 0.42);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

/* Author display rules (.view, .file-chip) would otherwise out-rank the
   browser's [hidden] rule, leaving every view visible at once. */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 50% -10%, #ffffff 0%, transparent 60%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
}

.shell {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Masthead -------------------------------------------------------------- */
.masthead {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}

.masthead__logo {
  height: 30px;
  width: auto;
}

.masthead__app h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -0.01em;
  color: var(--accent-strong);
}

.masthead__app p {
  margin: 3px 0 0;
  font-size: 13px;
  color: var(--muted);
}

/* Card ------------------------------------------------------------------ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 4px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}

.view {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

#upload-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Dropzone -------------------------------------------------------------- */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 38px 20px;
  text-align: center;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  background: #fafcfb;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.05s;
}

.dropzone:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dropzone:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-ring);
}

.dropzone.is-dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: scale(1.01);
}

.dropzone__icon {
  width: 38px;
  height: 38px;
  color: var(--accent);
}

.dropzone__title {
  font-weight: 600;
  font-size: 15px;
}

.dropzone__hint {
  font-size: 13px;
  color: var(--muted);
}

.dropzone__hint u {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

/* File chip ------------------------------------------------------------- */
.file-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fafcfb;
}

.file-chip__icon {
  width: 22px;
  height: 22px;
  color: var(--accent);
  flex: none;
}

.file-chip__name {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-chip__remove {
  flex: none;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
  border-radius: 6px;
}

.file-chip__remove:hover {
  color: var(--err);
  background: rgba(210, 59, 59, 0.08);
}

/* Buttons --------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 18px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s, opacity 0.15s;
}

.btn--primary {
  background: var(--accent);
  color: #fff;
}

.btn--primary:hover {
  background: var(--accent-strong);
}

.btn--primary:disabled {
  background: #b9c8c2;
  cursor: not-allowed;
}

.btn--ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
}

.btn--ghost:hover {
  color: var(--text);
  border-color: var(--muted);
}

.inline-error {
  margin: -6px 0 0;
  font-size: 13px;
  color: var(--err);
}

/* Progress -------------------------------------------------------------- */
.view[data-view="progress"],
.view[data-view="result"],
.view[data-view="error"] {
  align-items: center;
  text-align: center;
}

.spinner {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 3px solid var(--accent-soft);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

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

.progress__stage {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.progressbar {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  overflow: hidden;
}

.progressbar__fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-strong));
  transition: width 0.5s ease;
}

.progress__percent {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Result / error -------------------------------------------------------- */
.result__badge {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: grid;
  place-items: center;
}

.result__badge svg {
  width: 30px;
  height: 30px;
}

.result__badge--ok {
  background: var(--accent-soft);
  color: var(--ok);
}

.result__badge--err {
  background: rgba(210, 59, 59, 0.1);
  color: var(--err);
}

.result__title {
  margin: 0;
  font-size: 18px;
}

.result__file {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
  word-break: break-word;
}

.view[data-view="result"] .btn,
.view[data-view="error"] .btn {
  width: 100%;
}

/* Credit (knowway) ------------------------------------------------------ */
.credit {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  background: var(--accent-strong);
  border-top: 3px solid var(--knowway-yellow);
  border-radius: 14px;
  padding: 16px 20px;
}

.credit__brand {
  display: inline-flex;
}

.credit__logo {
  height: 20px;
  width: auto;
  display: block;
}

.credit__text {
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.72);
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation-duration: 1.6s;
  }
  .progressbar__fill {
    transition: none;
  }
}

/* Cluster review editor ------------------------------------------------- */
.shell--wide {
  max-width: 1040px;
}

.view--review {
  gap: 14px;
}

.editor-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.editor-title {
  margin: 0;
  font-size: 18px;
}

.editor-sub {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.45;
}

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

.btn--sm {
  padding: 8px 12px;
  font-size: 13px;
}

.btn--ghost.is-active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.editor-legend {
  margin-left: auto;
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.editor-canvas {
  position: relative;
  height: min(62vh, 620px);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background:
    linear-gradient(var(--accent-soft) 1px, transparent 1px) 0 0 / 28px 28px,
    linear-gradient(90deg, var(--accent-soft) 1px, transparent 1px) 0 0 / 28px 28px,
    #fafcfb;
  overflow: hidden;
}

#plan-svg {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}

#plan-svg.is-add-mode {
  cursor: crosshair;
}

/* Crisp, constant-width strokes regardless of zoom. */
.editor-canvas svg rect,
.editor-canvas svg polyline,
.editor-canvas svg polygon {
  vector-effect: non-scaling-stroke;
}

/* Real plan linework (walls / aisles / outlines) drawn behind everything. */
.plan-line {
  fill: none;
  stroke: rgba(22, 36, 31, 0.45);
  stroke-width: 0.75;
  pointer-events: none;
}

.entity-rect {
  pointer-events: none;
  stroke: rgba(22, 36, 31, 0.55);
  stroke-width: 1;
}

.entity-rect--unassigned {
  stroke: var(--err);
  stroke-dasharray: 3 2;
}

.cluster-poly {
  cursor: move;
}

.is-add-mode .cluster-poly,
.is-add-mode .cluster-handle {
  pointer-events: none;
}

.cluster-handle {
  fill: #fff;
  stroke: var(--accent-strong);
  stroke-width: 1.5;
  cursor: pointer;
}

/* Gondola number drawn at the centre of each region. A white halo keeps it
   legible over plan linework; the colour matches the region (set inline). */
.cluster-label {
  pointer-events: none;
  text-anchor: middle;
  dominant-baseline: central;
  font-family: var(--font, system-ui, sans-serif);
  font-weight: 700;
  paint-order: stroke;
  stroke: #fff;
  stroke-width: 3px;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.editor-rubber {
  fill: var(--accent-soft);
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-dasharray: 5 3;
  pointer-events: none;
}

/* In-progress polygon while placing corner points. */
.poly-progress {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.6;
  stroke-dasharray: 5 3;
  pointer-events: none;
}

.poly-vertex {
  fill: #fff;
  stroke: var(--accent);
  stroke-width: 1.5;
  pointer-events: none;
}

.editor-actions {
  display: flex;
  gap: 10px;
}

.editor-actions .btn {
  flex: 1;
}
