:root {
  --bg: #f6f3ee;
  --surface: #ffffff;
  --ink: #1e1a16;
  --muted: #6f665c;
  --line: #e6dfd5;
  --line-strong: #d4cabc;
  --side: #17130f;
  --side-ink: #cfc6b9;
  --accent: #80592f;
  --accent-soft: #f3eadd;
  --gold: #c9a271;
  --ok: #24704b;
  --ok-soft: #e4f1ea;
  --warn: #96590a;
  --warn-soft: #fbefdc;
  --bad: #ab3329;
  --bad-soft: #fae7e4;
  --info: #2d5f85;
  --info-soft: #e5eff6;
  --neutral-soft: #efeae2;
  --display: 'Marcellus', Georgia, serif;
  --text: 'Hanken Grotesk', system-ui, sans-serif;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(30, 26, 22, .05), 0 8px 24px rgba(30, 26, 22, .06);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 16px/1.5 var(--text); -webkit-font-smoothing: antialiased; }
h1, h2, h3, p { margin: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
svg.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Botões */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface); font-weight: 600; font-size: 15px; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s; }
.btn:hover { background: var(--bg); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.primary:hover { background: var(--accent); border-color: var(--accent); }
.btn.danger { color: var(--bad); border-color: #e6c3be; }
.btn.danger:hover { background: var(--bad-soft); }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn.icon-only { width: 44px; padding: 0; }
.link { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 600; cursor: pointer; font-size: 14px; text-decoration: none; }
.link:hover { text-decoration: underline; }

/* Login */
.login { min-height: 100vh; min-height: 100dvh;display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); background: var(--side); }
.login form { display: grid; align-content: center; gap: 18px; padding: 40px clamp(24px, 7vw, 96px); background: var(--bg); }
.login img.logo { width: 120px; filter: brightness(.68) saturate(1.1); margin-bottom: 12px; }
.login h1 { font: 400 34px/1.15 var(--display); }
.login .photo { background: url('/media/trabalhos/02.jpg') center / cover; }
.login .btn { width: 100%; }
.login .btn.google { background: #fff; color: var(--ink); border-color: var(--line-strong); gap: 12px; min-height: 52px; }
.login .btn.google:hover { background: var(--bg); }
.login .back { text-align: center; font-size: 14px; color: var(--muted); }

/* Estrutura */
.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100%; }
.side { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; padding: 20px 14px; position: sticky; top: 0; height: 100vh; }
.side .logo { width: 96px; margin: 4px 10px 26px; }
.side nav { display: grid; gap: 3px; }
.side nav a { display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 0 12px; border-radius: 8px; text-decoration: none; font-weight: 500; }
.side nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.side nav a.on { background: rgba(201, 162, 113, .16); color: #fff; }
.side nav a.on svg { color: var(--gold); }
.side .foot { margin-top: auto; display: grid; gap: 3px; }
.side .foot button, .side .foot a { display: flex; align-items: center; gap: 12px; min-height: 42px; padding: 0 12px; border-radius: 8px; background: none; border: 0; color: var(--side-ink); cursor: pointer; font-size: 15px; text-decoration: none; }
.side .foot button:hover, .side .foot a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.main { padding: clamp(18px, 3vw, 36px); min-width: 0; max-width: 1400px; width: 100%; }
.bottom-nav { display: none; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { font: 400 32px/1.15 var(--display); }
.page-head p { color: var(--muted); font-size: 15px; }
.page-head .tools { display: flex; gap: 8px; flex-wrap: wrap; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.search { position: relative; flex: 1 1 260px; max-width: 420px; }
.search svg { position: absolute; left: 12px; top: 12px; color: var(--muted); }
.search input[type=search] { padding-left: 40px; }
.check { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; font-size: 15px; cursor: pointer; }
.check input { width: 18px; height: 18px; min-height: 0; accent-color: var(--accent); }

.tabs { display: flex; gap: 4px; overflow-x: auto; margin-bottom: 16px; border-bottom: 1px solid var(--line); scrollbar-width: none; }
.tabs button { min-height: 44px; padding: 0 14px; background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; color: var(--muted); font-weight: 600; font-size: 15px; cursor: pointer; white-space: nowrap; }
.tabs button:hover { color: var(--ink); }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); }
.tabs small { font-size: 13px; font-weight: 500; margin-left: 4px; opacity: .75; }

/* Campos */
label.field { display: grid; gap: 5px; font-size: 14px; font-weight: 600; min-width: 0; align-content: start; }
label.field .hint { font-weight: 400; color: var(--muted); font-size: 13px; }
label.field .req { color: var(--bad); }
input:not([type=checkbox]), select, textarea { width: 100%; min-height: 44px; padding: 9px 12px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; font-size: 16px; font-weight: 400; }
textarea { resize: vertical; min-height: 84px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }

/* Cartões */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card > h2 { font-size: 16px; font-weight: 700; padding: 16px 18px 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; }

/* Tabela */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 13px; font-weight: 600; color: var(--muted); padding: 12px 16px; border-bottom: 1px solid var(--line); background: #fcfaf7; white-space: nowrap; }
.table td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { cursor: pointer; transition: background .12s; }
.table tbody tr:hover { background: #fbf8f3; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .strong { font-weight: 600; }
.table .sub { color: var(--muted); font-size: 14px; }
.table .actions-cell { width: 1%; white-space: nowrap; }

/* Selos de situação: sempre cor + ponto + texto */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: 13px; font-weight: 600; white-space: nowrap; background: var(--neutral-soft); color: var(--muted); }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

/* Estoque +/- */
.stepper { display: inline-flex; gap: 6px; }
.stepper button { width: 38px; height: 38px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface); display: grid; place-items: center; cursor: pointer; }
.stepper button:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.stepper svg.icon { width: 16px; height: 16px; }

/* Início */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { display: block; padding: 16px 18px; text-decoration: none; transition: border-color .15s, box-shadow .15s; }
.tile:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.tile .label { font-size: 14px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.tile .value { font: 500 32px/1.25 var(--text); letter-spacing: -0.01em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.tile .note { font-size: 14px; color: var(--muted); margin-top: 2px; min-height: 21px; }
.tile .note.alert { color: var(--bad); font-weight: 600; }
.home-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 12px; }
.home-grid .wide { grid-column: 1 / -1; }
.rows { padding: 6px 0 8px; }
.row { display: flex; align-items: center; gap: 12px; justify-content: space-between; padding: 10px 18px; text-decoration: none; width: 100%; background: none; border: 0; text-align: left; cursor: pointer; }
.row:hover { background: #fbf8f3; }
.row .t { font-weight: 600; }
.row .s { font-size: 14px; color: var(--muted); }
.row > div { min-width: 0; }
.row > div:last-child:not(:first-child) { text-align: right; flex: none; }
.empty-line { padding: 14px 18px 20px; color: var(--muted); font-size: 15px; }

.empty { display: grid; justify-items: center; gap: 10px; text-align: center; padding: clamp(40px, 8vw, 80px) 24px; background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--radius); }
.empty svg.icon { width: 34px; height: 34px; color: var(--gold); }
.empty h2 { font: 400 24px/1.2 var(--display); }
.empty p { color: var(--muted); max-width: 40ch; }

/* Quadro de projetos */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 10px; overflow-x: auto; padding-bottom: 12px; align-items: start; }
.column { background: #efeae2; border-radius: var(--radius); padding: 10px; min-height: 240px; transition: background .15s, box-shadow .15s; }
.column.over { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.column h2 { display: flex; justify-content: space-between; font-size: 14px; font-weight: 700; padding: 4px 6px 10px; }
.column h2 span { color: var(--muted); font-weight: 500; }
.pcard { display: block; width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin-bottom: 8px; cursor: pointer; }
.pcard:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.pcard.dragging { opacity: .45; }
.pcard .t { font-weight: 600; line-height: 1.3; }
.pcard .s { font-size: 14px; color: var(--muted); margin-bottom: 10px; }
.pcard .meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-top: 8px; }
.progress { height: 4px; border-radius: 4px; background: #ebe4da; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.column-empty { font-size: 14px; color: var(--muted); padding: 6px 6px 12px; }

/* Painéis laterais (dialog) */
dialog.drawer { border: 0; padding: 0; margin: 0 0 0 auto; width: min(560px, 100vw); max-width: none; height: 100dvh; max-height: none; background: var(--surface); color: var(--ink); box-shadow: -12px 0 40px rgba(30, 26, 22, .18); }
dialog.drawer[open] { display: flex; flex-direction: column; animation: slide .22s cubic-bezier(.2, .7, .2, 1); }
dialog.drawer.compact { width: min(420px, 100vw); }
dialog::backdrop { background: rgba(23, 19, 15, .45); }
@keyframes slide { from { transform: translateX(32px); } }
.d-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.d-head h2 { font: 600 20px/1.25 var(--text); min-width: 0; overflow-wrap: anywhere; }
.d-body { flex: 1; overflow-y: auto; padding: 20px; display: grid; gap: 18px; align-content: start; }
.d-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.d-foot .left { margin-right: auto; }
.close { width: 44px; height: 44px; display: grid; place-items: center; background: none; border: 0; border-radius: 8px; cursor: pointer; flex: none; }
.close:hover { background: var(--bg); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.with-add { display: flex; gap: 6px; }
.with-add select { flex: 1; min-width: 0; }
.error-box { background: var(--bad-soft); color: var(--bad); padding: 10px 14px; border-radius: 8px; font-size: 15px; font-weight: 500; }

/* Itens do pedido */
.items { display: grid; gap: 8px; }
.item { display: grid; grid-template-columns: minmax(0, 1fr) 66px 112px 38px; gap: 6px; align-items: center; }
.items-head { display: grid; grid-template-columns: minmax(0, 1fr) 66px 112px 38px; gap: 6px; font-size: 13px; color: var(--muted); }
.item button { width: 38px; height: 38px; background: none; border: 0; border-radius: 8px; color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.item button:hover { background: var(--bad-soft); color: var(--bad); }
.items-total { display: flex; justify-content: space-between; align-items: center; font-weight: 600; }
.items-total b { font: 600 22px/1 var(--text); font-variant-numeric: tabular-nums; }

/* Detalhes */
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.facts .full { grid-column: 1 / -1; }
.fact small { display: block; color: var(--muted); font-size: 13px; }
.fact div { overflow-wrap: anywhere; white-space: pre-line; }
.section-title { font-size: 14px; font-weight: 700; display: flex; justify-content: space-between; align-items: center; }
.list { border: 1px solid var(--line); border-radius: 8px; }
.list .row { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.list .row:last-child { border-bottom: 0; }
.quick { display: flex; gap: 8px; flex-wrap: wrap; }
.summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; background: var(--bg); padding: 12px 14px; border-radius: 8px; }
.summary small { display: block; font-size: 13px; color: var(--muted); }
.summary b { font-weight: 600; font-variant-numeric: tabular-nums; }

/* Etapas do projeto */
.stages { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; }
.stages button { background: none; border: 0; padding: 0 0 2px; cursor: pointer; display: grid; gap: 6px; font-size: 13px; color: var(--muted); text-align: left; min-height: 44px; align-content: start; }
.stages button i { display: block; height: 6px; border-radius: 3px; background: #e6dfd5; transition: background .2s; }
.stages button:hover i { background: var(--gold); }
.stages button.done i { background: var(--accent); }
.stages button.current { color: var(--ink); font-weight: 700; }

.timeline { display: grid; gap: 0; }
.timeline .ev { display: grid; grid-template-columns: 14px minmax(0, 1fr); gap: 10px; padding-bottom: 14px; position: relative; }
.timeline .ev::before { content: ''; width: 9px; height: 9px; margin-top: 7px; border-radius: 50%; background: var(--accent); }
.timeline .ev.etapa::before { background: var(--line-strong); }
.timeline .ev.etapa .tx { color: var(--muted); }
.timeline .ev small { color: var(--muted); font-size: 13px; }
.timeline .tx { white-space: pre-line; overflow-wrap: anywhere; }
.note-form { display: flex; gap: 8px; }
.note-form input { flex: 1; min-width: 0; }

/* Medição */
.m-back { display: inline-flex; align-items: center; gap: 4px; min-height: 40px; margin-bottom: 4px; color: var(--muted); font-size: 15px; text-decoration: none; }
.m-back:hover { color: var(--ink); }
.m-contact { margin-bottom: 12px; }
.m-contact .btn { white-space: normal; text-align: left; }
.m-status { position: sticky; top: 8px; z-index: 5; display: flex; justify-content: flex-end; height: 28px; margin-bottom: 8px; }
.m-status .badge { box-shadow: var(--shadow); background-color: var(--surface); }
.m-status .badge.ok { background: var(--ok-soft); }
.m-status .badge.warn { background: var(--warn-soft); }
.m-status .badge.bad { background: var(--bad-soft); }
.m-room { margin-bottom: 10px; scroll-margin-top: 40px; }
.m-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%; min-height: 64px; padding: 12px 16px; background: none; border: 0; text-align: left; cursor: pointer; }
.m-head b { display: block; font-size: 18px; font-weight: 600; }
.m-head small { display: block; color: var(--muted); font-size: 14px; }
.m-head svg.icon { color: var(--muted); transition: transform .2s; }
.m-room.open .m-head svg.icon { transform: rotate(180deg); }
.m-body { display: grid; gap: 20px; padding: 4px 16px 18px; border-top: 1px solid var(--line); padding-top: 16px; }
.m-value { position: relative; display: block; }
.m-value input { min-height: 54px; font-size: 22px; font-weight: 600; padding-right: 44px; font-variant-numeric: tabular-nums; }
.m-value em { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-style: normal; color: var(--muted); font-size: 15px; font-weight: 400; pointer-events: none; }
.m-sketch svg { display: block; width: 100%; max-width: 340px; margin: 8px auto 0; }
.m-sketch .wall { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1.5; }
.m-sketch .floor { stroke: var(--ink); stroke-width: 3; stroke-linecap: round; }
.m-sketch .item { fill: var(--surface); stroke: var(--accent); stroke-width: 1.5; }
.m-sketch text { font: 600 13px var(--text); fill: var(--ink); }
.m-sketch .num { font-size: 11px; fill: var(--accent); }
.m-hint { font-size: 14px; color: var(--muted); }
.m-wall-card { display: grid; gap: 12px; padding: 12px; background: #fbf8f3; border: 1px solid var(--line); border-radius: 8px; }
.m-wall-top { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.m-wall-top b { font: 400 20px/1.1 var(--display); color: var(--accent); white-space: nowrap; }
.m-wall-top button, .m-item-top button { width: 38px; height: 44px; display: grid; place-items: center; background: none; border: 0; border-radius: 8px; color: var(--muted); cursor: pointer; }
.m-wall-top button:hover, .m-item-top button:hover { background: var(--bad-soft); color: var(--bad); }
.m-size { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.m-items { display: grid; gap: 8px; }
.m-item { display: grid; gap: 8px; padding: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.m-item-top { display: grid; grid-template-columns: 26px minmax(0, 1fr) 38px; gap: 6px; align-items: center; }
.m-num { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid var(--accent); color: var(--accent); font-size: 13px; font-weight: 700; }
.m-item-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.m-mini { display: grid; gap: 3px; font-size: 13px; color: var(--muted); }
.m-mini input { font-size: 19px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.m-add-title { margin-bottom: -6px; }
.o-room { display: grid; gap: 10px; }
.o-room-name { font: 400 19px/1.2 var(--display); }
.o-wall { padding: 12px; border: 1px solid var(--line); border-radius: 8px; }
.o-wall .t { font-weight: 600; }
.o-items { margin: 10px 0 0; padding-left: 22px; font-size: 15px; display: grid; gap: 3px; }
.o-note { color: var(--muted); font-size: 15px; white-space: pre-line; }
.m-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.m-chips button { min-height: 40px; padding: 0 12px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 99px; font-size: 14px; font-weight: 500; cursor: pointer; }
.m-chips button:hover { border-color: var(--accent); color: var(--accent); }
.m-chips.big button { min-height: 46px; padding: 0 16px; font-size: 15px; }
.m-add { padding-bottom: 16px; }
.m-add .m-chips { padding: 0 16px; }
@media (min-width: 801px) {
  .m-item-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  #m-rooms, .m-add { max-width: 860px; }
}

/* Orçamento: editor */
.b-editor { display: grid; gap: 14px; max-width: 960px; }
.b-card { padding: 16px 18px 18px; display: grid; gap: 14px; }
.b-card > h2 { padding: 0; font-size: 17px; }
.b-card > h2 b { font-variant-numeric: tabular-nums; }
.b-lines { display: grid; gap: 10px; }
.b-line { display: grid; grid-template-columns: minmax(0, 1fr) 76px 84px 118px 112px 38px; grid-template-areas: "desc qty unit price total rm" "note note note note note ."; gap: 6px 8px; align-items: end; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.b-line:last-child { border-bottom: 0; padding-bottom: 0; }
.b-line > label { display: grid; gap: 3px; min-width: 0; }
.b-line > label:nth-child(1) { grid-area: desc; }
.b-line > label:nth-child(2) { grid-area: qty; }
.b-line > label:nth-child(3) { grid-area: unit; }
.b-line > label:nth-child(4) { grid-area: price; }
.b-line-total { grid-area: total; display: grid; gap: 3px; text-align: right; }
.b-line-total b { min-height: 44px; display: flex; align-items: center; justify-content: flex-end; font-variant-numeric: tabular-nums; font-weight: 600; }
.b-line .b-note { grid-area: note; }
.b-line .b-note input { min-height: 38px; font-size: 15px; }
.b-label { font-size: 13px; color: var(--muted); }
.b-line:not(:first-child) .b-label { display: none; }
.b-line:not(:first-child) .b-note .b-label { display: none; }
.b-remove { grid-area: rm; width: 38px; height: 44px; display: grid; place-items: center; background: none; border: 0; border-radius: 8px; color: var(--muted); cursor: pointer; }
.b-remove:hover { background: var(--bad-soft); color: var(--bad); }
.b-bar { position: sticky; bottom: 12px; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 16px; background: var(--ink); color: #fff; border-radius: var(--radius); box-shadow: var(--shadow); }
.b-bar small { display: block; font-size: 13px; color: var(--side-ink); }
.b-bar b { font: 600 24px/1.1 var(--text); font-variant-numeric: tabular-nums; }
.b-bar .btn.primary { background: var(--gold); border-color: var(--gold); color: var(--ink); }
.b-bar .btn.primary:hover { background: #d8b588; }

/* Orçamento: ações e documento */
.b-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.b-actions .btn.danger { margin-left: auto; }
.btn.approve { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.approve:hover { background: #1c5a3c; }
.b-hint { color: var(--muted); font-size: 14px; margin-bottom: 16px; }
.b-status select { min-height: 40px; width: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.sheet-wrap { overflow-x: auto; padding-bottom: 8px; }
.sheet { --s-brown: #3a2616; --s-orange: #e2a347; --s-cream: #fdf1df; --s-band: #f6f1ea; width: 100%; max-width: 794px; min-width: 0; background: #fff; color: #2a211a; padding: 44px 44px 40px; border: 1px solid var(--line); border-radius: 4px; box-shadow: var(--shadow); font: 400 13px/1.45 var(--text); }
.s-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; align-items: center; padding-bottom: 14px; border-bottom: 3px solid var(--s-orange); }
.s-logo { width: 72px; height: 50px; object-fit: cover; border-radius: 2px; background: #111; }
.s-company b { display: block; font-size: 17px; font-weight: 700; color: var(--s-brown); }
.s-company span, .s-number span { display: block; font-size: 12px; color: #7a6f64; }
.s-number { text-align: right; }
.s-number small, .s-parties small { display: block; font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #b36b16; }
.s-number b { display: block; font-size: 20px; font-weight: 700; color: var(--s-brown); }
.s-parties { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; padding: 14px 0 20px; }
.s-parties b { display: block; font-size: 15px; font-weight: 700; color: var(--s-brown); }
.s-parties span { display: block; font-size: 12px; color: #7a6f64; }
.s-sec { margin-bottom: 14px; }
.s-sec-head { display: flex; justify-content: space-between; padding: 7px 10px; background: var(--s-band); font-size: 11.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--s-brown); }
.s-line { display: flex; justify-content: space-between; gap: 16px; padding: 8px 10px; border-bottom: 1px solid #ece5dc; break-inside: avoid; }
.s-line > div { min-width: 0; }
.s-line b { font-weight: 700; color: var(--s-brown); }
.s-line > b { white-space: nowrap; font-variant-numeric: tabular-nums; }
.s-line small { display: block; font-size: 11px; color: #8a8076; }
.s-total { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; margin: 6px 0 12px; background: var(--s-brown); color: #fff; border-radius: 6px; break-inside: avoid; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.s-total span { font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.s-total b { font-size: 21px; font-weight: 700; font-variant-numeric: tabular-nums; }
.s-terms { margin: 0; padding: 0 2px; list-style: none; font-size: 12px; display: grid; gap: 2px; }
.s-terms li::before { content: '• '; }
.s-notes { font-size: 12px; margin-top: 8px; padding: 0 2px; white-space: pre-line; }
.s-approve { margin-top: 22px; padding: 11px; text-align: center; background: var(--s-cream); border-radius: 6px; font-size: 12.5px; font-weight: 700; color: var(--s-brown); break-inside: avoid; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.s-sec-head, .s-line { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
/* Cópia fora da tela usada para gerar o PDF em A4 (186 mm úteis). */
.pdf-holder { position: fixed; left: -10000px; top: 0; width: 703px; }
/* O html2pdf centraliza a folha na janela; no canto esquerdo a captura não depende da largura da tela. */
.html2pdf__container { margin: 0 !important; }
.pdf-holder .sheet, .sheet.pdf { max-width: none; width: 703px; min-width: 703px; padding: 0; border: 0; border-radius: 0; box-shadow: none; }

@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; }
  .side, .bottom-nav, .no-print, #toasts, dialog { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; max-width: none; }
  .sheet-wrap { overflow: visible; padding: 0; }
  .sheet { max-width: none; padding: 0; border: 0; box-shadow: none; }
}

/* Financeiro */
.fin-tiles .value { font-size: 26px; }
.value.neg, .neg, b.neg { color: var(--bad); }
b.in, .in { color: var(--ok); }
b.out, .out { color: var(--bad); }
.fin-right { display: grid; justify-items: end; gap: 4px; }
.fin-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.fin-box { padding: 16px 18px; display: grid; gap: 4px; align-content: start; }
.fin-box small { color: var(--muted); font-size: 14px; }
.fin-box b { font: 600 25px/1.2 var(--text); font-variant-numeric: tabular-nums; }
.fin-box span { font-size: 14px; color: var(--muted); }
.fin-box .link { justify-self: start; }
.fin-box .progress { margin: 4px 0 2px; }
.progress.over i { background: var(--bad); }
.fin-budget, .fin-suggest { padding: 14px 18px; margin-bottom: 12px; display: grid; gap: 8px; }
.fin-budget > div:first-child, .fin-suggest > div { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.fin-budget span, .fin-suggest span { color: var(--muted); font-size: 15px; }
.fin-suggest { grid-template-columns: minmax(0, 1fr) auto; align-items: center; background: var(--accent-soft); border-color: #e8d8c2; }
.fin-suggest > div { display: grid; gap: 2px; }
.alert-text { color: var(--bad); font-size: 14px; font-weight: 600; }
.fin-table b.in, .fin-table b.out { font-weight: 600; }

/* Menu "Mais" (celular) */
.more-nav { display: grid; gap: 4px; }
.more-nav a { display: flex; align-items: center; gap: 12px; min-height: 50px; padding: 0 12px; border-radius: 8px; text-decoration: none; font-weight: 600; }
.more-nav a:hover { background: var(--bg); }
.more-nav a.on { background: var(--accent-soft); color: var(--accent); }

/* Agenda */
.ag-day { margin-bottom: 18px; }
.ag-day > h2 { font-size: 16px; font-weight: 700; margin: 0 0 8px; display: flex; gap: 8px; align-items: baseline; }
.ag-day > h2 small { font-weight: 400; color: var(--muted); font-size: 14px; }
.ag-day > h2.today { color: var(--accent); }
.ag-day > h2.late { color: var(--bad); }
.ag { display: grid; grid-template-columns: 70px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 16px; margin-bottom: 8px; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--gold); border-radius: var(--radius); cursor: pointer; }
.ag:hover { border-color: var(--line-strong); border-left-color: var(--accent); }
.ag.late { border-left-color: var(--bad); }
.ag.done { opacity: .62; border-left-color: var(--line-strong); }
.ag.done .ag-title b { text-decoration: line-through; }
.ag-time { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 15px; }
.ag-main { min-width: 0; display: grid; gap: 3px; }
.ag-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ag-sub { font-size: 14px; color: var(--muted); }
a.ag-place { display: inline-flex; align-items: flex-start; gap: 4px; text-decoration: none; color: var(--info); }
a.ag-place .icon { width: 15px; height: 15px; flex: none; margin-top: 2px; }
.ag-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.btn.approve-soft { border-color: #bcd9c8; color: var(--ok); }
.btn.approve-soft:hover { background: var(--ok-soft); }
.ag-home { padding: 8px 18px 14px; }
.ag-home-day { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 8px 0 4px; }
.ag-home-day + .ag + .ag-home-day { margin-top: 10px; }
.ag-home .ag { margin-bottom: 4px; }

/* Sem internet */
.offline-bar { position: fixed; left: 50%; transform: translateX(-50%); bottom: 16px; z-index: 30; display: flex; align-items: center; gap: 10px; max-width: min(640px, calc(100vw - 32px)); padding: 10px 16px; background: var(--warn); color: #fff; border-radius: 10px; font-size: 14px; font-weight: 600; box-shadow: var(--shadow); }
.offline-bar[hidden] { display: none; }
.offline-bar .icon { flex: none; }
.warn-text { color: var(--warn); display: flex; gap: 8px; align-items: flex-start; font-weight: 600; }
.warn-text .icon { flex: none; margin-top: 2px; }

/* Contrato e recibo */
.s-title { font: 700 16px/1.3 var(--text); text-align: center; text-transform: uppercase; letter-spacing: .04em; color: var(--s-brown); margin: 18px 0 2px; }
.contract .s-parties { padding-top: 12px; }
.s-clause { margin-bottom: 10px; break-inside: avoid; }
.s-clause h3 { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: #b36b16; margin: 0 0 2px; }
.s-clause p { margin: 0; }
.s-clause b, .s-receipt-text b { color: var(--s-brown); }
.s-items { margin-top: 16px; }
.s-place { margin: 22px 0 0; text-align: right; break-inside: avoid; }
.s-signs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 34px 40px; margin-top: 46px; break-inside: avoid; }
.s-signs.one { grid-template-columns: minmax(0, 300px); justify-content: center; }
.s-signs > div { display: grid; text-align: center; font-size: 12px; }
.s-signs i { display: block; border-top: 1px solid #5a4a3c; margin-bottom: 6px; }
.s-signs b { color: var(--s-brown); font-size: 13px; }
.s-signs span { color: #7a6f64; }
.s-receipt-box { display: flex; justify-content: space-between; align-items: center; margin: 18px 0; padding: 14px 18px; background: var(--s-cream); border: 1px solid #f0dcbc; border-radius: 6px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.s-receipt-box span { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: #b36b16; }
.s-receipt-box b { font-size: 24px; font-weight: 700; color: var(--s-brown); font-variant-numeric: tabular-nums; }
.s-receipt-text { font-size: 14px; line-height: 1.7; margin: 0 0 12px; }
.s-receipt-sum { border-top: 1px solid #ece5dc; padding-bottom: 6px; }

/* Avisos */
#toasts { position: fixed; inset: auto 16px 16px auto; margin: 0; padding: 0; border: 0; background: none; overflow: visible; gap: 8px; pointer-events: none; }
#toasts:popover-open { display: grid; }
.toast { background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 8px; font-size: 15px; box-shadow: var(--shadow); max-width: 360px; animation: pop .2s ease; }
.toast.err { background: var(--bad); }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }

.loading { padding: 48px; text-align: center; color: var(--muted); }

@media (max-width: 1100px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .home-grid { grid-template-columns: minmax(0, 1fr); }
  .fin-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 800px) {
  .shell { display: block; }
  .side { display: none; }
  .main { padding: 16px 16px 92px; }
  .page-head h1 { font-size: 27px; }
  .login { grid-template-columns: minmax(0, 1fr); }
  .login .photo { display: none; }

  .bottom-nav { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--side); padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); }
  .bottom-nav a, .bottom-nav button { display: grid; justify-items: center; gap: 2px; padding: 8px 0 6px; font-size: 11.5px; color: var(--side-ink); text-decoration: none; border-radius: 8px; background: none; border: 0; cursor: pointer; min-width: 0; }
  .bottom-nav span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .bottom-nav a.on, .bottom-nav button.on { color: #fff; background: rgba(201, 162, 113, .16); }
  .bottom-nav a.on svg, .bottom-nav button.on svg { color: var(--gold); }

  .b-line { grid-template-columns: repeat(3, minmax(0, 1fr)) 38px; grid-template-areas: "desc desc desc rm" "qty unit price price" "note note total total"; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: #fbf8f3; }
  .b-line:last-child { padding-bottom: 12px; border-bottom: 1px solid var(--line); }
  .b-line:not(:first-child) .b-label, .b-line:not(:first-child) .b-note .b-label { display: block; }
  .b-line-total b { min-height: 38px; font-size: 17px; }
  .b-bar { bottom: 84px; flex-wrap: nowrap; padding: 10px 12px; }
  .b-bar b { font-size: 20px; }
  .b-actions .btn.danger { margin-left: 0; }
  /* Só a folha da tela se adapta ao celular; a cópia do PDF continua em A4. */
  .sheet-wrap .sheet { padding: 22px 16px; font-size: 12.5px; }
  .sheet-wrap .s-head { grid-template-columns: auto minmax(0, 1fr); }
  .sheet-wrap .s-number { grid-column: 1 / -1; text-align: left; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
  .sheet-wrap .s-parties { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .fin-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .fin-box { padding: 12px 14px; }
  .fin-box b, .fin-tiles .value { font-size: 19px; }
  .fin-tiles { gap: 8px; }
  .fin-tiles .tile { padding: 12px 14px; }
  .fin-rows .row { display: grid; gap: 6px; }
  .fin-rows .row > div:last-child:not(:first-child) { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; text-align: left; justify-items: start; }
  .fin-suggest { grid-template-columns: minmax(0, 1fr); }
  .m-account { display: inline-flex !important; }
  .desktop-only { display: none; }

  /* Tabelas viram cartões */
  .table-wrap { background: none; border: 0; }
  table.table, .table tbody, .table tr, .table td { display: block; }
  .table thead { display: none; }
  .table tbody tr { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 8px; }
  .table tbody tr:hover { background: var(--surface); }
  .table td { border: 0; padding: 3px 0; display: flex; justify-content: space-between; gap: 16px; align-items: center; text-align: right; min-height: 28px; }
  .table td.head-cell { display: block; text-align: left; padding-bottom: 6px; }
  .table td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: 14px; text-align: left; font-weight: 400; }
  .table td:empty { display: none; }
  .table .actions-cell { width: auto; justify-content: flex-end; padding-top: 6px; }

  .board { grid-auto-columns: 82vw; margin: 0 -16px; padding: 0 16px 12px; scroll-snap-type: x proximity; scroll-padding: 16px; }
  .column { scroll-snap-align: start; }
  dialog.drawer, dialog.drawer.compact { width: 100vw; }
  .item { grid-template-columns: minmax(0, 1fr) 58px 96px 34px; }
  .items-head { grid-template-columns: minmax(0, 1fr) 58px 96px 34px; }
  .stages button { font-size: 11.5px; }
}

@media (max-width: 460px) {
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid > * { grid-column: 1 / -1; }
}

.m-account { display: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media (max-width: 800px) {
  .ag { grid-template-columns: 52px minmax(0, 1fr); padding: 12px; gap: 6px 10px; align-items: start; }
  .ag-time { font-size: 14px; padding-top: 2px; }
  .ag-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .ag-home { padding: 6px 12px 12px; }
  .offline-bar { bottom: 84px; }
  .sheet-wrap .s-signs { grid-template-columns: minmax(0, 1fr); gap: 34px; }
}
@media (max-width: 420px) {
  .ag-actions .btn:not([data-done]) span { display: none; }
}
