:root {
  color-scheme: light;
  --bg: #f7f8f5;
  --panel: #ffffff;
  --ink: #1e2724;
  --muted: #68736e;
  --line: #dfe5df;
  --primary: #0d6b5f;
  --primary-dark: #084d45;
  --accent: #c84b31;
  --soft: #edf4f1;
  --shadow: 0 18px 40px rgba(30, 39, 36, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

[hidden] {
  display: none !important;
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.45rem, 2.4vw, 2.4rem);
}

h2 {
  margin-bottom: 4px;
  font-size: 1.2rem;
}

h3 {
  margin-bottom: 0;
  font-size: 1rem;
}

.panel {
  align-self: start;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.muted {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.asset-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

button,
.file-action {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 0 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  text-decoration: none;
}

.primary {
  width: 100%;
  margin-top: 16px;
  background: var(--primary);
  color: white;
  font-weight: 700;
}

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

.secondary,
.file-action {
  background: var(--soft);
  border-color: #cfe0da;
  color: var(--primary-dark);
  font-weight: 700;
}

.ghost {
  min-height: 36px;
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.file-action input {
  display: none;
}

label {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  color: #43504b;
  font-size: 0.9rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cfd8d2;
  border-radius: 7px;
  padding: 11px 12px;
  background: #fff;
  color: var(--ink);
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
.file-action:focus-within {
  outline: 3px solid rgba(13, 107, 95, 0.18);
  border-color: var(--primary);
}

.document-row {
  display: grid;
  grid-template-columns: 1fr 0.8fr 1fr;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.doc-file-name {
  min-height: 40px;
  display: flex;
  align-items: center;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.86rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-row .doc-link {
  grid-column: 1 / 3;
}

.document-row .remove-doc {
  justify-self: end;
}

.icon-button {
  width: 40px;
  min-height: 40px;
  padding: 0;
  background: #fff1ee;
  color: var(--accent);
  border-color: #f1c9bf;
  font-size: 1.35rem;
  line-height: 1;
}

.search {
  max-width: 260px;
}

.asset-list {
  display: grid;
  gap: 10px;
  max-height: 68vh;
  overflow: auto;
  padding-right: 4px;
}

.asset-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.asset-card.selected {
  border-color: var(--primary);
  background: #f3faf7;
}

.asset-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.asset-title strong {
  overflow-wrap: anywhere;
}

.asset-code {
  color: var(--primary-dark);
  font-weight: 800;
}

.asset-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 0.86rem;
}

.asset-documents {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.doc-open {
  min-height: 34px;
  max-width: 100%;
  padding: 0 10px;
  background: #fffdfa;
  border-color: var(--line);
  color: var(--primary-dark);
  font-size: 0.84rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tag {
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef0ea;
}

#qrCanvas {
  width: min(100%, 320px);
  height: auto;
  image-rendering: pixelated;
  background: #fff;
}

.tag-shell {
  width: 45mm;
  height: 20mm;
  position: relative;
  overflow: hidden;
  border: 0.3mm solid #111;
  border-radius: 2.4mm;
  background: linear-gradient(
      92deg,
      rgba(255, 255, 255, 0.52),
      rgba(116, 122, 123, 0.28) 24%,
      rgba(255, 255, 255, 0.48) 43%,
      rgba(82, 88, 89, 0.24) 70%,
      rgba(255, 255, 255, 0.38)
    ),
    repeating-linear-gradient(
      0deg,
      rgba(255, 255, 255, 0.2) 0,
      rgba(255, 255, 255, 0.2) 0.08mm,
      rgba(77, 82, 85, 0.16) 0.13mm,
      rgba(236, 238, 238, 0.2) 0.28mm
    ),
    repeating-linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.18) 0,
      rgba(255, 255, 255, 0.18) 0.16mm,
      rgba(111, 116, 119, 0.12) 0.24mm,
      rgba(238, 240, 239, 0.22) 0.55mm
    ),
    linear-gradient(#e3e6e4, #b2b7b5 48%, #e7e9e8);
  color: #000;
  font-family: Arial, Helvetica, sans-serif;
}

.tag-logo {
  position: absolute;
  left: 1.5mm;
  top: 50%;
  width: 17.3mm;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 8.35mm;
  font-weight: 900;
  letter-spacing: -0.5mm;
  line-height: 1;
}

.tag-logo img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
}

.tag-content {
  position: absolute;
  left: 19.6mm;
  top: 1mm;
  width: 22.7mm;
  height: 18mm;
}

.tag-title {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  text-align: center;
  font-size: 1.9mm;
  font-weight: 900;
  line-height: 1;
}

.tag-qr-box {
  position: absolute;
  top: 1.9mm;
  left: 50%;
  transform: translateX(-50%);
  width: 13mm;
  height: 12.8mm;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0.2mm solid #111;
  border-radius: 1.05mm;
  background: rgba(255, 255, 255, 0.86);
  overflow: hidden;
}

#tagQrCanvas,
.batch-qr {
  width: 12mm !important;
  height: 12mm !important;
  max-width: 12mm;
  max-height: 12mm;
  image-rendering: pixelated;
}

.batch-controls {
  padding: 18px;
}

.batch-import {
  margin: 12px 0 18px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.batch-import summary {
  cursor: pointer;
  font-weight: 700;
}

.batch-import textarea {
  width: 100%;
  margin-top: 8px;
}

.batch-import-actions,
.batch-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.batch-table-wrap {
  max-height: 520px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.batch-table {
  width: 100%;
  border-collapse: collapse;
}

.batch-table th,
.batch-table td {
  padding: 7px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.batch-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fff;
  font-size: 0.82rem;
}

.batch-table th:first-child,
.batch-index {
  width: 34px;
  color: var(--muted);
  text-align: center;
}

.batch-table th:last-child,
.batch-table td:last-child {
  width: 42px;
}

.batch-table input {
  width: 100%;
  min-width: 110px;
}

.batch-preview-scroll {
  max-width: 100%;
  max-height: 760px;
  overflow: auto;
  padding: 12px;
  border-radius: 8px;
  background: #d8ddda;
}

.batch-sheet {
  display: grid;
  grid-template-columns: repeat(4, 45mm);
  grid-auto-rows: 20mm;
  gap: 2mm;
  align-content: start;
  justify-content: center;
}

.preview-sheet {
  width: 210mm;
  min-height: 297mm;
  padding: 8mm;
  background: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.batch-tag {
  break-inside: avoid;
}

.batch-qr {
  width: 12mm !important;
  height: 12mm !important;
  max-width: 12mm;
  max-height: 12mm;
  image-rendering: pixelated;
}

.tag-invalid .tag-qr-box {
  border-color: var(--accent);
  background: #fff0ec;
}

.batch-print {
  display: none;
}

.tag-number {
  position: absolute;
  left: 50%;
  bottom: 0.2mm;
  transform: translateX(-50%);
  width: 13mm;
  height: 2.3mm;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0.36mm solid #111;
  border-radius: 0.85mm;
  background: rgba(255, 255, 255, 0.68);
  font-size: 1.7mm;
  font-weight: 900;
  line-height: 1;
  overflow: hidden;
  white-space: nowrap;
}

.empty-state {
  padding: 28px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 760px) {
  .section-heading,
  .asset-title {
    align-items: stretch;
    flex-direction: column;
  }

  .document-row {
    grid-template-columns: 1fr;
  }

  .document-row .doc-link {
    grid-column: auto;
  }

  .search {
    max-width: none;
  }
}

@media print {
  html,
  body,
  .tag-shell,
  .tag-shell * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }

  .tag-shell {
    background: linear-gradient(
        92deg,
        rgba(255, 255, 255, 0.52),
        rgba(116, 122, 123, 0.28) 24%,
        rgba(255, 255, 255, 0.48) 43%,
        rgba(82, 88, 89, 0.24) 70%,
        rgba(255, 255, 255, 0.38)
      ),
      repeating-linear-gradient(
        0deg,
        rgba(255, 255, 255, 0.2) 0,
        rgba(255, 255, 255, 0.2) 0.08mm,
        rgba(77, 82, 85, 0.16) 0.13mm,
        rgba(236, 238, 238, 0.2) 0.28mm
      ),
      repeating-linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.18) 0,
        rgba(255, 255, 255, 0.18) 0.16mm,
        rgba(111, 116, 119, 0.12) 0.24mm,
        rgba(238, 240, 239, 0.22) 0.55mm
      ),
      linear-gradient(#e3e6e4, #b2b7b5 48%, #e7e9e8) !important;
  }

  @page {
    size: A4 portrait;
    margin: 8mm;
  }

  body.printing-term * {
    visibility: hidden;
  }

  body.printing-term .term-signatures {
    display: grid;
    grid-template-columns: 1fr 1fr;
    margin-top: 20px;
    border: 1px solid #000;
  }

  body.printing-term .term-signatures div {
    min-height: 70px;
    display: grid;
    align-content: end;
    gap: 2px;
    padding: 0 10px 6px;
  }

  body.printing-term .term-signatures div + div {
    border-left: 1px solid #000;
  }

  body.printing-term .term-signatures strong {
    font-weight: 400;
  }

  body.printing-tag * {
    visibility: hidden;
  }

  body.printing-tag .tag-shell {
    width: 45mm;
    height: 20mm;
  }

  body.printing-batch * {
    visibility: hidden;
  }

  body.printing-batch > :not(.batch-print) {
    display: none !important;
  }

  body.printing-batch .batch-print,
  body.printing-batch .batch-print * {
    visibility: visible;
  }

  body.printing-batch .batch-print {
    display: block;
    position: absolute;
    inset: 0;
    width: 194mm;
  }

  body.printing-batch .print-sheet {
    width: 194mm;
    height: 281mm;
    break-after: page;
    page-break-after: always;
  }

  body.printing-batch .print-sheet:last-child {
    break-after: auto;
    page-break-after: auto;
  }
}

/* Módulo: Termo de Responsabilidade Digital */
