:root {
  --ink: #171717;
  --muted: #6f7782;
  --quiet: #9aa1aa;
  --line: #d9dde3;
  --panel: #f4f5f7;
  --soft: #fafafa;
  --accent: #c40000;
  --accent-dark: #990000;
  --green: #8bd95e;
  --focus: #147a83;
  --shadow: 0 12px 28px rgba(20, 20, 20, 0.08);
  --topbar-height: 88px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: #ffffff;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.topbar {
  height: var(--topbar-height);
  min-height: 64px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 20px;
  padding: 10px 22px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 230px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 6px;
  color: #fff;
  background: #111;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
  line-height: 1.2;
}

.brand small {
  color: var(--muted);
  margin-top: 2px;
}

.steps {
  display: flex;
  align-items: center;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.step-button {
  border: 0;
  border-bottom: 3px solid transparent;
  padding: 14px 13px 12px;
  color: #444;
  background: transparent;
  text-transform: uppercase;
  font-size: 12px;
}

.step-button.is-active {
  color: var(--accent);
  border-color: var(--accent);
  font-weight: 700;
}

.top-actions {
  display: flex;
  justify-content: end;
  gap: 8px;
}

.primary-button,
.ghost-button,
.tool-button,
.danger-button {
  border: 1px solid transparent;
  border-radius: 6px;
  min-height: 34px;
  padding: 8px 13px;
  font-weight: 700;
}

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

.primary-button:hover {
  background: var(--accent-dark);
}

.ghost-button {
  background: #ebedf0;
  color: #646b75;
}

.ghost-button:hover {
  color: #1f2328;
  background: #dde1e7;
}

.tool-button {
  border-color: var(--line);
  background: #fff;
  color: #1f2328;
}

.tool-button:hover {
  border-color: #aeb5bf;
}

.danger-button {
  border-color: #f1c3c3;
  color: #a00000;
  background: #fff4f4;
}

.builder-layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 430px;
  min-height: 0;
}

.preview-workbench {
  min-width: 0;
  padding: 20px 28px 26px;
}

.meta-row {
  min-height: 28px;
  display: flex;
  justify-content: flex-end;
  gap: 22px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 13px;
}

.meta-label {
  color: var(--muted);
  font-weight: 700;
}

.meta-row strong {
  color: var(--accent);
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(250px, 390px));
  justify-content: center;
  align-items: start;
  gap: 22px;
  margin-top: 22px;
}

.jersey-card {
  background: #e9e9e9;
  border: 1px solid #e2e2e2;
  min-height: 438px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 10px 18px;
}

.jersey-label {
  font-size: 15px;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.jersey-art {
  position: relative;
  width: min(100%, 360px);
  display: block;
  aspect-ratio: 18 / 20;
}

.jersey-art.is-mini {
  width: 78px;
}

.jersey-layer,
.jersey-layer-svg,
.jersey-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.jersey-layer {
  display: block;
  background: var(--layer-color);
  -webkit-mask: var(--mask-url) center / contain no-repeat;
  mask: var(--mask-url) center / contain no-repeat;
}

.jersey-overlay {
  pointer-events: none;
  overflow: visible;
}

.jersey-layer-svg {
  pointer-events: none;
  overflow: visible;
}

.mini-strip {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 18px;
}

.mini-card {
  width: 96px;
  padding: 7px;
  background: #e9e9e9;
  border: 1px solid #dfdfdf;
  text-align: center;
  font-size: 11px;
  text-transform: uppercase;
}

.mini-card svg {
  width: 78px;
  height: auto;
  display: block;
  margin: 0 auto 3px;
}

.mini-card .jersey-art {
  margin: 0 auto 3px;
}

.control-panel {
  border-left: 1px solid var(--line);
  background: #fff;
  min-width: 0;
  overflow: visible;
}

.panel-heading {
  background: #fff;
  border-bottom: 1px solid #aeb5bf;
  padding: 16px 18px;
}

.panel-heading h1 {
  margin: 0;
  font-size: 15px;
}

#panelContent {
  padding-bottom: 28px;
}

.section-label {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--accent);
  font-size: 14px;
  font-weight: 800;
  text-transform: uppercase;
  padding: 16px 18px 9px;
}

.section-label::before {
  content: "";
  width: 18px;
  height: 18px;
  background: #555;
}

.choice-row,
.option-row {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  border-top: 1px solid #e9ebee;
  background: var(--panel);
  padding: 10px 18px;
}

.option-block {
  border-top: 1px solid #e9ebee;
}

.option-block .option-row {
  width: 100%;
  border-top: 0;
  text-align: left;
}

.choice-row.is-selected,
.option-row.is-selected {
  background: #fff;
  box-shadow: inset 4px 0 0 var(--accent);
}

.row-caret {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.fabric-thumb {
  width: 48px;
  height: 48px;
  border: 1px solid #e2e2e2;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.9), rgba(210,210,210,0.3), rgba(255,255,255,0.8)),
    repeating-linear-gradient(45deg, #f6f6f6, #f6f6f6 4px, #e9e9e9 5px, #f9f9f9 8px);
}

.fabric-code {
  font-size: 24px;
  font-weight: 800;
}

.choice-name {
  display: block;
  font-weight: 800;
}

.choice-detail,
.option-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.swatch-pill {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.16);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.45);
  box-shadow: var(--shadow);
}

.swatch-pill.light {
  color: #222;
  text-shadow: none;
}

.color-picker {
  padding: 0 18px 18px;
  background: #fff;
  border-top: 1px solid #eceff2;
}

.inline-color-picker {
  padding: 2px 18px 18px 90px;
  background: #fff;
  border-top: 1px solid #eceff2;
  box-shadow: inset 4px 0 0 var(--accent);
}

.palette-heading {
  color: var(--accent);
  font-weight: 800;
  text-transform: uppercase;
  margin: 17px 0 9px;
}

.palette-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
  gap: 10px;
}

.color-button {
  height: 32px;
  border: 0;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.45);
  box-shadow: var(--shadow);
}

.color-button.light {
  color: #222;
  text-shadow: none;
}

.color-button.is-selected {
  outline: 3px solid var(--green);
  outline-offset: 2px;
}

.form-grid {
  display: grid;
  gap: 14px;
  padding: 16px 18px;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.range-field label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.range-field label strong {
  color: var(--ink);
  font-size: 12px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
}

.field input[type="range"] {
  min-height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  accent-color: var(--accent);
}

.field textarea {
  min-height: 84px;
  resize: vertical;
}

.inline-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 42px;
}

.toggle-row label {
  margin: 0;
}

.location-section {
  padding: 0 10px 8px;
}

.location-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  padding: 0 8px 16px;
}

.location-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft);
  padding: 6px;
  min-height: 103px;
  text-align: center;
}

.location-card.is-active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px rgba(196, 0, 0, 0.12);
}

.location-thumb {
  position: relative;
  width: 74px;
  height: 60px;
  display: block;
  margin: 0 auto;
}

.location-thumb svg,
.thumb-layer,
.thumb-layer-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.thumb-layer {
  display: block;
  background: var(--layer-color);
  -webkit-mask: var(--mask-url) center / contain no-repeat;
  mask: var(--mask-url) center / contain no-repeat;
}

.thumb-layer-svg {
  pointer-events: none;
}

.location-card svg {
  width: 74px;
  height: 60px;
}

.location-card span {
  display: block;
  color: #111;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.location-card small {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.active-decoration {
  border-top: 1px solid var(--line);
  background: #fff;
}

.decor-color-row {
  display: grid;
  grid-template-columns: 90px 1fr;
  align-items: start;
  gap: 10px;
}

.compact-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.compact-palette .color-button {
  width: 32px;
}

.file-name {
  color: var(--muted);
  font-size: 12px;
  min-height: 16px;
}

.roster-table-wrap {
  overflow-x: auto;
  padding: 0 18px 14px;
}

.roster-table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
}

.roster-table th,
.roster-table td {
  border-bottom: 1px solid #e8ebef;
  padding: 8px 5px;
  text-align: left;
}

.roster-table th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.roster-table input,
.roster-table select {
  width: 100%;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px;
}

.row-actions {
  width: 42px;
  text-align: right;
}

.icon-button {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-weight: 800;
}

.panel-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 4px 18px 18px;
}

.flow-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  padding: 18px;
  border-top: 1px solid #e8ebef;
  background: #fff;
}

.flow-actions .tool-button,
.flow-actions .primary-button {
  min-width: 128px;
}

@media (min-width: 1181px) {
  .topbar {
    flex: 0 0 var(--topbar-height);
  }

  .builder-layout {
    align-items: start;
  }

  .preview-workbench {
    position: sticky;
    top: var(--topbar-height);
    max-height: calc(100vh - var(--topbar-height));
    overflow-y: auto;
    overscroll-behavior: auto;
    scrollbar-gutter: stable;
  }
}

.stat-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 10px 18px;
  border-top: 1px solid #e9ebee;
  background: var(--panel);
}

.stat-row strong {
  color: var(--accent);
}

.summary-block {
  padding: 0 18px 18px;
}

.summary-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid var(--line);
}

.summary-table th,
.summary-table td {
  border-bottom: 1px solid #edf0f3;
  padding: 9px 10px;
  text-align: left;
  vertical-align: top;
}

.summary-table th {
  width: 34%;
  color: var(--muted);
  background: var(--soft);
  text-transform: uppercase;
  font-size: 12px;
}

.zone-highlight {
  fill: rgba(139, 217, 94, 0.55);
  stroke: #4f972f;
  stroke-width: 90;
}

.jersey-outline {
  fill: none;
  stroke: #101010;
  stroke-width: 2;
  stroke-linejoin: round;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(120%);
  transition: transform 180ms ease;
  padding: 10px 14px;
  border-radius: 6px;
  color: #fff;
  background: #1f2328;
  box-shadow: var(--shadow);
  z-index: 30;
}

.toast.is-visible {
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 1180px) {
  .builder-layout {
    grid-template-columns: 1fr;
  }

  .control-panel {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

}

@media (max-width: 760px) {
  .topbar {
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 8px;
    position: static;
  }

  .brand {
    min-width: 0;
  }

  .top-actions {
    justify-content: start;
  }

  .preview-workbench {
    padding: 14px;
  }

  .preview-grid {
    grid-template-columns: 1fr;
  }

  .jersey-card {
    min-height: auto;
  }

  .meta-row {
    justify-content: flex-start;
  }

  .panel-heading {
    position: static;
  }

  .location-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .inline-fields {
    grid-template-columns: 1fr;
  }
}

@media print {
  .topbar,
  .control-panel,
  .mini-strip {
    display: none;
  }

  .builder-layout {
    display: block;
  }

  .preview-workbench {
    padding: 0;
  }
}
