:root {
  --accent: #0f5e66; --accent-2: #0b4a51; --accent-soft: #e6f1f2; --on-accent: #fff;
  --bg: #f4f6f8; --surface: #fff; --text: #14171f; --muted: #5b6670; --border: #e2e7ec;
  --danger: #b42318; --danger-soft: #fdecec; --warn: #d9a400; --warn-soft: #fff4e0; --warn-text: #7a4d00;
  --ok: #0b5d2a; --ok-soft: #e6f4ea; --blue: #1d3f8a; --blue-soft: #e0ecff;
  --shadow: 0 1px 2px rgba(15,23,42,.06), 0 4px 14px rgba(15,23,42,.05);
  --r: 14px;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); line-height: 1.5; -webkit-font-smoothing: antialiased; min-height: 100vh; }
h1, h2, h3, h4, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* layout */
.topbar { position: sticky; top: 0; z-index: 30; background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-in { max-width: 1200px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { width: 40px; height: 40px; border-radius: 12px; background: var(--accent); color: #fff; display: grid; place-items: center; flex: 0 0 auto; }
.brand-name { font-weight: 800; font-size: 1.05rem; line-height: 1.1; }
.brand-sub { font-size: .78rem; color: var(--muted); }
.nav { display: flex; gap: 4px; margin-left: 12px; }
.nav button { border: 0; background: transparent; padding: 10px 14px; min-height: 44px; border-radius: 10px; font-weight: 600; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; gap: 8px; }
.nav button:hover { background: var(--bg); color: var(--text); }
.nav button.on { background: var(--accent-soft); color: var(--accent-2); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.streak { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; min-height: 40px; border-radius: 999px; background: var(--warn-soft); color: var(--warn-text); font-weight: 700; border: 1px solid #f3d9a4; font-size: .9rem; }
main.page { max-width: 1200px; margin: 0 auto; padding: 18px 16px 110px; display: flex; flex-direction: column; gap: 16px; }
.bottom-nav { display: none; }
@media (max-width: 860px) {
  .nav { display: none; }
  .brand-sub { display: none; }
  .bottom-nav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 40; background: var(--surface); border-top: 1px solid var(--border); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); }
  .bottom-nav button { flex: 1; border: 0; background: transparent; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; min-height: 54px; font-size: .72rem; font-weight: 600; color: var(--muted); border-radius: 10px; cursor: pointer; }
  .bottom-nav button.on { color: var(--accent); background: var(--accent-soft); }
}

/* blocos */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 18px; box-shadow: var(--shadow); }
.card-title { font-size: 1.05rem; font-weight: 700; }
.card-sub { font-size: .88rem; color: var(--muted); margin-top: 2px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grow { flex: 1 1 0; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.tiny { font-size: .78rem; }
.mt { margin-top: 12px; }
.grid-auto { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.eyebrow { display: inline-flex; font-size: .75rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-2); width: fit-content; }

/* controles */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px; border: 1px solid transparent; border-radius: 12px; background: var(--accent); color: var(--on-accent); font-weight: 600; cursor: pointer; white-space: nowrap; text-decoration: none; font-size: .95rem; }
.btn:hover { background: var(--accent-2); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn.outline { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn.outline:hover { border-color: var(--accent); }
.btn.ghost { background: transparent; color: var(--text); }
.btn.ghost:hover { background: var(--bg); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: .88rem; border-radius: 10px; }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer; display: inline-grid; place-items: center; flex: 0 0 auto; position: relative; }
.icon-btn:hover { background: var(--bg); color: var(--text); }
.icon-btn.del:hover { color: var(--danger); }
.dot { position: absolute; top: 6px; right: 6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--danger); color: #fff; font-size: .7rem; font-weight: 700; display: grid; place-items: center; }
.input { width: 100%; min-height: 44px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); font-size: 1rem; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(15,94,102,.18); }
textarea.input { min-height: 90px; resize: vertical; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field > .lbl { font-weight: 600; font-size: .9rem; }
.form-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .form-grid { grid-template-columns: 1fr 1fr; } .form-grid .full { grid-column: 1 / -1; } }
.check-line { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.check-line input { width: 22px; height: 22px; accent-color: var(--accent); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }
.chip { flex: 0 0 auto; min-height: 40px; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-weight: 600; cursor: pointer; font-size: .9rem; display: inline-flex; align-items: center; gap: 6px; }
.chip:hover { border-color: var(--accent); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip .count { background: var(--bg); }
.chip.on .count { background: rgba(255,255,255,.22); color: #fff; }
.count { min-width: 26px; text-align: center; padding: 1px 8px; border-radius: 999px; background: var(--bg); color: var(--muted); font-size: .78rem; font-weight: 700; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--accent-soft); color: var(--accent-2); border: 1px solid transparent; white-space: nowrap; }
.badge.outline { background: transparent; color: var(--text); border-color: var(--border); }
.badge.red { background: var(--danger-soft); color: var(--danger); }
.badge.warn { background: var(--warn-soft); color: var(--warn-text); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.notice { border-left: 4px solid var(--accent); background: var(--accent-soft); border-radius: 12px; padding: 12px 14px; font-size: .9rem; color: var(--accent-2); }
.notice.warn { border-left-color: var(--warn); background: var(--warn-soft); color: #5c4200; }
.notice.red { border-left-color: var(--danger); background: var(--danger-soft); color: #7a1410; }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(400px, 100%); background: var(--surface); border-radius: 20px; padding: 28px; box-shadow: 0 10px 40px rgba(15,23,42,.1); display: flex; flex-direction: column; gap: 14px; }
.login-card .brand-mark { width: 56px; height: 56px; border-radius: 16px; }

/* foco */
.capture { background: var(--surface); border: 2px solid var(--border); border-radius: 18px; padding: 4px; box-shadow: var(--shadow); transition: border-color .15s; }
.capture:focus-within { border-color: var(--accent); }
.capture input { width: 100%; border: 0; outline: none; background: transparent; font-size: 1.2rem; padding: 14px; min-height: 58px; }
.hint { font-size: .82rem; color: var(--muted); }
.hint code { background: var(--surface); padding: 1px 6px; border-radius: 6px; border: 1px solid var(--border); font-size: .78rem; }
.big-num { font-size: 2.1rem; font-weight: 800; line-height: 1; color: var(--accent-2); }
.big-num.red { color: var(--danger); }
.cap { font-size: .84rem; color: var(--muted); margin-top: 6px; }
.track { height: 12px; background: var(--border); border-radius: 999px; overflow: hidden; }
.fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width .2s; }
.layout { display: grid; gap: 16px; }
@media (min-width: 900px) { .layout { grid-template-columns: 250px 1fr; align-items: start; } .side { position: sticky; top: 80px; } }
.side-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; min-height: 42px; padding: 6px 10px; border-radius: 10px; border: 0; background: transparent; cursor: pointer; text-align: left; font-weight: 500; }
.side-item:hover { background: var(--bg); }
.side-item.on { background: var(--accent); color: #fff; }
.side-item.on .count { background: rgba(255,255,255,.22); color: #fff; }
.group-head { display: flex; align-items: center; justify-content: space-between; margin: 14px 0 8px; }
.group-head h3 { font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.group-head.red h3 { color: var(--danger); }
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.task { position: relative; display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 12px 10px 12px 18px; min-height: 62px; box-shadow: var(--shadow); overflow: hidden; transition: opacity .2s, transform .2s; }
.task::before, .os::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: #cbd2d9; }
.prio-alta::before { background: #d92d20 !important; }
.prio-media::before { background: var(--warn) !important; }
.prio-baixa::before { background: #98a2b3 !important; }
.task.done { opacity: .6; }
.task.done .task-text { text-decoration: line-through; color: var(--muted); }
.task.leaving { opacity: 0; transform: translateX(12px); }
.task-body { flex: 1; min-width: 0; cursor: pointer; }
.task-text { font-size: 1.02rem; font-weight: 600; word-break: break-word; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.check { flex: 0 0 auto; width: 44px; height: 44px; border-radius: 12px; border: 2px solid #98a2b3; background: var(--surface); cursor: pointer; display: grid; place-items: center; padding: 0; color: transparent; }
.check:hover { border-color: var(--accent); }
.check.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.empty { text-align: center; padding: 36px 20px; background: var(--surface); border: 1px dashed #b8c2cc; border-radius: 16px; }
.empty h3 { font-size: 1.1rem; margin: 6px 0; }
.empty p { color: var(--muted); max-width: 420px; margin: 0 auto; }

/* OS */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 10px; }
.kpis > div { background: var(--bg); border-radius: 12px; padding: 12px; text-align: center; border: 1px solid var(--border); }
.kpis strong { display: block; font-size: 1.5rem; color: var(--accent-2); line-height: 1.2; }
.kpis span { font-size: .78rem; color: var(--muted); }
.kpis .red strong { color: var(--danger); }
.kpis button { all: unset; display: block; cursor: pointer; }
.os { position: relative; display: flex; flex-direction: column; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 14px 14px 14px 20px; box-shadow: var(--shadow); overflow: hidden; }
.os.late { border-color: #f0b4ae; background: #fff8f7; }
.os.soon { box-shadow: 0 0 0 2px #f3d9a4; }
.os.parada { background-image: repeating-linear-gradient(135deg, transparent 0 14px, rgba(217,164,0,.05) 14px 28px); }
.os-num { font-weight: 800; font-size: .88rem; color: var(--accent-2); letter-spacing: .04em; }
.os-pac { font-size: 1.12rem; font-weight: 700; word-break: break-word; }
.os-work { word-break: break-word; }
.trail { display: flex; gap: 4px; flex-wrap: wrap; list-style: none; margin: 0; padding: 0; }
.trail li { width: 26px; height: 8px; border-radius: 4px; background: var(--border); }
.trail li.on { background: var(--accent); }
.os-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sel { min-height: 40px; border-radius: 10px; font-weight: 700; padding: 4px 10px; border: 2px solid var(--border); background: var(--surface); font-size: .9rem; }
.st-a-fazer { background: #eef2f6; color: #344054; border-color: #98a2b3; }
.st-em-producao { background: var(--warn-soft); color: var(--warn-text); border-color: var(--warn); }
.st-pronto { background: var(--ok-soft); color: var(--ok); border-color: #2e7d4f; }
.st-entregue { background: var(--blue-soft); color: var(--blue); border-color: #3b6fd1; }
.os-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.emp-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: 0 0 auto; }
.money { font-variant-numeric: tabular-nums; font-weight: 700; }

/* financeiro */
.fin-kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.fin-kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; box-shadow: var(--shadow); }
.fin-kpi .v { font-size: 1.45rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.2; margin-top: 2px; }
.fin-kpi .l { font-size: .82rem; color: var(--muted); }
.fin-kpi.red .v { color: var(--danger); } .fin-kpi.ok .v { color: var(--ok); }
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.t th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; padding: 8px 10px 8px 0; border-bottom: 1px solid var(--border); }
table.t td { padding: 9px 10px 9px 0; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.t .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.t tr.paid td { color: var(--muted); }
table.t tr.overdue td:first-child { box-shadow: inset 3px 0 0 var(--danger); padding-left: 8px; }
.month-nav { display: inline-flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 2px; }
.month-nav strong { min-width: 150px; text-align: center; }
.chart svg { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 16px; font-size: .82rem; color: var(--muted); justify-content: center; margin-top: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 6px; vertical-align: -1px; }

/* diálogos */
dialog.dlg { width: min(620px, calc(100vw - 24px)); max-height: calc(100vh - 24px); padding: 0; border: 1px solid var(--border); border-radius: 18px; background: var(--surface); color: var(--text); box-shadow: 0 20px 50px rgba(0,0,0,.25); }
dialog.dlg::backdrop { background: rgba(15,23,42,.5); }
.dlg-in { padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.dlg-head h2 { font-size: 1.15rem; font-weight: 700; }
.dlg-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.notif-item { padding: 10px 0; border-bottom: 1px solid var(--border); }
.notif-item.new { font-weight: 600; }
.hist-item { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: .9rem; }

/* toast */
.toaster { position: fixed; left: 50%; transform: translateX(-50%); bottom: 84px; z-index: 100; display: flex; flex-direction: column; gap: 8px; width: min(420px, calc(100vw - 24px)); pointer-events: none; }
@media (min-width: 861px) { .toaster { bottom: 20px; left: auto; right: 20px; transform: none; } }
.toast { pointer-events: auto; padding: 12px 14px; border-radius: 12px; background: #14171f; color: #fff; box-shadow: 0 8px 24px rgba(0,0,0,.2); font-size: .92rem; transition: opacity .2s, transform .2s; }
.toast.err { background: var(--danger); }
.toast.ok { background: var(--ok); }
.toast.hide { opacity: 0; transform: translateY(8px); }

@media print {
  .topbar, .bottom-nav, .no-print, button, .capture, .hint { display: none !important; }
  body { background: #fff; } .card, .task, .os { box-shadow: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
