:root {
  color-scheme: light;
  font-family: "Inter", "Segoe UI", sans-serif;
}

body {
  margin: 0;
  background: #f5f7fa;
  color: #1f2933;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

body.preview-open {
  overflow: hidden;
}

.app-topbar {
  --spw-topbar-background: #143a52;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.08);
}

.page-content {
  max-width: 960px;
  margin: 0 auto;
  padding: calc(var(--spw-topbar-height, 72px) + 2rem) 1.5rem 3rem;
  width: min(960px, 100%);
  box-sizing: border-box;
}

.card {
  background: #ffffff;
  border-radius: 12px;
  padding: 2rem;
  box-shadow: 0 16px 30px rgba(15, 23, 42, 0.12);
}

.card h1 {
  margin-top: 0;
  margin-bottom: 1rem;
  font-size: 1.75rem;
}

.form-grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.form-field span {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.form-field input:not([type='color']),
.form-field select {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: linear-gradient(180deg, #ffffff 0%, #f0f4f8 100%);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12);
  font-size: 1rem;
  font-weight: 500;
  color: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
  appearance: none;
}

.form-field select {
  background-image: url("data:image/svg+xml,%3Csvg width='14' height='9' viewBox='0 0 14 9' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L7 7.5L13 1.5' stroke='%23143A52' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 14px;
  padding-right: 3rem;
}

.form-field input:not([type='color'])::placeholder {
  color: rgba(31, 41, 51, 0.6);
}

.form-field input:not([type='color']):focus,
.form-field select:focus {
  border-color: rgba(20, 58, 82, 0.65);
  box-shadow: 0 0 0 4px rgba(20, 58, 82, 0.15);
  outline: none;
  transform: translateY(-1px);
}

.form-field--full {
  grid-column: 1 / -1;
}

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
}

.color-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.color-row label {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.color-row input[type='color'] {
  border: none;
  background: transparent;
  width: 64px;
  height: 40px;
  padding: 0;
}

.color-preview {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  border: 2px solid rgba(15, 23, 42, 0.15);
  background: #ffffff;
}

.label-preview {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  z-index: 100;
}

.label-preview.is-visible {
  opacity: 1;
  visibility: visible;
}

.label-preview__dialog {
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 24px 50px rgba(15, 23, 42, 0.35);
  padding: 2rem;
  width: min(900px, 100%);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.label-preview__header {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.label-preview__details {
  margin: 0;
  font-weight: 600;
  color: rgba(15, 23, 42, 0.75);
}

.label-preview__content {
  border-radius: 12px;
  background: #f8fafc;
  padding: 1.5rem;
  display: flex;
  justify-content: center;
  overflow-x: auto;
}

.label-preview__actions {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
}

.label-preview .label {
  margin: 0;
}

.label-preview .label__color {
  border-radius: 12px 0 0 12px;
}

.label {
  width: min(100%, 16cm);
  height: 8cm;
  display: flex;
  border: 1px solid #000000;
  background: #ffffff;
  color: #1f2933;
  font-family: 'Inter', 'Segoe UI', sans-serif;
}

.label__color {
  width: 7cm;
  height: 100%;
  color: #ffffff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.label__building {
  font-size: 3.2cm;
  font-weight: 700;
  line-height: 1;
}

.label__building--long {
  font-size: 1.5cm;
  letter-spacing: 0.05cm;
  white-space: nowrap;
}

.label__content {
  flex: 1;
  padding: 1cm;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.4cm;
  font-size: 0.65cm;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.label__content span {
  font-weight: 600;
}

.label__content p {
  margin: 0;
}

.label-preview .label__content {
  border-radius: 0 12px 12px 0;
}

@media print {
  body {
    background: #ffffff;
  }

  .label,
  .label__color,
  .label__content {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    color-adjust: exact;
  }
}

@media (max-width: 600px) {
  .card {
    padding: 1.5rem;
  }

  .page-content {
    padding: calc(var(--spw-topbar-height, 72px) + 1.5rem) 1rem 2.5rem;
  }

  .form-actions {
    justify-content: stretch;
  }

  .form-actions spw-button {
    width: 100%;
  }

  .form-field input:not([type='color']),
  .form-field select {
    font-size: 0.95rem;
    padding: 0.7rem 0.9rem;
  }

  .color-row {
    flex-direction: column;
    align-items: stretch;
  }

  .color-row label {
    justify-content: space-between;
  }

  .color-row .color-preview {
    align-self: flex-end;
  }

  .label-preview {
    padding: 1.5rem;
  }

  .label-preview__dialog {
    padding: 1.5rem;
  }
}
