/* ── Tokens (paleta Procel: azul-marinho + vermelho) ───────── */
:root {
  --color-brand:       #2b2b5e;
  --color-brand-light: #e7e7f3;
  --color-accent:      #e63329;

  --color-bg:          #f3f4f6;
  --color-fg:          #111827;

  --color-gray-50:  #f9fafb;
  --color-gray-100: #f3f4f6;
  --color-gray-200: #e5e7eb;
  --color-gray-300: #d1d5db;
  --color-gray-400: #9ca3af;
  --color-gray-500: #6b7280;
  --color-gray-600: #4b5563;
  --color-gray-700: #374151;
  --color-gray-900: #111827;

  --color-red-50:  #fef2f2;
  --color-red-100: #fee2e2;
  --color-red-600: #dc2626;
  --color-red-700: #b91c1c;
  --color-red-800: #991b1b;

  --color-green-100: #dcfce7;
  --color-green-800: #166534;

  --color-yellow-100: #fef9c3;
  --color-yellow-800: #854d0e;

  --color-blue-100: #dbeafe;
  --color-blue-800: #1e40af;

  --radius-xl:   0.75rem;
  --radius-2xl:  1rem;
  --radius-full: 9999px;

  --max-width: 28rem;
  --max-width-desktop: 48rem;
}

/* ── Reset ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; min-width: 0; }
html {
  overflow-x: hidden;
  max-width: 100%;
}
body {
  margin: 0;
  overflow-x: hidden;
  width: 100%;
  max-width: 100%;
  background: var(--color-bg);
  color: var(--color-fg);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
}
img, video, iframe, svg { max-width: 100%; }
input, select, textarea { font-size: 1rem; font-family: inherit; width: 100%; max-width: 100%; }
button { font-size: 1rem; font-family: inherit; max-width: 100%; }
a { color: inherit; text-decoration: none; }
p { margin: 0; overflow-wrap: break-word; word-break: break-word; }
h1, h2, h3 { margin: 0; overflow-wrap: break-word; word-break: break-word; }

/* ── Shell ───────────────────────────────────────────────── */
.app-shell { display: flex; min-height: 100vh; flex-direction: column; overflow-x: hidden; }
.app-main {
  margin: 0 auto;
  width: 100%;
  max-width: var(--max-width);
  min-width: 0;
  flex: 1;
  padding: 1rem;
  padding-bottom: 6rem;
  overflow-x: hidden;
}

/* ── Spacing helpers ─────────────────────────────────────── */
.space-y-4 > * + * { margin-top: 1rem; }
.space-y-3 > * + * { margin-top: 0.75rem; }
.space-y-2 > * + * { margin-top: 0.5rem; }

/* ── Header ──────────────────────────────────────────────── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 4px solid var(--color-accent);
  background: var(--color-brand);
  color: #fff;
  padding: 0.5rem 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.header-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.header-icon-link {
  font-size: 1.125rem;
  opacity: 0.85;
  text-decoration: none;
}
.header-icon-link:active { opacity: 0.6; }
.back-btn {
  background: none;
  border: none;
  color: #fff;
  padding: 0 0.25rem 0 0;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.85;
}
.back-btn:active { opacity: 0.5; }
.logo {
  height: 32px;
  width: auto;
  border-radius: 0.25rem;
  object-fit: contain;
}
.logout-btn {
  border-radius: 0.5rem;
  background: rgba(255,255,255,0.15);
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  border: none;
  color: #fff;
  cursor: pointer;
}
.logout-btn:active { background: rgba(255,255,255,0.25); }

/* ── Bottom nav ──────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  border-top: 1px solid var(--color-gray-200);
  background: #fff;
}
.nav-inner {
  margin: 0 auto;
  display: flex;
  width: 100%;
  max-width: var(--max-width);
}
.nav-item {
  flex: 1 1 0%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.125rem;
  padding: 0.625rem 0;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-gray-500);
}
.nav-item.active { color: var(--color-brand); }
.nav-icon { font-size: 1.25rem; }

/* ── Cards ───────────────────────────────────────────────── */
.card {
  border-radius: var(--radius-2xl);
  background: #fff;
  padding: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
}
.card-link { display: block; }

/* ── Status badge ────────────────────────────────────────── */
.status-badge {
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius-full);
  padding: 0.25rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-green  { background: var(--color-green-100);  color: var(--color-green-800); }
.badge-yellow { background: var(--color-yellow-100); color: var(--color-yellow-800); }
.badge-red    { background: var(--color-red-100);    color: var(--color-red-800); }
.badge-blue   { background: var(--color-blue-100);   color: var(--color-blue-800); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn-big {
  display: block;
  width: 100%;
  border-radius: var(--radius-xl);
  text-align: center;
  cursor: pointer;
  font-weight: 600;
}
.btn-big:active { opacity: 0.8; }
.btn-big-primary  { background: var(--color-brand); color: #fff; }
.btn-big-secondary { background: #fff; color: var(--color-gray-900); border: 1px solid var(--color-gray-300); }
.btn-big-lg { padding: 1rem; font-size: 1.125rem; }
.btn-big-sm { padding: 0.75rem 0.5rem; font-size: 0.875rem; }

.btn-submit {
  width: 100%;
  border-radius: var(--radius-xl);
  background: var(--color-accent);
  color: #fff;
  padding: 0.75rem 1rem;
  font-size: 1.125rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
}
.btn-submit:active   { opacity: 0.9; }
.btn-submit:disabled { opacity: 0.6; }

.btn-back {
  display: block;
  width: 100%;
  border-radius: var(--radius-xl);
  border: 1px solid var(--color-gray-300);
  background: #fff;
  padding: 0.75rem 0.5rem;
  text-align: center;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-gray-900);
  cursor: pointer;
}
.btn-back:active { opacity: 0.8; }

.btn-print {
  display: block;
  width: 100%;
  border-radius: var(--radius-xl);
  background: var(--color-brand-light);
  color: var(--color-brand);
  padding: 0.75rem 1rem;
  text-align: center;
  font-size: 0.9375rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
}
.btn-print:active { opacity: 0.8; }

.btn-delete {
  width: 100%;
  border-radius: var(--radius-xl);
  background: var(--color-red-50);
  color: var(--color-red-600);
  text-align: center;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.75rem 1rem;
  border: none;
  cursor: pointer;
}
.btn-delete:active { background: var(--color-red-100); }

.btn-link {
  display: inline-block;
  border-radius: var(--radius-xl);
  background: var(--color-brand-light);
  color: var(--color-brand);
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  text-align: center;
}

/* ── Form fields ─────────────────────────────────────────── */
.field { display: block; }
.section-label {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-gray-500);
  padding-top: 0.25rem;
}
.field-label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-gray-700);
}
.field-input,
.field-select,
.field-textarea {
  width: 100%;
  max-width: 100%;
  border-radius: var(--radius-xl);
  border: 1px solid var(--color-gray-300);
  background: #fff;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  color: var(--color-gray-900);
}
.field-input:focus,
.field-select:focus,
.field-textarea:focus  { border-color: var(--color-brand); outline: none; }
.field-input[disabled] { background: var(--color-gray-100); color: var(--color-gray-500); cursor: not-allowed; }

.foto-thumb {
  display: block;
  width: 100%;
  max-width: 160px;
  height: auto;
  border-radius: var(--radius-xl);
  margin-bottom: 0.5rem;
  border: 1px solid var(--color-gray-300);
}
.foto-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
.foto-grid img {
  width: 100%;
  height: auto;
  border-radius: var(--radius-xl);
  border: 1px solid var(--color-gray-300);
}
.foto-grid p {
  font-size: 0.75rem;
  color: var(--color-gray-500);
  margin-top: 0.25rem;
  text-align: center;
}

/* ── Listagem / linha de item ────────────────────────────── */
.item-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}
.item-main { min-width: 0; overflow: hidden; }
.item-title { font-weight: 600; overflow-wrap: break-word; word-break: break-word; }
.item-sub  { font-size: 0.875rem; color: var(--color-gray-500); overflow-wrap: break-word; }
.item-detail { margin-top: 0.25rem; font-size: 0.875rem; color: var(--color-gray-600); overflow-wrap: break-word; }
.item-valor { white-space: nowrap; font-weight: 600; color: var(--color-gray-900); }

/* ── Alertas e erros ─────────────────────────────────────── */
.alert-banner {
  border-radius: var(--radius-xl);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
}
.alert-banner.alert-red    { background: var(--color-red-100);    color: var(--color-red-800); }
.alert-banner.alert-yellow { background: var(--color-yellow-100); color: var(--color-yellow-800); }
.alert-banner.alert-green  { background: var(--color-green-100);  color: var(--color-green-800); }

.error-banner {
  border-radius: var(--radius-xl);
  background: var(--color-red-50);
  color: var(--color-red-700);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
}

.dashed-empty {
  border: 2px dashed var(--color-brand);
  background: var(--color-brand-light);
  border-radius: var(--radius-xl);
  padding: 1rem;
  text-align: center;
}

/* ── Cards de total (dashboard) ──────────────────────────── */
.total-card {
  background: var(--color-brand);
  color: #fff;
}
.total-card.accent {
  background: var(--color-accent);
}
.total-card .total-label { font-size: 0.8125rem; opacity: 0.85; text-transform: uppercase; letter-spacing: 0.04em; }
.total-card .total-valor { font-size: 1.5rem; font-weight: 700; margin-top: 0.25rem; }

.totais-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

/* ── Login ───────────────────────────────────────────────── */
.auth-body {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--color-brand);
  padding: 1.5rem;
}
.auth-card  { width: 100%; max-width: 24rem; }
.auth-logo  { display: block; margin: 0 auto 1rem; max-width: 220px; }
.auth-title {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-gray-900);
  margin-bottom: 0.25rem;
}
.auth-subtitle { text-align: center; color: var(--color-gray-500); margin-bottom: 1rem; }
.auth-error    { color: var(--color-red-600); font-size: 0.875rem; font-weight: 500; }
.auth-card .field-label { color: rgba(255,255,255,0.85); }

/* ── Utilitários ─────────────────────────────────────────── */
.text-xs  { font-size: 0.75rem; }
.text-sm  { font-size: 0.875rem; }
.text-lg  { font-size: 1.125rem; }
.text-xl  { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }

.font-medium   { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold     { font-weight: 700; }

.text-gray-400 { color: var(--color-gray-400); }
.text-gray-500 { color: var(--color-gray-500); }
.text-gray-600 { color: var(--color-gray-600); }
.text-gray-700 { color: var(--color-gray-700); }
.text-accent   { color: var(--color-accent); }
.text-brand    { color: var(--color-brand); }

.flex             { display: flex; }
.items-center     { align-items: center; }
.items-start      { align-items: flex-start; }
.justify-between  { justify-content: space-between; }
.gap-2            { gap: 0.5rem; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mb-2 { margin-bottom: 0.5rem; }

/* ── Sidebar (desktop) ──────────────────────────────────── */
.sidebar { display: none; }
.sidebar-logo { width: 100%; max-width: 160px; margin: 0 auto 2rem; display: block; }
.sidebar-nav { display: flex; flex-direction: column; gap: 0.25rem; flex: 1; }
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-xl);
  color: rgba(255,255,255,0.75);
  font-weight: 500;
  font-size: 0.9375rem;
  border-left: 3px solid transparent;
}
.sidebar-link:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar-link.active {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border-left-color: var(--color-accent);
}
.sidebar-logout-form { margin-top: auto; }
.sidebar-logout-btn {
  width: 100%;
  border-radius: var(--radius-xl);
  background: rgba(255,255,255,0.1);
  color: #fff;
  padding: 0.75rem 1rem;
  font-size: 0.9375rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
}
.sidebar-logout-btn:active { background: rgba(255,255,255,0.2); }

/* ── Desktop / telas largas ──────────────────────────────── */
@media (min-width: 768px) {
  .app-shell {
    flex-direction: row;
  }
  .sidebar {
    display: flex;
    flex-direction: column;
    width: 220px;
    flex-shrink: 0;
    background: var(--color-brand);
    border-right: 4px solid var(--color-accent);
    padding: 1.5rem 1rem;
    position: sticky;
    top: 0;
    height: 100vh;
  }
  .app-header,
  .bottom-nav {
    display: none;
  }
  .app-content {
    flex: 1;
    min-width: 0;
  }
  .app-main {
    max-width: var(--max-width-desktop);
    margin: 0 auto;
    padding: 2rem;
    padding-bottom: 2rem;
  }
  .form-card {
    max-width: 28rem;
    margin: 0 auto;
  }
}

@media (min-width: 900px) {
  .list-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
  }
  .list-grid > * {
    margin-top: 0;
  }
}

/* ── Recibo / impressão ──────────────────────────────────── */
.print-only { display: none; }

.receipt-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.receipt-logo { height: 48px; width: auto; }
.receipt-title { font-size: 1.125rem; font-weight: 700; }
.receipt-subtitle { font-size: 0.875rem; color: var(--color-gray-500); }
.receipt-row {
  display: flex;
  justify-content: space-between;
  padding: 0.375rem 0;
  border-bottom: 1px solid var(--color-gray-200);
  font-size: 0.9375rem;
}
.receipt-signature {
  margin-top: 3rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--color-gray-900);
  text-align: center;
  font-size: 0.875rem;
  color: var(--color-gray-600);
  max-width: 20rem;
  margin-left: auto;
  margin-right: auto;
}

@media print {
  body { background: #fff; }
  .sidebar,
  .app-header,
  .bottom-nav,
  .print-hidden {
    display: none !important;
  }
  .print-only { display: block; }
  .app-content { margin: 0; }
  .app-main {
    max-width: 100%;
    padding: 0;
  }
  .card {
    box-shadow: none;
    border: 1px solid var(--color-gray-300);
  }
}
