:root {
  --bg: #0f172a;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-strong: #ffffff;
  --line: rgba(15, 23, 42, 0.08);
  --text: #0f172a;
  --muted: #475569;
  --primary: #2563eb;
  --primary-2: #1d4ed8;
  --danger: #dc2626;
  --shadow: 0 18px 60px rgba(15, 23, 42, 0.18);
  --radius: 22px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: Inter, Segoe UI, Arial, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.35), transparent 28%),
    radial-gradient(circle at top right, rgba(14, 165, 233, 0.22), transparent 26%),
    linear-gradient(135deg, #020617, #0f172a 55%, #111827);
  color: var(--text);
}

body {
  min-height: 100vh;
}

.app-shell {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 24px;
  padding: 24px;
}

.sidebar,
.content {
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
  color: #fff;
}

.brand h1 {
  margin: 0;
  font-size: 1.5rem;
}

.brand p {
  margin: 4px 0 0;
  color: rgba(255,255,255,0.78);
}

.brand-badge {
  width: 54px;
  height: 54px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #3b82f6, #0ea5e9);
  color: #fff;
  font-size: 1.5rem;
  font-weight: 800;
  box-shadow: var(--shadow);
}

.card {
  background: var(--panel);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 18px;
}

.card h2 {
  margin-top: 0;
  margin-bottom: 16px;
  font-size: 1.1rem;
}

.card p,
.card li {
  color: var(--muted);
  line-height: 1.45;
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 0.92rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 0.98rem;
  background: #fff;
  outline: none;
  transition: 0.2s ease;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 4px rgba(96, 165, 250, 0.18);
}

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

.actions,
.toolbar-actions,
.modal-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 0.96rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.25);
}

.btn-secondary {
  background: #e2e8f0;
  color: #0f172a;
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444, var(--danger));
  color: #fff;
}

.content {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 28px;
  padding: 22px;
  backdrop-filter: blur(10px);
}

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 20px;
  color: #fff;
}

.toolbar h2 {
  margin: 0;
}

.toolbar p {
  margin: 6px 0 0;
  color: rgba(255,255,255,0.78);
}

.labels-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
}

.label-item {
  width: 50mm;
  height: 30mm;
  background: var(--panel-strong);
  border: 1px dashed rgba(15, 23, 42, 0.22);
  border-radius: 8px;
  padding: 3.2mm 3.4mm 2.6mm;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  overflow: hidden;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.14);
  font-size: calc(11.5pt * var(--font-scale, 1));
}

.label-line {
  display: flex;
  align-items: flex-start;
  gap: 1.2mm;
  color: #0f172a;
  line-height: 1.14;
  margin-bottom: 0.9mm;
}

.label-line-strong {
  font-weight: 800;
}

.label-prefix {
  flex: 0 0 auto;
  white-space: nowrap;
}

.lab-number,
.weight,
.observation {
  overflow: hidden;
  text-overflow: ellipsis;
}

.lab-number,
.weight {
  white-space: nowrap;
}

.lab-number {
  max-width: 24mm;
}

.weight {
  max-width: none;
  flex: 1 1 auto;
  white-space: nowrap;
}

.observation {
  display: inline;
  white-space: normal;
  word-break: break-word;
  overflow: visible;
  text-overflow: unset;
  margin-left: 0;
}

.empty-state {
  grid-column: 1 / -1;
  background: rgba(255,255,255,0.9);
  border: 1px dashed rgba(15, 23, 42, 0.15);
  color: var(--muted);
  border-radius: 18px;
  padding: 28px;
  text-align: center;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.66);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
}

.modal-overlay.hidden {
  display: none;
}

.modal-card {
  width: min(720px, 100%);
  background: #ffffff;
  color: #0f172a;
  border-radius: 24px;
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.35);
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px 16px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.modal-header h3 {
  margin: 0;
  font-size: 1.3rem;
}

.modal-header p {
  margin: 6px 0 0;
  color: var(--muted);
}

.modal-close {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 12px;
  background: #e2e8f0;
  color: #0f172a;
  font-size: 1.6rem;
  cursor: pointer;
}

.modal-body {
  padding: 20px 24px;
  display: grid;
  gap: 18px;
}

.modal-section {
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 18px;
  padding: 18px;
}

.modal-section h4 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.modal-section p,
.modal-help {
  margin: 0 0 12px;
  color: var(--muted);
  line-height: 1.45;
}

.import-feedback {
  min-height: 22px;
  font-size: 0.92rem;
  color: #1d4ed8;
  font-weight: 600;
}

.modal-actions {
  padding: 0 24px 24px;
  justify-content: flex-end;
}

@page {
  size: auto;
  margin: 0;
}

@media print {
  html,
  body {
    background: #fff !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  
  .app-signature {
    display: none !important;
  }

  .no-print,
  .modal-overlay {
    display: none !important;
  }

  .app-shell,
  .content {
    display: block;
    padding: 0;
    margin: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
  }

  .labels-grid {
    display: grid;
    grid-template-columns: repeat(2, 50mm);
    column-gap: 3mm;
    row-gap: 2.8mm;
    justify-content: start;
    align-content: start;
    width: 103mm;
    padding: 1.2mm 0 0 1.2mm;
    margin: 0;
  }

  .label-item {
    width: 50mm;
    height: 30mm;
    margin: 0;
    padding: 4mm 3.6mm 3mm;
    break-inside: avoid;
    page-break-inside: avoid;
    box-shadow: none;
    border: 0;
    border-radius: 0;
    justify-content: flex-start;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .label-line {
    line-height: 1.08;
    margin-bottom: 1mm;
  }

  .label-line-strong {
    font-weight: 800;
  }

  .label-prefix {
    font-weight: 800;
  }

  .lab-number {
  max-width: none;
  flex: 1 1 auto;
  white-space: nowrap;
  overflow: visible;
  text-overflow: unset;
}

  .weight {
  max-width: none;
  flex: 1 1 auto;
  white-space: nowrap;
  overflow: visible;
  text-overflow: unset;
}

  .observation {
    -webkit-line-clamp: 2;
  }

  .empty-state {
    display: none !important;
  }
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .inline-field,
  .toolbar {
    grid-template-columns: 1fr;
    display: grid;
  }

  .toolbar-actions,
  .actions,
  .modal-actions {
    width: 100%;
  }

  .btn {
    width: 100%;
  }
}

.brand-custom {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  padding: 10px 0 5px;
}

.brand-logo-full {
  width: 100%;
  max-width: 240px;
  height: auto;
  object-fit: contain;
}

.brand-subtitle {
  font-size: 14px;
  color: #cbd5e1;
  font-weight: 500;
}

.sidebar {
  padding-top: 0 !important;
}

.brand {
  margin-top: 0 !important;
  padding-top: 0 !important;
}

.observation-line {
  display: block !important;
}

.observation-line .label-prefix {
  display: inline;
  margin-right: 2px;
}

.observation-line .observation {
  display: inline;
}

.app-signature {
  position: fixed;
  bottom: max(20px, env(safe-area-inset-bottom));
  right: max(40px, env(safe-area-inset-right));
  font-size: 11px;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(255,255,255,0.08);
  backdrop-filter: blur(6px);
  color: rgba(255,255,255,0.7);
  z-index: 9999;
  pointer-events: none;
}

.label-line-strong:first-child {
  font-size: 1.30em;
}