:root {
  --bg: #f4f2ee;
  --surface: #ffffff;
  --surface-alt: #f9f8f5;
  --border: #e0ddd6;
  --accent: #233e53;
  --accent-light: #2558a0;
  --accent-pale: #e8eef6;
  --danger: #c0392b;
  --success: #1a6b45;
  --success-pale: #e6f4ee;
  --text: #1c1c1c;
  --text-muted: #7a7670;
  --text-light: #b0aca4;
  --radius: 12px;
  --radius-sm: 6px;
  --shadow: 0 2px 16px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.12);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "DM Sans", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 40px 16px 80px;
}

/* Page wrapper */
.page {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Header */
.header {
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 36px 40px 32px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.brand-name {
  font-family: "Syne", sans-serif;
  font-weight: 800;
  font-size: 1.5rem;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.brand-tagline {
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.6);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand-meta {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.75);
}

.os-badge {
  text-align: right;
}

.os-label {
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
}

.os-number {
  font-family: "Syne", sans-serif;
  font-weight: 800;
  font-size: 1.5rem;
  line-height: 1;
  letter-spacing: -0.04em;
  color: #fff;
  margin-top: 4px;
}

.os-validity {
  font-size: 0.76rem;
  color: rgba(255, 255, 255, 0.5);
  margin-top: 6px;
}

/* Status bar */
.status-bar {
  background: var(--accent-light);
  padding: 10px 40px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.85);
  letter-spacing: 0.04em;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #f0c040;
  flex-shrink: 0;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.4;
  }
}

/* Main card */
.card {
  background: var(--surface);
  box-shadow: var(--shadow);
}

.card-section {
  padding: 32px 40px;
  border-bottom: 1px solid var(--border);
}

.card-section:last-child {
  border-bottom: none;
}

/* Section heading */
.section-title {
  font-family: "Syne", sans-serif;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Info grid */
.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 32px;
}

.info-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-light);
  margin-bottom: 3px;
}

.info-value {
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.4;
}

.info-value.highlight {
  color: var(--accent);
  font-weight: 600;
}

/* Machine card */
.machine-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.machine-cell {
  background: var(--surface-alt);
  padding: 14px 18px;
}

/* Laudo */
.laudo-box {
  background: #fffbf0;
  border: 1px solid #f0e0a0;
  border-left: 4px solid #f0c040;
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  font-size: 0.9rem;
  color: #6b5800;
  line-height: 1.6;
}

.laudo-link-btn {
  display: inline-block;
  margin-top: 12px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: background 0.2s ease;
}

.laudo-link-btn:hover {
  background: var(--accent-light);
}

/* Table wrapper (previne overflow no mobile) */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-sm);
  background:
    linear-gradient(to right, white 30%, rgba(255, 255, 255, 0)),
    linear-gradient(to right, rgba(255, 255, 255, 0), white 70%) 100% 0,
    linear-gradient(to right, rgba(0, 0, 0, 0.06), rgba(0, 0, 0, 0)),
    linear-gradient(to right, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.06)) 100% 0;
  background-repeat: no-repeat;
  background-size: 40px 100%, 40px 100%, 12px 100%, 12px 100%;
  background-attachment: local, local, scroll, scroll;
}

/* Table */
.data-table {
  width: 100%;
  min-width: 480px;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.data-table thead tr {
  background: var(--accent);
  color: rgba(255, 255, 255, 0.9);
}

.data-table thead th {
  padding: 11px 16px;
  text-align: left;
  font-family: "Syne", sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
}

.data-table thead th:last-child,
.data-table td:last-child {
  text-align: right;
}

.data-table thead th:nth-child(3),
.data-table thead th:nth-child(4),
.data-table td:nth-child(3),
.data-table td:nth-child(4) {
  text-align: center;
}

.data-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

.data-table tbody tr:last-child {
  border-bottom: none;
}

.data-table tbody tr:hover {
  background: var(--surface-alt);
}

.data-table td {
  padding: 14px 16px;
  color: var(--text);
  white-space: nowrap;
}

/* So a coluna de descricao pode quebrar linha */
.data-table td:first-child {
  white-space: normal;
  min-width: 140px;
}

.item-code {
  font-family: "DM Sans", monospace;
  font-size: 0.75rem;
  color: var(--text-light);
  display: block;
  margin-top: 2px;
}

.ncm-badge {
  display: inline-block;
  background: var(--accent-pale);
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.currency {
  font-weight: 600;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

/* Totals */
.totals-section {
  background: var(--surface-alt);
  padding: 28px 40px;
  display: flex;
  justify-content: flex-end;
}

.totals-box {
  min-width: 280px;
}

.total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}

.total-row:last-child {
  border-bottom: none;
  padding-top: 14px;
  margin-top: 4px;
}

.total-label {
  color: var(--text-muted);
}

.total-value {
  font-weight: 500;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.grand-total-label {
  font-family: "Syne", sans-serif;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
}

.grand-total-value {
  font-family: "Syne", sans-serif;
  font-weight: 800;
  font-size: 1.4rem;
  color: var(--accent);
  letter-spacing: -0.02em;
}

/* Payment */
.payment-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.payment-chip {
  background: var(--accent-pale);
  border: 1px solid #c5d8ef;
  border-radius: var(--radius-sm);
  padding: 14px 18px;
}

.payment-chip .info-label {
  color: var(--accent-light);
}

.payment-chip .info-value {
  color: var(--accent);
}

/* Tech responsible */
.tech-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.tech-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-family: "Syne", sans-serif;
  font-weight: 700;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Signature section */
.signature-section {
  background: var(--surface);
  border-radius: 0 0 var(--radius) var(--radius);
  border-top: 2px solid var(--border);
  padding: 40px;
}

.signature-header {
  text-align: center;
  margin-bottom: 28px;
}

.signature-header h2 {
  font-family: "Syne", sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.signature-header p {
  font-size: 0.85rem;
  color: var(--text-muted);
  max-width: 460px;
  margin: 0 auto;
  line-height: 1.5;
}

.signature-form {
  max-width: 440px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sig-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.sig-field label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 500;
}

.sig-field input {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-family: "DM Sans", sans-serif;
  font-size: 0.92rem;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.sig-field input:focus {
  border-color: var(--accent-light);
  box-shadow: 0 0 0 3px rgba(37, 88, 160, 0.12);
}

.sig-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  font-size: 0.84rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.sig-checkbox input[type="checkbox"] {
  margin-top: 2px;
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  flex-shrink: 0;
  cursor: pointer;
}

.btn-authorize {
  width: 100%;
  padding: 15px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: "Syne", sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
  margin-top: 6px;
}

.btn-authorize:hover:not(:disabled) {
  background: var(--accent-light);
  box-shadow: 0 4px 18px rgba(26, 58, 92, 0.3);
}

.btn-authorize:active:not(:disabled) {
  transform: scale(0.98);
}

.btn-authorize:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Success state */
.success-message {
  display: none;
  background: var(--success-pale);
  border: 1.5px solid #a8dcc0;
  border-radius: var(--radius-sm);
  padding: 20px 24px;
  text-align: center;
  color: var(--success);
}

.success-message.visible {
  display: block;
  animation: fadeIn 0.4s ease;
}

.success-icon {
  font-size: 2rem;
  margin-bottom: 8px;
}

.success-message h3 {
  font-family: "Syne", sans-serif;
  font-weight: 700;
  margin-bottom: 4px;
}

.success-message p {
  font-size: 0.84rem;
  opacity: 0.8;
}

.success-meta {
  font-size: 0.75rem;
  margin-top: 8px;
  opacity: 0.65;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Footer */
.footer {
  text-align: center;
  margin-top: 28px;
  font-size: 0.75rem;
  color: var(--text-light);
  line-height: 1.6;
}

/* Table sub-header */
.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.table-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-pale);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: 20px;
}

@media (max-width: 600px) {
  .header {
    flex-direction: column;
    padding: 24px 24px 20px;
  }

  .os-badge {
    text-align: left;
  }

  .card-section {
    padding: 20px 16px;
  }

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

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

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

  .totals-section {
    padding: 20px 24px;
  }

  .signature-section {
    padding: 28px 24px;
  }

  .status-bar {
    padding: 10px 24px;
  }

  .data-table {
    font-size: 0.8rem;
    min-width: 420px;
  }

  .data-table th,
  .data-table td {
    padding: 9px 10px;
  }
}
