:root {
  --navy: #1F2A44;
  --gold: #A8823A;
  --gold-l: #C9A35A;
  --ivory: #F7F3EA;
  --sand: #EFE8D8;
  --sand-2: #E3DAC5;
  --line: #EEE9DD;
  --muted: #5B6170;
  --text-2: #3A4152;
  --late: #9A2E12;
  --ok: #24533A;
  --white: #FFFFFF;
  --serif: 'Crimson Text', Georgia, serif;
  --sans: 'DM Sans', system-ui, -apple-system, Roboto, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--ivory); color: var(--navy); font-family: var(--sans); font-size: 15px; }
button, input, select, textarea { font-family: inherit; font-size: 15px; color: inherit; }
a { color: var(--navy); }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; margin: 0; line-height: 1.1; }
h1 { font-size: 28px; }
h2 { font-size: 22px; }
.wrap { max-width: 560px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; }
main { flex: 1; padding: 0 16px calc(96px + var(--safe-b)); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.late { color: var(--late); font-weight: 600; }
.okc { color: var(--ok); font-weight: 600; }
.eyebrow { font-size: 12px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--muted); }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.hidden { display: none !important; }

/* Topo */
.top { display: flex; align-items: center; gap: 12px; padding: 14px 16px 10px; position: sticky; top: 0; background: var(--ivory); z-index: 5; }
.top img { width: 40px; height: 40px; border-radius: 10px; }
.top .title { font-family: var(--serif); font-size: 23px; font-weight: 600; line-height: 1.05; }
.sync { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 4px; background: var(--ok); display: inline-block; }
.dot.off { background: var(--gold); }
.dot.err { background: var(--late); }
.iconbtn { width: 44px; height: 44px; border-radius: 22px; border: 1px solid #D9D2C2; background: var(--white); display: inline-flex; align-items: center; justify-content: center; position: relative; cursor: pointer; padding: 0; text-decoration: none; }
.iconbtn .badge { position: absolute; top: 4px; right: 4px; }
.badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--navy); color: #fff; font-size: 11px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; }

/* Navegação inferior */
nav.tabs { position: fixed; left: 0; right: 0; bottom: 0; background: var(--white); border-top: 1px solid var(--line); padding-bottom: var(--safe-b); z-index: 10; }
nav.tabs .in { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, 1fr); height: 64px; }
nav.tabs a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; text-decoration: none; color: var(--muted); font-size: 11px; }
nav.tabs a svg { stroke: var(--muted); }
nav.tabs a.on { color: var(--navy); font-weight: 600; }
nav.tabs a.on svg { stroke: var(--gold); }

/* Cartões e listas */
.card { background: var(--white); border-radius: 14px; padding: 4px 14px; }
.card.pad { padding: 14px; }
.li { display: flex; gap: 10px; align-items: center; padding: 11px 0; border-top: 1px solid var(--line); text-decoration: none; color: inherit; }
.card > .li:first-child, .card > .sec + .li { border-top: none; }
.li .t { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li .m { font-size: 12px; color: var(--muted); }
.li .d { font-size: 12px; color: var(--muted); white-space: nowrap; }
.sec { padding: 12px 0 4px; font-size: 12px; font-weight: 600; letter-spacing: 1px; color: var(--muted); text-transform: uppercase; }
.empty { padding: 18px 0; text-align: center; color: var(--muted); font-size: 14px; }
.tag { flex-shrink: 0; width: 64px; text-align: center; padding: 4px 0; border-radius: 6px; font-size: 11px; font-weight: 600; }
.tag.reparo { background: #F6E3DC; color: #7A2E17; }
.tag.reforma { background: #E3E7F1; color: var(--navy); }
.tag.afazer { background: #F3EAD6; color: #6B5016; }
.tag.rotina { background: #E4EFE6; color: var(--ok); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--white); border-radius: 12px; padding: 10px 12px; }
.stat b { display: block; font-size: 22px; }

/* Botões */
.btn { height: 46px; padding: 0 18px; border-radius: 12px; border: none; background: var(--navy); color: var(--ivory); font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.btn.sm { height: 40px; padding: 0 14px; border-radius: 20px; font-size: 13px; }
.btn.ghost { background: transparent; color: var(--navy); border: 1px solid var(--navy); }
.btn.gold { background: var(--gold); color: #fff; }
.btn.danger { background: transparent; color: var(--late); border: 1px solid #E2C4BA; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; }
.link { background: none; border: none; color: #6B5016; font-weight: 600; cursor: pointer; padding: 8px; font-size: 14px; }

/* Planta */
.mapbox { background: var(--sand); border-radius: 12px; padding: 4px 0; display: flex; justify-content: center; }
.map { position: relative; width: 330px; height: 400px; }
.area { position: absolute; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; cursor: pointer; padding: 0; background: #fff; color: var(--navy); border: 2px solid var(--navy); border-radius: 2px; font-size: 11px; font-weight: 600; line-height: 1.15; text-align: center; }
.area.externa { background: var(--sand-2); border: 1.5px solid #B9AE95; }
.area.anexo { background: #F7F0DF; border: 2px dashed var(--gold); border-radius: 8px; }
.area.on { background: var(--navy); color: var(--ivory); border: 2px solid var(--navy); }
.area.on .badge { background: var(--gold-l); color: var(--navy); }
.sheet { background: var(--white); border-radius: 20px; margin-top: 12px; padding: 14px 16px 8px; box-shadow: 0 -2px 16px rgba(31,42,68,.06); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { padding: 7px 12px; border-radius: 16px; background: var(--white); border: 1px solid #E2DBCB; font-size: 12px; cursor: pointer; }
.chip.on { background: var(--navy); color: var(--ivory); border-color: var(--navy); font-weight: 600; }

/* Formulários */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 12px; font-weight: 600; letter-spacing: .6px; color: var(--muted); text-transform: uppercase; }
.input, select.input, textarea.input { width: 100%; min-height: 46px; padding: 10px 12px; border-radius: 12px; border: 1px solid #D9D2C2; background: var(--white); outline: none; }
textarea.input { min-height: 84px; resize: vertical; }
.input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(168,130,58,.18); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: #EAE3D3; border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { height: 38px; border: none; border-radius: 9px; background: transparent; font-size: 13px; cursor: pointer; }
.seg button.on { background: var(--navy); color: var(--ivory); font-weight: 600; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.check input { width: 22px; height: 22px; accent-color: var(--navy); }
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photo { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--sand-2); }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo span { position: absolute; left: 6px; bottom: 6px; background: rgba(31,42,68,.8); color: #fff; font-size: 10px; padding: 2px 6px; border-radius: 6px; }
.addphoto { aspect-ratio: 1; border-radius: 10px; border: 1.5px dashed #B9AE95; display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--muted); font-size: 12px; text-align: center; }
.back { display: inline-flex; align-items: center; gap: 4px; height: 44px; text-decoration: none; font-weight: 600; font-size: 14px; }

/* Modal e aviso */
.overlay { position: fixed; inset: 0; background: rgba(31,42,68,.55); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modal { width: 100%; max-width: 560px; background: var(--ivory); border-radius: 22px 22px 0 0; padding: 22px 18px calc(22px + var(--safe-b)); max-height: 85vh; overflow: auto; }
.qa { display: flex; gap: 6px; }
.qa button { height: 36px; padding: 0 10px; border-radius: 10px; border: 1px solid #D9D2C2; background: #fff; font-size: 12px; font-weight: 600; cursor: pointer; }
#toast { position: fixed; left: 50%; bottom: calc(84px + var(--safe-b)); transform: translateX(-50%); background: var(--navy); color: var(--ivory); padding: 10px 16px; border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 60; max-width: 90vw; }
#toast.show { opacity: 1; }

/* Login */
.login { min-height: 100vh; min-height: 100dvh; background: var(--navy); color: var(--ivory); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 24px; gap: 18px; }
.login img { width: 132px; }
.login h1 { font-size: 34px; }
.login .box { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px; }
.login .input { color: var(--navy); }
.login .btn.ghost { color: var(--ivory); border-color: var(--gold-l); }
.login .msg { min-height: 20px; font-size: 14px; color: #F3D9A6; text-align: center; }
iframe.agenda { width: 100%; height: 70vh; border: 0; border-radius: 14px; background: #fff; }
