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

:root {
  --bg: #0f0f0f;
  --bg2: #1a1a1a;
  --bg3: #252525;
  --border: #2e2e2e;
  --orange: #f47621;
  --orange-dim: #c25a10;
  --white: #f5f5f5;
  --gray: #888;
  --gray-light: #bbb;
  --green: #22c55e;
  --red: #ef4444;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(0,0,0,.5);
}

html, body { background: var(--bg); color: var(--white); font-family: 'Inter', sans-serif; min-height: 100vh; }

/* ─── LAYOUT ─── */
#app { max-width: 600px; margin: 0 auto; padding: 0 0 80px; min-height: 100vh; }

/* ─── HEADER ─── */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
  background: var(--bg);
}
.topbar-back {
  background: none; border: none; cursor: pointer;
  color: var(--orange); font-size: 22px; line-height: 1;
  padding: 4px 8px 4px 0; flex-shrink: 0;
}
.topbar-title { font-size: 17px; font-weight: 700; color: var(--white); flex: 1; }
.topbar-subtitle { font-size: 12px; color: var(--gray); margin-top: 1px; }
.topbar-action {
  background: var(--orange); border: none; cursor: pointer;
  color: var(--white); font-size: 13px; font-weight: 600;
  padding: 8px 14px; border-radius: 8px; white-space: nowrap;
}
.topbar-action:active { background: var(--orange-dim); }

/* ─── HOME ─── */
.home-header {
  display: flex; flex-direction: column; align-items: center;
  padding: 40px 24px 24px;
  text-align: center;
}
.home-logo { width: 80px; height: 80px; object-fit: contain; margin-bottom: 16px; border-radius: 16px; }
.home-logo-fallback {
  width: 80px; height: 80px; background: var(--orange); border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; font-weight: 700; color: var(--white); margin-bottom: 16px;
}
.home-title { font-size: 22px; font-weight: 700; color: var(--white); }
.home-sub { font-size: 13px; color: var(--gray); margin-top: 4px; }
.home-cards {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 16px; padding: 8px 16px 24px;
}
.module-card {
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 28px 16px; display: flex; flex-direction: column; align-items: center; gap: 12px;
  cursor: pointer; transition: border-color .2s, background .2s;
  text-align: center;
}
.module-card:active, .module-card:hover { border-color: var(--orange); background: #1f1f1f; }
.module-card.disabled { cursor: default; opacity: .6; }
.module-card.disabled:active, .module-card.disabled:hover { border-color: var(--border); background: var(--bg2); }
.module-icon { font-size: 42px; line-height: 1; }
.module-name { font-size: 16px; font-weight: 700; color: var(--white); letter-spacing: .5px; }
.module-badge {
  font-size: 11px; font-weight: 600; padding: 3px 8px;
  border-radius: 20px; background: var(--bg3); color: var(--gray);
}
.module-card.active .module-badge { background: var(--orange); color: var(--white); }

/* ─── CARDS / LIST ─── */
.list-section { padding: 12px 16px 0; }
.search-box {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 14px; margin-bottom: 16px;
}
.search-box input {
  background: none; border: none; outline: none; flex: 1;
  color: var(--white); font-size: 15px; font-family: inherit;
}
.search-box input::placeholder { color: var(--gray); }
.search-icon { color: var(--gray); font-size: 16px; }

.delivery-card {
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px; cursor: pointer;
  transition: border-color .15s;
}
.delivery-card:active, .delivery-card:hover { border-color: var(--orange); }
.delivery-card-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.delivery-number { font-size: 15px; font-weight: 700; color: var(--white); }
.badge {
  font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 20px;
}
.badge-rascunho { background: #2a2200; color: #f59e0b; }
.badge-finalizado { background: #052013; color: var(--green); }
.delivery-client { font-size: 14px; font-weight: 500; color: var(--white); margin-bottom: 4px; }
.delivery-meta { font-size: 12px; color: var(--gray); }
.empty-state { text-align: center; padding: 60px 24px; color: var(--gray); }
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-title { font-size: 16px; font-weight: 600; margin-bottom: 8px; color: var(--gray-light); }
.empty-sub { font-size: 13px; }

/* ─── FORM ─── */
.form-section { padding: 16px; }
.field { margin-bottom: 16px; }
.field-label { font-size: 12px; font-weight: 600; color: var(--gray); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px; display: block; }
.field-input {
  width: 100%; background: var(--bg2); border: 1px solid var(--border); border-radius: 10px;
  color: var(--white); font-size: 15px; font-family: inherit; padding: 12px 14px; outline: none;
  transition: border-color .15s;
}
.field-input:focus { border-color: var(--orange); }
.field-input::placeholder { color: var(--gray); }
textarea.field-input { resize: vertical; min-height: 80px; }

/* ─── DELIVERY DETAIL ─── */
.detail-section { padding: 16px; }
.detail-header {
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 16px;
}
.detail-row { display: flex; gap: 8px; margin-bottom: 8px; font-size: 14px; }
.detail-row:last-child { margin-bottom: 0; }
.detail-key { color: var(--gray); min-width: 110px; flex-shrink: 0; font-weight: 500; }
.detail-val { color: var(--white); flex: 1; }
.section-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px; margin-top: 4px;
}
.section-title { font-size: 16px; font-weight: 700; color: var(--white); }
.btn-add {
  background: var(--bg3); border: 1px solid var(--border); border-radius: 8px;
  color: var(--orange); font-size: 13px; font-weight: 600; padding: 7px 13px; cursor: pointer;
}
.btn-add:active { background: #2f2f2f; }

.bike-card {
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; margin-bottom: 10px;
}
.bike-card-top { display: flex; justify-content: space-between; align-items: flex-start; }
.bike-model { font-size: 14px; font-weight: 600; color: var(--white); }
.bike-chassi { font-size: 12px; color: var(--gray); margin-top: 2px; }
.bike-actions { display: flex; gap: 8px; }
.btn-icon {
  background: none; border: none; cursor: pointer; font-size: 18px;
  padding: 4px; border-radius: 6px; line-height: 1;
  transition: background .15s;
}
.btn-icon:active { background: var(--bg3); }
.btn-edit { color: var(--orange); }
.btn-del { color: var(--red); }
.checklist-preview { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.check-chip {
  font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 12px;
}
.check-ok { background: #052013; color: var(--green); }
.check-nok { background: #1a0505; color: var(--red); }

.sig-card {
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center;
}
.sig-info { flex: 1; }
.sig-name { font-size: 14px; font-weight: 600; color: var(--white); }
.sig-role { font-size: 12px; color: var(--gray); margin-top: 2px; }
.sig-img { width: 80px; height: 40px; object-fit: contain; border-radius: 4px; background: var(--bg3); }

/* ─── CHECKLIST ─── */
.checklist-section { margin-top: 8px; }
.checklist-title { font-size: 13px; font-weight: 700; color: var(--gray); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 12px; }
.check-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.check-item:last-of-type { border-bottom: none; }
.check-label { font-size: 15px; color: var(--white); }
.toggle-group { display: flex; gap: 6px; }
.toggle-btn {
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; font-weight: 600; padding: 7px 14px;
  cursor: pointer; background: var(--bg3); color: var(--gray);
  transition: all .15s;
}
.toggle-btn.ok.active { background: #052013; border-color: var(--green); color: var(--green); }
.toggle-btn.nok.active { background: #1a0505; border-color: var(--red); color: var(--red); }

/* quilometragem */
.km-field { display: flex; align-items: center; gap: 10px; }
.km-field input {
  flex: 1; background: var(--bg2); border: 1px solid var(--border); border-radius: 10px;
  color: var(--white); font-size: 16px; font-family: inherit; padding: 12px 14px; outline: none;
  transition: border-color .15s;
}
.km-field input:focus { border-color: var(--orange); }
.km-unit { font-size: 14px; color: var(--gray); font-weight: 500; }

/* ─── ASSINATURA ─── */
.sig-pad-wrapper {
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; margin-bottom: 12px;
}
.sig-pad-label {
  padding: 10px 14px; font-size: 12px; color: var(--gray); border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.sig-pad-clear {
  background: none; border: none; cursor: pointer; color: var(--gray);
  font-size: 12px; font-family: inherit;
}
.sig-pad-clear:active { color: var(--orange); }
canvas#sig-canvas {
  display: block; width: 100%; touch-action: none; background: #1e1e1e; cursor: crosshair;
}

/* ─── BOTÕES PRIMÁRIOS ─── */
.btn-primary {
  display: block; width: 100%; background: var(--orange); border: none;
  border-radius: var(--radius); color: var(--white); font-size: 16px; font-weight: 700;
  padding: 16px; cursor: pointer; text-align: center; font-family: inherit;
  transition: background .15s;
}
.btn-primary:active { background: var(--orange-dim); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-secondary {
  display: block; width: 100%; background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--white); font-size: 15px; font-weight: 600;
  padding: 14px; cursor: pointer; text-align: center; font-family: inherit;
  transition: background .15s;
}
.btn-secondary:active { background: #2f2f2f; }
.btn-secondary:disabled { opacity: .5; cursor: not-allowed; }
.btn-danger {
  display: block; width: 100%; background: #1a0505; border: 1px solid var(--red);
  border-radius: var(--radius); color: var(--red); font-size: 15px; font-weight: 600;
  padding: 14px; cursor: pointer; text-align: center; font-family: inherit;
}
.btn-group { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn-primary, .btn-row .btn-secondary { width: auto; flex: 1; padding: 14px 10px; }

/* ─── STATUS BLOCOS ─── */
.req-status {
  background: var(--bg3); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; margin-bottom: 14px;
}
.req-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--gray); margin-bottom: 4px; }
.req-row:last-child { margin-bottom: 0; }
.req-dot-ok { color: var(--green); font-size: 16px; }
.req-dot-fail { color: var(--red); font-size: 16px; }

/* ─── TOAST ─── */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #333; color: var(--white); font-size: 14px; font-weight: 500;
  padding: 12px 20px; border-radius: 10px; z-index: 1000;
  box-shadow: var(--shadow); transition: opacity .3s;
  max-width: 90vw; text-align: center;
}
.toast.hidden { opacity: 0; pointer-events: none; }
.toast.error { background: #7f1d1d; }
.toast.success { background: #14532d; }

/* ─── SPINNER ─── */
.spinner {
  width: 24px; height: 24px; border: 3px solid var(--border);
  border-top-color: var(--orange); border-radius: 50%;
  animation: spin .7s linear infinite; margin: 40px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-center { display: flex; justify-content: center; padding: 40px; }

/* ─── DIVIDER ─── */
.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* ─── LOGISTICA ─── */
.coming-soon {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 80px 24px; text-align: center;
}
.coming-soon-icon { font-size: 64px; margin-bottom: 20px; }
.coming-soon-title { font-size: 20px; font-weight: 700; color: var(--white); margin-bottom: 8px; }
.coming-soon-sub { font-size: 14px; color: var(--gray); line-height: 1.6; max-width: 280px; }

/* ─── DESKTOP ─── */
@media (min-width: 480px) {
  .home-cards { grid-template-columns: 1fr 1fr; }
  .module-card { padding: 36px 20px; }
  .module-icon { font-size: 52px; }
  .module-name { font-size: 18px; }
}
