:root {
  --navy-900: #081c36;
  --navy-700: #0d2b52;
  --navy-500: #1d4f91;
  --navy-100: #e8eef7;
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #12213a;
  --muted: #5a6b85;
  --line: #dde5f0;
  --green: #178a4c;
  --green-bg: #e3f4ea;
  --amber: #a86f00;
  --amber-bg: #fdf2d7;
  --red: #c0392b;
  --red-bg: #fde6e3;
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
}

/* ---------- topo ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--navy-700);
  color: #fff;
  padding: calc(env(safe-area-inset-top) + 14px) 16px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 56px;
}
.topbar h1 { font-size: 1.15rem; font-weight: 700; letter-spacing: 0.02em; }
.topbar .sub { font-size: 0.8rem; color: #b9c9e2; }

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px calc(env(safe-area-inset-bottom) + 150px);
}

/* ---------- navegação inferior ---------- */
.bottomnav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 0 8px;
  font-size: 0.7rem;
  color: var(--muted);
  text-decoration: none;
}
.bottomnav a.active { color: var(--navy-500); font-weight: 700; }
.bottomnav svg { width: 24px; height: 24px; }

/* ---------- navegação de data ---------- */
.datenav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}
.datenav .when { text-align: center; flex: 1; }
.datenav .when strong { display: block; font-size: 1.05rem; text-transform: capitalize; }
.datenav .when .chip { margin-top: 2px; }
.datenav button.nav {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--navy-700);
  font-size: 1.4rem;
  font-weight: 700;
}
.datenav .navslot { width: 48px; height: 48px; flex: none; }
.datenav .when.is-today {
  background: var(--navy-100);
  border-radius: 12px;
  padding: 6px 10px;
}
.today-label {
  display: block;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--navy-500);
  letter-spacing: 0.02em;
}
.today-date {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: capitalize;
}

/* ---------- cartões ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: 0 1px 2px rgba(8, 28, 54, 0.05);
}
.card .row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--navy-100);
  color: var(--navy-700);
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  font-size: 1.05rem;
}
.who { flex: 1; min-width: 0; }
.who .name { font-weight: 700; font-size: 1.02rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who .rate { font-size: 0.8rem; color: var(--muted); }
.owed {
  text-align: right;
  text-decoration: none;
  color: inherit;
  flex: none;
}
.owed .label { font-size: 0.7rem; color: var(--muted); }
.owed .value { font-weight: 800; color: var(--navy-500); font-size: 1.02rem; white-space: nowrap; }
.owed .value::after { content: " ›"; color: var(--muted); font-weight: 400; }

/* ---------- seletor de status ---------- */
.seg {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  margin-top: 12px;
}
.seg button {
  padding: 12px 4px;
  border-radius: 10px;
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 700;
}
.seg button.on-present { background: var(--green-bg); border-color: var(--green); color: var(--green); }
.seg button.on-half { background: var(--amber-bg); border-color: var(--amber); color: var(--amber); }
.seg button.on-absent { background: var(--red-bg); border-color: var(--red); color: var(--red); }
.seg button:disabled { opacity: 0.55; }

.chip {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}
.chip.navy { background: var(--navy-100); color: var(--navy-700); }
.chip.green { background: var(--green-bg); color: var(--green); }
.chip.amber { background: var(--amber-bg); color: var(--amber); }
.chip.red { background: var(--red-bg); color: var(--red); }
.chip.gray { background: #eef1f6; color: var(--muted); }

/* ---------- botões ---------- */
button { font: inherit; cursor: pointer; touch-action: manipulation; }
.btn {
  display: block;
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  border: none;
  font-weight: 700;
  font-size: 1rem;
  text-align: center;
  text-decoration: none;
}
.btn.primary { background: var(--navy-700); color: #fff; }
.btn.primary:active { background: var(--navy-900); }
.btn.ghost { background: none; border: 1.5px solid var(--navy-700); color: var(--navy-700); }
.btn.danger { background: var(--red); color: #fff; }
.btn.small { width: auto; padding: 10px 14px; font-size: 0.88rem; }
.btn:disabled { opacity: 0.6; }

.fab {
  position: fixed;
  right: 16px;
  bottom: calc(env(safe-area-inset-bottom) + 112px);
  z-index: 9;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: var(--navy-500);
  color: #fff;
  font-size: 1.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0 3px;
  opacity: 0.85;
  box-shadow: 0 4px 14px rgba(13, 43, 82, 0.35);
}

/* ---------- banner de pendências ---------- */
.banner {
  background: var(--navy-700);
  color: #fff;
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.banner p { margin-bottom: 10px; font-size: 0.92rem; }
.banner .actions { display: flex; gap: 8px; }
.banner .btn.small { background: #fff; color: var(--navy-700); }
.banner .btn.small.ghost { background: none; border: 1.5px solid #fff; color: #fff; }

/* ---------- rodapé de totais ---------- */
.totals {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(env(safe-area-inset-bottom) + 56px);
  z-index: 8;
  background: var(--navy-900);
  color: #fff;
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  font-size: 0.88rem;
}
.totals strong { font-size: 1rem; }

/* ---------- formulários ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 0.85rem; font-weight: 700; margin-bottom: 6px; color: var(--navy-700); }
.field input {
  width: 100%;
  padding: 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  font-size: 1.05rem;
  background: var(--card);
  color: var(--text);
}
.field input:focus { outline: 2px solid var(--navy-500); border-color: var(--navy-500); }
.error { color: var(--red); font-size: 0.88rem; margin: 8px 0; min-height: 1.2em; }

dialog {
  border: none;
  border-radius: var(--radius);
  padding: 20px;
  width: min(92vw, 420px);
  margin: auto;
}
dialog::backdrop { background: rgba(8, 28, 54, 0.55); }
dialog h2 { font-size: 1.1rem; margin-bottom: 14px; color: var(--navy-700); }
.dialog-actions { display: flex; gap: 8px; margin-top: 6px; }
.dialog-actions .btn { flex: 1; }

/* ---------- login ---------- */
.login-wrap { padding-top: 8vh; }
.login-logo { text-align: center; margin-bottom: 24px; }
.login-logo .mark {
  width: 84px;
  height: 84px;
  border-radius: 22px;
  margin: 0 auto 12px;
  background: var(--navy-700);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
  font-weight: 800;
}
.login-logo h1 { color: var(--navy-700); font-size: 1.6rem; }
.login-logo p { color: var(--muted); font-size: 0.9rem; margin-top: 4px; }
.tabs { display: flex; gap: 6px; margin-bottom: 16px; background: var(--navy-100); border-radius: 12px; padding: 4px; }
.tabs button {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: 9px;
  background: none;
  font-weight: 700;
  color: var(--navy-700);
}
.tabs button.active { background: var(--navy-700); color: #fff; }

/* ---------- listas e detalhes ---------- */
.section-title {
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 18px 0 8px;
}
.linelist { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.linelist .line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 0.92rem;
  color: inherit;
  text-decoration: none;
}
.linelist .line:last-child { border-bottom: none; }
.linelist .muted { color: var(--muted); font-size: 0.82rem; }

.bigtotal { text-align: center; padding: 18px 0 6px; }
.bigtotal .value { font-size: 2rem; font-weight: 800; color: var(--navy-700); }
.bigtotal .sub { color: var(--muted); font-size: 0.9rem; margin-top: 2px; }

.empty { text-align: center; color: var(--muted); padding: 40px 20px; font-size: 0.95rem; }
.empty .big { font-size: 2.6rem; margin-bottom: 10px; }

.iconbtn {
  border: none;
  background: none;
  color: var(--muted);
  padding: 8px;
  border-radius: 8px;
  flex: none;
}
.iconbtn svg { width: 20px; height: 20px; display: block; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 120px);
  transform: translateX(-50%);
  z-index: 50;
  background: var(--navy-900);
  color: #fff;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 0.9rem;
  max-width: 90vw;
  text-align: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}
.toast.err { background: var(--red); }

a.card.rowlink { display: block; text-decoration: none; color: inherit; }
a.card.rowlink:active { background: var(--navy-100); }

.hint { color: var(--muted); font-size: 0.82rem; margin-bottom: 10px; }

.picklist {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
  max-height: 50vh;
  overflow-y: auto;
}
.picklist label {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  font-weight: 600;
}
.picklist input { width: 20px; height: 20px; flex: none; accent-color: var(--navy-500); }
.picklist .muted { margin-left: auto; color: var(--muted); font-weight: 400; font-size: 0.85rem; }

.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.checks label {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  font-weight: 600;
}
.checks input { width: 20px; height: 20px; accent-color: var(--navy-500); }
