:root {
  /* Identidade visual — MWS · Martins Web Solutions */
  --navy: #0E2A47; --navy-2: #1A3A5C; --navy-line: #2C4867;
  --accent: #3FBF95; --accent-ink: #17705B; --accent-soft: #E6F4EF; --accent-line: #A9DCC9;
  /* laranja fica só como cor de alerta (demanda aberta, pendências) */
  --orange: #E8833A; --orange-soft: #FDEBDD; --orange-ink: #9A3412; --orange-line: #F2C9A5;
  --blue: #1F4E8C; --blue-soft: #E3ECF7;
  --green-soft: #DCFCE7; --green-ink: #14532D;
  --bg: #F4F5F7; --card: #FFFFFF; --line: #E3E6EB; --line-2: #D5DAE1;
  --ink: #0E2A47; --muted: #55667A; --muted-2: #445569; --on-dark: #DDE5EE; --on-dark-2: #C9D3DF;
  --r: 14px;
  font-family: "Segoe UI", Roboto, system-ui, -apple-system, sans-serif;
  color: var(--ink); background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
@font-face { font-family: "Archivo"; src: url("/fonts/archivo-latin-wdth-normal.woff2") format("woff2-variations"); font-weight: 100 900; font-stretch: 62% 125%; font-display: swap; }
* { box-sizing: border-box; }
h1, h2, h3, .kpi .v, .person .nome, .side .brand strong, .btn, .tt { font-family: "Archivo", "Segoe UI", Roboto, system-ui, sans-serif; }
h1 { font-stretch: 110%; letter-spacing: -0.01em; }
body { margin: 0; min-height: 100vh; background: var(--bg); }
a { color: var(--blue); }
a:hover { color: var(--navy); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; }
p { margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Estrutura */
.layout { display: flex; min-height: 100vh; }
main { flex: 1; min-width: 0; padding-bottom: 96px; }
.side { width: 240px; flex-shrink: 0; background: var(--navy); color: #fff; padding: 24px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .brand { display: flex; gap: 10px; align-items: center; padding: 0 8px 18px; }
.side a, .side button { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; border-radius: 10px; color: var(--on-dark); text-decoration: none; font-weight: 600; font-size: 14px; background: none; border: 0; cursor: pointer; text-align: left; }
.side a.on { background: var(--navy-2); color: #fff; font-weight: 800; }
.side .spacer { flex: 1; }
.bottom { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: space-around; align-items: center; height: calc(68px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: #fff; border-top: 1px solid var(--line); }
.bottom a { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 56px; font-size: 11px; font-weight: 600; color: var(--muted); text-decoration: none; }
.bottom a.on { color: var(--navy); font-weight: 800; }
.bottom a.fab { width: 54px; height: 54px; min-width: 0; border-radius: 50%; background: var(--accent); color: var(--navy); justify-content: center; }
@media (min-width: 960px) {
  .bottom { display: none !important; }
  main { padding-bottom: 32px; }
}
@media (max-width: 959px) { .side { display: none !important; } }

/* Cabeçalho escuro das telas */
.top { background: var(--navy); color: #fff; padding: calc(20px + env(safe-area-inset-top)) 20px 18px; display: flex; flex-direction: column; gap: 14px; }
.top .sub { font-size: 13px; color: var(--on-dark-2); }
.top h1 { font-size: 24px; font-weight: 800; line-height: 1.2; }
.top .row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.back { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; color: var(--on-dark); font-weight: 600; font-size: 14px; text-decoration: none; }
.back:hover { color: #fff; }
.wrap { padding: 16px; display: flex; flex-direction: column; gap: 14px; max-width: 1100px; margin: 0 auto; width: 100%; }
@media (min-width: 960px) { .top { padding: 28px 32px 22px; } .wrap { padding: 24px 32px; } }

/* Componentes */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.card h2 { font-size: 17px; font-weight: 800; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.xs { font-size: 12px; }
.strong { font-weight: 800; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1.5px solid var(--line-2); background: #fff; color: var(--ink); font-weight: 700; font-size: 14px; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--navy); color: var(--ink); }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.accent { background: var(--accent); border-color: var(--accent); color: var(--navy); font-weight: 800; }
.btn.danger { color: #9F1239; border-color: #FBCFE8; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn.block { width: 100%; min-height: 50px; font-size: 15px; }
.btn:disabled { opacity: 0.55; cursor: progress; }
.badge { display: inline-flex; align-items: center; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 8px; background: #EEF0F3; color: var(--muted-2); white-space: nowrap; }
.badge.orange { background: var(--orange-soft); color: var(--orange-ink); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.green { background: var(--green-soft); color: var(--green-ink); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chip { flex-shrink: 0; min-height: 36px; padding: 0 14px; border-radius: 18px; border: 1px solid var(--navy-line); background: transparent; color: #fff; font-weight: 600; font-size: 13px; cursor: pointer; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--navy); font-weight: 800; }
.seg { display: flex; gap: 4px; background: var(--navy-2); padding: 4px; border-radius: 12px; }
.seg button { flex: 1; min-height: 40px; border: 0; border-radius: 9px; background: transparent; color: var(--on-dark); font-weight: 600; font-size: 13px; cursor: pointer; }
.seg button.on { background: #fff; color: var(--navy); font-weight: 800; }
.avatar { width: 46px; height: 46px; flex-shrink: 0; border-radius: 50%; background: var(--blue-soft); color: var(--blue); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 15px; }
.avatar.lg { width: 64px; height: 64px; font-size: 22px; background: var(--accent); color: var(--navy); }

/* Formulários */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label, .lbl { font-size: 13px; font-weight: 700; color: var(--muted); }
.input, .field input, .field select, .field textarea { width: 100%; min-height: 48px; border: 1.5px solid var(--line-2); border-radius: 12px; padding: 0 12px; background: #fff; font-size: 16px; }
.field textarea { padding: 10px 12px; min-height: 90px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--navy); outline: none; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; line-height: 1.4; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; flex-shrink: 0; accent-color: var(--navy); }
.hint { padding: 10px 12px; border-radius: 12px; background: var(--blue-soft); font-size: 13px; line-height: 1.45; }
.erro { padding: 10px 12px; border-radius: 12px; background: #FFE4E6; color: #9F1239; font-size: 14px; font-weight: 600; }

/* Busca */
.search { display: flex; align-items: center; gap: 10px; background: #fff; border-radius: 14px; padding: 0 14px; height: 52px; color: var(--ink); }
.search input { flex: 1; border: 0; outline: none; font-size: 16px; min-width: 0; background: transparent; }
.person { display: flex; gap: 12px; align-items: center; padding: 14px; background: #fff; border: 1px solid var(--line); border-radius: 16px; text-decoration: none; color: var(--ink); }
.person:hover { border-color: var(--navy); color: var(--ink); }
.person .info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.person .nome { font-weight: 700; font-size: 16px; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 3px; }
.empty { padding: 28px 20px; text-align: center; background: #fff; border: 1px dashed #C9CFD8; border-radius: 16px; display: flex; flex-direction: column; gap: 10px; align-items: center; }

/* Ficha */
.actions3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.act { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 60px; border-radius: 14px; background: var(--navy-2); color: #fff; font-size: 12px; font-weight: 700; text-decoration: none; border: 0; cursor: pointer; }
.act:hover { color: #fff; background: var(--navy-line); }
.act.accent { background: var(--accent); color: var(--navy); font-weight: 800; }
.brief { background: var(--accent-soft); border: 1.5px solid var(--accent-line); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.brief h2 { font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent-ink); }
.brief p { white-space: pre-line; line-height: 1.5; }
.kv { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.kv > :first-child { color: var(--muted); }
.kv > :last-child { font-weight: 700; text-align: right; }
.item { display: flex; flex-direction: column; gap: 4px; padding: 12px; border-radius: 12px; background: var(--bg); }
.item .t { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.item .tt { font-size: 15px; font-weight: 700; }
.timeline { display: flex; flex-direction: column; gap: 14px; }
.tl { display: flex; gap: 12px; }
.tl .dot { width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: #8A93A3; flex-shrink: 0; }
.tl:first-child .dot { background: var(--accent); }
.tl p { font-size: 14px; line-height: 1.45; white-space: pre-line; }

/* Painel */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 4px; }
.kpi .v { font-size: 30px; font-weight: 800; }
.cols { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-start; }
.cols > * { flex: 1 1 320px; min-width: 0; }
.cols > .wide { flex: 3 1 440px; }
@media (max-width: 959px) { .cols > .first-mobile { order: -1; } }
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 700; padding: 8px 10px; }
td { padding: 11px 10px; border-top: 1px solid #EEF0F3; vertical-align: middle; }
.bar { height: 8px; border-radius: 4px; background: var(--line); flex: 1; min-width: 60px; }
.bar > span { display: block; height: 8px; border-radius: 4px; background: var(--blue); }
.bar.low > span { background: #C2410C; }

/* Mapa */
#mapa { height: 62vh; min-height: 380px; border-radius: 14px; border: 1px solid var(--line); z-index: 0; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; font-weight: 600; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }

/* Login */
.login { min-height: 100vh; background: var(--navy); display: flex; flex-direction: column; }
.login .hero { padding: 56px 28px 32px; color: #fff; display: flex; flex-direction: column; gap: 14px; max-width: 460px; width: 100%; margin: 0 auto; }
.login .panel { flex: 1; background: var(--bg); border-radius: 24px 24px 0 0; }
.login form { padding: 28px 24px; display: flex; flex-direction: column; gap: 16px; max-width: 460px; margin: 0 auto; }
.marca-login { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
.logo-login { width: 64px; height: auto; display: block; }
.marca-login span { font-family: "Archivo", "Segoe UI", sans-serif; font-weight: 800; font-stretch: 112%; font-size: 14px; letter-spacing: 0.06em; color: #fff; white-space: nowrap; }
.brand-mark { width: 44px; height: auto; display: block; flex-shrink: 0; }
.assinatura { display: flex; align-items: center; gap: 8px; padding: 12px 8px 0; font-size: 11px; color: var(--on-dark-2); letter-spacing: 0.04em; }
.assinatura img { width: 22px; height: auto; }

/* Toast e diálogo */
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 50; max-width: 520px; margin: 0 auto; padding: 13px 16px; border-radius: 12px; background: var(--navy); color: #fff; font-weight: 600; font-size: 14px; box-shadow: 0 6px 20px rgba(14, 42, 71, 0.25); }
.toast.erro { background: #9F1239; }
@media (min-width: 960px) { .toast { bottom: 24px; } }
dialog { border: 0; border-radius: 20px; padding: 0; width: min(520px, calc(100vw - 24px)); max-height: calc(100vh - 40px); color: var(--ink); }
dialog::backdrop { background: rgba(14, 42, 71, 0.55); }
dialog form { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.dlg-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.dlg-head h2 { font-size: 20px; font-weight: 800; }
.x { width: 44px; height: 44px; flex-shrink: 0; border-radius: 12px; border: 0; background: var(--bg); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.senha-temp { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 22px; font-weight: 800; letter-spacing: 0.06em; padding: 14px; text-align: center; background: var(--bg); border-radius: 12px; user-select: all; }
.loading { padding: 40px; text-align: center; color: var(--muted); }
