/* ROTIFIN: estilos do app. Mobile-first; a partir de 900px vira menu lateral. */

:root {
  --navy: #071B49;
  --surface: #063A85;
  --surface-2: #0A2A66;
  --action: #0878D1;
  --highlight: #27B9F2;
  --cyan: #19D3E5;
  --text: #FFFFFF;
  --muted: #AFC3D8;
  --green: #22C55E;
  --red: #EF4444;
  /* Vermelho claro para TEXTO sobre fundo escuro (contraste AA). */
  --red-text: #FCA5A5;
  --line: rgba(175, 195, 216, 0.25);
  --radius: 14px;
  --font: Montserrat, "Segoe UI", Roboto, "Helvetica Neue", Arial, system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--navy);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
}

a { color: var(--highlight); }

button, input, select, textarea { font: inherit; color: inherit; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

:focus-visible { outline: 3px solid var(--cyan); outline-offset: 2px; }

/* ---------- login ---------- */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px 16px;
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--surface); border-radius: var(--radius); padding: 28px 22px;
}
.login-logo { display: block; width: 180px; max-width: 70%; height: auto; margin: 0 auto 6px; }
.login-tagline { text-align: center; color: var(--muted); margin: 0 0 22px; }
/* Logotipo em texto: "ROTI" branco e "FIN" em azul claro (a logo PNG tem texto escuro, feito para fundo claro). */
.wordmark { text-align: center; font-size: 32px; font-weight: 800; font-style: italic; letter-spacing: 0.04em; margin: 0; }
.wordmark span, .wordmark-small span { color: var(--highlight); }
.wordmark-small { font-style: italic; font-weight: 800; }
.check-row { display: flex; align-items: center; gap: 10px; margin: 6px 0 18px; }
.check-row input { width: 20px; height: 20px; }

/* ---------- estrutura ---------- */
.app-shell { min-height: 100vh; padding-bottom: 76px; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--navy); border-bottom: 1px solid var(--line);
  padding: 10px 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: 0.06em; margin-right: auto; }
.brand img { width: 40px; height: 30px; object-fit: contain; }

.month-picker { display: flex; align-items: center; gap: 4px; }
.month-picker .month-label { width: auto; min-width: 170px; padding: 0 10px; text-align: center; font-weight: 700; white-space: nowrap; }
.icon-btn {
  background: var(--surface); border: 0; border-radius: 10px;
  width: 40px; height: 40px; cursor: pointer; font-size: 18px;
}
.icon-btn:hover { background: var(--action); }

.owner-filter { width: auto; min-width: 150px; flex: 1 1 150px; max-width: 260px; }

.future-note {
  width: 100%; margin: 0; font-size: 13px; color: var(--cyan);
}

.sidenav { display: none; }

.bottombar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface-2); border-top: 1px solid var(--line);
}
.bottombar a, .sidenav a {
  color: var(--muted); text-decoration: none; text-align: center;
  padding: 10px 2px 12px; font-size: 12px; font-weight: 600;
}
.bottombar a .nav-icon { display: block; font-size: 20px; line-height: 1.2; }
.bottombar a[aria-current="page"], .sidenav a[aria-current="page"] { color: var(--text); }
.bottombar a[aria-current="page"] .nav-icon { color: var(--highlight); }

main { padding: 16px; max-width: 1100px; margin: 0 auto; }
main h1 { font-size: 22px; margin: 4px 0 14px; }
main h2 { font-size: 17px; margin: 0 0 10px; }

@media (min-width: 900px) {
  .app-shell { display: grid; grid-template-columns: 230px 1fr; grid-template-rows: auto 1fr; padding-bottom: 0; }
  .topbar { grid-column: 1 / -1; }
  .bottombar { display: none; }
  .sidenav {
    display: flex; flex-direction: column; gap: 2px; padding: 16px 10px;
    border-right: 1px solid var(--line); min-height: calc(100vh - 62px);
  }
  .sidenav a { text-align: left; font-size: 15px; padding: 10px 14px; border-radius: 10px; }
  .sidenav a[aria-current="page"] { background: var(--surface); }
  .sidenav hr { border: 0; border-top: 1px solid var(--line); width: 100%; }
  main { width: 100%; padding: 22px 28px; }
}

/* ---------- componentes ---------- */
.card {
  background: var(--surface); border-radius: var(--radius); padding: 16px; margin-bottom: 14px;
}
.grid { display: grid; gap: 12px; }
/* No celular, os cartões de números ficam lado a lado para economizar espaço. */
.grid-3, .grid-2.stats { grid-template-columns: repeat(2, 1fr); }
.grid-3 > .card, .grid-2.stats > .card { margin-bottom: 0; padding: 12px; }
.grid-3, .grid-2.stats { margin-bottom: 12px; }
@media (max-width: 639px) {
  .stat .value { font-size: 18px; }
}
@media (min-width: 640px) {
  .grid-2 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .grid-4 { grid-template-columns: repeat(4, 1fr); }
}
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 22px; font-weight: 800; }
.stat .hint { color: var(--muted); font-size: 12px; }

.positive { color: var(--green); }
.negative { color: var(--red-text); }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar .grow { flex: 1 1 180px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--action); color: #fff; border: 0; border-radius: 10px;
  padding: 10px 16px; font-weight: 700; cursor: pointer; min-height: 42px;
}
.btn:hover { filter: brightness(1.1); }
.btn.secondary { background: transparent; border: 1px solid var(--muted); }
.btn.danger { background: transparent; border: 1px solid var(--red); color: var(--red-text); }
.btn.small { padding: 6px 10px; min-height: 34px; font-size: 14px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: 0.6; cursor: wait; }

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field label { font-size: 14px; font-weight: 600; color: var(--muted); }
.field small { color: var(--muted); font-size: 12px; }
input[type="text"], input[type="email"], input[type="password"], input[type="date"],
input[type="number"], input[type="search"], select, textarea {
  width: 100%; background: var(--navy); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; min-height: 44px;
}
input[aria-invalid="true"] { border-color: var(--red); }
textarea { min-height: 70px; resize: vertical; }

.list { list-style: none; margin: 0; padding: 0; }
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: 0; }
.row .main { flex: 1; min-width: 0; }
.row .title { font-weight: 700; overflow-wrap: anywhere; }
.row .meta { color: var(--muted); font-size: 13px; }
.row .amount { font-weight: 800; white-space: nowrap; text-align: right; }
.row .actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.paid-toggle {
  width: 40px; height: 40px; border-radius: 50%; flex: none; cursor: pointer;
  border: 2px solid var(--muted); background: transparent; font-size: 18px; color: transparent;
}
.paid-toggle[aria-pressed="true"] { background: var(--green); border-color: var(--green); color: var(--navy); }

.badge {
  display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); margin-left: 6px; vertical-align: middle;
}
.badge.alert { background: var(--red); color: #fff; }
.badge.ok { background: var(--green); color: var(--navy); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  background: var(--surface-2); border: 1px solid var(--line); color: var(--muted);
  border-radius: 999px; padding: 6px 12px; cursor: pointer; font-weight: 600; font-size: 14px;
}
.chip[aria-pressed="true"] { background: var(--action); color: #fff; border-color: var(--action); }

.bar-row { margin-bottom: 10px; }
.bar-row .bar-head { display: flex; justify-content: space-between; font-size: 14px; gap: 8px; }
.bar { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-top: 4px; }
.bar > span { display: block; height: 100%; background: var(--highlight); border-radius: 999px; }

.empty { color: var(--muted); text-align: center; padding: 18px 8px; }

.menu-list a {
  display: flex; justify-content: space-between; align-items: center;
  color: var(--text); text-decoration: none; padding: 14px 4px; border-bottom: 1px solid var(--line); font-weight: 600;
}

.notice { background: var(--surface-2); border-left: 4px solid var(--cyan); padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; font-size: 14px; }
.error-box { background: rgba(239, 68, 68, 0.15); border-left: 4px solid var(--red); padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; }

/* ---------- janela (dialog) ---------- */
dialog {
  border: 0; border-radius: var(--radius); padding: 0; width: min(560px, calc(100vw - 24px));
  background: var(--surface); color: var(--text); max-height: calc(100vh - 24px);
}
dialog::backdrop { background: rgba(3, 10, 30, 0.7); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 6px; }
.dialog-head h2 { margin: 0; font-size: 18px; }
.dialog-body { padding: 8px 18px 18px; overflow-y: auto; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 8px; }

.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%);
  background: var(--action); color: #fff; padding: 10px 16px; border-radius: 10px;
  font-weight: 600; max-width: calc(100vw - 32px); z-index: 50; display: none;
}
.toast.show { display: block; }
.toast.error { background: var(--red); }

.password-box {
  font-family: Consolas, "Courier New", monospace; font-size: 18px; background: var(--navy);
  padding: 10px; border-radius: 8px; user-select: all; overflow-wrap: anywhere;
}
