:root {
  --bg: #f5f5f5; --card: #fff; --line: #e5e5e5; --soft: #f1f1f1; --text: #171717; --muted: #6b6b6b;
  --primary: #171717; --primary-text: #fff; --green: #04855c; --red: #d92d20; --orange: #b45309; --blue: #1d4ed8;
  --warn-bg: #fff8e1; --warn-line: #f6d97a;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --title: 'Archivo', 'Inter', system-ui, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0f0f0f; --card: #191919; --line: #2c2c2c; --soft: #242424; --text: #f2f2f2; --muted: #a3a3a3;
  --primary: #f2f2f2; --primary-text: #111; --green: #34d399; --red: #f87171; --orange: #fbbf24; --blue: #93c5fd;
  --warn-bg: #2b2410; --warn-line: #5c4a12;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #0f0f0f; --card: #191919; --line: #2c2c2c; --soft: #242424; --text: #f2f2f2; --muted: #a3a3a3;
    --primary: #f2f2f2; --primary-text: #111; --green: #34d399; --red: #f87171; --orange: #fbbf24; --blue: #93c5fd;
    --warn-bg: #2b2410; --warn-line: #5c4a12;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); -webkit-text-size-adjust: 100%; }
a { color: inherit; text-decoration: none; }
a.link { text-decoration: underline; }
h1, h2, h3 { font-family: var(--title); font-stretch: 125%; margin: 0; letter-spacing: -.01em; }
h1 { font-size: 24px; }
h2 { font-size: 17px; }
h3 { font-size: 14px; font-family: var(--font); }
p { margin: 0 0 8px; }
svg.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.green { color: var(--green); }
.red { color: var(--red); }
.orange { color: var(--orange); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.loading { padding: 40px; text-align: center; color: var(--muted); }
.label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }

/* estrutura */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 240px; flex: none; background: var(--card); border-right: 1px solid var(--line); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 14px 10px; overflow-y: auto; }
.brand { font: 700 17px var(--title); font-stretch: 125%; padding: 6px 8px 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav a { display: flex; gap: 10px; align-items: center; padding: 9px 10px; border-radius: 8px; color: var(--muted); font-weight: 500; }
.nav a:hover { background: var(--soft); color: var(--text); }
.nav a.active { background: var(--primary); color: var(--primary-text); }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; display: grid; gap: 8px; }
.who { display: flex; gap: 10px; align-items: center; padding: 0 4px; min-width: 0; }
.who > div { min-width: 0; flex: 1; }
.who > div strong, .who > div span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.theme-seg button { display: inline-flex; align-items: center; justify-content: center; gap: 4px; padding: 5px 4px; font-size: 11px; }
.theme-seg svg.icon { width: 13px; height: 13px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--soft); display: grid; place-items: center; font-weight: 700; font-size: 12px; flex: none; }
.foot-link { display: flex; gap: 8px; align-items: center; background: none; border: 0; color: var(--muted); font: inherit; cursor: pointer; padding: 4px 8px; text-align: left; }
.main { flex: 1; min-width: 0; padding: 24px; }
.topbar, .bottomnav { display: none; }

.page-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 16px; }
.page-head p { color: var(--muted); margin: 4px 0 0; }
.back { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); margin: -6px 0 14px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.between { justify-content: space-between; }
.stack { display: grid; gap: 12px; align-content: start; grid-template-columns: minmax(0, 1fr); }
.narrow { max-width: 760px; }
.grid2 { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid3 { display: grid; gap: 12px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stats { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 14px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.stat strong { display: block; font-size: 17px; margin-top: 2px; }
.columns { display: grid; gap: 12px; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.card-head h3 { display: flex; gap: 8px; align-items: center; }
.list { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.item { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 11px 14px; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
a.item:hover, button.item:hover { background: var(--soft); }
button.item { width: 100%; background: none; border: 0; border-top: 1px solid var(--line); font: inherit; color: inherit; text-align: left; cursor: pointer; }
.item .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.empty { padding: 24px; text-align: center; color: var(--muted); }

/* botões e campos */
.btn { display: inline-flex; gap: 7px; align-items: center; justify-content: center; border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 8px; padding: 8px 14px; font: 600 13px var(--font); cursor: pointer; min-height: 36px; }
.btn:hover { filter: brightness(.96); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn.danger { color: var(--red); }
.btn.big { width: 100%; padding: 12px; }
.btn.sm { padding: 4px 10px; min-height: 28px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
.iconbtn { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 6px; display: inline-flex; }
.iconbtn:hover { background: var(--soft); color: var(--text); }
label.field { display: grid; gap: 4px; font-size: 12px; font-weight: 500; color: var(--muted); min-width: 0; align-content: start; }
label.field small { font-weight: 400; }
label.field small.caps { color: #d97706; font-weight: 600; }
.linklike { background: none; border: 0; padding: 6px; font: inherit; font-size: 13px; color: var(--muted); text-decoration: underline; cursor: pointer; justify-self: center; }
input, select, textarea { font: 14px var(--font); color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; min-height: 38px; }
textarea { min-height: 74px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--text); outline-offset: -1px; }
input[type="checkbox"] { width: 16px; height: 16px; min-height: 0; accent-color: var(--primary); }
label.check { display: flex; gap: 8px; align-items: center; cursor: pointer; }
form { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
.search { position: relative; }
.search svg { position: absolute; left: 11px; top: 11px; color: var(--muted); }
.search input { padding-left: 36px; }
.seg { display: flex; background: var(--soft); border-radius: 9px; padding: 3px; gap: 2px; }
.seg button { flex: 1; background: none; border: 0; border-radius: 7px; padding: 6px 10px; font: 500 13px var(--font); color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgb(0 0 0 / .12); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button { border: 1px solid var(--line); background: var(--card); color: var(--muted); border-radius: 999px; padding: 6px 13px; font: 500 13px var(--font); cursor: pointer; }
.chips button.on { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.tabs { display: flex; gap: 20px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 8px 2px 10px; color: var(--muted); font-weight: 500; white-space: nowrap; border-bottom: 2px solid transparent; }
.tabs a.on { color: var(--text); border-color: var(--text); }

.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 6px; background: var(--soft); color: var(--muted); white-space: nowrap; }
.b-blue { background: rgb(59 130 246 / .14); color: var(--blue); }
.b-yellow { background: rgb(245 158 11 / .16); color: var(--orange); }
.b-green { background: rgb(16 185 129 / .14); color: var(--green); }
.b-red { background: rgb(239 68 68 / .13); color: var(--red); }
.b-purple { background: rgb(139 92 246 / .15); color: #8b5cf6; }
.b-dark { background: var(--primary); color: var(--primary-text); }
.notice { background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; }
.tip { border: 1px dashed var(--line); border-radius: 10px; padding: 12px 14px; color: var(--muted); font-size: 13px; }

.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 12px; border-top: 1px solid var(--line); vertical-align: middle; }
th { border-top: 0; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--soft); white-space: nowrap; }
td.num, th.num { text-align: right; white-space: nowrap; }
tr.click { cursor: pointer; }
tr.click:hover { background: var(--soft); }
.canceled { opacity: .55; text-decoration: line-through; }

/* tela inicial */
.eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.hero { display: grid; gap: 12px; grid-template-columns: repeat(3, 1fr); margin: 20px 0 26px; }
.hero a { background: #171717; color: #fff; border-radius: 10px; padding: 20px 18px; position: relative; border: 1px solid var(--line); }
.hero a svg.icon { width: 24px; height: 24px; }
.hero a strong { display: block; font: 700 17px var(--title); font-stretch: 125%; margin-top: 18px; }
.hero a span { color: #a3a3a3; font-size: 12px; }
.hero a .arrow { position: absolute; right: 16px; top: 50%; color: #737373; }
.shortcuts { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); margin: 8px 0 22px; }
.shortcuts a { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: flex; gap: 10px; align-items: center; font-weight: 600; }

/* venda */
.pos { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
.products { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); align-content: start; margin-top: 10px; }
.product { display: flex; justify-content: space-between; gap: 8px; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: pointer; font: inherit; color: inherit; }
.product:hover { border-color: var(--text); }
.product:disabled { opacity: .45; cursor: default; }
.qty { display: flex; align-items: center; gap: 4px; }
.qty button { width: 28px; height: 28px; border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 6px; cursor: pointer; display: grid; place-items: center; padding: 0; }
.qty b { min-width: 22px; text-align: center; }
.total-line { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.total-line.big strong { font-size: 22px; }
.cart-price { width: 90px; min-height: 28px; padding: 2px 8px; text-align: right; }

/* OS */
.checklist { display: grid; gap: 6px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.checkrow { display: flex; justify-content: space-between; gap: 6px; align-items: center; background: var(--soft); border-radius: 8px; padding: 5px 6px 5px 10px; font-size: 13px; flex-wrap: wrap; }
.checkrow .opts { display: flex; gap: 3px; }
.checkrow button { border: 1px solid var(--line); background: var(--card); color: var(--muted); border-radius: 6px; font: 500 11px var(--font); padding: 4px 7px; cursor: pointer; }
.checkrow button.on.ok { background: var(--green); border-color: var(--green); color: var(--card); }
.checkrow button.on.defeito { background: var(--red); border-color: var(--red); color: var(--card); }
.checkrow button.on.nao_testado { background: var(--muted); border-color: var(--muted); color: var(--card); }
.express-box { background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 10px; padding: 12px; }
.service-line { display: grid; grid-template-columns: minmax(0, 1fr) 120px 34px; gap: 6px; align-items: center; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 6px; }
.photos figure { margin: 0; position: relative; }
.photos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; cursor: pointer; display: block; }
.photos .iconbtn { position: absolute; top: 3px; right: 3px; background: var(--card); }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.timeline li { display: grid; grid-template-columns: 10px 1fr auto; gap: 10px; align-items: start; }
.timeline .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text); margin-top: 6px; }
.timeline .pending { color: var(--muted); }
.timeline .pending .dot { background: var(--line); }
.pattern { position: relative; width: 192px; height: 192px; touch-action: none; user-select: none; margin: 4px auto; }
.pattern svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.pattern button { position: absolute; width: 44px; height: 44px; margin: -22px; border-radius: 50%; border: 2px solid var(--line); background: var(--card); color: var(--muted); font: 600 11px var(--font); cursor: pointer; touch-action: none; }
.pattern button.on { border-color: var(--text); background: var(--primary); color: var(--primary-text); }
.secret { font: 700 24px ui-monospace, monospace; letter-spacing: .1em; text-align: center; overflow-wrap: anywhere; }

/* relatórios */
.bar { height: 5px; border-radius: 4px; background: var(--soft); overflow: hidden; margin-top: 3px; }
.bar i { display: block; height: 100%; background: #2a78d6; }
.bar.green-bar i { background: #10b981; }
.bar.red-bar i { background: #f87171; }
.chart { width: 100%; height: auto; display: block; }
.chart text { font: 10px var(--font); fill: var(--muted); }
.chart line { stroke: var(--line); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 5px; }

/* janelas e avisos */
.overlay { position: fixed; inset: 0; background: rgb(0 0 0 / .5); display: grid; place-items: center; padding: 16px; z-index: 40; }
.modal { background: var(--card); border-radius: 14px; width: min(100%, 480px); max-height: calc(100vh - 32px); overflow-y: auto; padding: 18px; box-shadow: 0 20px 50px rgb(0 0 0 / .3); }
.modal.wide { width: min(100%, 640px); }
.modal > .card-head { align-items: flex-start; }
.sheet { place-items: end center; padding: 0; }
.sheet .modal { width: min(100%, 520px); border-radius: 16px 16px 0 0; }
#toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 60; max-width: calc(100vw - 32px); }
.toast { background: var(--primary); color: var(--primary-text); padding: 10px 16px; border-radius: 10px; box-shadow: 0 6px 20px rgb(0 0 0 / .25); }
.toast.error { background: #b42318; color: #fff; }
.banner { position: sticky; top: 0; z-index: 30; text-align: center; padding: 8px; font-weight: 600; }
.banner-offline { background: #b42318; color: #fff; }
.banner-update { position: fixed; top: auto; bottom: 76px; left: 50%; transform: translateX(-50%); background: var(--primary); color: var(--primary-text); border: 0; border-radius: 999px; padding: 10px 18px; cursor: pointer; font: 600 13px var(--font); white-space: nowrap; }
.support-bar { background: #7c3aed; color: #fff; text-align: center; padding: 6px; font-size: 12px; font-weight: 600; }

/* entrada */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: #0a0a0a; }
.auth .card { width: min(100%, 380px); }
.auth img { width: 150px; display: block; margin: 0 auto; border-radius: 12px; }

/* acompanhamento público */
.track { max-width: 420px; margin: 0 auto; padding: 24px 16px; }
.track header { text-align: center; margin-bottom: 16px; }
.track .status { font: 700 22px var(--title); font-stretch: 125%; margin: 6px 0; }
.track .steps { list-style: none; margin: 8px 0 0; padding: 0; }
.track .steps li { position: relative; padding: 0 0 16px 26px; }
.track .steps li::before { content: ''; position: absolute; left: 0; top: 3px; width: 11px; height: 11px; border-radius: 50%; background: var(--text); border: 1px solid var(--text); }
.track .steps li::after { content: ''; position: absolute; left: 6px; top: 18px; bottom: 0; width: 1px; background: var(--line); }
.track .steps li:last-child::after { display: none; }
.track .steps li.pending { color: var(--muted); }
.track .steps li.pending::before { background: var(--card); border-color: var(--line); }

@media (max-width: 1000px) {
  .columns, .pos { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .sidebar { display: none; }
  .shell { display: block; }
  .topbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: var(--card); border-bottom: 1px solid var(--line); padding: 10px 16px; }
  .topbar .brand { padding: 0; }
  .main { padding: 16px 12px 90px; }
  .bottomnav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0; background: var(--card); border-top: 1px solid var(--line); z-index: 20; padding-bottom: env(safe-area-inset-bottom); }
  .bottomnav a, .bottomnav button { display: grid; justify-items: center; gap: 2px; padding: 8px 0; font: 500 11px var(--font); color: var(--muted); background: none; border: 0; cursor: pointer; }
  .bottomnav .active { color: var(--text); font-weight: 700; }
  .bottomnav .active svg { background: var(--primary); color: var(--primary-text); border-radius: 999px; width: 40px; padding: 2px 0; }
  .grid2, .grid3, .hero, .checklist { grid-template-columns: minmax(0, 1fr); }
  .service-line { grid-template-columns: minmax(0, 1fr) 92px 30px; }
  .hide-mobile { display: none; }
  #toasts { bottom: 80px; }
}

/* impressão: sai só o documento, sempre no claro */
#print-area { display: none; }
@media print {
  body.printing > *:not(#print-area) { display: none !important; }
  body.printing { background: #fff; }
  body.printing #print-area { display: block; color: #000; font: 12px/1.4 Arial, sans-serif; }
  body:not(.printing) .sidebar, body:not(.printing) .bottomnav, body:not(.printing) .topbar, body:not(.printing) .no-print, body:not(.printing) .tabs { display: none !important; }
  body:not(.printing) { background: #fff; }
  body:not(.printing) .main { padding: 0; }
}
#print-area h1, #print-area h2, #print-area h3 { font-family: Arial, sans-serif; font-stretch: normal; }
#print-area h1 { font-size: 18px; }
#print-area h2 { font-size: 15px; }
#print-area h3 { font-size: 12px; border-bottom: 1px solid #ccc; padding-bottom: 3px; margin: 14px 0 6px; }
#print-area table th { background: none; color: #000; border-bottom: 1px solid #999; padding: 5px 4px; }
#print-area table td { border-top: 1px solid #ddd; padding: 5px 4px; }
#print-area .doc-head { display: flex; justify-content: space-between; gap: 16px; border-bottom: 2px solid #333; padding-bottom: 8px; margin-bottom: 12px; }
#print-area .two { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
#print-area .signs { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 46px; text-align: center; }
#print-area .signs div { border-top: 1px solid #000; padding-top: 4px; }
#print-area .doc-photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; break-before: page; }
#print-area .doc-photos img { width: 100%; break-inside: avoid; }
#print-area .coupon { width: 72mm; font: 11px/1.35 'Courier New', monospace; }
#print-area .coupon .center { text-align: center; }
#print-area .coupon hr { border: 0; border-top: 1px dashed #000; }
#print-area .coupon .total-line { display: flex; justify-content: space-between; }
