:root {
  --brand: #f5b921;
  --brand-ink: #0b0b0b;
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-2: #eceef2;
  --ink: #15171c;
  --muted: #5b6270;
  --line: #dde1e7;
  --ok: #1d8a4b;
  --warn: #b86e00;
  --danger: #c93b3b;
  --info: #2563a8;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 6px 18px rgba(0,0,0,.06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1014; --surface: #171a20; --surface-2: #21252d; --ink: #eef0f3;
    --muted: #9aa3b0; --line: #2b3039; --ok: #3cc47c; --warn: #f0a83a;
    --danger: #ef6b6b; --info: #6aa7ec; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1014; --surface: #171a20; --surface-2: #21252d; --ink: #eef0f3;
  --muted: #9aa3b0; --line: #2b3039; --ok: #3cc47c; --warn: #f0a83a;
  --danger: #ef6b6b; --info: #6aa7ec; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 16px/1.45 var(--font); -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.4rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
p { margin: .25rem 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hidden { display: none !important; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: .75rem; }
.grow { flex: 1; }
.mono { font-variant-numeric: tabular-nums; }

/* ---------- shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: .75rem;
  padding: .6rem 1rem; background: var(--brand-ink); color: #fff;
}
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 800; letter-spacing: .02em; text-decoration: none; white-space: nowrap; }
.brand img { height: 30px; width: auto; border-radius: 6px; }
.brand .mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--brand); color: var(--brand-ink); font-size: .85rem; }
.topsearch { flex: 1; display: flex; max-width: 520px; }
.topsearch input { width: 100%; border: 0; border-radius: 10px; padding: .55rem .8rem; font-size: 16px; background: #2a2d33; color: #fff; }
.topsearch input::placeholder { color: #b8bec8; }
.nuvem-ind { position: relative; text-decoration: none; font-size: 1.15rem; padding: .2rem .3rem; }
.nuvem-ind::after { content: ''; position: absolute; right: 0; bottom: .2rem; width: 9px; height: 9px; border-radius: 50%; background: var(--ok); border: 2px solid #0b0b0b; }
.nuvem-ind[data-st="sincronizando"]::after, .nuvem-ind[data-st="parado"]::after { background: var(--info); }
.nuvem-ind[data-st="pendente"]::after, .nuvem-ind[data-st="offline"]::after { background: var(--warn); }
.nuvem-ind[data-st="erro"]::after { background: var(--danger); }
.userbtn { background: none; border: 1px solid #444; color: #fff; border-radius: 999px; padding: .35rem .7rem; font-size: .85rem; cursor: pointer; white-space: nowrap; }

.layout { display: flex; min-height: calc(100vh - 52px); }
.sidenav { display: none; }
main#view { flex: 1; padding: 1rem 1rem 6rem; max-width: 1100px; margin: 0 auto; width: 100%; min-width: 0; }

.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav a, .bottomnav button {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: .5rem 0 .55rem; font-size: .72rem;
  color: var(--muted); text-decoration: none; background: none; border: 0; cursor: pointer; font-family: inherit;
}
.bottomnav a.ativo { color: var(--ink); font-weight: 700; }
.bottomnav .ic { font-size: 1.3rem; line-height: 1; }
.bottomnav .novo .ic { background: var(--brand); color: var(--brand-ink); border-radius: 12px; width: 44px; height: 32px; display: grid; place-items: center; font-weight: 800; }

@media (min-width: 900px) {
  .bottomnav { display: none; }
  .sidenav { display: flex; flex-direction: column; gap: 2px; width: 220px; padding: 1rem .6rem; border-right: 1px solid var(--line); background: var(--surface); position: sticky; top: 52px; height: calc(100vh - 52px); }
  .sidenav a, .sidenav button { display: flex; gap: .6rem; align-items: center; padding: .6rem .8rem; border-radius: 10px; text-decoration: none; color: var(--ink); background: none; border: 0; font: inherit; cursor: pointer; text-align: left; }
  .sidenav a:hover { background: var(--surface-2); }
  .sidenav a.ativo { background: var(--surface-2); font-weight: 700; }
  .sidenav .novo { background: var(--brand); color: var(--brand-ink); font-weight: 700; margin-bottom: .6rem; justify-content: center; }
  main#view { padding: 1.5rem 2rem 3rem; }
}

.brand img { height: 38px; border-radius: 0; }
.brand-txt { display: flex; flex-direction: column; line-height: 1.1; }
.brand-txt b { color: var(--brand); font-size: .95rem; }
.brand-txt small { color: #c9ced6; font-weight: 500; font-size: .72rem; letter-spacing: .04em; text-transform: uppercase; }
@media (max-width: 520px) { .hide-sm { display: none; } }
.navgrp { font-size: .7rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); padding: .9rem .8rem .3rem; }
.navgrp:first-of-type { padding-top: .3rem; }
.menu-sheet { display: flex; flex-direction: column; }
.menu-sheet a { display: flex; gap: .6rem; align-items: center; padding: .65rem .6rem; border-radius: 10px; text-decoration: none; font-weight: 600; }
.menu-sheet a:hover, .menu-sheet a:active { background: var(--surface-2); }
@media (min-width: 900px) { .sidenav { overflow-y: auto; width: 250px; } .sidenav a { padding: .5rem .8rem; font-size: .93rem; } }

/* ---------- components ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); }
.card + .card { margin-top: .9rem; }
.card h2 { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.grid { display: grid; gap: .75rem; }
.grid.kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 700px) { .grid.kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } .grid.two { grid-template-columns: 1fr 1fr; } }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem; text-decoration: none; display: block; }
.kpi .v { font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.kpi .l { font-size: .8rem; color: var(--muted); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 44px; padding: .55rem 1rem; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: 600 .95rem var(--font); cursor: pointer; text-decoration: none; }
.btn:hover { filter: brightness(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.dark { background: var(--brand-ink); border-color: var(--brand-ink); color: #fff; }
.btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.block { width: 100%; }
.btn.big { min-height: 60px; font-size: 1.1rem; border-radius: 16px; }
.btn.sm { min-height: 34px; padding: .3rem .7rem; font-size: .85rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.actions.grid3 { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }

.chip { display: inline-block; padding: .12rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 700; border: 1px solid currentColor; white-space: nowrap; }
.chip-ok { color: var(--ok); } .chip-warn { color: var(--warn); } .chip-danger { color: var(--danger); }
.chip-info { color: var(--info); } .chip-muted { color: var(--muted); }

.list { display: flex; flex-direction: column; }
.item { display: flex; gap: .75rem; align-items: center; padding: .75rem .25rem; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.item:last-child { border-bottom: 0; }
.item .main { flex: 1; min-width: 0; }
.item .t { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .s { font-size: .85rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .side { text-align: right; font-size: .85rem; }
.avatar { width: 48px; height: 48px; border-radius: 10px; background: var(--surface-2); display: grid; place-items: center; flex: none; overflow: hidden; font-weight: 800; color: var(--muted); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.alert { display: flex; gap: .6rem; align-items: flex-start; padding: .7rem .8rem; border-radius: 12px; border-left: 4px solid var(--info); background: var(--surface-2); text-decoration: none; color: inherit; }
.alert + .alert { margin-top: .5rem; }
.alert.danger { border-color: var(--danger); } .alert.warn { border-color: var(--warn); } .alert.ok { border-color: var(--ok); }

.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .8rem; }
.field > span { font-size: .85rem; font-weight: 600; color: var(--muted); }
input, select, textarea { font: 16px var(--font); color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: .6rem .7rem; min-height: 44px; width: 100%; }
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand); }
input.huge { font-size: 2rem; font-weight: 800; text-align: center; font-variant-numeric: tabular-nums; }
.check { display: flex; gap: .5rem; align-items: center; margin-bottom: .8rem; }
.check input { width: 22px; height: 22px; min-height: 0; }
.formgrid { display: grid; gap: 0 .9rem; }
@media (min-width: 700px) { .formgrid { grid-template-columns: 1fr 1fr; } .formgrid .full { grid-column: 1 / -1; } }
.seg { display: flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin-bottom: .8rem; }
.seg label { flex: 1; text-align: center; padding: .6rem; cursor: pointer; font-weight: 600; }
.seg input { display: none; }
.seg label:has(input:checked) { background: var(--brand); color: var(--brand-ink); }

.tabs { display: flex; gap: .25rem; overflow-x: auto; border-bottom: 1px solid var(--line); margin: 1rem 0 .8rem; scrollbar-width: none; }
.tabs button { background: none; border: 0; padding: .6rem .8rem; font: 600 .92rem var(--font); color: var(--muted); border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap; }
.tabs button.ativo { color: var(--ink); border-color: var(--brand); }

.filters { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .3rem; margin-bottom: .6rem; scrollbar-width: none; }
.filters button { flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: .35rem .8rem; font: 600 .85rem var(--font); color: var(--ink); cursor: pointer; }
.filters button.ativo { background: var(--brand-ink); color: #fff; border-color: var(--brand-ink); }

.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: .5rem; }
.thumb { padding: 0; border: 0; border-radius: 10px; overflow: hidden; aspect-ratio: 1; background: var(--surface-2); cursor: pointer; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.foto-full { max-width: 100%; max-height: 80vh; display: block; margin: auto; border-radius: 8px; }
.photo-btn { display: flex; align-items: center; justify-content: center; gap: .5rem; min-height: 64px; border: 2px dashed var(--line); border-radius: 14px; cursor: pointer; font-weight: 700; color: var(--muted); }
.photo-btn input { display: none; }
.preview img { max-width: 100%; max-height: 220px; border-radius: 10px; display: block; margin-top: .5rem; }

.timeline { position: relative; padding-left: 1.1rem; }
.timeline::before { content: ""; position: absolute; left: .35rem; top: .3rem; bottom: .3rem; width: 2px; background: var(--line); }
.tl { position: relative; padding: .2rem 0 .9rem; }
.tl::before { content: ""; position: absolute; left: -1rem; top: .5rem; width: 10px; height: 10px; border-radius: 50%; background: var(--muted); border: 2px solid var(--surface); }
.tl.os::before { background: var(--info); } .tl.manut::before { background: var(--warn); } .tl.troca::before { background: var(--danger); }
.tl .d { font-size: .78rem; color: var(--muted); }

.progress { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--ok); }
.progress.warn > i { background: var(--warn); } .progress.danger > i { background: var(--danger); }

.head { display: flex; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }
.head .avatar { width: 84px; height: 84px; border-radius: 14px; font-size: 1.4rem; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .6rem; margin-top: .8rem; }
.stat { background: var(--surface-2); border-radius: 12px; padding: .6rem .7rem; }
.stat .l { font-size: .75rem; color: var(--muted); } .stat .v { font-weight: 800; font-size: 1.1rem; }

table.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tbl th, .tbl td { text-align: left; padding: .5rem .4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th { color: var(--muted); font-weight: 600; font-size: .8rem; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tblwrap { overflow-x: auto; }

.empty { text-align: center; padding: 1.5rem .5rem; color: var(--muted); }

dialog { border: 0; border-radius: 18px; padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px); background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.35); }
dialog::backdrop { background: rgba(0,0,0,.5); }
dialog .dlg { padding: 1.1rem; overflow-y: auto; max-height: calc(100vh - 32px); }
dialog .dlg-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1rem; flex-wrap: wrap; }
@media (max-width: 600px) { dialog { margin: auto auto 0; border-radius: 18px 18px 0 0; width: 100vw; max-width: 100vw; } }

.sheet-list { display: grid; gap: .5rem; }
.sheet-list a { display: flex; gap: .75rem; align-items: center; padding: .85rem; border-radius: 12px; background: var(--surface-2); text-decoration: none; font-weight: 700; }
.sheet-list .ic { font-size: 1.4rem; }

#toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: .4rem; align-items: center; pointer-events: none; }
.toast { background: var(--brand-ink); color: #fff; padding: .6rem 1rem; border-radius: 12px; font-weight: 600; box-shadow: var(--shadow); max-width: 90vw; }
.toast.erro { background: var(--danger); }

.sig { width: 100%; height: 180px; border: 1px dashed var(--line); border-radius: 12px; background: #fff; touch-action: none; display: block; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: var(--brand-ink); }
.login .card { width: min(420px, 100%); }
.users { display: grid; gap: .5rem; margin: 1rem 0; }
.users button { display: flex; gap: .75rem; align-items: center; padding: .7rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); cursor: pointer; text-align: left; font: inherit; }
.users button.sel { border-color: var(--brand); outline: 2px solid var(--brand); }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-top: .8rem; }
.pinpad button { min-height: 56px; font-size: 1.3rem; font-weight: 700; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); cursor: pointer; }
.pindots { display: flex; justify-content: center; gap: .6rem; margin: .6rem 0; }
.pindots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--muted); }
.pindots i.on { background: var(--ink); border-color: var(--ink); }

/* ---------- print ---------- */
.doc { background: #fff; color: #111; padding: 1.5rem; border-radius: 8px; }
.doc h1 { font-size: 1.3rem; }
.doc .hdr { display: flex; justify-content: space-between; border-bottom: 3px solid var(--brand); padding-bottom: .6rem; margin-bottom: 1rem; gap: 1rem; }
.doc table { width: 100%; border-collapse: collapse; margin: .5rem 0 1rem; }
.doc td, .doc th { border: 1px solid #ccc; padding: .35rem .5rem; text-align: left; font-size: .9rem; }
.doc .fotos { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.doc .fotos img { width: 100%; height: 160px; object-fit: cover; border-radius: 4px; }
.etiqueta { width: 300px; margin: 0 auto; text-align: center; border: 2px solid #111; border-radius: 12px; padding: 1rem; background: #fff; color: #111; }
.etiqueta svg, .etiqueta img { width: 220px; height: 220px; }
@media print {
  .topbar, .sidenav, .bottomnav, .noprint, #toast { display: none !important; }
  body, main#view { background: #fff; padding: 0; }
  .doc { padding: 0; }
}
