/* Fonts are shared with the proof itself so the preview matches the PDF. */
@font-face { font-family: 'HNCondBlack'; src: url('/assets/fonts/HelveticaNeue-CondensedBlack.ttf') format('truetype'); }
@font-face { font-family: 'HNCondBold';  src: url('/assets/fonts/HelveticaNeue-CondensedBold.ttf') format('truetype'); }
@font-face { font-family: 'HelvLight';   src: url('/assets/fonts/Helvetica-Light.ttf') format('truetype'); }
@font-face { font-family: 'HelvBold';    src: url('/assets/fonts/Helvetica-Bold.ttf') format('truetype'); }
@font-face { font-family: 'FuturaBd';    src: url('/assets/fonts/Futura-Bold.ttf') format('truetype'); }
@font-face { font-family: 'FuturaMed';   src: url('/assets/fonts/Futura-MediumItalic.ttf') format('truetype'); }

:root {
  --green: #2eb886;
  --green-dark: #229b70;
  --ink: #1c2024;
  --muted: #6b7480;
  --line: #dfe3e8;
  --bg: #f4f6f8;
  --panel: #fff;
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
}

body {
  display: grid;
  grid-template-rows: auto 1fr auto;
}

/* ---------- top bar ---------- */
.bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.bar__logo { width: 34px; height: 34px; }
.bar__title { font-size: 17px; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
.bar__open { display: flex; align-items: center; gap: 8px; margin-left: 12px; color: var(--muted); font-size: 13px; }
.bar__actions { margin-left: auto; display: flex; gap: 8px; }

/* ---------- controls ---------- */
.btn {
  font: inherit;
  font-size: 14px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}
.btn:hover { border-color: #c3cad3; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn--primary { background: var(--green); border-color: var(--green); color: #fff; font-weight: 600; }
.btn--primary:hover:not(:disabled) { background: var(--green-dark); border-color: var(--green-dark); }
.btn--ghost { width: 100%; color: var(--muted); border-style: dashed; }
.btn--danger { border: none; background: none; color: var(--muted); padding: 4px 6px; font-size: 13px; }
.btn--danger:hover { color: #c0392b; }

input, select {
  font: inherit;
  font-size: 14px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  width: 100%;
  min-width: 0;
}
input:focus, select:focus { outline: 2px solid var(--green); outline-offset: -1px; border-color: var(--green); }

/* ---------- layout ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(300px, 340px) 1fr;
  gap: 0;
  min-height: 0;
}

.panel {
  overflow-y: auto;
  padding: 16px 18px 32px;
  background: var(--panel);
  border-right: 1px solid var(--line);
}

.group { border: none; margin: 0 0 22px; padding: 0; }
.group legend {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--green);
  padding: 0;
  margin-bottom: 10px;
}

.field { display: block; margin-bottom: 10px; font-size: 12px; color: var(--muted); }
.field input, .field select { margin-top: 4px; }
.field__label { display: block; margin-bottom: 6px; }

.radios { display: flex; gap: 14px; font-size: 14px; color: var(--ink); }
.radios label { display: flex; align-items: center; gap: 6px; }
.radios input { width: auto; }

.stack { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px 12px;
  background: #fbfcfd;
}
.card__head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.card__head select { flex: 1; }
.card__row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.card__art { margin-top: 8px; font-size: 12px; color: var(--muted); }
.card__art input[type=file] { border: none; padding: 4px 0; font-size: 12px; }
.card__art-name { display: block; margin-top: 2px; color: var(--ink); word-break: break-all; }

.ink { display: flex; align-items: center; gap: 8px; }
.ink input[type=color] { width: 38px; height: 38px; padding: 2px; flex: none; cursor: pointer; }

.hint { font-size: 12px; color: var(--muted); line-height: 1.45; margin: 0 0 10px; }
.warnings { margin: 10px 0 0; padding-left: 18px; font-size: 12px; color: #8a5a12; }
.warnings li { margin-bottom: 3px; }

/* ---------- calibration ---------- */
.stage--cal svg.cal { width: 100%; max-width: 620px; height: auto; display: block; background: #fff;
  box-shadow: 0 2px 14px rgba(20,30,45,.14); border-radius: 2px; }
.cal__ref { stroke: #9aa4b0; stroke-dasharray: 8 8; }
.cal__chest line { stroke: var(--green); }
.cal__chest text { fill: var(--green); font-family: var(--font); font-weight: 700; }
.cal__handle line { stroke: #1c2024; }
.cal__handle { cursor: ew-resize; }
.cal__handle:hover line { stroke: var(--green); }
.cal__collar { cursor: ns-resize; }
.cal__collar line { stroke: #ec008c; }
.cal__collar text { fill: #ec008c; font-family: var(--font); font-weight: 700; }

/* ---------- preview ---------- */
.preview { display: flex; flex-direction: column; min-width: 0; padding: 14px 18px 18px; }
.preview__hint { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.stage {
  flex: 1;
  display: grid;
  align-content: start;
  gap: 18px;
  overflow: auto;
  min-height: 0;
}
.stage svg.proof-page {
  width: 100%;
  height: auto;
  max-width: 1100px;
  display: block;
  box-shadow: 0 2px 14px rgba(20, 30, 45, 0.14);
  border-radius: 2px;
  background: #fff;
}
.stage__empty { color: var(--muted); font-size: 14px; padding: 40px 0; }

.stage g.art { cursor: grab; }
.stage g.art:active { cursor: grabbing; }
.stage g.art::after { content: ''; }
.stage g.art.is-dragging { opacity: 0.85; }

/* ---------- change request ---------- */
.ask { background: var(--panel); border-top: 1px solid var(--line); padding: 12px 18px; }
.ask__form { display: flex; gap: 8px; }
.ask__input { flex: 1; }
.ask__result {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: #fbfcfd;
}
.ask__summary { font-weight: 600; margin: 0 0 4px; }
.ask__radius { margin: 0 0 8px; font-size: 13px; color: var(--muted); }
.ask__radius--wide { color: #b0631a; font-weight: 600; }
.ask__edits { margin: 0 0 10px; padding-left: 18px; font-size: 13px; color: var(--ink); }
.ask__edits li { margin-bottom: 2px; }
.ask__edit--garment { color: #b0631a; }
.ask__note { margin: 0; font-size: 13px; color: var(--muted); }
.ask__buttons { display: flex; gap: 8px; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.2);
  z-index: 10;
  max-width: min(560px, 90vw);
}
.toast--error { background: #b3311f; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .panel { border-right: none; border-bottom: 1px solid var(--line); }
}

/* ---------- settings & bulk import ---------- */
.body--plain { display: block; overflow-y: auto; }
.sheet { max-width: 940px; margin: 0 auto; padding: 22px 18px 60px; }
.sheet__block { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px 20px; margin-bottom: 20px; }
.sheet__block h2 { font-size: 16px; margin: 0 0 8px; }
.sheet__actions { display: flex; align-items: center; gap: 12px; margin-top: 14px; }

.settings { display: flex; flex-direction: column; gap: 14px; margin-top: 4px; }
.settings__row { display: grid; grid-template-columns: 190px 1fr; grid-template-areas:
  "label status" "input input" "note note"; gap: 4px 12px; align-items: center; }
.settings__label { grid-area: label; font-weight: 600; font-size: 14px; }
.settings__status { grid-area: status; font-size: 12px; color: var(--muted); justify-self: start; }
.settings__status--on { color: var(--green); font-weight: 600; }
.settings__input { grid-area: input; }
.settings__row input { grid-area: input; }
.settings__note { grid-area: note; font-size: 12px; color: var(--muted); }

.bulk__wrap { overflow-x: auto; margin-top: 12px; }
table.bulk { border-collapse: collapse; width: 100%; font-size: 13px; }
table.bulk th { text-align: left; font-size: 11px; letter-spacing: .07em; text-transform: uppercase;
  color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--line); font-weight: 700; }
table.bulk td { padding: 5px 8px; border-bottom: 1px solid #eef1f4; vertical-align: middle; }
table.bulk input { padding: 5px 7px; font-size: 13px; }
.bulk__thumb { width: 42px; height: 42px; object-fit: contain; background: #f4f6f8; border-radius: 4px; display: block; }
.bulk__views { color: var(--muted); white-space: nowrap; }
.bulk__note { font-size: 12px; color: #8a5a12; padding-top: 0 !important; padding-bottom: 8px !important; }
.bulk__row--blocked { opacity: .55; }
.bulk__source { font-size: 12px; color: var(--green); padding-top: 0 !important; padding-bottom: 8px !important; }

/* ---------- AS Colour picker ---------- */
.asc { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 12px; }
.asc__item { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 8px; background: #fbfcfd; cursor: pointer; font-size: 13px; }
.asc__item:hover { border-color: #c3cad3; }
.asc__item input { width: auto; flex: none; }
.asc__item img { width: 30px; height: 30px; object-fit: contain; flex: none; background: #fff; border-radius: 3px; }
.asc__item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- vectorize panel ---------- */
.trace { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.trace__status { font-size: 12px; color: var(--muted); margin: 0 0 8px; line-height: 1.4; }
.trace__inks { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.trace__ink { display: inline-flex; align-items: center; gap: 5px; font-size: 12px;
  background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 2px 9px 2px 3px; }
.trace__ink i { width: 15px; height: 15px; border-radius: 50%; border: 1px solid rgba(0,0,0,.18); flex: none; }
.trace__actions { display: flex; gap: 8px; align-items: center; }
.trace__count { width: auto; flex: none; padding: 6px 8px; font-size: 13px; }

/* ---------- garment picker ---------- */
.picker { position: relative; }
.picker__input { width: 100%; }
.picker__results {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px);
  max-height: 340px; overflow-y: auto; background: #fff;
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 6px 22px rgba(20,30,45,.16);
}
.picker__group {
  font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); padding: 8px 10px 4px; background: #fbfcfd;
  position: sticky; top: 0;
}
.picker__item { padding: 7px 10px; cursor: pointer; display: flex; flex-direction: column; gap: 1px; }
.picker__item:hover { background: #eef7f3; }
.picker__label { font-size: 13px; color: var(--ink); }
.picker__detail { font-size: 11px; color: var(--muted); }
.picker__note { padding: 8px 10px; font-size: 12px; color: var(--muted); line-height: 1.4; }
.picker__fetch { padding: 8px 10px; }
.picker__fetch .btn { width: 100%; font-size: 12px; }
.picker__colorways {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 6px; padding: 8px 10px;
}
.picker__colorway {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  border: 1px solid var(--line); border-radius: 6px; background: #fff;
  padding: 5px 4px; cursor: pointer; font: inherit; font-size: 11px; color: var(--ink);
}
.picker__colorway:hover:not(:disabled) { border-color: var(--green); }
.picker__colorway:disabled { opacity: .6; cursor: default; }
.picker__colorway img { width: 100%; height: 46px; object-fit: contain; }
.picker__colorway span { text-align: center; line-height: 1.2; overflow: hidden; }

/* An unconfirmed neckline moves every "down" measurement on the proof, so it is
   called out beside the preview rather than left to be noticed. */
.preview__warn {
  margin: 0 0 10px; padding: 8px 12px; border-radius: 6px;
  background: #fff4e5; border: 1px solid #f0c48a; color: #7a4b09;
  font-size: 12px; line-height: 1.45;
}
.preview__warn a { color: inherit; font-weight: 600; }

.card__art-download { font-size: 12px; color: var(--green, #2eb886); text-decoration: underline; margin-left: 8px; white-space: nowrap; }

/* One tab per item (proof page). The active item is the one the form edits. */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.tabs__tab { padding: 5px 12px; border: 1px solid var(--line); border-radius: 6px;
  background: none; font: inherit; font-size: 13px; cursor: pointer; }
.tabs__tab--active { background: var(--green, #2eb886); border-color: var(--green, #2eb886);
  color: #fff; font-weight: 600; }
.tabs__tab--ghost { border-style: dashed; color: var(--muted); }
