/* ============================================================
   Sistema de Coletas Externas — Laboratório Analisys | Estilos
   Mesma identidade do Analisys Connect (vermelho #db0110 + branco +
   preto, Inter + Sora): é o mesmo laboratório e a recepção usa os dois
   sistemas lado a lado.
   ============================================================ */
:root {
  --red: #db0110;
  --red-2: #a8010c;
  --red-soft: #fdeceb;
  --red-bright: #ff5252;
  --ink-900: #141414;
  --ink-800: #1e1e1e;
  --bg: #f7f7f7;
  --card: #ffffff;
  --ink: #161616;
  --muted: #6b6b6b;
  --line: #e6e6e6;
  --ok: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --blue: #0ea5e9;
  --violet: #8b5cf6;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 8px 24px rgba(0,0,0,.06);
  --shadow-lg: 0 20px 50px rgba(0,0,0,.2);
  font-synthesis: none;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg); color: var(--ink);
  -webkit-font-smoothing: antialiased; line-height: 1.5;
}
h1, h2, h3, .num { font-family: "Sora", "Inter", sans-serif; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ===================== Layout ===================== */
.layout { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, var(--ink-900) 0%, #202020 60%, #0c0c0c 100%);
  color: #e2e2e2; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar__brand { padding: 20px 20px 10px; }
.sidebar__logo { width: 100%; max-width: 180px; height: auto; display: block; }
.sidebar__tag { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .12em; color: #9a9a9a; margin: 6px 20px 10px; font-weight: 700; }
.sidebar__nav { padding: 6px 12px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.navlink {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px;
  color: #cfcfcf; font-size: 14px; font-weight: 500; border: 0; background: none; width: 100%; text-align: left;
}
.navlink:hover { background: rgba(255,255,255,.07); color: #fff; }
.navlink--on { background: var(--red); color: #fff; font-weight: 600; }
.navlink__ico { width: 18px; text-align: center; }
.sidebar__foot { padding: 14px 16px 18px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12.5px; color: #a6a6a6; }
.sidebar__user { color: #fff; font-weight: 600; font-size: 13.5px; }
.sidebar__acoes { display: flex; gap: 6px; margin-top: 10px; }
.sidebar__acoes button {
  flex: 1; background: rgba(255,255,255,.08); color: #ddd; border: 0; border-radius: 8px; padding: 7px; font-size: 12px;
}
.sidebar__acoes button:hover { background: rgba(255,255,255,.16); color: #fff; }

.main { min-width: 0; }
.topbar {
  background: #fff; border-bottom: 1px solid var(--line); padding: 16px 28px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  position: sticky; top: 0; z-index: 5;
}
.topbar h1 { margin: 0; font-size: 20px; }
.topbar__sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.content { padding: 24px 28px 60px; }

/* ===================== Componentes ===================== */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card + .card { margin-top: 16px; }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card__head h2 { margin: 0; font-size: 16px; }
.card__head p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }

.grid { display: grid; gap: 16px; }
.grid--kpi { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
/* Painel: a tabela de coletas em andamento tem 6 colunas e não cabe em metade
   da tela — o gráfico ao lado cabe folgado em bem menos. minmax(0,…) impede
   que a tabela larga estoure a coluna do grid. */
.grid--painel { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); }
@media (max-width: 1100px) { .grid--painel { grid-template-columns: 1fr; } }
.grid--form { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }

.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.kpi__rot { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; font-weight: 600; }
.kpi__num { font-family: "Sora", sans-serif; font-size: 30px; font-weight: 700; line-height: 1.1; margin-top: 6px; }
.kpi__pe { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.kpi--alerta { border-color: #f3c7c5; background: var(--red-soft); }
.kpi--alerta .kpi__num { color: var(--red-2); }

.btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 10px;
  padding: 9px 14px; font-size: 13.5px; font-weight: 600;
}
.btn:hover { background: #fafafa; }
.btn--primario { background: var(--red); border-color: var(--red); color: #fff; }
.btn--primario:hover { background: var(--red-2); border-color: var(--red-2); }
.btn--fantasma { background: transparent; }
.btn--perigo { color: var(--bad); border-color: #f3c7c5; }
.btn--mini { padding: 5px 9px; font-size: 12px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

label { display: block; font-size: 12.5px; font-weight: 600; color: #3f3f3f; margin-bottom: 5px; }
input, select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px;
  font-family: inherit; font-size: 14px; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(219,1,16,.25); border-color: var(--red); }
textarea { resize: vertical; min-height: 72px; }
.campo { margin-bottom: 12px; }
.campo__dica { font-size: 11.5px; color: var(--muted); margin-top: 4px; }

.filtros { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.filtros .campo { margin: 0; min-width: 150px; }
.filtros .campo--busca { flex: 1; min-width: 220px; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid #f1f1f1; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfbfb; }
.tabela-wrap { overflow-x: auto; }
.td-acoes { text-align: right; white-space: nowrap; }
.vazio { text-align: center; color: var(--muted); padding: 34px 12px; font-size: 14px; }

.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.tag--agendada { background: #eef2ff; color: #4338ca; }
.tag--aguardando_tecnico { background: #fff7ed; color: #b45309; }
.tag--em_deslocamento { background: #e0f2fe; color: #0369a1; }
.tag--tecnico_no_local { background: #ede9fe; color: #6d28d9; }
.tag--coleta_realizada { background: #dcfce7; color: #15803d; }
.tag--finalizada { background: #f1f5f9; color: #334155; }
.tag--cancelada { background: #fee2e2; color: #b91c1c; }
.tag--pago { background: #dcfce7; color: #15803d; }
.tag--a_receber { background: #fef3c7; color: #92400e; }
.tag--neutra { background: #f1f5f9; color: #475569; }

.codigo { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-weight: 700; letter-spacing: .06em; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.mut { color: var(--muted); }
.peq { font-size: 12.5px; }
.strong { font-weight: 700; }

.avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; background: #eee; display: block; }
.avatar--g { width: 64px; height: 64px; }
.avatar--iniciais { display: inline-flex; align-items: center; justify-content: center; background: var(--ink-800); color: #fff; font-size: 12px; font-weight: 700; }
.pessoa { display: flex; align-items: center; gap: 9px; }

/* ===================== Modal ===================== */
.modal { position: fixed; inset: 0; z-index: 50; display: none; align-items: center; justify-content: center; padding: 20px; }
.modal.open { display: flex; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.5); }
.modal__box {
  position: relative; background: #fff; border-radius: 18px; box-shadow: var(--shadow-lg);
  width: min(880px, 100%); max-height: 90vh; display: flex; flex-direction: column;
}
.modal__head { padding: 18px 22px 12px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.modal__head h3 { margin: 0; font-size: 17px; }
.modal__head p { margin: 3px 0 0; font-size: 13px; color: var(--muted); }
.modal__x { border: 0; background: none; font-size: 22px; line-height: 1; color: var(--muted); padding: 0 4px; }
.modal__body { padding: 18px 22px; overflow-y: auto; }
.modal__foot { padding: 14px 22px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }

/* ===================== Login ===================== */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr; }
.login__arte {
  background: linear-gradient(150deg, var(--ink-900) 0%, #2a0407 55%, var(--red-2) 100%);
  color: #fff; padding: 56px 52px; display: flex; flex-direction: column; justify-content: space-between;
}
.login__arte img { max-width: 210px; }
.login__arte h2 { font-size: 30px; line-height: 1.22; margin: 0 0 14px; }
.login__arte p { color: #dcdcdc; font-size: 15px; max-width: 420px; margin: 0; }
.login__form { display: flex; align-items: center; justify-content: center; padding: 40px 32px; background: #fff; }
.login__form form { width: min(380px, 100%); }
.login__form h1 { margin: 0 0 4px; font-size: 24px; }
.login__form > form > p { margin: 0 0 22px; color: var(--muted); font-size: 14px; }
.erro { background: var(--red-soft); border: 1px solid #f3c7c5; color: var(--red-2); padding: 10px 12px; border-radius: 10px; font-size: 13px; margin-bottom: 14px; }
.aviso-ok { background: #ecfdf5; border: 1px solid #bbf7d0; color: #15803d; padding: 10px 12px; border-radius: 10px; font-size: 13px; margin-bottom: 14px; }

/* ===================== Timeline ===================== */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 12px; padding-bottom: 16px; position: relative; }
.timeline li:not(:last-child)::before { content: ""; position: absolute; left: 8px; top: 20px; bottom: 0; width: 2px; background: var(--line); }
.timeline__ponto { width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 3px solid var(--line); flex: none; margin-top: 2px; z-index: 1; }
.timeline li.feito .timeline__ponto { border-color: var(--ok); background: var(--ok); }
.timeline li.atual .timeline__ponto { border-color: var(--red); background: var(--red); box-shadow: 0 0 0 4px rgba(219,1,16,.16); }
.timeline__txt { font-size: 13.5px; }
.timeline__quando { font-size: 12px; color: var(--muted); }

/* ===================== Mapa ===================== */
.mapa { width: 100%; height: 320px; border-radius: 14px; border: 1px solid var(--line); background: #eef1f4; overflow: hidden; position: relative; }
.mapa--alto { height: 380px; }
.mapa__aviso {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; text-align: center; padding: 20px; color: var(--muted); font-size: 13.5px; background: #eef1f4;
}

/* ===================== Página pública (paciente) ===================== */
.pub { min-height: 100vh; background: linear-gradient(180deg, #f7f7f7 0%, #ededed 100%); }
.pub__topo { background: var(--ink-900); padding: 16px 20px; display: flex; justify-content: center; }
.pub__topo img { max-width: 160px; }
.pub__wrap { max-width: 560px; margin: 0 auto; padding: 24px 16px 60px; }
.pub__card { background: #fff; border-radius: 20px; box-shadow: var(--shadow); padding: 22px; }
.pub__card + .pub__card { margin-top: 14px; }
.pub__status { text-align: center; padding: 8px 0 4px; }
.pub__status h2 { margin: 6px 0 2px; font-size: 22px; }
.pub__status p { margin: 0; color: var(--muted); font-size: 14px; }
.pub__eta { font-family: "Sora", sans-serif; font-size: 34px; font-weight: 700; color: var(--red); line-height: 1.1; }
.pub__tec { display: flex; align-items: center; gap: 14px; }
.pub__tec b { display: block; font-size: 15px; }
.pub__busca { display: flex; gap: 10px; margin-top: 14px; }
.pub__busca input { text-transform: uppercase; letter-spacing: .18em; font-weight: 700; text-align: center; font-size: 18px; }

/* ===================== Impressão do relatório ===================== */
.rel-head { display: none; }
@media print {
  @page { size: A4 landscape; margin: 12mm 10mm; }
  .sidebar, .topbar, .filtros, .btn, .modal, .no-print { display: none !important; }
  .layout { display: block; }
  .content { padding: 0; }
  .card { box-shadow: none; border: 0; padding: 0; }
  .card + .card { margin-top: 14px; }
  .rel-head { display: flex; align-items: center; justify-content: space-between; border-bottom: 2px solid var(--red); padding-bottom: 8px; margin-bottom: 14px; }
  .rel-head img { max-width: 150px; }
  /* Tabela larga só cabe em paisagem com largura fixa — mesma lição já
     aprendida no relatório do Controle de Investimentos (03/09). */
  table { table-layout: fixed; font-size: 10px; }
  th, td { padding: 4px 5px; word-wrap: break-word; }
  tr, .kpi, .card { break-inside: avoid; page-break-inside: avoid; }
  body { background: #fff; }
}

/* ===================== Responsivo ===================== */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .sidebar__nav { flex-direction: row; flex-wrap: wrap; }
  .navlink { width: auto; }
  .login { grid-template-columns: 1fr; }
  .login__arte { display: none; }
  .content, .topbar { padding-left: 16px; padding-right: 16px; }
}
