/* ProjetoPam — estilo "A — Índigo Clássico".
   Variáveis de tema em :root (claro) e [data-theme="dark"] (escuro, mockups:
   fundo #111827, superfícies #1f2937, marca #4f46e5). */

:root {
  --bg: #f8f9fc;
  --surface: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --brand: #4f46e5;
  --brand-contrast: #ffffff;
  --border: #e5e7eb;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, .06);
}

[data-theme="dark"] {
  --bg: #111827;
  --surface: #1f2937;
  --text: #f9fafb;
  --muted: #9ca3af;
  --brand: #4f46e5;
  --brand-contrast: #ffffff;
  --border: #374151;
  --shadow: 0 1px 3px rgba(0, 0, 0, .4);
}

html {
  font-size: 14px;
  min-height: 100%;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a {
  color: var(--brand);
}

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

[data-theme="dark"] :focus-visible {
  outline-color: #a5b4fc;
}

/* ---------- Shell autenticado ---------- */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  width: 220px;
  flex: 0 0 220px;
  background: var(--brand);
  color: #fff;
  padding: 1rem 0.75rem;
}

.sidebar-brand {
  display: block;
  margin: 0 0.25rem 1.25rem;
  padding: 0.55rem 0.6rem;
  background: #fff;
  border-radius: 10px;
}

.sidebar-brand img {
  display: block;
  width: 100%;
  height: auto;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-link {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.75rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

.nav-link:hover {
  background: rgba(255, 255, 255, .15);
  color: #fff;
  text-decoration: none;
}

.nav-link.active {
  background: #fff;
  color: var(--brand);
  font-weight: 600;
}

.sidebar-logout {
  margin-top: auto;
  padding-top: 0.75rem;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 0.75rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.icon-button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  font-size: 1rem;
}

.menu-toggle,
.sidebar-close {
  display: none;
}

.sidebar-close {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, .18);
  color: #fff;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.sidebar-close:hover {
  background: rgba(255, 255, 255, .3);
}

.sidebar-backdrop {
  display: none;
}

.lang-switch {
  display: flex;
  gap: 0.25rem;
}

.lang-switch a {
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  font-size: 0.85rem;
}

.lang-switch a:hover {
  background: var(--brand);
  color: var(--brand-contrast);
}

.content {
  padding: 1.5rem;
}

/* ---------- Login (shell anónimo) ---------- */

.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.auth-topbar {
  position: fixed;
  top: 1rem;
  right: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  z-index: 10;
}

.auth-card {
  padding: 2rem;
}

.auth-brand {
  display: inline-block;
  margin-bottom: 1rem;
  padding: 0.5rem 0.6rem;
  background: #fff;
  border-radius: 10px;
}

.auth-brand img {
  display: block;
  width: 200px;
  max-width: 100%;
  height: auto;
}

.auth-card .form-label {
  color: var(--muted);
}

.auth-card .form-control {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.auth-card .form-control:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 0.2rem rgba(79, 70, 229, 0.15);
}

.auth-card .btn-brand {
  width: 100%;
  padding: 0.6rem 1rem;
  font-size: 0.95rem;
}

.btn-brand:hover {
  background: #4338ca;
  color: var(--brand-contrast);
}

/* ---------- Página / cartões ---------- */

.page {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
}

.page-head h1 {
  margin: 0;
}

.greeting {
  font-size: 1.5rem;
  margin: 0;
}

.card {
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.25rem;
}

.kpi-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.kpi {
  flex: 1 1 180px;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.kpi-label {
  color: var(--muted);
  font-size: 0.85rem;
}

.kpi-value {
  font-size: 1.75rem;
  font-weight: 700;
}

.kpi-brand {
  background: var(--brand);
  color: var(--brand-contrast);
}

.kpi-brand .kpi-label {
  color: rgba(255, 255, 255, .75);
}

/* ---------- Fila ---------- */

.queue-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.queue-title {
  font-size: 1.1rem;
  margin: 0;
}

.filters {
  display: flex;
  gap: 0.35rem;
}

.filter {
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  font-size: 0.85rem;
}

.filter.active {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--brand-contrast);
}

.search {
  margin-left: auto;
  display: flex;
  gap: 0.35rem;
}

.search-input {
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.btn-brand,
.btn-open {
  border: 0;
  border-radius: 999px;
  background: var(--brand);
  color: var(--brand-contrast);
  padding: 0.35rem 0.85rem;
  text-decoration: none;
  cursor: pointer;
  font-size: 0.85rem;
}

.btn-open:hover {
  color: var(--brand-contrast);
  text-decoration: none;
}

.queue-table {
  width: 100%;
  border-collapse: collapse;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-scroll > table {
  width: 100%;
}

.queue-table th,
.queue-table td {
  text-align: left;
  padding: 0.6rem 0.5rem;
  border-bottom: 1px solid var(--border);
}

.queue-table th {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.queue-thumb-cell {
  width: 3.5rem;
}

.queue-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 0.5rem;
  object-fit: cover;
  background: var(--surface-alt, rgba(127, 127, 127, .15));
}

.queue-thumb-placeholder {
  color: var(--muted);
  font-size: 1rem;
}

.empty {
  color: var(--muted);
  margin: 0;
  padding: 0.5rem 0;
}

/* ---------- Badges de status ---------- */

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 0.15rem 0.7rem;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-aguardandogestor,
.badge-aguardandorh,
.badge-aguardandoreembolso {
  background: #fef3c7;
  color: #92400e;
}

.badge-concluido {
  background: #d1fae5;
  color: #065f46;
}

.badge-devolvido {
  background: #fee2e2;
  color: #991b1b;
}

.badge-finalizado {
  background: #ede9fe;
  color: #5b21b6;
}

/* ---------- Configurações ---------- */

.profile {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 0.5rem 1rem;
  margin: 0;
}

.profile dt {
  color: var(--muted);
  font-weight: 500;
}

.profile dd {
  margin: 0;
}

.prefs {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.pref {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.pref-label {
  min-width: 120px;
  color: var(--muted);
}

.theme-buttons {
  display: flex;
  gap: 0.5rem;
}

.btn-theme-option {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 0.3rem 0.9rem;
  cursor: pointer;
}

/* ---------- Wizard "Novo lote" ---------- */

.wizard-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 760px;
}

.wizard-progress {
  color: var(--muted);
  font-size: 0.85rem;
}

.wizard-notice {
  margin: 0;
  background: #eef2ff;
  color: #3730a3;
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
}

[data-theme="dark"] .wizard-notice {
  background: rgba(79, 70, 229, .2);
  color: #c7d2fe;
}

.ai-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.ai-status [data-ai-failed] {
  color: #b45309;
}

.ai-status [data-ai-not-configured] {
  color: var(--muted);
}

.field-meal,
.fiscal-grid > div {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.field-meal[hidden] {
  display: none;
}

.fiscal-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.6rem;
}

@media (max-width: 620px) {
  .fiscal-grid {
    grid-template-columns: 1fr;
  }
}

.wizard-error:not(:empty) {
  background: #fee2e2;
  color: #991b1b;
  border-radius: 8px;
  padding: 0.6rem 1rem;
}

.wizard-error ul {
  margin: 0;
  padding-left: 1.1rem;
}

.receipt-group {
  display: none;
  flex-direction: column;
  gap: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.25rem;
}

.receipt-group.active {
  display: flex;
}

.field-photo,
.field-data {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

[data-step="1"] .field-data,
[data-step="2"] .field-photo,
[data-step="3"] .receipts {
  display: none;
}

.receipt-photo label {
  font-weight: 600;
}

.receipt-photo .hint {
  color: var(--muted);
  font-size: 0.8rem;
}

.hint-warning {
  color: #b45309;
  font-weight: 600;
}

.receipt-data label {
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 0.35rem;
}

.receipt-data input,
.receipt-data select {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

.wizard-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

[data-step="1"] [data-step-panel="2"],
[data-step="1"] [data-step-panel="3"],
[data-step="2"] [data-step-panel="1"],
[data-step="2"] [data-step-panel="3"],
[data-step="3"] [data-step-panel="1"],
[data-step="3"] [data-step-panel="2"] {
  display: none;
}

[data-step-panel="3"] {
  flex-direction: column;
  gap: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.25rem;
}

.review-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.review-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
}

.review-label {
  flex: 1;
}

.review-amount {
  font-weight: 600;
}

.review-remove {
  border: 0;
  background: transparent;
  color: #dc2626;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}

.review-edit {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.8rem;
}

.review-total {
  display: flex;
  justify-content: space-between;
  background: #eef2ff;
  color: #3730a3;
  border-radius: 8px;
  padding: 0.6rem 0.85rem;
}

.review-item-invalid {
  border-color: #fca5a5;
  background: #fef2f2;
}

[data-theme="dark"] .review-item-invalid {
  background: rgba(220, 38, 38, .15);
}

.review-item-invalid .review-label {
  color: #b91c1c;
}

.review-item-invalid .review-amount {
  color: #b91c1c;
  text-decoration: line-through;
}

.review-warning {
  margin: 0;
  background: #fef3c7;
  color: #92400e;
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
}

[data-theme="dark"] .review-warning {
  background: rgba(245, 158, 11, .18);
  color: #fcd34d;
}

[data-theme="dark"] .review-total {
  background: rgba(79, 70, 229, .2);
  color: #c7d2fe;
}

.wizard-actions {
  display: flex;
  gap: 0.5rem;
}

.btn-secondary {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  cursor: pointer;
  font-size: 0.85rem;
}

.btn-brand:disabled {
  opacity: .5;
  cursor: not-allowed;
}

/* ---------- Detalhe do lote ---------- */

.batch-detail {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.detail-head h1 {
  font-size: 1.35rem;
  margin: 0 0 0.35rem;
}

.detail-submitter {
  margin: 0;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.detail-total {
  font-size: 1.35rem;
  font-weight: 700;
}

.detail-error:not(:empty) {
  background: #fee2e2;
  color: #991b1b;
  border-radius: 8px;
  padding: 0.6rem 1rem;
}

.detail-error ul {
  margin: 0;
  padding-left: 1.1rem;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.75rem;
}

.action-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
}

.btn-danger {
  border: 1px solid #fecaca;
  background: var(--surface);
  color: #dc2626;
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  cursor: pointer;
  font-size: 0.85rem;
  list-style: none;
}

.return-box summary {
  cursor: pointer;
}

.return-box[open] {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
}

.return-box[open] summary {
  font-weight: 600;
  color: #dc2626;
}

.return-box label {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 0.5rem;
}

.return-box textarea {
  width: 100%;
  min-height: 72px;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  margin-bottom: 0.5rem;
}

.detail-columns {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 900px) {
  .detail-columns {
    grid-template-columns: 1fr;
  }
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}

.receipt-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.receipt-photo {
  display: block;
  height: 120px;
  background: linear-gradient(135deg, #c7d2fe, #a5b4fc);
}

.receipt-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.receipt-meta {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.6rem 0.75rem;
  font-size: 0.85rem;
}

.receipt-line {
  color: var(--muted);
  font-size: 0.8rem;
}

.receipt-link {
  margin-top: 0.25rem;
  font-size: 0.8rem;
}

.timeline {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.timeline-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--muted);
  margin: 0;
}

.timeline-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.timeline-item {
  display: flex;
  gap: 0.6rem;
}

.timeline-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--brand);
  margin-top: 4px;
  flex: 0 0 10px;
}

.timeline-body {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.timeline-date {
  color: var(--muted);
  font-size: 0.78rem;
}

.timeline-comment {
  margin: 0.15rem 0 0;
  font-size: 0.82rem;
}

.reimbursement {
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}

.reimbursement h3 {
  margin: 0 0 0.25rem;
  font-size: 0.9rem;
}

.reimbursement-note {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0.25rem 0 0;
}

/* ---------- Toasts ---------- */

.toast-container {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 1080;
}

.toast-message {
  background: var(--surface);
  color: var(--text);
  border-left: 4px solid var(--brand);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 0.6rem 1rem;
}

/* Administração: formulários e ações alinhados com os restantes ecrãs. */
.admin-form {
  display: grid;
  gap: 0.75rem;
  max-width: 34rem;
}

.admin-form label {
  font-weight: 600;
}

.admin-form input,
.admin-form select,
.admin-inline-form input {
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.admin-form button {
  justify-self: start;
}

.admin-inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin: 0 0 1rem;
}

.admin-actions {
  display: flex;
  gap: 0.35rem;
  align-items: center;
}

.admin-actions form {
  display: inline;
}

.admin-table td {
  vertical-align: middle;
}

.decision-modal {
  width: min(560px, calc(100vw - 2rem));
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  padding: 0;
}

.decision-modal::backdrop {
  background: rgb(0 0 0 / 45%);
}

.decision-modal form {
  display: grid;
  gap: 0.7rem;
  padding: 1.2rem;
}

.decision-modal header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.decision-modal h2 {
  margin: 0;
  font-size: 1.2rem;
}

.decision-modal label {
  font-weight: 600;
  font-size: 0.88rem;
}

.decision-modal select,
.decision-modal textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.decision-modal textarea {
  min-height: 5rem;
  resize: vertical;
}

.decision-modal .icon-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.4rem;
}

.decision-summary {
  display: flex;
  gap: 0.9rem;
  align-items: center;
  margin-bottom: 1rem;
}

.decision-summary-photo img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.receipt-fiscal {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.15rem 0.5rem;
  margin: 0.5rem 0;
  font-size: 0.82rem;
}

.receipt-fiscal dt {
  color: var(--muted);
}

.receipt-fiscal dd {
  margin: 0;
}

.rejection-card {
  display: grid;
  gap: 0.3rem;
  border-left: 4px solid #b42318;
  margin-bottom: 1rem;
}

.edit-form {
  display: grid;
  gap: 1rem;
}

.edit-receipt {
  display: grid;
  grid-template-columns: minmax(140px, 220px) 1fr;
  gap: 1rem;
}

.edit-photo img {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.edit-fields {
  display: grid;
  gap: 0.45rem;
}

.edit-fields label {
  font-weight: 600;
  font-size: 0.85rem;
}

.edit-fields input,
.edit-fields select {
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.fiscal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.6rem;
}

.fiscal-grid label {
  display: block;
  margin-bottom: 0.2rem;
}

@media (max-width: 767.98px) {
  .menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: 0.25rem;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    justify-content: flex-start;
    padding: 0.6rem 1rem;
  }

  .topbar #theme-toggle {
    margin-left: auto;
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1040;
    width: min(82vw, 300px);
    max-width: 300px;
    padding-top: 3rem;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-close {
    display: inline-flex;
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1030;
    background: rgba(17, 24, 39, 0.45);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.22s ease, visibility 0.22s ease;
  }

  .sidebar-backdrop.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  body.nav-open {
    overflow: hidden;
  }

  .content {
    padding: 1rem;
  }

  .page {
    gap: 1rem;
  }

  .page-head {
    align-items: flex-start;
  }

  .filters {
    flex-wrap: wrap;
  }

  .search {
    width: 100%;
    margin-left: 0;
  }

  .search-input {
    flex: 1;
    min-width: 0;
  }

  .profile {
    grid-template-columns: 1fr;
    gap: 0.15rem;
  }

  .profile dt {
    margin-top: 0.5rem;
  }

  .edit-receipt {
    grid-template-columns: 1fr;
  }

  .detail-head {
    flex-wrap: wrap;
  }

  .card {
    padding: 1rem;
  }

  .admin-form {
    max-width: none;
  }

  .admin-inline-form label,
  .admin-inline-form input {
    flex: 1 1 100%;
  }

  .admin-inline-form label {
    margin-bottom: -0.25rem;
  }

  .photo-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }

  .table-scroll .queue-table th,
  .table-scroll .queue-table td {
    white-space: nowrap;
  }

  .table-scroll-wide > table {
    min-width: 48rem;
  }
}

@media (max-width: 480px) {
  .auth-shell {
    padding: 1rem;
  }

  .auth-card {
    padding: 1.25rem;
  }

  .decision-modal {
    width: calc(100vw - 1rem);
  }

  .decision-modal form {
    padding: 0.9rem;
  }

  .dialog-actions {
    flex-direction: column-reverse;
  }

  .dialog-actions button {
    width: 100%;
  }

  .receipt-fiscal {
    grid-template-columns: 1fr;
  }

  .receipt-fiscal dt {
    margin-top: 0.35rem;
  }
}

[data-theme="dark"] .table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--text);
  --bs-table-border-color: var(--border);
  --bs-table-striped-color: var(--text);
  --bs-table-striped-bg: rgba(255, 255, 255, .04);
  --bs-table-active-color: var(--text);
  --bs-table-active-bg: rgba(255, 255, 255, .08);
  --bs-table-hover-color: var(--text);
  --bs-table-hover-bg: rgba(255, 255, 255, .06);
}

[data-theme="dark"] .wizard-error {
  background: rgba(220, 38, 38, .18);
  color: #fecaca;
}

[data-theme="dark"] .rejection-card {
  border-left-color: #f87171;
}

@media print {
  .site-header,
  .sidebar,
  .detail-actions,
  .print-actions,
  .flash {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
  }

  .card,
  .receipt-card {
    box-shadow: none;
    break-inside: avoid;
  }

  a {
    color: inherit;
    text-decoration: none;
  }
}
