:root {
  --pri: #1f4e79; --pri-2: #2d6aa3; --bg: #f2f4f7; --card: #fff; --txt: #1b2430; --mut: #6b7785;
  --ok: #1e8e4e; --warn: #c77700; --bad: #c0392b; --line: #e1e5ea; --r: 12px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--txt);
  padding-top: calc(52px + env(safe-area-inset-top)); padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
#topbar { position: fixed; top: 0; left: 0; right: 0; z-index: 10; background: var(--pri); color: #fff; display: flex; align-items: center;
  gap: 6px; padding: env(safe-area-inset-top) 10px 0; height: calc(52px + env(safe-area-inset-top)); }
#topbar h1 { font-size: 18px; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#back { background: none; border: 0; color: #fff; font-size: 32px; line-height: 1; padding: 0 10px 4px; cursor: pointer; }
#actions { display: flex; gap: 6px; }
#actions button { background: rgba(255,255,255,.18); color: #fff; border: 0; border-radius: 8px; padding: 8px 12px; font-size: 14px; cursor: pointer; }
#nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; background: var(--card); border-top: 1px solid var(--line); display: flex;
  padding-bottom: env(safe-area-inset-bottom); }
#nav a { flex: 1; text-align: center; padding: 8px 2px 6px; color: var(--mut); text-decoration: none; font-size: 11px; }
#nav a span { display: block; font-size: 20px; }
#nav a.on { color: var(--pri); font-weight: 600; }
main { max-width: 760px; margin: 0 auto; padding: 12px; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.chip { flex: none; background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 7px 14px; font-size: 14px; cursor: pointer; color: var(--txt); }
.chip.on { background: var(--pri); border-color: var(--pri); color: #fff; }
.chip small { opacity: .7; margin-left: 4px; }
input, select, textarea { width: 100%; font: inherit; padding: 11px 12px; border: 1px solid #cbd2da; border-radius: 10px; background: #fff; color: var(--txt); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--pri-2); border-color: transparent; }
.search { margin-bottom: 10px; }
.row { display: flex; gap: 8px; align-items: center; }
.seg { display: flex; gap: 6px; margin-bottom: 10px; }
.seg button { flex: 1; padding: 8px 4px; border: 1px solid var(--line); background: var(--card); border-radius: 8px; font-size: 13px; cursor: pointer; color: var(--txt); }
.seg button.on { border-color: var(--pri); color: var(--pri); font-weight: 600; background: #eaf2fa; }

.card { background: var(--card); border-radius: var(--r); padding: 12px 14px; margin-bottom: 8px; box-shadow: 0 1px 2px rgba(0,0,0,.05); display: block; color: inherit; text-decoration: none; }
a.card:active, .card.tap:active { background: #f6f8fa; }
.item { display: flex; gap: 12px; align-items: center; }
.item .ic { font-size: 26px; flex: none; }
.item .main { flex: 1; min-width: 0; }
.item .t { font-weight: 600; font-size: 16px; }
.item .s { color: var(--mut); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item input[type=checkbox] { width: 22px; height: 22px; flex: none; }
.badge { display: inline-block; font-size: 12px; padding: 2px 9px; border-radius: 10px; background: #e8edf2; color: #3a4654; white-space: nowrap; }
.badge.ok { background: #e0f4e8; color: var(--ok); }
.badge.out { background: #e6eefa; color: var(--pri); }
.badge.warn { background: #fdf0d9; color: var(--warn); }
.badge.bad { background: #fbe4e1; color: var(--bad); }

.kv { display: grid; grid-template-columns: 38% 1fr; gap: 8px 10px; font-size: 15px; }
.kv dt { color: var(--mut); } .kv dd { margin: 0; font-weight: 500; word-break: break-word; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--mut); margin: 18px 4px 8px; display: flex; justify-content: space-between; align-items: center; }
h2 button { text-transform: none; letter-spacing: 0; }

.btn { border: 0; border-radius: 10px; padding: 12px 16px; font: inherit; font-weight: 600; cursor: pointer; background: var(--pri); color: #fff; }
.btn.sec { background: #e4e9ef; color: var(--txt); }
.btn.bad { background: var(--bad); }
.btn.sm { padding: 6px 12px; font-size: 14px; font-weight: 500; }
.btn:disabled { opacity: .5; }
.btns { display: flex; gap: 8px; margin: 12px 0; }
.btns .btn { flex: 1; }
.field { margin-bottom: 12px; } .field label { display: block; font-size: 13px; color: var(--mut); margin-bottom: 4px; }
.field .req { color: var(--bad); }
.check { display: flex; gap: 8px; align-items: center; font-size: 15px; } .check input { width: 20px; height: 20px; }
.empty { text-align: center; color: var(--mut); padding: 40px 10px; }
.fab { position: fixed; right: 16px; bottom: calc(78px + env(safe-area-inset-bottom)); width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--pri);
  color: #fff; font-size: 30px; box-shadow: 0 4px 12px rgba(0,0,0,.3); cursor: pointer; z-index: 9; }
.selbar { position: fixed; left: 0; right: 0; bottom: calc(64px + env(safe-area-inset-bottom)); background: var(--card); border-top: 1px solid var(--line); padding: 10px 12px; display: flex; gap: 8px; z-index: 9; align-items: center; }
.selbar span { flex: 1; font-weight: 600; }
.tl { border-left: 2px solid var(--line); margin-left: 6px; padding-left: 14px; }
.tl .ev { position: relative; padding-bottom: 12px; font-size: 14px; }
.tl .ev::before { content: ''; position: absolute; left: -20px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--pri-2); }
.tl .ev.devolucao::before { background: var(--ok); } .tl .ev .d { color: var(--mut); font-size: 12px; }

#sheet { position: fixed; inset: 0; z-index: 50; }
#sheet .backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.45); }
#sheet .panel { position: absolute; left: 0; right: 0; bottom: 0; max-height: 88%; overflow: auto; background: var(--card); border-radius: 18px 18px 0 0;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); max-width: 760px; margin: 0 auto; }
#sheet h3 { margin: 0 0 12px; }
#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(90px + env(safe-area-inset-bottom)); background: #222; color: #fff; padding: 10px 18px; border-radius: 22px; z-index: 60; font-size: 14px; max-width: 90%; }
#toast.err { background: var(--bad); }

/* login */
body.login { padding: 0; }
body.login #topbar, body.login #nav { display: none; }
.loginbox { max-width: 360px; margin: 12vh auto 0; padding: 24px 20px; }
.loginbox .logo { text-align: center; margin-bottom: 8px; } .loginbox .logo img { border-radius: 14px; }
.lerr { background: #fbe4e1; color: var(--bad); border-radius: 8px; padding: 9px 12px; margin: 10px 0; font-size: 14px; }
