/* Pátio NR — app fase 1. Base visual herdada do protótipo (prototipo/style.css). */
:root {
  --preto: #0b0b0c; --preto2: #18181b; --cinza: #f2f2f4; --linha: #dedee3; --texto: #17171a; --sub: #5f6068;
  --vermelho: #e30613; --vermelho2: #b8040f; --verde: #15803d; --amarelo: #b45309; --azul: #1d4ed8;
  --raio: 10px; --sombra: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; background: var(--cinza); color: var(--texto); min-height: 100vh; }
a { color: var(--azul); }
h1 { font-size: 1.35rem; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 1.2rem 0 .5rem; }
h3 { font-size: 1rem; margin: .8rem 0 .4rem; }
p { margin: .4rem 0; }
.sub { color: var(--sub); font-size: .9rem; }
.top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: .6rem; background: var(--preto); color: #fff; padding: .5rem .8rem; border-bottom: 3px solid var(--vermelho); }
.brand { display: flex; align-items: center; gap: .55rem; color: #fff; text-decoration: none; font-weight: 700; min-width: 0; }
.brand img { height: 26px; width: auto; }
.brand span { white-space: nowrap; font-size: 1rem; border-left: 1px solid #444; padding-left: .55rem; }
.usuario { margin-left: auto; font-size: .78rem; color: #bbb; display: flex; align-items: center; gap: .35rem; }
.usuario select { background: var(--preto2); color: #fff; border: 1px solid #444; border-radius: 6px; padding: .3rem .4rem; font-size: .85rem; }
.icon-btn { background: none; border: 0; color: #fff; font-size: 1.4rem; cursor: pointer; padding: .1rem .3rem; }
.aviso { background: #fff4e5; color: #7a4100; font-size: .8rem; padding: .35rem .8rem; border-bottom: 1px solid #f3d6ab; }
.layout { display: flex; min-height: calc(100vh - 80px); }
.nav { width: 220px; flex: none; background: var(--preto2); padding: .6rem 0; }
.nav a { display: flex; align-items: center; gap: .55rem; color: #d4d4d8; text-decoration: none; padding: .55rem 1rem; font-size: .93rem; border-left: 3px solid transparent; }
.nav a:hover { background: #27272a; color: #fff; }
.nav a.ativo { background: #27272a; color: #fff; border-left-color: var(--vermelho); font-weight: 600; }
.nav .grupo { color: #71717a; font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; padding: .8rem 1rem .25rem; }
.nav .badge { margin-left: auto; }
main { flex: 1; min-width: 0; padding: 1rem 1.2rem 3rem; }
main:focus { outline: none; }
.cab { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .6rem; margin-bottom: .8rem; }
.cab > div:first-child { flex: 1 1 260px; }
.card { background: #fff; border: 1px solid var(--linha); border-radius: var(--raio); padding: .9rem; box-shadow: var(--sombra); margin-bottom: .8rem; }
.grid { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid.k { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.kpi { background: #fff; border: 1px solid var(--linha); border-radius: var(--raio); padding: .7rem .8rem; }
.kpi b { display: block; font-size: 1.45rem; }
.kpi span { color: var(--sub); font-size: .82rem; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; border: 1px solid var(--linha); background: #fff; color: var(--texto); padding: .55rem .9rem; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; min-height: 40px; }
.btn:hover { border-color: #b9b9c0; }
.btn.p { background: var(--vermelho); border-color: var(--vermelho); color: #fff; }
.btn.p:hover { background: var(--vermelho2); }
.btn.v { background: var(--verde); border-color: var(--verde); color: #fff; }
.btn.esc { background: var(--preto); border-color: var(--preto); color: #fff; }
.btn.peq { padding: .3rem .6rem; min-height: 32px; font-size: .85rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.acoes { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .6rem; }
.badge { display: inline-block; font-size: .72rem; font-weight: 700; padding: .12rem .45rem; border-radius: 99px; background: #e4e4e7; color: #3f3f46; white-space: nowrap; }
.badge.r { background: var(--vermelho); color: #fff; }
.badge.a { background: #fde68a; color: #78350f; }
.badge.g { background: #bbf7d0; color: #14532d; }
.badge.b { background: #dbeafe; color: #1e3a8a; }
label.f { display: block; font-size: .82rem; color: var(--sub); margin: .5rem 0 .2rem; font-weight: 600; }
input, select, textarea { font: inherit; width: 100%; padding: .55rem .6rem; border: 1px solid #c9c9cf; border-radius: 8px; background: #fff; color: var(--texto); }
textarea { min-height: 70px; resize: vertical; }
input[type=checkbox], input[type=radio] { width: auto; }
.linha { display: flex; gap: .6rem; flex-wrap: wrap; }
.linha > * { flex: 1 1 140px; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--linha); vertical-align: top; }
th { font-size: .75rem; color: var(--sub); text-transform: uppercase; letter-spacing: .03em; }
td.n, th.n { text-align: right; white-space: nowrap; }
.tabela { overflow-x: auto; }
.tabs { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: .8rem; }
.tabs button { border: 1px solid var(--linha); background: #fff; padding: .45rem .8rem; border-radius: 99px; font: inherit; font-size: .88rem; cursor: pointer; }
.tabs button.ativo { background: var(--preto); color: #fff; border-color: var(--preto); }
.alerta { border-left: 4px solid var(--vermelho); background: #fff1f1; padding: .6rem .8rem; border-radius: 6px; margin: .5rem 0; }
.alerta.a { border-color: #d97706; background: #fffbeb; }
.alerta.g { border-color: var(--verde); background: #f0fdf4; }
.vazio { color: var(--sub); font-style: italic; padding: .6rem 0; }

/* pátio */
.patio { display: flex; gap: .7rem; overflow-x: auto; padding-bottom: .6rem; scroll-snap-type: x mandatory; }
.col { flex: 0 0 250px; background: #e8e8ec; border-radius: var(--raio); padding: .5rem; scroll-snap-align: start; }
.col h3 { margin: .1rem .2rem .5rem; font-size: .85rem; display: flex; justify-content: space-between; }
.carro { display: block; background: #fff; border-radius: 8px; padding: .55rem .6rem; margin-bottom: .5rem; border: 1px solid var(--linha); border-left: 5px solid #a1a1aa; text-decoration: none; color: inherit; box-shadow: var(--sombra); }
.carro:hover { border-color: #a1a1aa; }
.carro.atraso { border-left-color: #d97706; }
.carro.risco { border-left-color: var(--vermelho); background: #fff5f5; }
.placa { display: inline-block; font-family: ui-monospace, Consolas, monospace; font-weight: 800; letter-spacing: .06em; border: 2px solid #1e293b; border-top-width: 6px; border-top-color: #1d4ed8; border-radius: 4px; padding: 0 .35rem; background: #fff; font-size: .85rem; }
.carro .mod { font-size: .85rem; margin: .25rem 0; }
.carro .meta { display: flex; justify-content: space-between; gap: .3rem; font-size: .78rem; color: var(--sub); flex-wrap: wrap; }
.carro .tag-risco { margin-top: .35rem; font-size: .76rem; font-weight: 700; color: #fff; background: var(--vermelho); border-radius: 5px; padding: .15rem .35rem; }
.carro .tag-atraso { margin-top: .35rem; font-size: .76rem; font-weight: 700; color: #78350f; background: #fde68a; border-radius: 5px; padding: .15rem .35rem; }
.dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; margin-right: .25rem; vertical-align: middle; }

/* agenda */
.ag-grade { display: grid; border: 1px solid var(--linha); border-radius: var(--raio); overflow: hidden; background: #fff; }
.ag-grade .hd { background: var(--preto2); color: #fff; font-size: .8rem; font-weight: 700; padding: .4rem; text-align: center; position: sticky; top: 0; }
.ag-grade .hr { font-size: .72rem; color: var(--sub); padding: .2rem .3rem; border-top: 1px solid #eee; text-align: right; }
.ag-grade .sl { border-top: 1px solid #eee; border-left: 1px solid #eee; min-height: 30px; position: relative; cursor: pointer; }
.ag-grade .sl:hover { background: #fafafa; }
.ev { font-size: .75rem; border-radius: 6px; padding: .2rem .35rem; color: #fff; margin: 2px; cursor: pointer; line-height: 1.25; }
.ev.pre { background: #fde68a !important; color: #78350f; border: 1px dashed #b45309; }
.semana { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .5rem; }
.semana .dia { background: #fff; border: 1px solid var(--linha); border-radius: var(--raio); padding: .5rem; min-height: 120px; }
.semana .dia.fech { background: #f4f4f5; color: var(--sub); }
.semana .dia h4 { margin: 0 0 .35rem; font-size: .85rem; }

/* conversas */
.conv-lista a { display: block; text-decoration: none; color: inherit; padding: .6rem; border-bottom: 1px solid var(--linha); }
.conv-lista a:hover { background: #fafafa; }
.conv-wrap { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: .8rem; }
.zap { background: #e9e2d7; border-radius: var(--raio); padding: .7rem; min-height: 360px; max-height: 60vh; overflow-y: auto; display: flex; flex-direction: column; gap: .35rem; }
.msg { max-width: 82%; padding: .45rem .6rem; border-radius: 8px; font-size: .9rem; box-shadow: 0 1px 1px rgba(0,0,0,.08); white-space: pre-wrap; word-wrap: break-word; }
.msg small { display: block; font-size: .68rem; color: #6b7280; margin-top: .15rem; text-align: right; }
.msg.cliente { background: #fff; align-self: flex-start; }
.msg.bot { background: #d9fdd3; align-self: flex-end; }
.msg.equipe { background: #cfe3ff; align-self: flex-end; }
.msg .quem { font-size: .7rem; font-weight: 700; color: #475569; display: block; }
.ficha dt { font-size: .74rem; color: var(--sub); font-weight: 700; text-transform: uppercase; margin-top: .4rem; }
.ficha dd { margin: 0; font-size: .9rem; }

/* vistoria */
.vistas { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: .6rem; }
.vista { background: #fafafa; border: 1px solid var(--linha); border-radius: 8px; padding: .4rem; position: relative; }
.vista svg { width: 100%; height: auto; display: block; touch-action: manipulation; cursor: crosshair; }
.vista .nome { font-size: .78rem; font-weight: 700; color: var(--sub); }
.acess { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: .1rem .8rem; }
.acess .it { display: flex; justify-content: space-between; align-items: center; padding: .3rem 0; border-bottom: 1px solid #eee; font-size: .88rem; }
.sna { display: flex; gap: 2px; }
.sna button { border: 1px solid #c9c9cf; background: #fff; width: 34px; height: 30px; font-weight: 700; cursor: pointer; border-radius: 5px; }
.sna button.on[data-v=S] { background: var(--verde); color: #fff; border-color: var(--verde); }
.sna button.on[data-v=N] { background: #71717a; color: #fff; border-color: #71717a; }
.sna button.on[data-v=A] { background: var(--vermelho); color: #fff; border-color: var(--vermelho); }
.fotos { display: flex; flex-wrap: wrap; gap: .4rem; }
.foto { width: 96px; height: 72px; border-radius: 6px; background: repeating-linear-gradient(45deg, #3f3f46, #3f3f46 6px, #52525b 6px, #52525b 12px); color: #fff; font-size: .68rem; display: flex; align-items: flex-end; padding: .25rem; line-height: 1.1; }
.assin { border: 2px dashed #a1a1aa; border-radius: 8px; background: #fff; width: 100%; height: 160px; touch-action: none; display: block; }
.comb { display: flex; align-items: center; gap: .5rem; }
.comb input { flex: 1; }

/* barras */
.barra { display: flex; align-items: center; gap: .5rem; font-size: .85rem; margin: .3rem 0; }
.barra .lb { width: 160px; flex: none; }
.barra .tr { flex: 1; background: #ececf0; border-radius: 4px; height: 16px; overflow: hidden; }
.barra .tr i { display: block; height: 100%; background: var(--vermelho); }
.barra .vl { width: 70px; text-align: right; font-weight: 700; flex: none; }

/* roteiro */
.passos { counter-reset: p; list-style: none; padding: 0; margin: 0; }
.passos li { counter-increment: p; display: flex; gap: .6rem; align-items: flex-start; padding: .55rem 0; border-bottom: 1px solid var(--linha); }
.passos li::before { content: counter(p); flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--preto); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; }
.passos li.ok::before { content: "✓"; background: var(--verde); }
.passos li > div { flex: 1; }

.toast { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%) translateY(150%); background: var(--preto); color: #fff; padding: .6rem 1rem; border-radius: 8px; font-size: .9rem; transition: transform .25s; z-index: 60; max-width: 92vw; box-shadow: 0 4px 14px rgba(0,0,0,.25); }
.toast.on { transform: translateX(-50%) translateY(0); }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal[hidden] { display: none; }
.modal-box { background: #fff; border-radius: 12px; padding: 1rem; width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto; }

@media (max-width: 860px) {
  .nav { position: fixed; top: 0; bottom: 0; left: 0; z-index: 40; transform: translateX(-100%); transition: transform .2s; padding-top: 3.5rem; overflow-y: auto; width: 250px; }
  body.menu-on .nav { transform: none; box-shadow: 4px 0 18px rgba(0,0,0,.4); }
  main { padding: .8rem .8rem 3rem; }
  .conv-wrap { grid-template-columns: 1fr; }
  .brand span { display: none; }
  .barra .lb { width: 110px; }
}
@media (min-width: 861px) { #menuBtn { display: none; } .nav { position: sticky; top: 49px; align-self: flex-start; height: calc(100vh - 49px); overflow-y: auto; } }
@media print { .top, .nav, .aviso, .acoes, .no-print { display: none !important; } main { padding: 0; } }

/* modo tablet: Pátio rápido e layout 768–1280 px */
.rapido { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: .8rem; }
.rcard { background: #fff; border: 1px solid var(--linha); border-left: 8px solid #a1a1aa; border-radius: 12px; padding: .9rem; box-shadow: var(--sombra); }
.rcard.atraso { border-left-color: #d97706; }
.rcard.risco { border-left-color: var(--vermelho); background: #fff5f5; }
.rcard .placa { font-size: 1.25rem; }
.rcard .mod { margin: .35rem 0; font-size: 1rem; }
.rcard .btns { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-top: .7rem; }
.rcard .btn { min-height: 56px; font-size: 1rem; }
.rcard .btn.gr { grid-column: 1 / -1; min-height: 64px; font-size: 1.1rem; }
.chips { display: flex; gap: .5rem; overflow-x: auto; padding-bottom: .4rem; margin-bottom: .6rem; }
.chips button { flex: none; min-height: 48px; padding: 0 1rem; border-radius: 99px; border: 1px solid var(--linha); background: #fff; font: inherit; font-weight: 600; cursor: pointer; }
.chips button.ativo { background: var(--preto); color: #fff; border-color: var(--preto); }
@media (min-width: 700px) and (max-width: 1280px) {
  .btn, .tabs button, select, input { min-height: 48px; }
  .sna button { width: 46px; height: 42px; }
  .acess { grid-template-columns: repeat(2, 1fr); }
  .vistas { grid-template-columns: repeat(2, 1fr); }
  #menuBtn { display: none; }
  .nav { position: sticky; top: 49px; transform: none; box-shadow: none; padding-top: .4rem; align-self: flex-start; height: calc(100vh - 49px); overflow-y: auto; width: 76px; }
  .brand span { display: inline; }
  .conv-wrap { grid-template-columns: 1.3fr 1fr; }
  .nav a { flex-direction: column; gap: .15rem; font-size: .62rem; text-align: center; padding: .7rem .2rem; border-left-width: 0; border-bottom: 0; }
  .nav a span:first-child { font-size: 1.4rem; }
  .nav .grupo { display: none; }
  .nav .badge { margin: 0; }
}


.fotofrente { margin-left: auto; display: flex; flex-direction: column; align-items: center; gap: .15rem; }
.fotofrente img, .fotofrente svg { width: 150px; height: 96px; object-fit: cover; border: 1px solid var(--linha); border-radius: 8px; background: #fff; }
.fotofrente .sub { font-size: .7rem; }
.frente-vazia { display: flex; align-items: center; justify-content: center; text-align: center; width: 150px; height: 96px; border: 2px dashed var(--vermelho); border-radius: 8px; font-size: .8rem; font-weight: 600; cursor: pointer; background: #fff8f8; color: var(--vermelho2); }
.frente-box { border: 2px dashed var(--vermelho); border-radius: 10px; padding: .6rem; background: #fff8f8; }
.frente-box .fotofrente { margin-left: 0; align-items: flex-start; }
@media (max-width: 520px) { .fotofrente { margin-left: 0; } }
.zapaviso { border-left: 4px solid #16a34a; background: #f0fdf4; padding: .5rem .7rem; border-radius: 8px; margin: .4rem 0; font-size: .88rem; }

/* ---------- app fase 1 ---------- */
[hidden] { display: none !important; }
.usuario span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
body.sem-login .layout { display: block; }
.login { max-width: 420px; margin: 2rem auto; }
.perfis { display: grid; gap: .5rem; }
.perfis .btn { justify-content: space-between; min-height: 52px; }
.lista-busca { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: .6rem; }
.lista-busca input { flex: 1 1 220px; }
.itens-cad a { display: flex; justify-content: space-between; gap: .6rem; align-items: center; padding: .6rem .3rem; border-top: 1px solid var(--linha); text-decoration: none; color: inherit; }
.itens-cad a:first-child { border-top: 0; }
.itens-cad a:hover { background: #fafafa; }
.itens-cad .dir { text-align: right; flex: none; }
.erro-campo { color: var(--vermelho2); font-size: .8rem; margin-top: .15rem; }
input.invalido { border-color: var(--vermelho); background: #fff8f8; }
.check { display: flex; align-items: center; gap: .5rem; margin-top: .6rem; font-size: .92rem; }
.etapas { display: flex; flex-wrap: wrap; gap: .25rem; margin: .4rem 0; }
.etapas span { font-size: .72rem; padding: .2rem .45rem; border-radius: 99px; background: #e4e4e7; color: #52525b; }
.etapas span.feita { background: #d1fae5; color: #065f46; }
.etapas span.atual { background: var(--preto); color: #fff; font-weight: 700; }
.os-topo { display: flex; gap: .8rem; flex-wrap: wrap; align-items: flex-start; }
.os-topo .dados { flex: 1 1 240px; min-width: 0; }
.capa { width: 170px; height: 110px; border-radius: 8px; border: 1px solid var(--linha); object-fit: cover; background: #fff; display: block; }
.capa-vazia { width: 170px; height: 110px; border-radius: 8px; border: 2px dashed #c9c9cf; display: flex; align-items: center; justify-content: center; text-align: center; font-size: .8rem; color: var(--sub); padding: .4rem; }
.grupo-itens h3 { display: flex; justify-content: space-between; align-items: baseline; }
.item-linha { display: grid; grid-template-columns: 1fr 70px 100px 100px 36px; gap: .4rem; align-items: center; padding: .3rem 0; border-bottom: 1px solid #eee; font-size: .9rem; }
.item-linha .n { text-align: right; white-space: nowrap; }
.item-novo { display: grid; grid-template-columns: 1fr 70px 100px auto; gap: .4rem; margin-top: .4rem; }
.total-os { font-size: 1.2rem; font-weight: 800; text-align: right; }
.frente-box img { max-width: 100%; width: 260px; border-radius: 8px; border: 1px solid var(--linha); display: block; margin: .4rem 0; }
.miniaturas { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .4rem; }
.miniaturas img { width: 96px; height: 72px; object-fit: cover; border-radius: 6px; border: 1px solid var(--linha); }
.hist li { font-size: .88rem; margin: .2rem 0; }
.carro .capa-mini { width: 100%; height: 70px; object-fit: cover; border-radius: 6px; margin-bottom: .35rem; display: block; }
@media (max-width: 560px) {
  .item-linha { grid-template-columns: 1fr 50px 84px 32px; }
  .item-linha .unit { display: none; }
  .item-novo { grid-template-columns: 1fr 1fr; }
  .item-novo input:first-child { grid-column: 1 / -1; }
  .usuario span { max-width: 46vw; font-size: .75rem; }
  .capa, .capa-vazia { width: 100%; height: 160px; }
  .os-topo > div:first-child { flex: 1 1 100%; }
}
@media (max-width: 480px) { .top { flex-wrap: nowrap; } .usuario { margin-left: auto; } }
.btn.desab { opacity: .45; pointer-events: none; }
.toast:not(.on) { opacity: 0; pointer-events: none; }
@media (max-width: 420px) { .usuario span { display: none; } .brand { flex: 0 1 auto; } .brand img { height: 22px; } }
.ev .placa { color: var(--texto); } .ev .btn { color: var(--texto); }
