:root {
  --bg: #12110E;
  --bg2: #1B1A16;
  --card: #23221C;
  --line: rgba(245, 236, 214, .10);
  --text: #F5F0E6;
  --muted: #A39B8B;
  --gold: #E0B14A;
  --gold2: #C8942A;
  --danger: #E26A5A;
  --ok: #7CB98A;
  --manut: #6EA8D8;
  --gas: #7CB98A;
  --doc: #C49BDB;
  --out: #B8A98A;
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); min-height: 100%; }
body { padding-bottom: calc(88px + var(--safe-bot)); }
button, input { font: inherit; color: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); }
.err { color: var(--danger); font-size: 14px; margin: 8px 0 0; }
.label { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0 0 6px; }
.opt { text-transform: none; letter-spacing: 0; font-weight: 400; }

.gate {
  min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(224,177,74,.18), transparent 60%),
    var(--bg);
}
.gate form {
  width: 100%; max-width: 360px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 32px 24px 28px;
  text-align: center;
}
.gate-mark {
  width: 72px; height: 72px; margin: 0 auto 16px;
  border-radius: 20px;
  background: linear-gradient(160deg, var(--gold), var(--gold2));
  color: #1A1408;
  font-weight: 800; font-size: 36px;
  display: flex; align-items: center; justify-content: center;
  letter-spacing: -1px;
}
.gate h1 { margin: 0; font-size: 26px; font-weight: 700; }
.gate-sub { margin: 6px 0 22px; color: var(--muted); }
.gate input, .sheet input, .sheet select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 14px;
  outline: none;
}
.gate input:focus, .sheet input:focus { border-color: var(--gold); }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 100%; min-height: 48px;
  border: 0; border-radius: 12px;
  padding: 12px 16px;
  font-weight: 650;
  cursor: pointer;
}
.btn.primary { background: linear-gradient(180deg, var(--gold), var(--gold2)); color: #1A1408; margin-top: 12px; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); margin-top: 8px; }
.btn.danger.link { background: none; color: var(--danger); margin-top: 8px; }
.btn[disabled] { opacity: .55; pointer-events: none; }

#app { max-width: 560px; margin: 0 auto; padding: calc(12px + var(--safe-top)) 16px 0; }
.top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.top h1 { margin: 0; font-size: 24px; letter-spacing: -.02em; }
.kicker { margin: 0 0 2px; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--gold); }
.chip {
  border: 1px solid var(--line); background: var(--card);
  border-radius: 999px; padding: 8px 12px; font-size: 13px; white-space: nowrap;
}
.chip[data-state="ok"] { color: var(--ok); }
.chip[data-state="err"], .chip[data-state="off"] { color: var(--danger); }
.chip[data-state="busy"] { color: var(--gold); }

.banner { background: #3A2A16; color: #F3D9A0; border-radius: 10px; padding: 10px 12px; font-size: 13px; }

.hero {
  background: linear-gradient(180deg, #2A261C, var(--card));
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 20px 18px 16px;
  margin: 12px 0;
}
.hero-value { margin: 0; font-size: 34px; font-weight: 750; letter-spacing: -.03em; }

.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 12px;
}
.card .value { margin: 4px 0 0; font-size: 17px; font-weight: 700; }
.card.wide { grid-column: 1 / -1; }

.cats { margin: 16px 0 8px; display: grid; gap: 8px; }
.cat-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; font-size: 13px; align-items: center; }
.bar { height: 6px; background: var(--bg2); border-radius: 99px; overflow: hidden; grid-column: 1 / -1; }
.bar > span { display: block; height: 100%; border-radius: 99px; }
.bar.manut > span { background: var(--manut); }
.bar.gas > span { background: var(--gas); }
.bar.doc > span { background: var(--doc); }
.bar.out > span { background: var(--out); }

.filters {
  display: flex; gap: 8px; overflow-x: auto;
  padding: 8px 0 12px;
  position: sticky; top: 0; background: var(--bg); z-index: 2;
  -webkit-overflow-scrolling: touch;
}
.filters button {
  border: 1px solid var(--line); background: var(--card);
  border-radius: 999px; padding: 8px 14px; white-space: nowrap; min-height: 40px;
}
.filters button[aria-pressed="true"] { background: var(--text); color: #16140F; border-color: var(--text); font-weight: 650; }

.list-head { display: flex; justify-content: space-between; align-items: baseline; margin: 8px 0; }
.list-head h2 { margin: 0; font-size: 16px; }
.list { display: flex; flex-direction: column; gap: 8px; }
.item {
  width: 100%; text-align: left;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 12px 14px;
  display: grid; grid-template-columns: 1fr auto; gap: 2px 12px;
  cursor: pointer;
}
.item .desc { font-weight: 650; }
.item .meta { font-size: 12px; color: var(--muted); grid-column: 1; }
.item .val { font-weight: 750; }
.pill {
  display: inline-block; font-size: 11px; font-weight: 650;
  border-radius: 99px; padding: 2px 8px; margin-right: 6px;
}
.pill.Manutenção { background: rgba(110,168,216,.18); color: var(--manut); }
.pill.Gasolina { background: rgba(124,185,138,.18); color: var(--gas); }
.pill.Documentação { background: rgba(196,155,219,.18); color: var(--doc); }
.pill.Outros { background: rgba(184,169,138,.18); color: var(--out); }
.empty { text-align: center; color: var(--muted); padding: 28px 8px; }

.fab {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(16px + var(--safe-bot));
  width: calc(100% - 32px); max-width: 528px;
  min-height: 52px;
  border: 0; border-radius: 16px;
  background: linear-gradient(180deg, var(--gold), var(--gold2));
  color: #1A1408; font-weight: 750; font-size: 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  z-index: 5;
}

.sheet { position: fixed; inset: 0; z-index: 20; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.55); }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: var(--bg2);
  border-radius: 24px 24px 0 0;
  padding: 10px 18px calc(20px + var(--safe-bot));
  max-height: 92dvh; overflow: auto;
}
.sheet-grab { width: 44px; height: 4px; background: var(--line); border-radius: 99px; margin: 6px auto 14px; }
.sheet h2 { margin: 0 0 14px; font-size: 20px; }
.sheet label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 0; }
.sheet label input { margin-top: 6px; color: var(--text); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg button {
  border: 1px solid var(--line); background: var(--card);
  border-radius: 12px; min-height: 42px; padding: 8px;
}
.seg button[aria-pressed="true"] { border-color: var(--gold); background: #2C271A; color: var(--gold); font-weight: 700; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(80px + var(--safe-bot));
  background: #F5F0E6; color: #16140F;
  padding: 10px 16px; border-radius: 999px;
  font-weight: 650; font-size: 14px; z-index: 30;
  box-shadow: 0 8px 20px rgba(0,0,0,.35);
}

@media (min-width: 720px) {
  #app { padding-top: 24px; }
  .hero-value { font-size: 40px; }
}
