:root {
  --bg: #e3e5e9;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --ink: #161b22;
  --ink-2: #4b5563;
  --ink-3: #8a93a1;
  --line: #e3e6eb;
  --accent: #e8590c;
  --accent-ink: #ffffff;
  --accent-soft: #fff1e8;
  --bar: #474fb5;
  --bar-2: #3a4199;
  --bar-ink: #ffffff;
  --add: #f4a917;
  --ok: #15803d; --ok-soft: #e7f6ec;
  --warn: #b45309; --warn-soft: #fef3e2;
  --info: #1d4ed8; --info-soft: #e8efff;
  --bad: #b91c1c; --bad-soft: #fdecec;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --gutter: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1318; --surface: #171c23; --surface-2: #1d232b; --ink: #eef1f5; --ink-2: #b4bcc8; --ink-3: #7d8696;
    --line: #2a313b; --accent: #ff7a2f; --accent-soft: #3a2316; --bar: #2b3077; --bar-2: #222660;
    --ok: #4ade80; --ok-soft: #12301d; --warn: #fbbf24; --warn-soft: #34270d; --info: #7aa2ff; --info-soft: #17223d;
    --bad: #f87171; --bad-soft: #3a1717; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1318; --surface: #171c23; --surface-2: #1d232b; --ink: #eef1f5; --ink-2: #b4bcc8; --ink-3: #7d8696;
  --line: #2a313b; --accent: #ff7a2f; --accent-soft: #3a2316; --bar: #2b3077; --bar-2: #222660;
  --ok: #4ade80; --ok-soft: #12301d; --warn: #fbbf24; --warn-soft: #34270d; --info: #7aa2ff; --info-soft: #17223d;
  --bad: #f87171; --bad-soft: #3a1717; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
a { color: var(--accent); }

/* ---------- barra superior ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px;
  background: var(--bar); color: var(--bar-ink); padding: 10px var(--gutter);
  padding-top: max(10px, env(safe-area-inset-top)); min-height: 56px;
}
.topbar-title { min-width: 0; flex: 1; }
.brand { font-weight: 700; display: flex; align-items: center; gap: 8px; font-size: 16px; }
.brand-mark { background: var(--accent); color: #fff; font-size: 11px; letter-spacing: .06em; padding: 3px 6px; border-radius: 6px; }
.crumb { font-size: 12px; color: #aab3c0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { background: transparent; border: 0; color: inherit; padding: 6px; border-radius: 10px; cursor: pointer; display: grid; place-items: center; }
.icon-btn:hover { background: rgba(255,255,255,.08); }
.topnav { display: none; gap: 4px; }
.topnav a, .bottomnav a { text-decoration: none; color: inherit; }
.topnav a { padding: 8px 12px; border-radius: 10px; color: #c9d1dc; font-weight: 500; }
.topnav a.on { background: rgba(255,255,255,.1); color: #fff; }

.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: flex;
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 6px; font-size: 11px; color: var(--ink-3); font-weight: 500; }
.bottomnav a.on { color: var(--accent); }
.bottomnav svg { width: 22px; height: 22px; }

@media (min-width: 820px) {
  .topnav { display: flex; }
  .bottomnav { display: none !important; }
}

/* ---------- layout ---------- */
.app { max-width: 980px; margin: 0 auto; padding: 16px var(--gutter) 120px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 4px 0 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; margin: 0; line-height: 1.2; }
.page-head p { margin: 2px 0 0; color: var(--ink-2); font-size: 13px; }
.stack { display: grid; gap: 12px; }
.grid2 { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid2 { grid-template-columns: 1fr 1fr; } }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 16px; }
.section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.section > header { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.section > header h2 { font-size: 15px; margin: 0; flex: 1; }
.section > header .count { font-size: 12px; color: var(--ink-3); font-weight: 600; }
.section .body { padding: 14px 16px; }
.sec-ico { width: 30px; height: 30px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: none; }
.sec-ico svg { width: 17px; height: 17px; }

/* ---------- obras ---------- */
.obra-card { display: block; text-decoration: none; color: inherit; padding: 16px; transition: border-color .15s; }
.obra-card:hover { border-color: var(--accent); }
.obra-card h3 { margin: 0 0 2px; font-size: 16px; }
.obra-card .meta { color: var(--ink-2); font-size: 13px; }
.obra-stats { display: flex; gap: 16px; margin-top: 12px; flex-wrap: wrap; }
.stat { min-width: 0; }
.stat b { display: block; font-size: 18px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat span { font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 640px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.kpi b { font-size: 22px; display: block; font-variant-numeric: tabular-nums; }
.kpi span { font-size: 12px; color: var(--ink-2); }

/* ---------- lista de RDOs ---------- */
.rdo-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; text-decoration: none; color: inherit; border-top: 1px solid var(--line); }
.rdo-row:first-child { border-top: 0; }
.rdo-row:hover { background: var(--surface-2); }
.rdo-date { width: 48px; text-align: center; flex: none; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); padding: 4px 0; }
.rdo-date b { display: block; font-size: 18px; line-height: 1.1; }
.rdo-date span { font-size: 10px; text-transform: uppercase; color: var(--ink-3); font-weight: 600; }
.rdo-info { flex: 1; min-width: 0; }
.rdo-info .t { font-weight: 600; }
.rdo-info .s { font-size: 12px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.preenchendo { background: var(--info-soft); color: var(--info); }
.pill.revisar { background: var(--warn-soft); color: var(--warn); }
.pill.aprovado { background: var(--ok-soft); color: var(--ok); }
.pill.ativa { background: var(--ok-soft); color: var(--ok); }
.pill.paralisada { background: var(--warn-soft); color: var(--warn); }
.pill.concluida { background: var(--surface-2); color: var(--ink-3); }

/* ---------- formulários ---------- */
label.f { display: grid; gap: 4px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.input, select.input, textarea.input {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font-size: 16px; font-weight: 400;
}
textarea.input { min-height: 88px; resize: vertical; }
.input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.input:disabled { background: var(--surface-2); color: var(--ink-2); }
.row { display: flex; gap: 8px; align-items: center; }
.row > .grow { flex: 1; min-width: 0; }
.fields { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .fields.c2 { grid-template-columns: 1fr 1fr; } .fields.c3 { grid-template-columns: repeat(3, 1fr); } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px;
  border-radius: 11px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.danger { color: var(--bad); }
.btn.sm { min-height: 34px; padding: 0 10px; font-size: 13px; border-radius: 9px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn svg { width: 18px; height: 18px; }
.add-btn { width: 100%; border-style: dashed; color: var(--accent); margin-top: 8px; }

/* itens repetidos (mão de obra, equipamentos...) */
.items { display: grid; gap: 8px; }
.item { display: grid; gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.item .row .qtd { width: 84px; flex: none; text-align: center; }
.x-btn { width: 40px; height: 40px; flex: none; border: 0; background: transparent; color: var(--ink-3); border-radius: 10px; cursor: pointer; display: grid; place-items: center; }
.x-btn:hover { background: var(--bad-soft); color: var(--bad); }
.stepper { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); flex: none; }
.stepper button { width: 38px; height: 42px; border: 0; background: transparent; font-size: 20px; cursor: pointer; color: var(--ink-2); }
.stepper input { width: 44px; border: 0; text-align: center; background: transparent; font-size: 16px; font-weight: 600; padding: 0; height: 42px; }
.stepper input:focus { outline: none; }

/* segmentado (clima, condição, status) */
.seg { display: flex; border: 1px solid var(--line); border-radius: 11px; padding: 3px; background: var(--surface-2); gap: 3px; }
.seg button { flex: 1; border: 0; background: transparent; border-radius: 8px; padding: 8px 4px; font-size: 13px; font-weight: 600; color: var(--ink-2); cursor: pointer; min-height: 38px; display: inline-flex; gap: 5px; align-items: center; justify-content: center; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.seg button.on.bad { color: var(--bad); }
.seg button.on.good { color: var(--ok); }
.turno { display: grid; gap: 8px; }
.turno h4 { margin: 0; font-size: 13px; color: var(--ink-2); }

.range-row { display: flex; align-items: center; gap: 10px; }
.range-row input[type=range] { flex: 1; accent-color: var(--accent); }
.range-row output { width: 44px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

/* fotos */
.photos { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 640px) { .photos { grid-template-columns: repeat(3, 1fr); } }
.photo { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface-2); display: flex; flex-direction: column; }
.photo .img { aspect-ratio: 4/3; background: var(--line) center/cover no-repeat; position: relative; cursor: zoom-in; }
.photo .img.loading::after { content: "carregando…"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 12px; color: var(--ink-3); }
.photo input { border: 0; border-top: 1px solid var(--line); border-radius: 0; min-height: 38px; font-size: 13px; padding: 6px 8px; background: var(--surface); }
.photo .del { position: absolute; top: 6px; right: 6px; width: 30px; height: 30px; border-radius: 50%; border: 0; background: rgba(0,0,0,.55); color: #fff; cursor: pointer; display: grid; place-items: center; }
.photo-add { border: 2px dashed var(--line); border-radius: 12px; aspect-ratio: 4/3; display: grid; place-items: center; text-align: center; color: var(--accent); font-weight: 600; font-size: 13px; cursor: pointer; background: var(--surface); }
.photo-add svg { width: 28px; height: 28px; display: block; margin: 0 auto 4px; }
.progress { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: 8px; }
.progress i { display: block; height: 100%; background: var(--accent); transition: width .2s; }

/* barra de ações fixa do RDO */
.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; background: var(--surface);
  border-top: 1px solid var(--line); padding: 10px var(--gutter); padding-bottom: max(10px, env(safe-area-inset-bottom));
  display: flex; gap: 8px; justify-content: center;
}
.actionbar .inner { width: 100%; max-width: 980px; display: flex; gap: 8px; align-items: center; }
.actionbar .btn { flex: 1; }
.actionbar .btn.more { flex: none; width: 48px; padding: 0; }
.dirty-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); display: inline-block; }
body.has-actionbar .bottomnav { display: none !important; }

/* status do RDO no topo */
.rdo-head { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; justify-content: space-between; }
.rdo-head h1 { font-size: 20px; margin: 0; }
.rdo-sub { color: var(--ink-2); font-size: 13px; }
.notice { padding: 10px 14px; border-radius: 12px; font-size: 13px; display: flex; gap: 8px; align-items: flex-start; }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.info { background: var(--info-soft); color: var(--info); }
.notice.ok { background: var(--ok-soft); color: var(--ok); }

.empty { text-align: center; padding: 36px 16px; color: var(--ink-2); }
.empty svg { width: 44px; height: 44px; color: var(--ink-3); margin-bottom: 6px; }
.muted { color: var(--ink-3); font-size: 13px; }
.spin { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* login */
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 24px var(--gutter); }
.login { width: 100%; max-width: 380px; }
.login .logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; margin-bottom: 18px; }
.login .logo .brand-mark { font-size: 13px; padding: 5px 8px; }

/* toast + modal */
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
  background: #1c2430; color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 60;
  transition: .2s; max-width: calc(100vw - 32px); box-shadow: 0 8px 24px rgba(0,0,0,.2);
}
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.err { background: #b91c1c; }
.modal-back { position: fixed; inset: 0; background: rgba(10,14,20,.55); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modal { background: var(--surface); width: 100%; max-width: 560px; max-height: 92dvh; overflow: auto; border-radius: 18px 18px 0 0; padding: 18px var(--gutter) max(18px, env(safe-area-inset-bottom)); }
@media (min-width: 640px) { .modal-back { align-items: center; } .modal { border-radius: 18px; padding: 22px; } }
.modal h2 { margin: 0 0 14px; font-size: 18px; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.menu-list { display: grid; gap: 4px; }
.menu-list button { text-align: left; justify-content: flex-start; border: 0; background: transparent; }
.menu-list button:hover { background: var(--surface-2); }
.viewer { position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 70; display: grid; place-items: center; padding: 16px; }
.viewer img { max-width: 100%; max-height: 86dvh; border-radius: 8px; }
.viewer p { color: #fff; text-align: center; margin: 10px 0 0; }

.check-list { display: grid; gap: 6px; max-height: 220px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.check-list label { display: flex; gap: 8px; align-items: center; font-size: 14px; }
.user-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); }
.user-row:first-child { border-top: 0; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; flex: none; }

/* opções prontas (toque) */
.pick-hint { margin: 0 0 6px; font-size: 12px; font-weight: 600; color: var(--ink-3); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 6px 12px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-size: 13px; font-weight: 500; cursor: pointer; text-align: left; line-height: 1.25;
}
.chip:hover { border-color: var(--accent); }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.chip b { background: var(--accent); color: #fff; border-radius: 999px; min-width: 20px; height: 20px; padding: 0 6px; font-size: 11px; display: inline-grid; place-items: center; }
.subpanel { border: 1px solid var(--accent); background: var(--accent-soft); border-radius: 12px; padding: 10px 12px; margin: -4px 0 12px; }
.subpanel .chips { margin-bottom: 0; }
.subpanel .chip { background: var(--surface); }
.subpanel .chip.on { background: var(--accent); color: #fff; }
.subhead { display: flex; align-items: center; justify-content: space-between; font-size: 13px; margin-bottom: 8px; color: var(--ink); }
.subhead .x-btn { width: 32px; height: 32px; }
.item.flash { animation: flash 1s ease-out; }
@keyframes flash { from { background: var(--accent-soft); border-color: var(--accent); } }

/* permissões do perfil */
.perm-list { display: grid; gap: 4px; border: 1px solid var(--line); border-radius: 12px; padding: 6px; }
.perm { display: flex; gap: 10px; align-items: flex-start; padding: 8px; border-radius: 9px; cursor: pointer; font-size: 14px; }
.perm:hover { background: var(--surface-2); }
.perm input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }
.perm small { display: block; color: var(--ink-3); font-size: 12px; }

/* =================== layout estilo painel (barra azul) =================== */
.topbar { background: var(--bar); color: var(--bar-ink); gap: 0; padding: 0 0 0 var(--gutter); min-height: 64px; box-shadow: 0 2px 6px rgba(0,0,0,.15); }
.brand { color: #fff; text-decoration: none; font-weight: 800; font-size: 16px; letter-spacing: .01em; margin-right: 18px; white-space: nowrap; }
.brand-short { display: none; }
.topnav { display: none; align-self: stretch; gap: 0; }
.topnav a, .nav-dd { display: flex; align-items: center; gap: 4px; padding: 0 18px; color: #e6e8ff; font-weight: 500; font-size: 16px; text-decoration: none; border-radius: 0; background: transparent; border: 0; cursor: pointer; height: 100%; }
.topnav a:hover, .nav-dd:hover { background: rgba(255,255,255,.08); }
.topnav a.on, .nav-dd.on { background: var(--bar-2); color: #fff; }
.topnav .dd { display: flex; }
.top-right { margin-left: auto; display: flex; align-items: stretch; align-self: stretch; }
.top-right > .dd { display: flex; align-items: center; }
.dd { position: relative; }
.dd-menu { position: absolute; top: calc(100% + 4px); left: 0; min-width: 210px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.18); padding: 6px; z-index: 40; display: grid; }
.topnav .dd-menu { top: 100%; }
.dd-menu.right { left: auto; right: 8px; }
.dd-menu a, .dd-menu button { display: block; text-align: left; padding: 10px 12px; border-radius: 8px; color: var(--ink); text-decoration: none; background: none; border: 0; cursor: pointer; font-size: 14px; }
.dd-menu a:hover, .dd-menu button:hover { background: var(--surface-2); }
.dd-head { padding: 8px 12px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; display: grid; }
.dd-head small { color: var(--ink-3); }
.add-top { display: inline-flex; align-items: center; gap: 6px; background: var(--add); color: #fff; border: 0; border-radius: 4px; height: 42px; padding: 0 16px; font-weight: 700; letter-spacing: .05em; cursor: pointer; margin-right: 14px; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.add-top:hover { filter: brightness(1.05); }
.user-chip { display: flex; align-items: center; gap: 10px; height: 100%; background: var(--bar-2); color: #fff; border: 0; padding: 0 14px; cursor: pointer; max-width: 260px; }
.user-chip .avatar { width: 36px; height: 36px; background: rgba(255,255,255,.25); color: #fff; font-size: 13px; }
.uc-text { display: grid; text-align: left; min-width: 0; }
.uc-text b, .uc-text small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.uc-text b { font-size: 15px; font-weight: 600; }
.uc-text small { font-size: 12px; opacity: .8; }

.subbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.subbar-in { max-width: 1240px; margin: 0 auto; padding: 10px var(--gutter); display: flex; align-items: center; gap: 12px; flex-wrap: wrap; min-height: 64px; }
.subbar h1 { font-size: 22px; font-weight: 500; margin: 0; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back-btn { width: 42px; height: 42px; border: 0; border-radius: 6px; background: var(--surface-2); color: var(--info); cursor: pointer; display: grid; place-items: center; flex: none; }
.back-btn:hover { background: var(--line); }
.sub-tools { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.input.sm { min-height: 40px; padding: 6px 10px; font-size: 14px; border-radius: 4px; width: auto; }
.sub-tools input[type=search] { width: 280px; max-width: 100%; }
.app { max-width: 1240px; padding-top: 24px; }

@media (min-width: 900px) { .topnav { display: flex; } .bottomnav { display: none !important; } }
@media (max-width: 899px) {
  .brand-full { display: none; } .brand-short { display: inline; }
  .add-top span, .uc-text, .user-chip .caret { display: none; }
  .add-top { padding: 0 11px; margin-right: 8px; }
  .user-chip { padding: 0 12px; }
  .subbar h1 { font-size: 19px; flex-basis: calc(100% - 60px); }
  .sub-tools { width: 100%; }
  .sub-tools > * { flex: 1; }
  .sub-tools input[type=search] { width: auto; }
}

/* cartões de obra */
.ogrid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.ocard { background: var(--surface); border-radius: 4px; box-shadow: 0 1px 3px rgba(0,0,0,.12); text-decoration: none; color: var(--ink); overflow: hidden; display: flex; flex-direction: column; transition: box-shadow .15s, transform .15s; }
.ocard:hover { box-shadow: 0 6px 18px rgba(0,0,0,.16); transform: translateY(-1px); }
.ocover { position: relative; aspect-ratio: 300 / 175; background: #f3f3f4 center/cover no-repeat; display: grid; place-items: center; color: #b4b6ba; }
.ocover.has-img .ph { display: none; }
.ocover.big { border-radius: 4px; aspect-ratio: 236 / 150; }
.obadge { position: absolute; top: 18px; left: 18px; font-size: 12.5px; font-weight: 700; color: #fff; background: #3b82f6; padding: 2px 6px; border-radius: 3px; }
.obadge.paralisada { background: #f0a500; }
.obadge.concluida { background: #6b7280; }
.obadge.inline { position: static; display: inline-block; }
.obody { padding: 14px 18px 26px; }
.ometa { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--ink-3); }
.ometa-warn { color: var(--warn); font-weight: 600; }
.oname { font-size: 17px; margin-top: 6px; text-transform: uppercase; }
.osub { font-size: 13px; color: var(--ink-2); margin-top: 2px; }

/* página da obra */
.olayout { display: grid; grid-template-columns: 1fr; gap: 20px; }
.oside { background: var(--surface); border-radius: 4px; box-shadow: 0 1px 3px rgba(0,0,0,.1); padding: 18px 0 10px; align-self: start; }
.oside .ocover.big { margin: 0 18px 14px; }
.side-nav { display: grid; }
.side-nav.sep { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 10px; }
.side-nav a { display: flex; align-items: center; gap: 10px; padding: 10px 20px; color: var(--ink); text-decoration: none; font-size: 15px; }
.side-nav a:hover { background: var(--surface-2); }
.side-nav a.on { background: var(--info-soft); color: #2f6fe0; }
.side-nav .cnt { margin-left: auto; background: var(--line); color: var(--ink-2); font-size: 12px; border-radius: 4px; padding: 1px 7px; }
@media (min-width: 900px) {
  .olayout { grid-template-columns: 255px 1fr; gap: 28px; }
}
@media (max-width: 899px) {
  .oside .ocover.big { display: none; }
  .oside { padding: 4px; display: flex; flex-wrap: wrap; }
  .side-nav, .side-nav.sep { display: flex; flex-wrap: wrap; border: 0; margin: 0; padding: 0; }
  .side-nav a { padding: 8px 12px; font-size: 14px; border-radius: 4px; }
}
.omain { display: grid; gap: 24px; min-width: 0; align-content: start; }
.kcards { display: grid; gap: 16px; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 640px) { .kcards { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1100px) { .kcards { grid-template-columns: repeat(5, 1fr); } }
.kcard { position: relative; background: var(--surface); border-top: 3px solid var(--accent); border-radius: 4px; box-shadow: 0 1px 3px rgba(0,0,0,.1); padding: 14px 18px 16px; text-decoration: none; color: var(--ink); min-height: 92px; }
.kcard b { display: block; font-size: 28px; font-weight: 500; color: var(--accent); line-height: 1.2; }
.kcard span { font-size: 15px; color: var(--ink-2); }
.kcard svg { position: absolute; right: 16px; bottom: 16px; width: 26px; height: 26px; color: #9a9da3; }
a.kcard:hover { box-shadow: 0 4px 12px rgba(0,0,0,.14); }
.panels { display: grid; gap: 24px; grid-template-columns: 1fr; }
@media (min-width: 1000px) { .panels { grid-template-columns: 1fr 1fr; } }
.panel { background: var(--surface); border-radius: 4px; box-shadow: 0 1px 3px rgba(0,0,0,.1); min-width: 0; }
.panel > header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.panel > header h2 { margin: 0; font-size: 18px; font-weight: 600; color: var(--accent); }
.panel > header a { color: #2f6fe0; text-decoration: none; font-size: 15px; }
.panel-empty { display: grid; justify-items: center; text-align: center; gap: 6px; padding: 48px 20px; color: var(--ink-2); }
.panel-empty svg { width: 46px; height: 46px; color: var(--ink); margin-bottom: 6px; }
.panel-empty b { font-weight: 500; font-size: 17px; color: var(--ink); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filters input[type=search] { min-width: 200px; }
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 15px; }
.tbl th { text-align: left; font-weight: 600; padding: 12px 20px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 11px 20px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td.cut { max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.tbl tbody tr { cursor: pointer; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl a { color: #2f6fe0; text-decoration: none; }
@media (max-width: 640px) { .hide-sm { display: none; } .tbl th, .tbl td { padding: 10px 12px; } }
.badge { display: inline-block; font-size: 13px; font-weight: 700; color: #fff; padding: 2px 6px; border-radius: 3px; }
.badge.preenchendo { background: #f0a500; }
.badge.revisar { background: #2f6fe0; }
.badge.aprovado { background: #2e9d4f; }
.pgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 16px; }
.pthumb { aspect-ratio: 4/3; border-radius: 4px; background: var(--line) center/cover no-repeat; }
.info { margin: 0; padding: 8px 20px 18px; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px 24px; }
.info div { padding: 10px 0; border-bottom: 1px solid var(--line); }
.info dt { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.info dd { margin: 0; color: var(--ink-2); }

/* acesso por obra no cadastro de usuário */
.acc-list { display: grid; gap: 6px; max-height: 300px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; padding: 6px; }
.acc-row { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; }
.acc-row.on { background: var(--accent-soft); }
.acc-name { flex: 1; min-width: 0; font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-row select { width: 170px; flex: none; }
.user-row .grow { flex: 1; }

/* reprovação / histórico / andamento */
.notice.bad { background: var(--bad-soft); color: var(--bad); }
.notice.bad small { opacity: .85; }
.badge.reprovado { background: #c62828; }
.btn.danger-solid { background: #c62828; border-color: #c62828; color: #fff; }
.pct-box { display: inline-flex; align-items: center; gap: 2px; font-weight: 700; }
.pct { width: 58px; min-height: 36px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 8px; text-align: right; font-size: 15px; font-weight: 600; background: var(--surface); color: var(--ink); }
.hist { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.hist li { border-left: 3px solid var(--line); padding: 2px 0 2px 12px; font-size: 14px; color: var(--ink-2); }
.hist li b { color: var(--ink); }
.hist li.h-aprovado { border-color: #2e9d4f; }
.hist li.h-reprovado { border-color: #c62828; }
.hist li.h-enviado { border-color: #2f6fe0; }
.h-motivo { margin-top: 4px; padding: 8px 10px; background: var(--bad-soft); color: var(--bad); border-radius: 8px; white-space: pre-wrap; }

/* capa da obra */
.ocover.editavel { cursor: pointer; }
.capa-edit { position: absolute; left: 8px; bottom: 8px; display: inline-flex; align-items: center; gap: 5px; background: rgba(0,0,0,.6); color: #fff; font-size: 12px; font-weight: 600; padding: 5px 9px; border-radius: 6px; opacity: .9; }
.ocover.editavel:hover .capa-edit { opacity: 1; }
.capa-row { display: flex; gap: 14px; align-items: center; margin-top: 14px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
.capa-mini, .capa-prev { position: relative; display: grid; place-items: center; background: #f3f3f4 center/cover no-repeat; color: #b4b6ba; border-radius: 6px; flex: none; }
.capa-mini { width: 110px; aspect-ratio: 4/3; }
.capa-mini .ph { width: 44px; height: 44px; }
.capa-prev { width: 100%; aspect-ratio: 16/10; }
.capa-mini.has-img .ph, .capa-prev.has-img .ph { display: none; }

/* relatórios semanais / mensais */
.pad { padding: 16px 20px; margin: 0; }
.rel-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.rel-tit { font-size: 20px; font-weight: 600; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.rel-periodo { display: flex; gap: 10px; align-items: flex-end; }
.rel-periodo .f { min-width: 150px; }
.kcard b small { font-size: 16px; color: var(--ink-3); }
.tbl.static tbody tr { cursor: default; }
.tbl.static td { white-space: normal; }
.tbl .up { color: #2e9d4f; font-weight: 700; }
.texto { white-space: pre-wrap; margin: 0; }
.panel textarea.input { min-height: 96px; }
.sel-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); padding: 16px 20px 20px; }
.sel-foto { border: 2px solid transparent; border-radius: 8px; overflow: hidden; background: var(--surface-2); cursor: pointer; }
.sel-foto.on { border-color: var(--accent); }
.sel-img { position: relative; aspect-ratio: 4/3; background: var(--line) center/cover no-repeat; }
.sel-n { position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; background: rgba(0,0,0,.35); color: #fff; font-size: 13px; font-weight: 700; display: grid; place-items: center; }
.sel-foto.on .sel-n { background: var(--accent); }
.sel-cap { padding: 6px 8px; font-size: 12px; color: var(--ink-2); display: grid; gap: 4px; }
.sel-cap .input { min-height: 32px; font-size: 13px; padding: 4px 8px; }
.rel-page .notice { margin: 0; }

/* IA */
.ia-panel { border: 1px solid #c9b8ff; background: linear-gradient(135deg, #f6f2ff, #eef4ff); }
.ia-row { display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.ia-row > div { flex: 1; min-width: 220px; }
.ia-btn { background: linear-gradient(135deg, #6d4aff, #2f6fe0); color: #fff; border: 0; }
.ia-btn:disabled { opacity: .85; }
.mini-spin { width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; display: inline-block; animation: spin .8s linear infinite; }
textarea.ia-preenchido { background: #f8f5ff; border-color: #c9b8ff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ia-panel { background: #1d1a33; border-color: #4a3d8a; } :root:not([data-theme="light"]) textarea.ia-preenchido { background: #1d1a33; } }

/* medição */
@media (min-width: 1100px) { .kcards.k4 { grid-template-columns: repeat(4, 1fr); } }
.kcards.k4 .kcard b { font-size: 22px; }
.med-tbl { font-size: 13.5px; }
.med-tbl th, .med-tbl td { padding: 8px 10px; }
.med-tbl .num { text-align: right; white-space: nowrap; }
.med-tbl td.desc { white-space: normal; min-width: 220px; max-width: 420px; line-height: 1.35; }
.med-tbl tr.tit td { background: var(--surface-2); font-weight: 700; color: var(--ink); }
.med-tbl tr.med td { background: color-mix(in srgb, var(--accent-soft) 55%, transparent); }
.med-tbl tr.exc td { background: var(--bad-soft); color: var(--bad); }
.med-wrap { max-height: 70vh; overflow: auto; }
.med-wrap thead th { position: sticky; top: 0; background: var(--surface); z-index: 1; }
.qcell { display: inline-flex; align-items: center; gap: 4px; justify-content: flex-end; }
.qin { width: 96px; text-align: right; min-height: 34px; }
.memb { border: 1px solid var(--line); background: var(--surface); border-radius: 6px; width: 32px; height: 32px; cursor: pointer; opacity: .55; }
.memb.on { opacity: 1; border-color: var(--accent); background: var(--accent-soft); }
.mem-head, .mem-row { display: grid; grid-template-columns: 1.2fr 1.2fr 90px 36px; gap: 6px; align-items: center; }
.mem-head { font-size: 12px; font-weight: 600; color: var(--ink-3); margin-bottom: 4px; }
.mem-row { margin-bottom: 6px; }
.mem-res { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.mem-res.bad { color: var(--bad); font-weight: 600; }
.mono { font-family: ui-monospace, Consolas, monospace; }
.mem-total { margin-top: 10px; text-align: right; font-size: 15px; }
@media (max-width: 640px) { .mem-head { display: none; } .mem-row { grid-template-columns: 1fr 90px 36px; } .mem-row > input[data-md] { grid-column: 1 / -1; } }

/* medição no formato da planilha (Orçamento Sintético + colunas da medição) */
.med-cab { display: grid; grid-template-columns: 2.4fr 1.2fr .7fr 1.6fr auto; gap: 0; background: #fff; border: 1px solid #c9ced6; border-radius: 4px; overflow: hidden; color: #111; font-family: Arial, Helvetica, sans-serif; }
.med-cab > div { padding: 8px 12px; border-right: 1px solid #e3e6eb; display: grid; gap: 2px; align-content: start; min-width: 0; }
.med-cab span { font-size: 12px; font-weight: 700; }
.med-cab b { font-size: 12.5px; font-weight: 700; line-height: 1.3; }
.med-cab .mc-med { border: 2px solid #111; border-radius: 0; text-align: center; align-content: center; min-width: 210px; }
.med-cab .mc-med b { font-size: 15px; }
.med-cab .mc-med span { font-weight: 700; font-size: 12px; }
@media (max-width: 900px) { .med-cab { grid-template-columns: 1fr 1fr; } .med-cab .mc-obra, .med-cab .mc-med { grid-column: 1 / -1; } }
.med-x { border-collapse: collapse; font-family: Arial, Helvetica, sans-serif; font-size: 12px; color: #111; min-width: 1500px; width: 100%; background: #fff; }
.med-x th, .med-x td { border: 1px solid #9aa1ab; padding: 4px 6px; vertical-align: top; white-space: nowrap; }
.med-x thead th { background: #fff; font-weight: 700; text-align: left; position: sticky; z-index: 1; }
.med-x thead tr.g th { top: 0; text-align: center; font-size: 12.5px; border-bottom: 2px solid #111; }
.med-x thead tr:nth-child(2) th { top: 27px; }
.med-x .g-orc { text-align: center; }
.med-x .num { text-align: right; }
.med-x .c-desc { white-space: normal; min-width: 340px; max-width: 520px; }
.med-x .bq { border-left: 2px solid #111; }
.med-x tr.tit td { background: #bad4ef; font-weight: 700; }
.med-x tr.srv td { background: #dee2e6; }
.med-x tr.srv.med td { background: #fff3cd; }
.med-x tr.srv.exc td { background: #f8c9c9; color: #8b0000; }
.med-x td.q-nesta { background: #fffbe6 !important; padding: 2px 4px; }
.med-x .qin { width: 90px; min-height: 28px; padding: 2px 6px; font-size: 12.5px; border-radius: 3px; }
.med-x .memb { width: 26px; height: 26px; font-size: 13px; }
.med-x tfoot td { background: #fff; font-weight: 700; border-top: 2px solid #111; }
.med-x tfoot .lbl { text-align: right; }
.med-x tfoot tr.tg td { background: #eef1f5; }
.med-x .warn-i { color: #b45309; }
.med-wrap { max-height: 72vh; }
.meta-orc { display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: flex-end; border-top: 1px solid var(--line); }
.meta-orc div { display: grid; gap: 2px; min-width: 120px; max-width: 360px; }
.meta-orc span { font-size: 11px; color: var(--ink-3); font-weight: 600; text-transform: uppercase; }
.meta-orc b { font-size: 13px; font-weight: 600; }

/* RDO ligado à planilha / medição */
.plan-tag { font-size: 12px; font-weight: 700; color: #1d4ed8; background: #e8efff; border-radius: 6px; padding: 3px 8px; justify-self: start; }
.plan-qtd .input { max-width: 160px; font-weight: 700; }
.plan-btn { color: #1d4ed8; border-color: #b9cdf7; }
.plan-list { display: grid; gap: 4px; max-height: 55vh; overflow: auto; margin-top: 10px; }
.pl-tit { font-size: 12px; font-weight: 700; background: #bad4ef; color: #111; padding: 4px 8px; border-radius: 4px; margin-top: 6px; }
.pl-item { display: grid; grid-template-columns: 60px 1fr auto; gap: 8px; text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 8px; cursor: pointer; font-size: 13px; color: var(--ink); }
.pl-item:hover { border-color: #1d4ed8; background: #f3f7ff; }
.pl-item i { font-style: normal; color: var(--ink-3); font-weight: 600; }
.rdo-hint { font-size: 10.5px; color: #1d4ed8; text-align: right; margin-top: 2px; white-space: nowrap; }
.rdo-hint.diff { color: #b45309; }
.rdo-hint .pend { color: var(--ink-3); }
.link-btn { border: 0; background: none; color: #1d4ed8; text-decoration: underline; cursor: pointer; font-size: 10.5px; padding: 0 2px; }
.med-x .qin.auto { background: #e8efff; border-color: #9db7ef; font-weight: 700; }
.saldo { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; color: var(--ink-2); background: #f3f7ff; border: 1px solid #d6e2fb; border-radius: 8px; padding: 6px 10px; }
.saldo:empty { display: none; }
.saldo b { color: var(--ink); }
.saldo .disp b { color: #15803d; }
.saldo .neg, .saldo .neg b { color: var(--bad); }
.range-row.auto-pct input[type=range] { accent-color: #1d4ed8; opacity: .9; }
.range-row.auto-pct .muted { color: #1d4ed8; font-weight: 600; }

/* cronograma */
.cron-tbl th, .cron-tbl td { padding: 6px 8px; font-size: 13px; }
.cron-tbl .num { text-align: right; white-space: nowrap; }
.cron-tbl .sticky-c { position: sticky; left: 0; background: var(--surface); z-index: 1; min-width: 220px; max-width: 280px; white-space: normal; }
.cron-tbl .cin { width: 64px; min-height: 30px; padding: 2px 6px; text-align: right; font-size: 13px; }
.cron-tbl tfoot td { font-weight: 700; background: var(--surface-2); }
.cron-tbl tfoot .sticky-c { background: var(--surface-2); }
.neg { color: var(--bad) !important; }
.pos { color: #15803d; }
.curva-s { width: 100%; height: auto; max-height: 280px; }
.curva-s .cs-g { stroke: var(--line); stroke-width: 1; }
.curva-s .cs-t { fill: var(--ink-3); font-size: 11px; font-family: inherit; }
.curva-s .cs-prev { fill: none; stroke: #2f6fe0; stroke-width: 2.5; stroke-dasharray: 6 4; }
.curva-s .cs-real { fill: none; stroke: var(--accent); stroke-width: 3; }
.curva-s .cs-pp { fill: #2f6fe0; } .curva-s .cs-rp { fill: var(--accent); }
.cs-leg { display: flex; gap: 18px; justify-content: center; font-size: 12.5px; color: var(--ink-2); margin-top: 4px; }
.cs-leg span::before { content: ""; display: inline-block; width: 22px; height: 0; border-top: 3px solid; vertical-align: middle; margin-right: 6px; }
.cs-leg .lp::before { border-color: #2f6fe0; border-top-style: dashed; } .cs-leg .lr::before { border-color: var(--accent); }
.situ-tbl td, .situ-tbl th { font-size: 13px; padding: 8px 10px; }
.situ-tbl .num { text-align: right; white-space: nowrap; }
.situ-tbl tr.tot td { font-weight: 700; background: var(--surface-2); }
.barra { position: relative; height: 12px; background: var(--surface-2); border-radius: 6px; min-width: 120px; overflow: hidden; }
.barra i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 6px; }
.barra .bp { background: #c9d9fb; }
.barra .br { background: #15803d; height: 6px; top: 3px; }
.barra .br.atr { background: var(--bad); }
.crono-res { display: flex; flex-wrap: wrap; gap: 10px 28px; }
.crono-res div { display: grid; gap: 2px; }
.crono-res span { font-size: 11px; color: var(--ink-3); font-weight: 600; text-transform: uppercase; }
.crono-res b { font-size: 17px; }
.kcard b .neg, .kcard b .pos { font-size: inherit; }
.rdo-hint.tempo { color: #7c3aed; }

/* histórico e backups */
.hist-row { display: flex; gap: 14px; padding: 10px 16px; border-top: 1px solid var(--line); font-size: 14px; }
.hist-row:first-child { border-top: 0; }
.hist-quando { width: 130px; flex: none; color: var(--ink-3); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.hist-det { font-size: 12.5px; margin-top: 2px; white-space: pre-wrap; }
.bk-dia { border-top: 1px solid var(--line); }
.bk-dia:first-child { border-top: 0; }
.bk-dia summary { padding: 12px 16px; cursor: pointer; display: flex; gap: 8px; align-items: center; }
.bk-arqs { padding: 0 16px 12px; display: grid; gap: 6px; }
.bk-arq { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 6px 10px; background: var(--surface-2); border-radius: 8px; font-size: 13.5px; }
@media (max-width: 640px) { .hist-row { flex-direction: column; gap: 2px; } .hist-quando { width: auto; } }
