:root {
  --bg: #f1f5f9; --card: #fff; --ink: #0f172a; --muted: #64748b; --line: #e2e8f0; --brand: #f59e0b; --brand-ink: #1c1917;
  --nav: #1e293b; --nav-ink: #cbd5e1; --ok: #16a34a; --bad: #dc2626; --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; }
a { color: #0369a1; text-decoration: none; } a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1 { font-size: 1.35rem; margin: 0 0 12px; } h2 { font-size: 1.05rem; margin: 0 0 10px; } h3 { font-size: .95rem; margin: 0 0 8px; }

/* layout */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
nav.side { align-self: start; background: var(--nav); color: var(--nav-ink); padding: 14px 10px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
nav.side .logo { color: #fff; font-weight: 800; font-size: 1.25rem; letter-spacing: 1px; padding: 4px 10px 2px; }
nav.side .logo small { font-weight: 400; font-size: .7rem; color: #94a3b8; letter-spacing: 0; margin-left: 4px; }
nav.side .emp { font-size: .78rem; color: #94a3b8; padding: 0 10px 12px; }
nav.side a { color: var(--nav-ink); padding: 9px 12px; border-radius: 8px; display: flex; gap: 10px; align-items: center; text-decoration: none; }
nav.side a:hover { background: #334155; } nav.side a.on { background: var(--brand); color: var(--brand-ink); font-weight: 600; }
nav.side .fim { margin-top: auto; font-size: .85rem; border-top: 1px solid #334155; padding-top: 8px; }
main { padding: 16px 22px 80px; min-width: 0; }
.topo { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; }
.topo .menu { display: none; }
.pesq-global { position: relative; flex: 1; max-width: 460px; }
.pesq-global input { width: 100%; padding: 10px 14px; border: 1px solid var(--line); border-radius: 999px; background: #fff; font-weight: 600; letter-spacing: .5px; }
.pesq-res { position: absolute; top: 46px; left: 0; right: 0; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px #0002; z-index: 30; max-height: 70vh; overflow: auto; }
.pesq-res a { display: block; padding: 8px 14px; color: var(--ink); border-bottom: 1px solid var(--line); } .pesq-res a:hover { background: #f8fafc; text-decoration: none; }
.pesq-res .t { font-size: .75rem; color: var(--muted); padding: 6px 14px 2px; text-transform: uppercase; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  nav.side { position: fixed; left: 0; top: 0; bottom: 0; width: 250px; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  nav.side.aberto { transform: none; box-shadow: 0 0 0 100vmax #0006; }
  .topo .menu { display: inline-flex; }
  .topo { flex-wrap: wrap; } .pesq-global { order: 3; flex-basis: 100%; max-width: none; }
  .linhas td input { width: 64px; }
  main { padding: 12px 12px 90px; }
}

/* componentes */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; }
.card.flush { padding: 0; overflow: hidden; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; } .spacer { flex: 1; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-weight: 600; white-space: nowrap; text-decoration: none !important; color: var(--ink); }
.btn:hover { background: #f8fafc; } .btn:disabled { opacity: .5; cursor: default; }
.btn.pri { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); } .btn.pri:hover { filter: brightness(.95); }
.btn.dark { background: var(--nav); border-color: var(--nav); color: #fff; }
.btn.perigo { color: var(--bad); border-color: #fecaca; } .btn.perigo:hover { background: #fef2f2; }
.btn.sm { padding: 4px 10px; font-size: .85rem; } .btn.ico { padding: 6px 9px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 8px 12px; border-bottom: 3px solid transparent; color: var(--muted); font-weight: 600; text-decoration: none; }
.tabs a.on { color: var(--ink); border-color: var(--brand); }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 700; color: #fff; white-space: nowrap; }
.tag { display: inline-block; padding: 1px 7px; border-radius: 6px; font-size: .75rem; background: #e2e8f0; color: #334155; font-weight: 600; }
.tag.ok { background: #dcfce7; color: #166534; } .tag.bad { background: #fee2e2; color: #991b1b; } .tag.warn { background: #fef3c7; color: #92400e; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .r { text-align: right; } .b { font-weight: 700; } .nowrap { white-space: nowrap; }
.mat { font-family: Consolas, "Courier New", monospace; font-weight: 700; background: #fff; border: 1.5px solid #0f172a; border-radius: 4px; padding: 0 6px; letter-spacing: 1px; white-space: nowrap; }
.vazio { text-align: center; color: var(--muted); padding: 30px 10px; }

table.lista { width: 100%; border-collapse: collapse; }
table.lista th, table.lista td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
table.lista th { font-size: .75rem; text-transform: uppercase; color: var(--muted); background: #f8fafc; letter-spacing: .3px; }
table.lista tbody tr.clic { cursor: pointer; } table.lista tbody tr.clic:hover { background: #fffbeb; }
table.lista td.r, table.lista th.r { text-align: right; }
.tw { overflow-x: auto; }
@media (max-width: 700px) {
  table.lista.resp thead { display: none; }
  table.lista.resp tr { display: block; padding: 8px 12px; border-bottom: 1px solid var(--line); }
  table.lista.resp td { display: inline-block; border: 0; padding: 2px 8px 2px 0; }
  table.lista.resp td.esc { display: none; }
}

/* formulários */
.form { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px 14px; }
.form .full { grid-column: 1 / -1; } .form .dupla { grid-column: span 2; }
@media (max-width: 520px) { .form .dupla { grid-column: 1 / -1; } }
label.f { display: flex; flex-direction: column; gap: 3px; font-size: .8rem; color: var(--muted); font-weight: 600; }
label.f input, label.f select, label.f textarea, .inp { padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: 8px; background: #fff; font-size: .95rem; color: var(--ink); font-weight: 400; width: 100%; }
label.f textarea { min-height: 70px; resize: vertical; }
label.f input:focus, label.f select:focus, label.f textarea:focus, .inp:focus { outline: 2px solid #fcd34d; border-color: var(--brand); }
label.chk { display: flex; gap: 8px; align-items: center; font-size: .92rem; cursor: pointer; }
label.chk input { width: 18px; height: 18px; }
.secao { font-size: .78rem; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 700; margin: 6px 0 -2px; grid-column: 1 / -1; border-bottom: 1px solid var(--line); padding-bottom: 3px; }

/* dashboard */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; border-left: 5px solid var(--c, var(--brand)); display: block; color: var(--ink); text-decoration: none !important; }
.kpi:hover { box-shadow: 0 2px 10px #0001; }
.kpi .v { font-size: 1.6rem; font-weight: 800; line-height: 1.1; } .kpi .l { color: var(--muted); font-size: .82rem; font-weight: 600; }

/* intervenção */
.int-cab { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.int-cab .tit { flex: 1; min-width: 240px; }
.int-cab .tit .n { font-size: 1.35rem; font-weight: 800; }
.estado-sel { font-weight: 700; color: #fff; border: 0; border-radius: 8px; padding: 8px 12px; cursor: pointer; }
.estado-sel option { color: var(--ink); background: #fff; }
.gravado { font-size: .8rem; color: var(--ok); opacity: 0; transition: opacity .3s; } .gravado.on { opacity: 1; }
.totais { display: grid; grid-template-columns: 1fr auto; gap: 3px 16px; max-width: 360px; margin-left: auto; }
.totais .t { font-size: 1.25rem; font-weight: 800; border-top: 2px solid var(--ink); padding-top: 4px; }
.fotos { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.fotos .f { position: relative; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: #f8fafc; }
.fotos img { width: 100%; height: 110px; object-fit: cover; display: block; cursor: zoom-in; }
.fotos .f input { width: 100%; border: 0; border-top: 1px solid var(--line); padding: 4px 6px; font-size: .8rem; }
.fotos .f button { position: absolute; top: 4px; right: 4px; background: #000a; color: #fff; border: 0; border-radius: 6px; width: 26px; height: 26px; cursor: pointer; }
.add-foto { display: flex; align-items: center; justify-content: center; flex-direction: column; height: 110px; border: 2px dashed #cbd5e1; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 600; font-size: .85rem; text-align: center; }
.add-foto:hover { border-color: var(--brand); color: var(--ink); }
.assin-img { max-height: 90px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.linhas td input { width: 90px; padding: 4px 6px; border: 1px solid #cbd5e1; border-radius: 6px; text-align: right; }
.linhas td input.desc { width: 100%; min-width: 160px; text-align: left; }
.sug { position: relative; }
.sug-lista { position: absolute; top: 100%; left: 0; right: 0; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 10px 24px #0002; z-index: 20; max-height: 280px; overflow: auto; }
.sug-lista div { padding: 7px 10px; cursor: pointer; border-bottom: 1px solid var(--line); } .sug-lista div:hover, .sug-lista div.on { background: #fffbeb; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: #0f172a88; z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 30px 12px; overflow-y: auto; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 720px; padding: 18px 20px; box-shadow: 0 20px 60px #0004; }
.modal.lg { max-width: 960px; } .modal.sm { max-width: 440px; }
.modal .mh { display: flex; align-items: center; margin-bottom: 12px; } .modal .mh h2 { margin: 0; flex: 1; }
.modal .mf { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.x { border: 0; background: none; font-size: 1.5rem; cursor: pointer; line-height: 1; color: var(--muted); }
canvas.assinar { width: 100%; height: 220px; border: 2px dashed #94a3b8; border-radius: 10px; touch-action: none; background: #fff; cursor: crosshair; }
.zoom { position: fixed; inset: 0; background: #000e; z-index: 200; display: flex; align-items: center; justify-content: center; cursor: zoom-out; }
.zoom img { max-width: 96vw; max-height: 94vh; }

/* login */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: linear-gradient(135deg, #1e293b, #334155); }
.login .card { width: 100%; max-width: 380px; padding: 26px; }
.login .marca { font-size: 1.8rem; font-weight: 800; letter-spacing: 2px; text-align: center; } .login .marca span { color: var(--brand); }
.login form { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.erro { color: var(--bad); font-weight: 600; font-size: .9rem; min-height: 1.2em; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
#toast div { background: #0f172a; color: #fff; padding: 10px 18px; border-radius: 10px; box-shadow: 0 8px 24px #0004; font-weight: 600; }
#toast div.erro { background: var(--bad); color: #fff; }
.barra-fixa { position: sticky; bottom: 0; background: #fffe; backdrop-filter: blur(6px); border-top: 1px solid var(--line); padding: 10px 0; margin-top: 10px; z-index: 5; }

/* badges */
nav.side a .badge { margin-left: auto; background: #dc2626; color: #fff; border-radius: 999px; font-size: .72rem; padding: 1px 7px; font-weight: 700; }

/* mapa anual */
.mapa { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.mapa .mes .mt { font-weight: 800; margin-bottom: 4px; }
.mapa table { width: 100%; border-collapse: separate; border-spacing: 2px; table-layout: fixed; }
.mapa th { font-size: .7rem; color: var(--muted); font-weight: 700; }
.mapa td { text-align: center; font-size: .8rem; height: 30px; border-radius: 5px; background: #f8fafc; position: relative; vertical-align: top; padding-top: 2px; cursor: default; }
.mapa td:empty { background: none; }
.mapa td.fds { background: #e2e8f0; color: #94a3b8; }
.mapa td.fer { background: #fee2e2; color: #b91c1c; font-weight: 700; box-shadow: inset 0 0 0 1px #fca5a5; }
.mapa td.hoje { box-shadow: inset 0 0 0 2px #0f172a; font-weight: 800; }
.mapa .dots { display: flex; gap: 2px; justify-content: center; flex-wrap: wrap; font-size: .6rem; line-height: 1; }
.mapa .dots i { width: 7px; height: 7px; border-radius: 50%; display: inline-block; box-sizing: border-box; }
i.lg { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; margin-right: 5px; box-sizing: border-box; }
.feriados { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 4px 16px; font-size: .9rem; }

/* impressão das páginas da app (mapa, saldos, listagens) */
@media print {
  nav.side, .topo, .tabs, .noprint, #toast { display: none !important; }
  .shell { display: block; } main { padding: 0; } body { background: #fff; }
  .card { border: 0; padding: 0; margin-bottom: 8px; } .soprint { display: block !important; }
  .mapa { grid-template-columns: repeat(4, 1fr); gap: 8px; } .mapa td { height: 22px; font-size: .7rem; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
@media (max-width: 700px) { .row > h1 { flex-basis: 100% !important; } }

/* agenda */
.ag { display: grid; min-width: 100%; position: relative; }
.ag-h { position: sticky; top: 0; z-index: 3; background: #f8fafc; border-bottom: 1px solid var(--line); border-left: 1px solid var(--line); padding: 8px 6px; font-weight: 700; font-size: .85rem; text-align: center; min-height: 40px; }
.ag-h.fer { background: #fee2e2; color: #b91c1c; } .ag-h.hoje { background: #fef3c7; }
.ag-t { position: relative; } .ag-t div { position: absolute; right: 6px; font-size: .72rem; color: var(--muted); transform: translateY(-6px); }
.ag-c { position: relative; border-left: 1px solid var(--line); cursor: copy; }
.ag-c:hover { background: #fffbeb55; }
.ag-l { position: absolute; left: 0; right: 0; border-top: 1px solid #e2e8f0; } .ag-l.meia { border-top-style: dashed; border-top-color: #eef2f7; }
.ag-fech { position: absolute; left: 0; right: 0; background: repeating-linear-gradient(135deg, #f1f5f9 0 6px, #e8edf3 6px 12px); }
.ag-e { position: absolute; border-left: 4px solid; border-radius: 6px; padding: 2px 5px; font-size: .74rem; line-height: 1.25; overflow: hidden; cursor: pointer; box-shadow: 0 1px 2px #0002; background: #fff; z-index: 2; }
.ag-e:hover { z-index: 4; box-shadow: 0 4px 14px #0003; } .ag-e .t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .ag-e.feita { opacity: .6; }
.tip { position: absolute; pointer-events: none; background: #0f172a; color: #fff; padding: 6px 10px; border-radius: 8px; font-size: .8rem; z-index: 5; max-width: 230px; }
.fotos .f button.vis { background: #fffe; color: #000; }
