@font-face { font-family: "Open Sans"; src: url("/fonts/open-sans-latin.woff2") format("woff2"); font-weight: 300 800; font-style: normal; font-display: swap; }
:root {
  color-scheme: dark;
  --night: #070b12;
  --navy: #0d1420;
  --navy-2: #131c2b;
  --navy-3: #1b2636;
  --navy-4: #243145;
  --gold: #cfa14f;
  --gold-light: #e6c47f;
  --gold-deep: #a57c33;
  --on-gold: #070b12;
  --silver: #d9dadb;
  --text: #eef0f3;
  --text-soft: #b2bac6;
  --text-muted: #8f99a9;
  --line: rgba(217, 218, 219, .12);
  --line-gold: rgba(207, 161, 79, .38);
  --success: #5fce9b;
  --success-bg: rgba(95, 206, 155, .12);
  --danger: #ef8a7c;
  --danger-bg: rgba(239, 138, 124, .12);
  --warn: #f0c56a;
  --warn-bg: rgba(240, 197, 106, .12);
  --info: #7fb2ef;
  --sidebar: 256px;
  --topbar: 64px;
  --c-avista: #cfa14f;
  --c-entrada: #7fb2ef;
  --c-parcela: #5fce9b;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--text); background: var(--night); font-size: 14px; line-height: 1.45; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: var(--gold-light); text-decoration: none; }
a:hover { text-decoration: underline; }
svg.i { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 2px solid var(--gold-light); outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }

/* Marca */
.brand { display: flex; align-items: center; gap: 11px; color: var(--silver); }
.brand .mark { width: 40px; height: 23px; }
.brand small { display: block; font-size: 7.5px; font-weight: 700; letter-spacing: .36em; color: var(--gold); }
.brand strong { display: block; margin-top: 1px; font-size: 17px; font-weight: 800; line-height: 1; color: var(--silver); }
.brand strong em { font-style: normal; color: var(--gold); }

/* Estrutura */
.topbar { position: fixed; inset: 0 0 auto 0; height: var(--topbar); z-index: 30; display: flex; align-items: center; gap: 12px; padding: 0 18px; background: var(--night); border-bottom: 1px solid var(--line); }
.topbar .grow { flex: 1; }
.top-user { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-soft); }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--navy-3); color: var(--gold-light); font-weight: 700; border: 1px solid var(--line-gold); }
.icon-btn { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 8px; color: var(--text-soft); font-size: 18px; position: relative; }
.icon-btn:hover { background: var(--navy-2); color: var(--text); }
.icon-btn .dot { position: absolute; top: 6px; right: 6px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; }
.menu-btn { display: none; }
.sidebar { position: fixed; top: var(--topbar); bottom: 0; left: 0; width: var(--sidebar); z-index: 20; padding: 14px 12px 28px; overflow-y: auto; background: var(--night); border-right: 1px solid var(--line); scrollbar-width: thin; scrollbar-color: var(--navy-3) transparent; }
.main { margin-left: var(--sidebar); padding-top: var(--topbar); min-height: 100vh; background: radial-gradient(900px 500px at 100% 0, rgba(207,161,79,.08), transparent 65%), var(--navy); }
.content { max-width: 1280px; margin: 0 auto; padding: 26px 26px 90px; }
.nav-label { margin: 18px 12px 6px; font-size: 10.5px; font-weight: 700; letter-spacing: .14em; color: var(--text-muted); text-transform: uppercase; }
.nav-item { width: 100%; min-height: 40px; margin-top: 2px; padding: 0 12px; display: flex; align-items: center; gap: 12px; border-radius: 8px; font-size: 13.5px; font-weight: 500; color: var(--text-soft); text-align: left; }
.nav-item svg { font-size: 17px; }
.nav-item:hover { background: var(--navy-2); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--navy-3); color: var(--gold-light); font-weight: 600; box-shadow: inset 3px 0 0 var(--gold); }
.backdrop { display: none; }

/* Títulos */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { font-size: 22px; font-weight: 700; }
.page-head p { margin-top: 4px; color: var(--text-muted); font-size: 13px; }
.eyebrow { font-size: 10.5px; font-weight: 700; letter-spacing: .16em; color: var(--gold); text-transform: uppercase; }
h2.sec { font-size: 15px; font-weight: 700; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
h2.sec svg { color: var(--gold); }

/* Componentes */
.card { border: 1px solid var(--line); border-radius: 12px; background: var(--navy-2); padding: 18px; }
.card + .card { margin-top: 16px; }
.card.gold { border-color: var(--line-gold); background: linear-gradient(150deg, var(--navy-3), var(--navy-2)); }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stack > * + * { margin-top: 16px; }
.kpi { padding: 16px 18px; border-radius: 12px; border: 1px solid var(--line); background: linear-gradient(150deg, var(--navy-3), var(--navy-2)); }
.kpi small { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--text-muted); }
.kpi small svg { color: var(--gold); font-size: 14px; }
.kpi strong { display: block; margin-top: 8px; font-size: 22px; font-weight: 700; }
.kpi span { display: block; margin-top: 2px; font-size: 12px; color: var(--text-muted); }
.kpi.ok strong { color: var(--success); }
.kpi.bad strong { color: var(--danger); }
.kpi.gold { border-color: var(--line-gold); }
.kpi.gold strong { color: var(--gold-light); }

.btn { height: 40px; padding: 0 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 8px; font-size: 13.5px; font-weight: 600; white-space: nowrap; border: 1px solid var(--line); background: var(--navy-3); color: var(--text); }
.btn:hover { background: var(--navy-4); text-decoration: none; }
.btn.primary { background: var(--gold); color: var(--on-gold); border-color: var(--gold); }
.btn.primary:hover { background: var(--gold-light); }
.btn.danger { color: var(--danger); border-color: rgba(239,138,124,.35); background: transparent; }
.btn.danger:hover { background: var(--danger-bg); }
.btn.ghost { background: transparent; }
.btn.ok { color: var(--success); border-color: rgba(95,206,155,.35); background: transparent; }
.btn.ok:hover { background: var(--success-bg); }
.btn.wa { color: #4fd08a; border-color: rgba(79,208,138,.35); background: transparent; }
.btn.sm { height: 32px; padding: 0 10px; font-size: 12.5px; }
.btn.xs { height: 28px; padding: 0 8px; font-size: 12px; border-radius: 6px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { font-size: 15px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.muted { color: var(--text-muted); }
.soft { color: var(--text-soft); }
.small { font-size: 12px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mt { margin-top: 16px; }
.mt-s { margin-top: 8px; }

/* Formulários */
.form { display: grid; gap: 14px; grid-template-columns: repeat(12, minmax(0, 1fr)); }
.form > * { grid-column: span 12; }
.c3 { grid-column: span 3 !important; } .c4 { grid-column: span 4 !important; } .c5 { grid-column: span 5 !important; } .c6 { grid-column: span 6 !important; } .c8 { grid-column: span 8 !important; } .c9 { grid-column: span 9 !important; } .c2 { grid-column: span 2 !important; }
label.f { display: grid; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--text-soft); }
label.f small { font-weight: 400; color: var(--text-muted); }
.input, select.input, textarea.input { width: 100%; height: 42px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--night); color: var(--text); font-size: 14px; }
textarea.input { height: auto; min-height: 90px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
textarea.code { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; min-height: 480px; }
.input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(207,161,79,.15); }
.input::placeholder { color: var(--text-muted); }
.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text-soft); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--gold); }
.seg { display: inline-flex; padding: 3px; border-radius: 9px; background: var(--night); border: 1px solid var(--line); flex-wrap: wrap; }
.seg button { height: 32px; padding: 0 12px; border-radius: 6px; font-size: 13px; font-weight: 600; color: var(--text-soft); }
.seg button.on { background: var(--navy-3); color: var(--gold-light); }
.search { position: relative; flex: 1; min-width: 220px; }
.search svg { position: absolute; left: 12px; top: 13px; color: var(--text-muted); font-size: 16px; }
.search .input { padding-left: 38px; }

/* Tabelas */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--navy-2); }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th { text-align: left; padding: 11px 14px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--navy-3); }
table.t td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: rgba(255,255,255,.025); }
table.t td.num, table.t th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.t tfoot td { font-weight: 700; background: var(--navy-3); }
.empty { padding: 34px 16px; text-align: center; color: var(--text-muted); }

.tag { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 11px; font-size: 11.5px; font-weight: 600; background: var(--navy-4); color: var(--text-soft); white-space: nowrap; }
.tag.ok { background: var(--success-bg); color: var(--success); }
.tag.bad { background: var(--danger-bg); color: var(--danger); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.gold { background: rgba(207,161,79,.14); color: var(--gold-light); }
.tag.info { background: rgba(127,178,239,.14); color: var(--info); }

.dl { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px 20px; }
.dl div small { display: block; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); }
.dl div span { display: block; margin-top: 3px; word-break: break-word; }

/* Modelos de contrato */
.models { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.model { text-align: left; padding: 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--navy-2); display: grid; gap: 8px; }
.model:hover { border-color: var(--line-gold); }
.model.on { border-color: var(--gold); background: linear-gradient(150deg, rgba(207,161,79,.14), var(--navy-2)); }
.model svg { font-size: 22px; color: var(--gold); }
.model strong { font-size: 14px; }
.steps { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.steps span { height: 30px; padding: 0 12px; display: inline-flex; align-items: center; gap: 8px; border-radius: 15px; font-size: 12.5px; font-weight: 600; color: var(--text-muted); border: 1px solid var(--line); }
.steps span b { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; background: var(--navy-4); }
.steps span.on { color: var(--gold-light); border-color: var(--line-gold); }
.steps span.on b { background: var(--gold); color: var(--on-gold); }

.attach-list { display: grid; gap: 10px; }
.attach { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--night); }
.attach img { width: 74px; height: 50px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); background: #fff; }
.attach .pdf { width: 74px; height: 50px; border-radius: 6px; display: grid; place-items: center; background: var(--danger-bg); color: var(--danger); font-weight: 800; font-size: 12px; }
.attach .grow { flex: 1; min-width: 0; }
.attach .input { height: 34px; }

/* Recorte */
.crop-stage { position: relative; display: grid; place-items: center; background: #05080d; border-radius: 10px; overflow: hidden; touch-action: none; user-select: none; }
.crop-stage canvas { display: block; max-width: 100%; touch-action: none; cursor: crosshair; }

/* Gráficos */
.chart { width: 100%; height: 260px; }
.chart text { fill: var(--text-muted); font-size: 11px; font-family: inherit; }
.chart .grid-line { stroke: var(--line); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-soft); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.bars-h { display: grid; gap: 10px; }
.bar-h { display: grid; grid-template-columns: 150px 1fr auto; gap: 10px; align-items: center; font-size: 12.5px; }
.bar-h .track { height: 10px; border-radius: 5px; background: var(--navy-4); overflow: hidden; }
.bar-h .fill { height: 100%; border-radius: 5px; background: linear-gradient(90deg, var(--gold-deep), var(--gold-light)); }

/* Avisos */
.notice { padding: 14px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--navy-2); border-left: 4px solid var(--info); }
.notice.importante { border-left-color: var(--warn); }
.notice.urgente { border-left-color: var(--danger); }
.notice + .notice { margin-top: 10px; }
.notice h3 { font-size: 14px; }
.notice p { margin-top: 6px; white-space: pre-wrap; color: var(--text-soft); }

/* Janela e aviso rápido */
.modal-bg { position: fixed; inset: 0; z-index: 60; background: rgba(3,5,9,.72); display: grid; place-items: center; padding: 16px; }
.modal { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; border-radius: 14px; border: 1px solid var(--line-gold); background: var(--navy-2); padding: 20px; box-shadow: 0 30px 80px rgba(0,0,0,.5); }
.modal.wide { width: min(980px, 100%); }
.modal h3 { font-size: 16px; margin-bottom: 14px; }
.modal .foot { margin-top: 18px; display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 80; display: grid; gap: 8px; }
.toast { max-width: 360px; padding: 12px 14px; border-radius: 10px; background: var(--navy-3); border: 1px solid var(--line); box-shadow: 0 14px 40px rgba(0,0,0,.4); font-size: 13px; }
.toast.ok { border-color: rgba(95,206,155,.4); }
.toast.bad { border-color: rgba(239,138,124,.5); color: #ffd6cf; }
.loading { padding: 40px; text-align: center; color: var(--text-muted); }

/* Login */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(800px 500px at 80% 0, rgba(207,161,79,.12), transparent 60%), var(--night); }
.auth-box { width: min(420px, 100%); padding: 30px 26px; border-radius: 16px; border: 1px solid var(--line-gold); background: linear-gradient(160deg, var(--navy-3), var(--navy-2)); }
.auth-box .brand { justify-content: center; margin-bottom: 22px; }
.auth-box h1 { font-size: 19px; text-align: center; }
.auth-box p.sub { text-align: center; color: var(--text-muted); margin: 6px 0 20px; font-size: 13px; }
.auth-box .btn { width: 100%; height: 44px; }
.err { padding: 10px 12px; border-radius: 8px; background: var(--danger-bg); color: var(--danger); font-size: 13px; }

@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .menu-btn { display: grid; }
  .sidebar { transform: translateX(-100%); transition: transform .2s; box-shadow: 20px 0 60px rgba(0,0,0,.5); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .backdrop { display: block; position: fixed; inset: var(--topbar) 0 0 0; z-index: 15; background: rgba(0,0,0,.5); }
  .main { margin-left: 0; }
  .content { padding: 18px 16px 80px; }
  .g2, .g3 { grid-template-columns: minmax(0, 1fr); }
  .form > * { grid-column: span 12 !important; }
  .top-user .who { display: none; }
  .bar-h { grid-template-columns: 100px 1fr auto; }
}
@media (max-width: 520px) {
  .g4 { grid-template-columns: minmax(0, 1fr); }
  .page-head h1 { font-size: 19px; }
  .brand strong { font-size: 15px; }
}
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .main { margin: 0; padding: 0; background: #fff; color: #000; }
}
.pre { white-space: pre-wrap; }
.row > .input, .row > select.input { width: auto; flex: 0 1 auto; }
.row > .search { flex: 1 1 260px; }

/* Celular: tabelas viram cartões (cada linha um cartão, rótulo à esquerda e valor à direita) */
@media (max-width: 760px) {
  .table-wrap { overflow: visible; border: 0; background: transparent; }
  table.t, table.t tbody, table.t tfoot, table.t tr, table.t td { display: block; width: 100%; }
  table.t thead { display: none; }
  table.t tr { margin-bottom: 10px; padding: 8px 0; border: 1px solid var(--line); border-radius: 12px; background: var(--navy-2); }
  table.t tr:last-child { margin-bottom: 0; }
  table.t td { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 14px; border: 0; text-align: right; min-height: 32px; }
  table.t td::before { content: attr(data-label); flex: none; max-width: 45%; text-align: left; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }
  table.t td:not([data-label])::before, table.t td[data-label=""]::before { display: none; }
  table.t td:not([data-label]), table.t td[data-label=""] { justify-content: flex-end; flex-wrap: wrap; }
  table.t td > div, table.t td > a { text-align: right; }
  table.t td.num { white-space: normal; }
  table.t td:first-child { font-weight: 600; }
  table.t td:first-child:not([data-label=""])::before { display: none; }
  table.t td:first-child { justify-content: flex-start; text-align: left; flex-direction: column; align-items: flex-start; }
  table.t td:first-child > div { text-align: left; }
  table.t td .input { max-width: 60%; }
  table.t tfoot tr { background: var(--navy-3); }
  table.t tfoot td { background: transparent; }
  table.t tr.click:hover td { background: transparent; }
  .page-head > .row, .page-head > .btn, .page-head > a.btn { width: 100%; }
  .page-head > .row > .btn, .page-head > .row > a.btn { flex: 1 1 auto; }
  .row.between > .seg, .row > .seg { max-width: 100%; }
  .seg { display: flex; flex-wrap: wrap; }
  .seg button { flex: 1 1 auto; }
  .modal { padding: 16px; }
  .modal .foot .btn { flex: 1 1 auto; }
  .toasts { left: 12px; right: 12px; }
  .toast { max-width: none; }
  .kpi strong { font-size: 20px; }
  .dl { grid-template-columns: 1fr 1fr; }
  .attach { flex-wrap: wrap; }
  .attach .grow { flex: 1 1 160px; }
  .search { min-width: 0; flex-basis: 100%; }
  .row > select.input, .row > .input { flex: 1 1 140px; }
}
@media (max-width: 520px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 12px; }
  .kpi small { font-size: 9.5px; letter-spacing: .06em; }
  .kpi strong { font-size: 17px; margin-top: 6px; }
  .kpi span { font-size: 11px; }
  .brand strong { white-space: nowrap; font-size: 14px; }
  .brand .mark { width: 32px; height: 19px; }
  .topbar { padding: 0 10px; gap: 6px; }
  .content { padding: 16px 12px 80px; }
  .card { padding: 14px; }
}
@media (max-width: 520px) {
  .models { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .model { padding: 12px; gap: 4px; }
  .model strong { font-size: 13px; line-height: 1.25; }
  .model svg { font-size: 18px; }
  .steps span { height: 26px; font-size: 11.5px; padding: 0 9px; }
  .periodo { display: grid !important; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); width: 100%; }
  .periodo > .input { min-width: 0; width: 100%; padding: 0 8px; }
  .periodo > span { display: none; }
  .periodo > .btn { grid-column: span 2; }
  .page-head p { font-size: 12.5px; }
}
/* iPhone: campos com letra menor que 16px fazem a tela dar zoom ao tocar */
@media (max-width: 760px) {
  .input, select.input, textarea.input { font-size: 16px; }
  textarea.code { font-size: 13px; }
}
input[type="date"].input, input[type="month"].input { min-width: 0; }
.drop { display: grid; place-items: center; gap: 6px; padding: 22px 16px; text-align: center; border: 1.5px dashed var(--line-gold); border-radius: 12px; background: rgba(207,161,79,.05); cursor: pointer; }
.drop:hover, .drop.on { background: rgba(207,161,79,.12); border-color: var(--gold); }
.drop svg { font-size: 24px; color: var(--gold); }
.attach .pdf.img { background: rgba(127,178,239,.14); color: var(--info); }
.attach select.input { width: auto; flex: 0 1 190px; height: 34px; }
