/* =====================================================================
   Aluguéis · Rodolfo Turri Neto — visual no padrão Galacci Juris
   (menu lateral escuro, detalhe dourado, cartões, tabelas em cartão)
   Cor base: verde-petróleo. Para o azul-marinho do GJ, troque --navy
   por #1f2f4a e --navy-2 por #2a4066.
   ===================================================================== */
:root {
  --navy: #0f4c5c; --navy-2: #14697f; --navy-dark: #0a3440; --gold: #b8955a; --gold-2: #d4b483;
  --bg: #f4f5f8; --card: #ffffff; --line: #e3e6ec; --text: #1c2230; --muted: #6b7280;
  --ok: #1e8e5a; --warn: #c98a12; --danger: #c0392b; --info: #2b6cb0;
  --radius: 12px; --shadow: 0 1px 3px rgba(20,30,50,.08), 0 6px 18px rgba(20,30,50,.06);
  --sidebar-w: 250px;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif; font-size: 14.5px; color: var(--text); background: var(--bg); }
a { color: var(--info); }
h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.25; }
h1 { font-size: 20px; color: var(--navy); } h2 { font-size: 15px; color: var(--navy); margin-bottom: 12px; } h3 { font-size: 13px; color: var(--navy); text-transform: uppercase; letter-spacing: .4px; margin: 10px 0 6px; }
p { margin: 0 0 10px; }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 12.5px; } .right { text-align: right; } .center { text-align: center; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; word-break: break-all; }

/* ---------- layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: var(--navy); color: #dfe5f0; display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; z-index: 40; transition: transform .2s; }
.brand { display: flex; gap: 12px; align-items: center; }
.brand h1 { font-size: 22px; color: var(--navy); } .brand p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.brand-mark { width: 46px; height: 46px; border-radius: 12px; background: var(--navy); color: var(--gold-2); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 18px; letter-spacing: .5px; flex-shrink: 0; }
.brand.small { color: #fff; padding: 18px 16px 12px; }
.brand.small .brand-mark { width: 38px; height: 38px; font-size: 15px; background: rgba(255,255,255,.12); }
.brand.small .muted { color: #a9b4c8; font-size: 12px; }
.nav { display: flex; flex-direction: column; padding: 6px 10px; gap: 2px; flex: 1; overflow: auto; }
.nav button { background: none; border: 0; text-align: left; color: #c7d0e0; padding: 10px 12px; border-radius: 9px; display: flex; align-items: center; gap: 10px; font-size: 14px; font-family: inherit; cursor: pointer; }
.nav button .ico { width: 20px; text-align: center; opacity: .85; }
.nav button:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav button.ativa { background: rgba(184,149,90,.25); color: #fff; font-weight: 600; }
.sidebar-foot { padding: 12px 14px; border-top: 1px solid rgba(255,255,255,.1); }
.user-box { font-size: 13px; margin-bottom: 10px; line-height: 1.35; }
.user-box .perfil { display: inline-block; background: var(--gold); color: #1a1a1a; border-radius: 6px; padding: 1px 7px; font-size: 11px; font-weight: 600; margin-top: 4px; }
.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 12px 22px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
.topbar h2 { font-size: 18px; color: var(--navy); margin: 0; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.btn-icon { display: none; border: 1px solid var(--line); background: var(--card); border-radius: 9px; width: 38px; height: 38px; cursor: pointer; font-size: 17px; }
.view { padding: 22px 22px 90px; max-width: 1400px; width: 100%; }
.faixa-demo { background: #fdf1d8; color: #8a5d00; padding: 8px 16px; text-align: center; font-size: 13px; }

/* login */
body.modo-login { background: linear-gradient(160deg, var(--navy) 0%, var(--navy-dark) 100%); }
.app.deslogado .sidebar, .app.deslogado .topbar { display: none; }
.app.deslogado .main { margin-left: 0; }
.app.deslogado .view { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; max-width: none; }
.login { background: var(--card); border-radius: 18px; padding: 34px 30px; width: 100%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.login form { margin-top: 20px; }
.login-foot { margin-top: 16px; font-size: 12.5px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.login .brand h1 { font-size: 22px; }
.erro { background: #fbe4e1; color: var(--danger); padding: 8px 12px; border-radius: 8px; font-size: 13px; margin: 14px 0 0; }
.sucesso { background: #e3f5ec; color: var(--ok); padding: 8px 12px; border-radius: 8px; font-size: 13px; margin: 14px 0 0; }

/* ---------- cartões / grade ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.card.compacto { padding: 12px 16px; }
.grade { display: grid; gap: 16px; }
.grade.c2 { grid-template-columns: repeat(2, 1fr); }
.grade.c3 { grid-template-columns: repeat(3, 1fr); }
.grade.c4 { grid-template-columns: repeat(4, 1fr); }
.grade > .card { margin-bottom: 0; }
.grade > div > .card { margin-bottom: 16px; }
.kpi { padding: 16px 18px; border-left: 0; }
.kpi .rotulo { color: var(--muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: .4px; }
.kpi .valor { font-size: 26px; font-weight: 700; color: var(--navy); margin-top: 4px; }
.kpi .detalhe { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.kpi.warn .valor { color: var(--warn); } .kpi.bad .valor { color: var(--danger); } .kpi.ok .valor { color: var(--ok); }
.cabecalho { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.cabecalho h1 { font-size: 20px; }
.cabecalho .acoes { margin-left: auto; }
.acoes { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- botões ---------- */
.btn { border: 1px solid transparent; border-radius: 9px; padding: 8px 14px; font: inherit; font-weight: 600; cursor: pointer; background: var(--navy); color: #fff; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover { filter: brightness(1.08); }
.btn.sec { background: #e8ebf1; color: var(--text); }
.btn.sec:hover { filter: brightness(.96); }
.btn.ok { background: var(--ok); } .btn.bad { background: var(--danger); } .btn.warn { background: var(--gold); }
.btn.mini, .btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }
.btn-ghost { background: transparent; border-color: rgba(255,255,255,.3); color: #dfe5f0; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-link { background: none; border: none; color: var(--info); cursor: pointer; padding: 0; font: inherit; text-decoration: underline; }

/* ---------- formulários ---------- */
input, select, textarea { font: inherit; border: 1px solid #cfd5df; border-radius: 8px; padding: 8px 10px; background: #fff; color: var(--text); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(43,108,176,.25); border-color: var(--info); }
input[readonly] { background: #f7f8fb; color: var(--muted); }
textarea { min-height: 80px; resize: vertical; }
label { display: block; font-size: 12.5px; color: #4b5563; font-weight: 500; margin-bottom: 4px; }
.campo { margin-bottom: 12px; }
.linha { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text); }
.check input { width: 18px; height: 18px; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 0 0 12px; }
legend { font-size: 12.5px; font-weight: 600; color: var(--navy); padding: 0 6px; }

/* ---------- tabelas ---------- */
.tabela-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { background: #f7f8fb; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .3px; white-space: nowrap; }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fafbfd; }
tr.total td { font-weight: 700; background: #f7f8fb; border-top: 2px solid var(--line); }
.card > table { border: 0; }

/* ---------- etiquetas ---------- */
.tag { display: inline-block; padding: 2px 8px; border-radius: 7px; font-size: 11.5px; font-weight: 600; background: #eef1f6; color: #374151; white-space: nowrap; }
.tag.paga { background: #e3f5ec; color: var(--ok); }
.tag.aberta { background: #e1ecfa; color: var(--info); }
.tag.atrasada { background: #fbe4e1; color: var(--danger); }
.tag.cancelada { background: #eef1f6; color: var(--muted); }
.tag.praca { background: #f3e9d7; color: #6b4e1a; }
.tag.alerta { background: #fdf1d8; color: #8a5d00; }

/* ---------- alertas ---------- */
.alerta { display: flex; gap: 8px; padding: 8px 12px; border-radius: 9px; background: #fdf1d8; color: #8a5d00; margin-bottom: 6px; font-size: 13.5px; border-left: 3px solid var(--warn); }
.alerta.bad { background: #fbe4e1; color: var(--danger); border-left-color: var(--danger); }
.alerta.info { background: #e1ecfa; color: var(--info); border-left-color: var(--info); }

/* ---------- modal ---------- */
.modal-fundo { position: fixed; inset: 0; background: rgba(15,23,42,.55); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 30px 12px; overflow-y: auto; }
.modal { background: var(--card); border-radius: 16px; width: 100%; max-width: 760px; box-shadow: 0 30px 80px rgba(0,0,0,.35); animation: pop .15s ease-out; }
.modal .mod-cab { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal .mod-cab h2 { font-size: 17px; margin: 0; }
.modal .mod-corpo { padding: 18px 20px; max-height: calc(100vh - 170px); overflow: auto; }
.modal .mod-rodape { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.fechar { margin-left: auto; background: none; border: none; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- toast ---------- */
#toast { position: fixed; bottom: 20px; right: 20px; background: #111827; color: #fff; padding: 11px 16px; border-radius: 10px; font-size: 13.5px; z-index: 99; box-shadow: var(--shadow); opacity: 0; transition: opacity .2s; pointer-events: none; }
#toast.show { opacity: 1; }

/* ---------- totais e QR ---------- */
.totais { display: grid; grid-template-columns: 1fr auto; gap: 4px 24px; font-size: 13.5px; max-width: 420px; margin-left: auto; }
.totais .tot { font-weight: 700; font-size: 15px; border-top: 1px solid var(--line); padding-top: 4px; color: var(--navy); }
.qr-box { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.qr-box svg { border: 1px solid var(--line); border-radius: 8px; }

/* ---------- responsivo ---------- */
@media (max-width: 1000px) { .grade.c4 { grid-template-columns: repeat(2, 1fr); } .grade.c3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 800px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; box-shadow: 0 0 0 100vw rgba(0,0,0,.4); }
  .main { margin-left: 0; }
  .btn-icon { display: inline-block; }
  .grade.c2, .grade.c3, .grade.c4 { grid-template-columns: 1fr; }
  .view { padding: 14px 14px 80px; }
  .topbar { padding: 10px 14px; }
  th, td { padding: 8px 8px; font-size: 13px; }
  .esconde-mobile { display: none; }
  .cabecalho .acoes { margin-left: 0; }
}
@media print { .sidebar, .topbar { display: none; } .main { margin: 0; } }

/* título já aparece na barra superior */
.view .cabecalho > h1 { display: none; }
.view .cabecalho { margin-bottom: 12px; }
.view .cabecalho:has(> h1:only-child) { display: none; }
td .acoes { flex-wrap: nowrap; justify-content: flex-end; }
