:root {
  --bg: #0b1020; --s1: #121a30; --s2: #1a2442; --s3: #243055; --line: #2a3556;
  --tx: #e6e9f2; --mut: #9aa4c0;
  --blue: #3b82f6; --blue-d: #1e3a8a; --green: #22c55e; --green-d: #14532d; --orange: #fb923c; --orange-d: #9a3412;
  --danger: #ef4444; --ok: #22c55e; --warn: #f59e0b;
  --r: 12px;
}
* { box-sizing: border-box; }
html { color-scheme: dark; }
body { margin: 0; background: var(--bg); color: var(--tx); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
.hidden { display: none !important; }
h1 { font-size: 1.35rem; margin: 0 0 12px; } h2 { font-size: 1.1rem; margin: 0 0 10px; } h3 { font-size: 1rem; margin: 0 0 8px; }
a { color: var(--blue); }
.muted { color: var(--mut); } .small { font-size: .82rem; }

.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--s1); border-bottom: 1px solid var(--line); padding-top: max(8px, env(safe-area-inset-top)); }
.brand { flex: 1; display: flex; align-items: center; gap: 8px; font-weight: 600; min-width: 0; }
.brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-logo { height: 30px; max-width: 120px; object-fit: contain; }
.icon-btn { background: transparent; border: 1px solid var(--line); color: var(--tx); border-radius: 10px; width: 42px; height: 42px; font-size: 1.2rem; cursor: pointer; }

.menu { position: fixed; z-index: 30; top: 0; left: 0; bottom: 0; width: min(82vw, 300px); background: var(--s1); border-right: 1px solid var(--line); padding: 16px 12px; overflow-y: auto; transform: translateX(-102%); transition: transform .2s; display: block; }
.menu.open { transform: none; }
.menu-scrim { position: fixed; inset: 0; z-index: 25; background: rgba(0, 0, 0, .55); }
.menu .item { display: block; width: 100%; text-align: left; background: transparent; border: 0; color: var(--tx); padding: 12px; border-radius: 10px; font: inherit; cursor: pointer; }
.menu .item:hover, .menu .item.active { background: var(--s3); }
.menu .sub { padding-left: 14px; }
.menu .sub .item { color: var(--mut); padding: 9px 12px; }
.menu .sub .item.active { color: var(--tx); }

.view { padding: 14px 12px 70px; max-width: 1100px; margin: 0 auto; outline: none; }
.rodape { position: fixed; right: 10px; bottom: 6px; font-size: .68rem; color: var(--mut); z-index: 5; pointer-events: none; text-align: right; padding-bottom: env(safe-area-inset-bottom); }

.card { background: var(--s1); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin-bottom: 14px; }
.card.dev { border-color: var(--blue-d); }
.grid { display: grid; gap: 12px; }
.cards { grid-template-columns: repeat(2, 1fr); }
.stat { background: var(--s1); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; }
.stat .n { font-size: 1.35rem; font-weight: 700; } .stat .l { color: var(--mut); font-size: .8rem; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }

label { display: block; font-size: .85rem; color: var(--mut); margin: 10px 0 4px; }
input, select, textarea { width: 100%; background: var(--bg); color: var(--tx); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; font: inherit; min-height: 44px; }
input[type=checkbox] { width: 20px; height: 20px; min-height: 0; accent-color: var(--blue); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue); outline-offset: 1px; }
textarea { min-height: 110px; resize: vertical; }
.check { display: flex; align-items: center; gap: 10px; color: var(--tx); font-size: .95rem; margin: 10px 0; }
.check input { flex: none; }
.pw { position: relative; } .pw input { padding-right: 48px; }
.pw .eye { position: absolute; right: 4px; top: 2px; width: 42px; height: 42px; background: transparent; border: 0; color: var(--mut); font-size: 1.1rem; cursor: pointer; }
.counter { text-align: right; font-size: .78rem; color: var(--mut); }
.err { color: #fca5a5; font-size: .88rem; margin-top: 8px; min-height: 1.2em; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--blue); color: #fff; border: 0; border-radius: 10px; padding: 11px 16px; font: inherit; font-weight: 600; cursor: pointer; min-height: 44px; }
.btn:hover { filter: brightness(1.1); } .btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--tx); }
.btn-danger { background: #b91c1c; } .btn-ok { background: #15803d; } .btn-warn { background: #b45309; }
.btn-sm { padding: 7px 11px; min-height: 36px; font-size: .88rem; }
.btn-block { width: 100%; }

.tag { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .74rem; font-weight: 700; background: var(--s3); }
.tag.DEV { background: var(--blue-d); color: #dbeafe; } .tag.USE { background: var(--green-d); color: #dcfce7; }
.tag.off { background: #7f1d1d; color: #fee2e2; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #ef4444; flex: none; box-shadow: 0 0 6px #ef4444; }
.dot.empty { background: transparent; box-shadow: none; }

.list-row { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.list-row:last-child { border-bottom: 0; }
.list-row .name { flex: 1; min-width: 140px; word-break: break-word; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }

.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 14px; padding-bottom: 2px; }
.tabs button { flex: none; background: var(--s1); border: 1px solid var(--line); color: var(--mut); border-radius: 99px; padding: 8px 16px; font: inherit; cursor: pointer; min-height: 40px; }
.tabs button.active { background: var(--blue); color: #fff; border-color: var(--blue); }

.table-wrap { overflow: auto; max-height: 60vh; border: 1px solid var(--line); border-radius: var(--r); }
table { border-collapse: collapse; width: 100%; font-size: .85rem; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: top; }
td.wrap { white-space: normal; min-width: 180px; }
th { position: sticky; top: 0; background: var(--s2); cursor: default; z-index: 1; }
th.sortable { cursor: pointer; }
.horarios td { white-space: normal; padding: 6px 4px; } .horarios input { padding: 7px 6px; min-height: 38px; }

.modal-scrim { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .65); display: flex; align-items: center; justify-content: center; padding: 14px; overflow-y: auto; }
.modal { background: var(--s1); border: 1px solid var(--line); border-radius: 14px; padding: 18px; width: min(100%, 520px); max-height: 92vh; overflow-y: auto; }
.modal.wide { width: min(100%, 860px); }
.modal .foot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.terms-frame { width: 100%; height: 55vh; border: 1px solid var(--line); border-radius: 10px; background: #fff; }

.toast-root { position: fixed; z-index: 90; left: 12px; right: 12px; bottom: 36px; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--s3); border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; max-width: 520px; }
.toast.err { background: #7f1d1d; } .toast.ok { background: #14532d; }

.chart-box { position: relative; height: 260px; } .chart-box.tall { height: 320px; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(100%, 400px); }
.login-logo { display: block; max-height: 70px; max-width: 220px; margin: 0 auto 10px; object-fit: contain; }
.login-title { text-align: center; margin-bottom: 14px; }

/* Pastas / documentos */
/* Largura única das pastas = largura do maior nome de mês (calculada em área.js e gravada em --pasta-w) */
.pastas { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, var(--pasta-w, 11rem)); justify-content: start; }
.pasta-col { display: flex; flex-direction: column; gap: 8px; }
.pasta { width: var(--pasta-w, 11rem); }
.pasta:not(.societario) { min-height: 35.2px; padding: 4px 12px; } /* 20% menor que os 44px originais */
.pasta { background: var(--s2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; color: var(--tx); font: inherit; text-align: left; min-height: 44px; }
.pasta:hover { background: var(--s3); }
.pasta.societario { background: var(--blue-d); border-color: var(--blue); margin-bottom: 12px; gap: 6px; }
.pasta.societario > span:first-child { white-space: normal; }
.doc { display: flex; gap: 8px; align-items: center; padding: 7.1px 8px; border-bottom: 1px solid var(--line); cursor: grab; user-select: none; touch-action: pan-y; }
.doc.sel { background: var(--s3); }
.doc .nm { flex: 1; word-break: break-word; color: var(--blue); text-decoration: underline; cursor: pointer; }
.trash { position: fixed; right: 14px; bottom: 34px; z-index: 40; width: 74px; height: 74px; border-radius: 50%; background: var(--s3); border: 2px dashed var(--mut); display: grid; place-items: center; font-size: 2rem; transition: transform .15s; }
.trash.over { transform: scale(1.2); border-color: var(--danger); }
.fx-canvas { position: fixed; inset: 0; z-index: 80; pointer-events: none; width: 100%; height: 100%; }
.chat { display: flex; flex-direction: column; gap: 8px; max-height: 40vh; overflow-y: auto; margin-bottom: 8px; }
.bubble { padding: 8px 12px; border-radius: 12px; max-width: 85%; background: var(--s3); word-break: break-word; }
.bubble.U { align-self: flex-end; background: var(--blue-d); }
.bubble .t { display: block; font-size: .68rem; color: var(--mut); }

@media (min-width: 720px) {
  .cards { grid-template-columns: repeat(3, 1fr); }
  .two { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 980px) {
  .menu { transform: none; width: 240px; }
  .menu-scrim { display: none; }
  .app .view, .app .topbar { margin-left: 240px; }
  .app .view { max-width: none; margin-right: auto; }
  #btn-menu { display: none; }
  .cards { grid-template-columns: repeat(4, 1fr); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

.handle { touch-action: none; cursor: grab; padding: 0 8px; font-size: 1.1rem; line-height: 1; }
.ghost-drag { position: fixed; z-index: 70; pointer-events: none; }

.xml { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px; max-height: 50vh; overflow: auto; white-space: pre-wrap; word-break: break-all; font-size: .75rem; }

.table-wrap.tall { max-height: 62vh; }
table.sheet th, table.sheet td { padding: 4px; }
table.sheet input, table.sheet select, table.sheet textarea { min-width: 130px; padding: 8px; min-height: 38px; font-size: .88rem; }
table.sheet input.num { min-width: 100px; text-align: right; }
table.sheet textarea { min-width: 220px; min-height: 38px; resize: vertical; }
table.sheet td:nth-child(2) select { min-width: 220px; }
tr.row-err td { background: rgba(127, 29, 29, .25); }
.cell-msg { color: #fca5a5; white-space: normal; max-width: 260px; }
.modal p { white-space: pre-line; }

.file-list { padding-left: 18px; word-break: break-word; font-size: .9rem; }

.doc { user-select: none; -webkit-user-select: none; }
.doc.sel { outline: 2px solid var(--blue); outline-offset: -2px; }

table.sheet input.ro { min-width: 150px; opacity: .8; background: var(--s2); cursor: default; }

/* Pagamentos: tabela Clientes x Meses */
.anos { gap: 8px; align-items: center; } .anos .ano { min-width: 4ch; text-align: center; font-size: 1.15rem; }
table.pg-table th, table.pg-table td { padding: 4px 6px; text-align: center; }
table.pg-table td.num, table.pg-table th:last-child { text-align: right; font-variant-numeric: tabular-nums; }
table.pg-table th:first-child, table.pg-table td.cli, table.pg-table tfoot td:first-child { position: sticky; left: 0; text-align: left; background: var(--s1); min-width: 150px; z-index: 2; }
table.pg-table thead th:first-child { background: var(--s2); z-index: 3; }
table.pg-table tfoot td { position: sticky; bottom: 0; background: var(--s2); font-weight: 700; }
table.pg-table td.cel.off { background: rgba(255, 255, 255, .03); }
label.pg { display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; min-width: 64px; }
label.pg .pv { min-height: 1em; font-size: .7rem; }

.senha-row { flex-wrap: nowrap; gap: 8px; } .senha-temp { font-family: ui-monospace, Consolas, monospace; font-size: 1.1rem; letter-spacing: .04em; }
.icon-copy { flex: none; padding: 8px 12px; font-size: 1.1rem; }

/* Menu lateral em coluna: itens no topo; usuário e Sair presos ao rodapé */
.menu { display: flex; flex-direction: column; }
.menu .menu-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); display: grid; gap: 10px; }
.menu .menu-user { display: flex; flex-direction: column; gap: 2px; padding: 0 4px; word-break: break-word; }
