/* =========================================================
   INNOVASEG — sistema interno
   Feito primeiro para o celular do técnico
   ========================================================= */
:root {
  --navy-950: #081629;
  --navy-900: #0B1E39;
  --navy-800: #12264A;
  --navy-700: #1A3360;
  --cell: #1B3A6B;
  --orange: #F28A1E;
  --orange-dark: #C9650A;
  --paper: #F3F5F8;
  --text: #12264A;
  --muted: #5A6577;
  --line: #DCE2EA;
  --white: #FFFFFF;
  --ok: #1E7F4F;
  --erro: #B42318;
  --aviso: #9A5B00;
  --wa: #1FA855;
  --radius: 10px;
  --font-display: "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --pv-grid:
    linear-gradient(rgba(255,255,255,.07) 1px, transparent 1px) 0 0 / 34px 34px,
    linear-gradient(90deg, rgba(255,255,255,.07) 1px, transparent 1px) 0 0 / 34px 34px;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font-body); font-size: 16px; line-height: 1.5;
  color: var(--text); background: var(--paper); -webkit-font-smoothing: antialiased;
  padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px));
}
a { color: var(--navy-700); }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; margin: 0; letter-spacing: -0.01em; }
p { margin: 0; }
img { max-width: 100%; display: block; }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; border-radius: 4px; }
.ic { width: 20px; height: 20px; flex-shrink: 0; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.pre { white-space: pre-wrap; }
.right { text-align: right; }
[hidden] { display: none !important; }

/* ---------- Barra superior ---------- */
.app-top {
  position: sticky; top: 0; z-index: 50;
  background: var(--navy-900); color: var(--white);
  padding-top: env(safe-area-inset-top, 0px);
}
.app-top-in { max-width: 1080px; margin: 0 auto; height: 58px; padding: 0 16px; display: flex; align-items: center; gap: 24px; }
.app-logo { font-family: var(--font-display); font-weight: 700; font-size: 1.3rem; color: var(--white); text-decoration: none; }
.app-logo span { color: var(--orange); }
.app-logo.dark { color: var(--navy-800); }
.app-nav { display: none; gap: 4px; }
.app-nav a { display: flex; align-items: center; gap: 8px; color: rgba(255,255,255,.8); text-decoration: none; font-weight: 500; font-size: .95rem; padding: 8px 12px; border-radius: 6px; }
.app-nav a:hover { color: var(--white); background: rgba(255,255,255,.06); }
.app-nav a[aria-current="page"] { color: var(--white); background: rgba(242,138,30,.18); }
.app-nav a[aria-current="page"] .ic { color: var(--orange); }
.app-user { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.app-user > span { display: none; text-align: right; font-size: .9rem; line-height: 1.2; margin-right: 6px; }
.app-user small { display: block; color: rgba(255,255,255,.6); font-size: .78rem; }
.app-user a { color: rgba(255,255,255,.8); padding: 8px; border-radius: 6px; display: grid; }
.app-user a:hover { color: var(--orange); }

/* ---------- Barra de abas (celular) ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: var(--white); border-top: 1px solid var(--line);
  display: flex; padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 10px 4px 9px; color: var(--muted); text-decoration: none; font-size: .78rem; font-weight: 600;
}
.tabbar a .ic { width: 24px; height: 24px; }
.tabbar a[aria-current="page"] { color: var(--navy-800); }
.tabbar a[aria-current="page"] .ic { color: var(--orange); }

/* ---------- Conteúdo ---------- */
.app-main { max-width: 1080px; margin: 0 auto; padding: 18px 14px 32px; }
.page-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.page-head h1 { font-size: 1.55rem; }
.back { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 8px; background: var(--white); border: 1px solid var(--line); color: var(--navy-800); flex-shrink: 0; }

.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; }
.card h3 { font-size: 1.05rem; margin-bottom: 10px; }
.card h3 + p, .card .pre + h3 { margin-bottom: 14px; }
.card .pre + h3 { margin-top: 16px; }
.big { font-family: var(--font-display); font-weight: 600; font-size: 1.2rem; margin-bottom: 8px; }
.big a { color: var(--navy-800); }
.label { font-weight: 600; font-size: .9rem; margin: 10px 0 8px; color: var(--navy-800); }

.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 22px 0 10px; }
.section-title h2 { font-size: 1.15rem; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.toolbar.search input[type="search"] { flex: 1 1 240px; }
.toolbar select { flex: 0 1 220px; }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 600 1rem var(--font-display); padding: 12px 18px; min-height: 46px;
  border-radius: 8px; border: 1.5px solid transparent; cursor: pointer; text-decoration: none;
  transition: background-color .15s ease, border-color .15s ease;
}
.btn-primary { background: var(--orange); color: var(--navy-950); }
.btn-primary:hover { background: #FF9A33; }
.btn-ghost { background: var(--white); color: var(--navy-800); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--navy-700); }
.btn-wa { background: var(--wa); color: var(--white); }
.btn-wa:hover { background: #17924A; }
.btn-danger { background: var(--white); color: var(--erro); border-color: #F2C4BF; }
.btn-danger:hover { border-color: var(--erro); }
.btn-sm { min-height: 38px; padding: 8px 14px; font-size: .92rem; }
.btn-lg { min-height: 56px; font-size: 1.1rem; }
.btn-block { width: 100%; }
.link { background: none; border: 0; padding: 6px 0; color: var(--navy-700); font: inherit; font-size: .9rem; text-decoration: underline; cursor: pointer; }
.quick { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
.cta-start { margin-bottom: 14px; }

/* ---------- Formulários ---------- */
.form { display: grid; gap: 14px; }
.form.narrow { max-width: 520px; }
.form label { display: grid; gap: 6px; font-weight: 600; font-size: .92rem; color: var(--navy-800); }
input, select, textarea {
  font: inherit; font-size: 16px; font-weight: 400; color: var(--text);
  width: 100%; padding: 12px 13px; border: 1.5px solid var(--line); border-radius: 8px; background: var(--white);
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px rgba(242,138,30,.18); }
.form label.check { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.check input { width: 20px; height: 20px; accent-color: var(--orange); }
.hint { font-size: .85rem; color: var(--muted); margin-top: -6px; }
.grid2 { display: grid; gap: 14px; }
.grid2.tight { gap: 10px; grid-template-columns: 1fr 1fr; }
.row-inline { display: flex; gap: 8px; }
.row-inline select { flex: 1; }
.pass { position: relative; display: block; }
.pass input { padding-right: 90px; }
.pass-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: none; border: 0; font: 600 .9rem var(--font-body); color: var(--muted); padding: 8px; cursor: pointer; }

/* ---------- Alertas ---------- */
.alert { padding: 12px 14px; border-radius: 8px; margin-bottom: 14px; font-size: .95rem; border: 1px solid; }
.alert-ok { background: #EAF6EF; border-color: #B7E0C6; color: var(--ok); }
.alert-erro { background: #FDECEA; border-color: #F2C4BF; color: var(--erro); }
.alert-aviso { background: #FFF4E5; border-color: #F6CF93; color: var(--aviso); }
.alert a { color: inherit; font-weight: 600; }

/* ---------- Painel ---------- */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
.stat { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; text-decoration: none; color: var(--text); border-top: 3px solid var(--navy-800); }
.stat strong { display: block; font: 700 1.8rem var(--font-display); line-height: 1.1; }
.stat span { color: var(--muted); font-size: .9rem; }

/* ---------- Listas em cartões ---------- */
.cards { display: grid; gap: 10px; }
.os-card, .cli-card {
  display: grid; gap: 4px; background: var(--white); border: 1px solid var(--line);
  border-left: 4px solid var(--navy-800); border-radius: var(--radius); padding: 14px 16px;
  text-decoration: none; color: var(--text); position: relative;
}
.os-card:hover, .cli-card:hover { border-color: var(--navy-700); }
.os-card.urgente { border-left-color: var(--erro); }
.os-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.os-num { font: 600 .85rem var(--font-display); color: var(--muted); }
.os-title { font: 600 1.05rem var(--font-display); }
.os-cli { color: var(--text); }
.os-meta, .cli-meta { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: .88rem; margin-top: 2px; }
.late { color: var(--erro); font-weight: 600; }
.tag-urgente { justify-self: start; font-size: .75rem; font-weight: 700; color: var(--erro); background: #FDECEA; padding: 2px 8px; border-radius: 4px; }
.os-head .tag-urgente { margin-left: 8px; }
.os-head .os-card-top { justify-content: flex-start; }
.os-head h2 { font-size: 1.35rem; margin: 10px 0 12px; }

.st { display: inline-block; font-size: .78rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.st-aberta { background: #E8EEF8; color: var(--navy-700); }
.st-em_andamento { background: #FFF1E0; color: #A65400; }
.st-aguardando_peca { background: #F4ECFB; color: #6B3FA0; }
.st-concluida { background: #EAF6EF; color: var(--ok); }
.st-cancelada { background: #EEF0F3; color: var(--muted); }

.empty { text-align: center; padding: 28px 18px; display: grid; gap: 14px; justify-items: center; }
.empty p { color: var(--muted); }

/* ---------- Abas de filtro ---------- */
.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; padding-bottom: 2px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { white-space: nowrap; text-decoration: none; font-weight: 600; font-size: .92rem; color: var(--navy-800); background: var(--white); border: 1px solid var(--line); padding: 8px 14px; border-radius: 999px; }
.tabs a[aria-current="page"] { background: var(--navy-800); color: var(--white); border-color: var(--navy-800); }

/* ---------- Informações ---------- */
.info { margin: 0; display: grid; gap: 8px; }
.info div { display: grid; grid-template-columns: 100px 1fr; gap: 10px; }
.info dt { color: var(--muted); font-size: .9rem; }
.info dd { margin: 0; }
.info.compact div { grid-template-columns: 92px 1fr; }

/* ---------- Fotos ---------- */
.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.gallery figure { margin: 0; position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--paper); }
.gallery img { width: 100%; height: 100%; object-fit: cover; }
.gallery form { position: absolute; top: 4px; right: 4px; }
.x { width: 30px; height: 30px; border-radius: 50%; border: 0; background: rgba(8,22,41,.75); color: #fff; font-size: 1.2rem; line-height: 1; cursor: pointer; }
.upload { margin-top: 14px; }
.seg { display: flex; border: 1.5px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg label { flex: 1; display: block; font-weight: 600; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg span { display: block; text-align: center; padding: 10px 6px; cursor: pointer; }
.seg label + label span { border-left: 1.5px solid var(--line); }
.seg input:checked + span { background: var(--navy-800); color: var(--white); }
.seg input:focus-visible + span { outline: 3px solid var(--orange); outline-offset: -3px; }
.file-btn {
  display: flex !important; align-items: center; justify-content: center; gap: 10px;
  border: 2px dashed #B9C3D1; border-radius: 10px; padding: 18px; cursor: pointer;
  font: 600 1rem var(--font-display) !important; color: var(--navy-800);
}
.file-btn .ic { width: 26px; height: 26px; color: var(--orange); }
.file-btn input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.file-btn:focus-within { border-color: var(--orange); }
.preview { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.preview img { aspect-ratio: 1; object-fit: cover; border-radius: 6px; }

/* ---------- Materiais ---------- */
.mat-list { list-style: none; margin: 0 0 12px; padding: 0; }
.mat-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.mat-list .x { background: var(--paper); color: var(--muted); }
.mat-form { display: grid; grid-template-columns: 1fr 72px 78px; gap: 8px; }
.mat-form .btn { grid-column: 1 / -1; }

/* ---------- Assinatura ---------- */
.sign-wrap { display: grid; gap: 6px; }
.sign { width: 100%; height: 190px; border: 2px dashed #B9C3D1; border-radius: 10px; background: #FBFCFD; touch-action: none; }
.sign-img { max-height: 140px; border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 6px; margin-bottom: 8px; }

/* ---------- Histórico ---------- */
.hist { list-style: none; margin: 0; padding: 0; }
.hist li { display: grid; gap: 2px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: .92rem; }
.hist time { color: var(--muted); font-size: .82rem; }

/* ---------- Tabelas ---------- */
.table-wrap { padding: 0; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th { font-size: .85rem; color: var(--muted); font-weight: 600; }
.table tr.off td { color: var(--muted); }

/* ---------- Menu Mais ---------- */
.list-menu { padding: 0; }
.list-menu .me { padding: 18px; border-bottom: 1px solid var(--line); display: grid; gap: 2px; }
.list-menu a { display: flex; align-items: center; gap: 12px; padding: 16px 18px; text-decoration: none; color: var(--text); font-weight: 600; border-bottom: 1px solid var(--line); }
.list-menu a:last-child { border-bottom: 0; }
.list-menu a.danger { color: var(--erro); }

/* ---------- Login e instalação ---------- */
body.login { display: grid; min-height: 100vh; min-height: 100dvh; grid-template-columns: 1fr; padding: 0; background: var(--white); }
.login-side { background: var(--cell); background-image: var(--pv-grid); color: var(--white); padding: 24px 22px 28px; display: grid; gap: 22px; align-content: start; }
.login-side h1 { font-size: 1.7rem; max-width: 14ch; margin-bottom: 10px; }
.login-side p { color: rgba(255,255,255,.82); max-width: 38ch; }
.login-back { color: rgba(255,255,255,.75); font-size: .92rem; display: none; }
.login-main { display: grid; place-items: start center; padding: 28px 20px 40px; }
.login-box { width: 100%; max-width: 400px; display: grid; gap: 14px; }
.login-box h2 { font-size: 1.8rem; }
body.auth { padding: 0; display: grid; place-items: center; min-height: 100vh; background: var(--paper); }
.auth-box { width: min(440px, calc(100% - 28px)); background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 26px; display: grid; gap: 14px; margin: 24px 0; }
.auth-box h1 { font-size: 1.5rem; }

/* ---------- Telas maiores ---------- */
@media (min-width: 720px) {
  .grid2 { grid-template-columns: 1fr 1fr; }
  .grid2 .span2 { grid-column: span 2; }
  .stats { grid-template-columns: repeat(4, 1fr); }
  .cards { grid-template-columns: repeat(2, 1fr); }
  .gallery { grid-template-columns: repeat(5, 1fr); }
  .mat-form { grid-template-columns: 1fr 80px 90px auto; }
  .mat-form .btn { grid-column: auto; }
  .preview { grid-template-columns: repeat(8, 1fr); }
}
@media (min-width: 900px) {
  body { padding-bottom: 0; }
  .tabbar { display: none; }
  .app-nav { display: flex; }
  .app-user > span { display: block; }
  .app-main { padding: 28px 24px 48px; }
  .page-head h1 { font-size: 1.9rem; }
  .cards { grid-template-columns: repeat(3, 1fr); }
  body.login { grid-template-columns: 1fr 1fr; }
  .login-side { padding: 44px 48px; align-content: space-between; }
  .login-side h1 { font-size: 2.6rem; }
  .login-back { display: inline; }
  .login-main { place-items: center; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* =========================================================
   Orçamentos, catálogo e contratos
   ========================================================= */
.st-orc-rascunho { background: #EEF0F3; color: var(--muted); }
.st-orc-enviado { background: #E8EEF8; color: var(--navy-700); }
.st-orc-aprovado { background: #EAF6EF; color: var(--ok); }
.st-orc-recusado { background: #FDECEA; color: var(--erro); }
.st-ct-gerado { background: #FFF1E0; color: #A65400; }
.st-ct-assinado { background: #EAF6EF; color: var(--ok); }
.st-ct-cancelado { background: #EEF0F3; color: var(--muted); }
.tag-ok { justify-self: start; font-size: .75rem; font-weight: 700; color: var(--ok); background: #EAF6EF; padding: 2px 8px; border-radius: 4px; }
.money { font-family: var(--font-display); color: var(--navy-800); font-weight: 700; }
.total-big { font: 700 1.9rem var(--font-display); color: var(--navy-800); margin: 4px 0 2px; }
.stat.orange { border-top-color: var(--orange); }
.stat .money-big { font-size: 1.35rem; }
.inline { display: inline; }
.wrap { white-space: normal !important; min-width: 220px; }
.table-wrap.flat { border: 0; margin: 0 -18px; }
.tipo-produto, .tipo-servico { display: inline-block; font-size: .7rem; font-weight: 700; padding: 1px 6px; border-radius: 4px; margin-right: 4px; vertical-align: 1px; }
.tipo-produto { background: #E8EEF8; color: var(--navy-700); }
.tipo-servico { background: #FFF1E0; color: #A65400; }

.item-add { display: grid; gap: 10px; margin-bottom: 14px; }
.itens { display: grid; gap: 10px; }
.item { border: 1px solid var(--line); border-left: 4px solid var(--navy-700); border-radius: 8px; padding: 12px; display: grid; gap: 8px; background: #FBFCFD; }
.item.servico { border-left-color: var(--orange); }
.item-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.item-top select { width: auto; padding: 6px 10px; font-size: .9rem; }
.item .x { background: var(--paper); color: var(--muted); }
.item textarea { min-height: 54px; }
.item-nums { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: end; }
.item-nums label { display: grid; gap: 4px; font-size: .8rem; font-weight: 600; color: var(--muted); }
.item-nums input, .item-nums select { padding: 10px; }
.item-total { display: grid; gap: 2px; text-align: right; }
.item-total span { font-size: .8rem; color: var(--muted); font-weight: 600; }
.item-total b { font: 700 1.1rem var(--font-display); color: var(--navy-800); padding: 8px 0; }

.totais { margin-top: 16px; border-top: 2px solid var(--line); padding-top: 12px; display: grid; gap: 6px; }
.totais > div { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.totais span, .totais label { color: var(--muted); font-size: .95rem; font-weight: 500; }
.totais input { width: 140px; text-align: right; padding: 8px 10px; }
.totais .total { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 4px; }
.totais .total span { color: var(--navy-800); font-weight: 700; font-size: 1.05rem; }
.totais .total b { font: 700 1.5rem var(--font-display); color: var(--navy-800); }
.sticky-actions { position: sticky; bottom: calc(68px + env(safe-area-inset-bottom, 0px)); background: linear-gradient(transparent, var(--paper) 30%); padding: 12px 0 4px; z-index: 5; }
.sticky-actions .btn { width: 100%; }

.copy-row { display: flex; gap: 8px; margin-top: 12px; }
.copy-row input { font-size: .85rem; color: var(--muted); background: var(--paper); }
.status-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.next-steps { border-color: #B7E0C6; background: #F6FBF8; }
.steps-grid { display: grid; gap: 10px; }
.next-steps .alert { margin: 12px 0 0; }
details.mini { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
details.mini summary { cursor: pointer; font-weight: 600; color: var(--navy-700); padding: 4px 0; }
details.mini .form { margin-top: 10px; }
.contrato-edit { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .88rem; line-height: 1.55; }
.contrato-view { max-height: 60vh; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 14px; font-size: .92rem; }
.contrato-view p { margin: 0 0 8px; }
.contrato-view .titulo { font: 700 1rem var(--font-display); text-align: center; }
.contrato-view .clausula { font: 700 .95rem var(--font-display); margin-top: 14px; }

@media (min-width: 720px) {
  .item-nums { grid-template-columns: 110px 100px 1fr 150px; }
  .steps-grid { grid-template-columns: 1fr 1fr; }
  .totais { margin-left: auto; max-width: 380px; }
  .sticky-actions .btn { width: auto; }
}
@media (min-width: 900px) {
  .sticky-actions { bottom: 0; }
}

/* =========================================================
   Financeiro
   ========================================================= */
.pos { color: var(--ok) !important; }
.neg { color: var(--erro) !important; }
.btn-ok { background: var(--ok); color: #fff; }
.btn-ok:hover { background: #17663F; }
.block-link { display: block; text-decoration: none; }
.stats.fin .stat.in { border-top-color: var(--ok); }
.stats.fin .stat.out { border-top-color: var(--erro); }
.stats.fin .stat span b { font-weight: 700; }
.stats.compact { margin: 6px 0 16px; }
.stats.compact .stat { padding: 10px 12px; }
.stats.compact .stat strong { font-size: 1.4rem; }

.tabs.small a { font-size: .85rem; padding: 6px 12px; }
.toolbar input[type="month"] { flex: 0 1 170px; }

.fin-list { padding: 0; overflow: hidden; }
.fin-item { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); border-left: 4px solid var(--ok); }
.fin-item.despesa { border-left-color: var(--erro); }
.fin-item:last-child { border-bottom: 0; }
.fin-item.pago { opacity: .75; }
.fin-main { flex: 1; min-width: 0; display: grid; gap: 2px; text-decoration: none; color: var(--text); }
.fin-main strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.fin-main .muted { font-size: .85rem; }
.fin-meta { font-size: .82rem; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.sit { font-size: .72rem; font-weight: 700; padding: 1px 7px; border-radius: 999px; }
.sit-aberto { background: #E8EEF8; color: var(--navy-700); }
.sit-vencido { background: #FDECEA; color: var(--erro); }
.sit-pago { background: #EAF6EF; color: var(--ok); }
.fin-side { display: grid; justify-items: end; gap: 6px; flex-shrink: 0; }
.fin-valor { font: 700 1rem var(--font-display); color: var(--ok); white-space: nowrap; }
.fin-item.despesa .fin-valor { color: var(--erro); }
.fin-side .btn { min-height: 34px; padding: 6px 12px; font-size: .85rem; }
.fin-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.fin-row:last-child { border-bottom: 0; }

.totais.wide { max-width: none !important; margin-left: 0 !important; }
.totais.readonly b { font-family: var(--font-display); }
.divisao { margin-top: 14px; padding: 14px; background: var(--paper); border-radius: 8px; display: grid; gap: 6px; }
.divisao > div { display: flex; justify-content: space-between; gap: 12px; }
.divisao span { color: var(--muted); }
.divisao .total { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 4px; }
.divisao .total span { color: var(--navy-800); font-weight: 700; }
.divisao .total b { font: 700 1.2rem var(--font-display); color: var(--ok); }

.month-nav { justify-content: flex-start; }
.month-nav h2 { flex: 1; text-align: center; }
.back.flip .ic { transform: scaleX(-1); }

fieldset.repetir { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px 14px; margin: 0; display: grid; gap: 12px; }
fieldset.repetir legend { font-weight: 700; font-size: .9rem; padding: 0 6px; color: var(--navy-800); }

.chart { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; align-items: end; height: 170px; margin: 6px 0 8px; }
.chart .col { display: grid; grid-template-rows: 1fr auto; height: 100%; text-decoration: none; color: var(--muted); border-radius: 6px; padding: 2px 0; }
.chart .col.atual { background: var(--paper); color: var(--navy-800); font-weight: 700; }
.chart .pair { display: flex; align-items: flex-end; justify-content: center; gap: 2px; height: 100%; }
.chart .pair i { display: block; width: 40%; max-width: 14px; min-height: 2px; border-radius: 3px 3px 0 0; }
.chart i.in, .dot.in, .bar-track i.in { background: var(--ok); }
.chart i.out, .dot.out, .bar-track i.out { background: var(--erro); }
.chart small { text-align: center; font-size: .72rem; padding-top: 4px; }
.legend { font-size: .85rem; color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 10px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-left: 6px; }
.table tr.hl td { background: #FFF8EF; }
.table tr.sum td { font-weight: 700; border-top: 2px solid var(--line); }

.grid-rel { display: grid; gap: 14px; }
.grid-rel .card { margin: 0; }
.bars { display: grid; gap: 10px; margin-top: 8px; }
.bar-top { display: flex; justify-content: space-between; gap: 10px; font-size: .92rem; }
.bar-top b { white-space: nowrap; }
.bar-top small { color: var(--muted); font-weight: 500; }
.bar-track { height: 8px; background: var(--paper); border-radius: 999px; overflow: hidden; margin-top: 4px; }
.bar-track i { display: block; height: 100%; border-radius: 999px; }

.cad-list { display: grid; gap: 8px; margin-bottom: 8px; }
.cad-row { display: grid; grid-template-columns: 1fr; gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; align-items: center; }
.cad-row.off { opacity: .6; }
.cad-row.nova { border-style: dashed; }
.cad-row .check { font-size: .9rem; }
.mini-lbl { display: grid; gap: 4px; font-size: .8rem; font-weight: 600; color: var(--muted); }

@media (min-width: 720px) {
  .grid-rel { grid-template-columns: 1fr 1fr; margin-bottom: 14px; }
  .cad-row { grid-template-columns: 1fr auto auto auto auto; }
  .cad-row .mini-lbl { grid-auto-flow: column; align-items: center; }
  .cad-row .mini-lbl input { width: 130px; }
}

/* =========================================================
   WhatsApp e CRM
   ========================================================= */
.selo-n { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--wa); color: #fff; font: 700 .72rem var(--font-body); margin-left: 6px; }
.tabbar a { position: relative; }
.tabbar .selo-n { position: absolute; top: 4px; left: 50%; margin-left: 6px; }
.pad { padding: 18px; }
.center { text-align: center; }

.wa-app { display: grid; grid-template-columns: 1fr; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; height: calc(100dvh - 58px - 76px - 90px - env(safe-area-inset-bottom, 0px)); min-height: 420px; }
.wa-app.tem-conversa .wa-lista, .wa-app:not(.tem-conversa) .wa-chat, .wa-app:not(.tem-conversa) .wa-vazio, .wa-app:not(.tem-conversa) .wa-crm { display: none; }
.wa-lista { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); }
.wa-lista-top { padding: 12px; display: grid; gap: 8px; border-bottom: 1px solid var(--line); }
.wa-lista-top .tabs { margin: 0; }
.wa-acoes { display: flex; gap: 6px; flex-wrap: wrap; }
.wa-nova { display: flex; gap: 6px; }
.wa-nova[hidden] { display: none; }
.wa-convs { overflow-y: auto; flex: 1; }
.wa-conv { display: flex; gap: 10px; padding: 12px; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--text); align-items: flex-start; }
.wa-conv:hover { background: var(--paper); }
.wa-conv.ativa { background: #FFF6EC; }
.wa-av { width: 42px; height: 42px; border-radius: 50%; background: var(--cell); color: #fff; display: grid; place-items: center; font: 700 1.05rem var(--font-display); flex-shrink: 0; }
.wa-conv-txt { flex: 1; min-width: 0; display: grid; gap: 2px; }
.wa-conv-top { display: flex; justify-content: space-between; gap: 8px; }
.wa-conv-top b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-conv-top small { color: var(--muted); flex-shrink: 0; }
.wa-conv.nova .wa-conv-top small { color: var(--wa); font-weight: 700; }
.wa-conv-ult { color: var(--muted); font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-conv-tags { display: flex; gap: 4px; flex-wrap: wrap; }
.wa-conv-tags i { font-style: normal; font-size: .7rem; font-weight: 600; padding: 1px 6px; border-radius: 4px; background: var(--paper); color: var(--muted); }
.wa-conv-tags i.sem-cad { background: #FFF4E5; color: var(--aviso); }
.wa-conv .selo-n { margin-top: 22px; }
.et-novo { background: #E8EEF8 !important; color: var(--navy-700) !important; }
.et-atendimento { background: #FFF1E0 !important; color: #A65400 !important; }
.et-orcamento { background: #F4ECFB !important; color: #6B3FA0 !important; }
.et-fechado { background: #EAF6EF !important; color: var(--ok) !important; }
.et-perdido { background: #EEF0F3 !important; color: var(--muted) !important; }

.wa-chat { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: #F4F1EC; }
.wa-chat-top { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--white); border-bottom: 1px solid var(--line); }
.wa-chat-top > div { flex: 1; min-width: 0; display: grid; }
.wa-chat-top strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-msgs { flex: 1; overflow-y: auto; padding: 14px 12px; display: flex; flex-direction: column; gap: 6px; }
.wa-b { max-width: 82%; padding: 8px 10px 4px; border-radius: 10px; font-size: .95rem; line-height: 1.4; box-shadow: 0 1px 1px rgba(0,0,0,.06); overflow-wrap: anywhere; }
.wa-b.ele { align-self: flex-start; background: #fff; border-top-left-radius: 2px; }
.wa-b.eu { align-self: flex-end; background: #DCF5D4; border-top-right-radius: 2px; }
.wa-b small { display: block; text-align: right; font-size: .7rem; color: var(--muted); margin-top: 2px; }
.wa-b img { max-width: 240px; max-height: 260px; border-radius: 6px; margin-bottom: 4px; object-fit: cover; }
.wa-b audio { max-width: 240px; }
.wa-b video { max-width: 240px; border-radius: 6px; }
.wa-b a { color: var(--navy-700); }
.wa-dia { text-align: center; margin: 8px 0; }
.wa-dia span { font-size: .75rem; background: #fff; padding: 3px 10px; border-radius: 6px; color: var(--muted); }
.wa-enviar { padding: 8px 10px; background: var(--white); border-top: 1px solid var(--line); display: grid; gap: 6px; }
.wa-enviar select { padding: 8px 10px; font-size: .9rem; }
.wa-input { display: flex; gap: 8px; align-items: flex-end; }
.wa-input textarea { resize: none; min-height: 46px; max-height: 160px; }
.wa-erro { color: var(--erro); font-size: .88rem; }
.wa-vazio { display: grid; place-items: center; color: var(--muted); background: #F4F1EC; }

.wa-crm { position: fixed; inset: 0 0 0 auto; width: min(340px, 92vw); background: var(--white); border-left: 1px solid var(--line); z-index: 60; transform: translateX(105%); transition: transform .2s ease; overflow-y: auto; box-shadow: -8px 0 24px rgba(0,0,0,.12); }
.wa-crm.aberto { transform: none; }
.wa-crm-in { padding: 16px; display: grid; gap: 12px; }
.wa-crm h3 { font-size: 1rem; margin-top: 6px; }
.wa-crm .mini-lbl select, .wa-crm .mini-lbl textarea { font-size: .95rem; }

.wa-status { padding: 12px 14px; border-radius: 8px; background: var(--paper); font-weight: 600; margin-bottom: 12px; }
.wa-status[data-estado="open"] { background: #EAF6EF; color: var(--ok); }
.wa-status[data-estado="erro"] { background: #FDECEA; color: var(--erro); }
.wa-qr { display: grid; gap: 12px; justify-items: center; margin-bottom: 14px; }
.wa-qr img { width: 260px; height: 260px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.wa-qr ol { margin: 0; padding-left: 20px; }
.wrap-code { word-break: break-all; font-size: .8rem; }
.resp-row { display: grid; gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; }
.resp-row.nova { border-style: dashed; }

.funil { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 10px; }
.funil-col { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; display: grid; gap: 8px; align-content: start; border-top: 4px solid var(--navy-700); }
.funil-col.etapa-atendimento { border-top-color: var(--orange); }
.funil-col.etapa-orcamento { border-top-color: #6B3FA0; }
.funil-col.etapa-fechado { border-top-color: var(--ok); }
.funil-col.etapa-perdido { border-top-color: #9AA3B2; }
.funil-col h3 { font-size: .98rem; display: flex; justify-content: space-between; }
.funil-col h3 span { color: var(--muted); }
.funil-card { background: var(--white); border: 1px solid var(--line); border-radius: 8px; padding: 10px; display: grid; gap: 4px; }
.funil-card a { color: var(--navy-800); text-decoration: none; }
.funil-meta { font-size: .78rem; color: var(--muted); }
.funil-card select { padding: 6px 8px; font-size: .85rem; margin-top: 4px; }

@media (min-width: 900px) {
  .wa-app { height: calc(100dvh - 58px - 120px); grid-template-columns: 340px 1fr; }
  .wa-app.tem-conversa .wa-lista { display: flex; }
  .wa-app:not(.tem-conversa) .wa-vazio { display: grid; }
  .wa-chat-top .back { display: none; }
}
@media (min-width: 1200px) {
  .wa-app.tem-conversa { grid-template-columns: 320px 1fr 300px; }
  .wa-crm { position: static; transform: none; width: auto; box-shadow: none; z-index: auto; }
  .wa-crm-btn { display: none; }
  .app-main:has(.wa-app) { max-width: 1400px; }
}

/* Menu do topo com muitos itens */
.app-top-in { max-width: 1400px; }
.app-nav { gap: 2px; }
.app-nav a { padding: 8px 10px; font-size: .92rem; white-space: nowrap; }
@media (min-width: 900px) and (max-width: 1320px) {
  .app-user > span { display: none; }
  .app-nav a .ic { display: none; }
}
