:root {
  --bg: #f5f5f5;
  --pr: #e1e1e1;
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  background-color: var(--bg);
}

.app {
  max-width: 70rem;
  margin: auto;
  padding: 1.5rem;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

h1 { 
  margin: 0; 
  font-size: 22px;
}

.controls-bar {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 1rem;
  background: var(--pr);
  border-radius: .5rem;
  margin-bottom: 2rem;
  font-size: 1rem;
}

.control-bar {
  display: flex;
  gap: 1rem;
}

.check-label {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.checkbox {
  cursor: pointer;
}

/* ── HSL sliders ── */
.hsl-controls {
  display: flex;
  gap: 3rem;
  flex-wrap: wrap;
  align-items: center;
}

.hsl-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.hsl-label { font-weight: bold; }

.hsl-item input[type="range"] { width: 110px; }

.hsl-val {
  width: 2rem;
  text-align: center;
  font-size: 12px;
}

.step-btn,
.slider-reset {
  background: none;
  border: 1px solid #444;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 1px 5px;
}

.step-btn:hover,
.slider-reset:hover { 
  background: #adadad; 
}

.content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  margin-bottom: 2rem;

  @media( max-width: 75rem) {
    flex-direction: column;
  }
}

.panel {
  background: var(--pr);
  border-radius: .5rem;
  padding: 1rem;
  width: fit-content;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel--full {
  max-width: 70rem;
  margin-bottom: 2rem;
}

.panel h2 { 
  margin: 0 0 8px; 
  font-size: 1.2rem; 
}

img {
  max-width: 512px;
  max-height: 512px;
  display: block;
  object-fit: cover;
}

/* ── Grid ── */
#gridWrapper { display: flex; }
#grid { line-height: 0; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #d7d7d7;
  padding: 6px 10px;
  font-size: 12px;
}

.legend-color {
  width: 14px;
  height: 14px;
  border: 1px solid #333;
}

.inv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.inv-table th {
  font-weight: normal;
  padding: 8px 4px;
  text-align: center;
  border-bottom: 1px solid #444;
  white-space: nowrap;
}

.inv-table td {
  padding: 2px;
  border-bottom: 1px solid #999;

  input {
    width: 100%;
  }
}

.inv-color-label {
  text-align: left !important;
  white-space: nowrap;
  padding: 4px 12px 4px 8px !important;
}

.inv-swatch {
  width: 14px;
  height: 14px;
  display: inline-block;
  vertical-align: middle;
  margin-right: 8px;
  border: 1px solid rgba(0,0,0,0.2);
}

.inv-input {
  width: 50px;
  padding: 4px 2px;
  text-align: center;
  font-size: 12px;
  border: 1px solid #888;
  box-sizing: border-box;
}

.inv-empty {
  border-color: #a0a0a0;
  color: #888;
  background: #c8c8c8;
}

.inv-table tfoot tr:first-child td { border-top: 2px solid #444; }

.inv-total-cell {
  text-align: center;
  padding: 6px 4px;
  font-size: 12px;
}

.footer {
  text-align: center;
  margin-top: 2rem;
}

.inv-upload-label {
  font-size: 14px;
  background-color: #F0F0F0;
  padding: 1px 6px;
  border: 1px solid black;
  cursor: pointer;
}

.help-button {
  position: absolute;
  right: 1rem;
  cursor: pointer;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-box {
  background: #fff;
  padding: 2rem;
  max-width: 540px;
  width: 90%;
  overflow-y: auto;
  position: relative;
}

.modal-box h2 {
  font-size: 1.2rem; 
  font-weight: 600; 
  margin: 0 0 1.25rem; 
}

.modal-box h3 { 
  font-size: 1rem; 
  font-weight: 600; 
  margin: 1rem 0 0.5rem; 
}

.modal-box p  { 
  font-size: 1rem; 
  line-height: 1.6; 
  margin: 0; 
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  color: var(--color-text-secondary, #888);
  line-height: 1;
  padding: 4px;
}