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

:root {
  --azul: #1a73e8;
  --azul-escuro: #1557b0;
  --cinza-bg: #f5f7fa;
  --cinza-borda: #e0e4ea;
  --cinza-texto: #5f6368;
  --preto: #202124;
  --branco: #ffffff;
  --verde: #34a853;
  --vermelho: #ea4335;
  --amarelo: #fbbc04;
  --laranja: #fa7b17;
  --nav-height: 64px;
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 15px;
  background: var(--cinza-bg);
  color: var(--preto);
  min-height: 100vh;
  padding-bottom: var(--nav-height);
}

/* ── Splash ── */
.tela-carregando {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1a1a2e;
}
.logo-splash { text-align: center; }
.logo-ticia { color: #aaa; font-size: 13px; letter-spacing: 3px; text-transform: uppercase; }
.logo-sistema { color: #fff; font-size: 36px; font-weight: 700; letter-spacing: 2px; margin-top: 4px; }

/* ── Bottom Nav ── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-height);
  background: var(--branco);
  border-top: 1px solid var(--cinza-borda);
  display: flex;
  z-index: 100;
  box-shadow: 0 -2px 8px rgba(0,0,0,.06);
}
.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--cinza-texto);
  font-family: inherit;
  font-size: 11px;
  position: relative;
  transition: color .15s;
}
.nav-btn.active { color: var(--azul); }
.nav-icon { font-size: 20px; line-height: 1; }
.nav-label { font-size: 10px; font-weight: 500; }
.nav-badge {
  position: absolute;
  top: 6px; right: calc(50% - 16px);
  background: var(--vermelho);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}
.nav-badge.visible { display: flex; }

/* ── Views ── */
.view { display: none; padding: 16px; }
.view.active { display: block; }

.view-header { margin-bottom: 16px; }
.view-header h1 { font-size: 20px; font-weight: 600; }
.view-subtitle { font-size: 12px; color: var(--cinza-texto); margin-top: 2px; }

/* ── Cards de OS ── */
.os-card {
  background: var(--branco);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,.07);
  cursor: pointer;
  transition: box-shadow .15s;
}
.os-card:active { box-shadow: 0 2px 8px rgba(0,0,0,.12); }

.os-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.os-ticket { font-size: 11px; font-weight: 700; color: var(--azul); }
.os-cliente { font-size: 15px; font-weight: 600; flex: 1; }
.os-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12px;
  color: var(--cinza-texto);
  margin-top: 4px;
}
.os-desc {
  font-size: 13px;
  color: var(--cinza-texto);
  margin-top: 6px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.os-tecnicos-lista {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}
.tecnico-chip {
  background: #e8f0fe;
  color: var(--azul);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
}
.tecnico-chip.apoio { background: #f1f3f4; color: var(--cinza-texto); }

/* ── Chips de status e tipo ── */
.chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.chip-pool           { background: #f1f3f4; color: var(--cinza-texto); }
.chip-assumida       { background: #e8f0fe; color: var(--azul); }
.chip-deslocamento   { background: #fef7e0; color: #b06000; }
.chip-checkin        { background: #e6f4ea; color: #1e7e34; }
.chip-finalizado_ok  { background: #e6f4ea; color: var(--verde); }
.chip-finalizado_pendencia { background: #fce8e6; color: var(--vermelho); }
.chip-cancelada      { background: #f1f3f4; color: var(--cinza-texto); }

.chip-instalacao      { background: #e8f0fe; color: var(--azul); }
.chip-manutencao      { background: #fef7e0; color: #b06000; }
.chip-reparo_rapido   { background: #fce8e6; color: var(--vermelho); }
.chip-visita_tecnica  { background: #f1f3f4; color: var(--cinza-texto); }

/* ── Botões ── */
.btn-primary {
  background: var(--azul);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  width: 100%;
  transition: background .15s;
}
.btn-primary:active { background: var(--azul-escuro); }
.btn-primary.verde { background: var(--verde); }
.btn-primary.vermelho { background: var(--vermelho); }
.btn-primary.laranja { background: var(--laranja); }

.btn-secondary {
  background: #f1f3f4;
  color: var(--preto);
  border: none;
  border-radius: 8px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  width: 100%;
  transition: background .15s;
}

.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}
.btn-row .btn-primary,
.btn-row .btn-secondary { flex: 1; width: auto; padding: 12px 12px; }

/* ── Formulários ── */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--cinza-texto);
  text-transform: uppercase;
  letter-spacing: .4px;
  margin-bottom: 5px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--cinza-borda);
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
  background: var(--branco);
  color: var(--preto);
  outline: none;
  transition: border-color .15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--azul); }
.form-group textarea { resize: vertical; min-height: 80px; }

/* autocomplete */
.autocomplete-lista {
  border: 1px solid var(--cinza-borda);
  border-top: none;
  border-radius: 0 0 8px 8px;
  background: var(--branco);
  max-height: 200px;
  overflow-y: auto;
}
.autocomplete-item {
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--cinza-borda);
  font-size: 14px;
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:active { background: var(--cinza-bg); }
.autocomplete-sub { font-size: 11px; color: var(--cinza-texto); margin-top: 2px; }

/* ── Modal ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  align-items: flex-end;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--branco);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--cinza-borda);
  flex-shrink: 0;
}
.modal-header h2 { font-size: 17px; font-weight: 600; }
.modal-close {
  background: #f1f3f4;
  border: none;
  width: 30px; height: 30px;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-body {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  padding: 12px 20px 20px;
  border-top: 1px solid var(--cinza-borda);
  flex-shrink: 0;
}

/* ── Seções no modal ── */
.secao-titulo {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--cinza-texto);
  margin: 16px 0 8px;
}
.secao-titulo:first-child { margin-top: 0; }

/* ── Movimentos / histórico ── */
.movimento-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--cinza-borda);
  font-size: 13px;
}
.movimento-item:last-child { border-bottom: none; }
.movimento-header { display: flex; justify-content: space-between; align-items: center; }
.movimento-tecnico { font-weight: 600; }
.movimento-data { color: var(--cinza-texto); font-size: 11px; }
.movimento-obs { color: var(--cinza-texto); margin-top: 3px; }

/* ── Custo item ── */
.custo-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--cinza-borda);
  font-size: 13px;
}
.custo-item:last-child { border-bottom: none; }
.custo-valor { font-weight: 700; color: var(--preto); }
.custo-forma { font-size: 11px; color: var(--cinza-texto); }

/* ── Agenda ── */
.agenda-dia {
  margin-bottom: 20px;
}
.agenda-dia-titulo {
  font-size: 13px;
  font-weight: 700;
  color: var(--cinza-texto);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 2px solid var(--cinza-borda);
}
.agenda-dia-titulo.hoje { color: var(--azul); border-color: var(--azul); }

/* ── Visão geral ── */
.tecnico-row {
  background: var(--branco);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.tecnico-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--azul);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}
.tecnico-info { flex: 1; min-width: 0; }
.tecnico-nome { font-weight: 600; font-size: 14px; }
.tecnico-os-count { font-size: 12px; color: var(--cinza-texto); margin-top: 2px; }

/* ── Vazio ── */
.vazio {
  text-align: center;
  padding: 48px 24px;
  color: var(--cinza-texto);
}
.vazio-icone { font-size: 40px; margin-bottom: 12px; }
.vazio-titulo { font-size: 16px; font-weight: 600; color: var(--preto); margin-bottom: 4px; }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: calc(var(--nav-height) + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--preto);
  color: #fff;
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  transition: opacity .2s, transform .2s;
  pointer-events: none;
  white-space: nowrap;
  z-index: 300;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.erro { background: var(--vermelho); }
.toast.ok { background: var(--verde); }

/* ── Desktop (>= 768px) ── */
@media (min-width: 768px) {
  body { display: flex; padding-bottom: 0; }

  .bottom-nav {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: 200px;
    height: 100vh;
    flex-direction: column;
    border-top: none;
    border-right: 1px solid var(--cinza-borda);
    padding: 24px 0;
    box-shadow: 2px 0 8px rgba(0,0,0,.04);
  }

  .nav-btn {
    flex-direction: row;
    justify-content: flex-start;
    padding: 12px 20px;
    gap: 12px;
    border-radius: 0;
    font-size: 14px;
  }
  .nav-icon { font-size: 18px; }
  .nav-label { font-size: 14px; }
  .nav-badge { position: static; margin-left: auto; }

  #app { margin-left: 200px; flex: 1; }

  .view { max-width: 800px; padding: 24px; }

  .modal-overlay { align-items: center; }
  .modal {
    border-radius: 16px;
    max-width: 560px;
    margin: 0 auto;
    max-height: 85vh;
  }

  .toast { bottom: 24px; }
}
