/* ── Tokens ─────────────────────────────────────────────── */
:root {
  --color-brand:       #2b185a;
  --color-brand-light: #ece8f6;
  --color-accent:      #f6d200;
  --color-secondary:   #009f3b;

  --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;

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

  --max-width: 28rem;
}

/* ── Reset ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-fg);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
}
input, select, textarea, button { font-size: 1rem; font-family: inherit; }
a { color: inherit; text-decoration: none; }
p { margin: 0; }
h1, h2, h3 { margin: 0; }

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

/* ── 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;
}
.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 {
  width: 56px;
  height: 45px;
  border-radius: 0.25rem;
  background: #fff;
  padding: 0.25rem;
  object-fit: contain;
}
.brand-title { line-height: 1.2; }
.brand-name { font-size: 1rem; font-weight: 700; }
.brand-sub  { font-size: 0.75rem; opacity: 0.9; }
.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); }

/* ── 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-brand);
  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-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-print {
  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;
  border: none;
  cursor: pointer;
}
.btn-print:active { opacity: 0.8; }

/* ── Form fields ─────────────────────────────────────────── */
.field { display: block; }
.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%;
  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; }

.field-checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-gray-700);
}
.field-checkbox-label input[type=checkbox] { width: 1.25rem; height: 1.25rem; }

/* ── Histórico card ──────────────────────────────────────── */
.historico-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}
.historico-main { min-width: 0; }
.historico-title { font-weight: 600; }
.historico-sub  { font-size: 0.875rem; color: var(--color-gray-500); }
.historico-detail { margin-top: 0.25rem; font-size: 0.875rem; color: var(--color-gray-600); }
.historico-custo { white-space: nowrap; font-weight: 600; color: var(--color-gray-900); }

/* ── Vehicle info card ───────────────────────────────────── */
.vehicle-info-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: var(--radius-xl);
  background: var(--color-brand-light);
  padding: 0.75rem 1rem;
}
.vic-label  { font-size: 0.75rem; font-weight: 500; text-transform: uppercase; color: var(--color-brand); }
.vic-placa  { font-size: 1.125rem; font-weight: 700; color: var(--color-brand); }
.vic-modelo { font-size: 0.875rem; color: var(--color-gray-600); }
.vic-trocar { font-size: 0.875rem; font-weight: 500; color: var(--color-brand); text-decoration: underline; }

/* ── 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); }

.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;
}

/* ── Total card ──────────────────────────────────────────── */
.total-card {
  background: var(--color-brand);
  color: #fff;
}

/* ── Login ───────────────────────────────────────────────── */
.auth-body {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--color-gray-50);
  padding: 1.5rem;
}
.auth-card  { width: 100%; max-width: 24rem; }
.auth-logo  { display: block; margin: 0 auto 0.5rem; }
.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); }
.auth-error    { color: var(--color-red-600); font-size: 0.875rem; font-weight: 500; }

/* ── 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); }

.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; }

.print-only { display: none; }

/* ── Impressão ───────────────────────────────────────────── */
@media print {
  body { background: #fff; }

  .print-hidden { display: none !important; }
  .print-only   { display: block !important; }

  .app-main {
    max-width: 100%;
    padding: 0;
    padding-bottom: 0;
  }

  .card {
    box-shadow: none;
    border: 1px solid var(--color-gray-300);
    border-radius: 0;
    break-inside: avoid;
  }

  .total-card {
    background: #fff !important;
    color: var(--color-gray-900) !important;
    border: 1px solid var(--color-gray-300);
    box-shadow: none;
  }
}
