:root {
  --bg: #eef1f6;
  --bg-deep: #e2e7ef;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --ink: #152033;
  --muted: #5b6b7c;
  --line: #d5dde8;
  --line-strong: #b8c4d4;
  --brand: #1a365d;
  --brand-mid: #234876;
  --brand-soft: #e8eef7;
  --accent: #1d6a9f;
  --accent-soft: #e3f0f8;
  --danger: #b42318;
  --danger-soft: #fef3f2;
  --ok: #067647;
  --ok-soft: #ecfdf3;
  --warn: #b54708;
  --warn-soft: #fffaeb;
  --shadow: 0 1px 2px rgba(21, 32, 51, 0.04), 0 8px 24px rgba(21, 32, 51, 0.06);
  --radius: 8px;
  --radius-sm: 6px;
  --font: "Source Sans 3", "Segoe UI", sans-serif;
  --display: "Source Sans 3", "Segoe UI", sans-serif;
  --topbar-h: 60px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: var(--font);
  font-size: 15.5px;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ——— Topbar corporativa ——— */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--topbar-h);
  background: var(--brand);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 2px 8px rgba(15, 30, 55, 0.18);
}

.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
}

.brand-logo-wrap {
  width: 168px;
  min-height: 42px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  padding: 0.35rem 0.7rem;
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.brand-logo {
  width: 100%;
  height: auto;
  max-height: 34px;
  display: block;
  object-fit: contain;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-text strong {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.01em;
}

.brand-text small {
  color: rgba(255, 255, 255, 0.62);
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.15rem;
}

.nav a {
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, 0.72);
  font-weight: 600;
  font-size: 0.92rem;
  transition: background 0.15s, color 0.15s;
}

.nav a:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.nav a.is-active {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.nav a[href="logout.php"] {
  margin-left: 0.35rem;
  color: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.nav a[href="logout.php"]:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.35);
}

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  flex-shrink: 0;
}

.nav-toggle-bar {
  display: block;
  width: 1.15rem;
  height: 2px;
  margin: 0 auto;
  background: #fff;
  border-radius: 1px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(2) {
  opacity: 0;
}

.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

body.nav-open {
  overflow: hidden;
}

/* ——— Página ——— */
.page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.75rem 1.5rem 3rem;
}

.footer {
  text-align: center;
  color: var(--muted);
  padding: 0 1rem 2rem;
  font-size: 0.85rem;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}

.page-head h1,
.section-title,
.login-card h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.page-head h1 {
  font-size: 1.65rem;
}

.section-title {
  font-size: 1.05rem;
}

.page-head p,
.muted {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

/* ——— Stats / painéis ——— */
.grid-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr));
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}

.grid-stats--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-stats--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-stats--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-stats--5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }

.stat-ok strong { color: var(--ok); }
.stat-warn strong { color: var(--warn); }
.stat-danger strong { color: var(--danger); }

.mb-1 { margin-bottom: 1rem; }
.mb-075 { margin-bottom: 0.75rem; }
.text-danger { color: var(--danger); }
.text-center { text-align: center; }
.table-wrap--plain { box-shadow: none; border: 0; }

.stat,
.panel,
.login-card,
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stat {
  padding: 1rem 1.15rem;
  position: relative;
  overflow: hidden;
}

.stat::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.4rem;
}

.stat strong {
  font-family: var(--display);
  font-size: 1.45rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.panel {
  padding: 1.25rem;
  margin-bottom: 1.15rem;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--line);
}

.charts {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 1rem;
}

.chart-box {
  min-height: 280px;
}

/* ——— Botões ——— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 0.65rem 1.1rem;
  font: inherit;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  background: var(--brand);
  color: #fff;
  transition: background 0.15s, box-shadow 0.15s;
}

.btn:hover {
  background: var(--brand-mid);
}

.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line-strong);
}

.btn-secondary:hover {
  background: var(--surface-2);
  border-color: var(--muted);
}

.btn-danger {
  background: var(--danger);
}

.btn-danger:hover {
  background: #912018;
}

.btn-small {
  padding: 0.35rem 0.7rem;
  font-size: 0.84rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

/* ——— Alertas ——— */
.alert {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  border: 1px solid transparent;
  font-size: 0.92rem;
  font-weight: 500;
}

.alert-success {
  background: var(--ok-soft);
  color: var(--ok);
  border-color: #a6f4c5;
}

.alert-error {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: #fecdca;
}

.alert-info {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: #fedf89;
}

/* ——— Tabelas ——— */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.table-wrap table {
  min-width: 640px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  font-size: 0.94rem;
}

th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  background: var(--surface-2);
  font-weight: 700;
  white-space: nowrap;
}

tr:last-child td { border-bottom: 0; }

tr:hover td {
  background: rgba(29, 106, 159, 0.03);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.badge-moveis { background: var(--brand-soft); color: var(--brand); }
.badge-portas { background: var(--accent-soft); color: var(--accent); }
.badge-fechado { background: var(--ok-soft); color: var(--ok); }
.badge-aberto { background: var(--warn-soft); color: var(--warn); }
.badge-falta { background: var(--danger-soft); color: var(--danger); }

/* ——— Formulários ——— */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.form-grid .full { grid-column: 1 / -1; }

.field-hint {
  margin: 0.35rem 0 0;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.45;
}

.form-section {
  margin-top: 0.5rem;
  padding-top: 0.25rem;
  border-top: 1px solid var(--line);
}

.form-section .section-title {
  margin-bottom: 0;
}

input.is-readonly,
input[readonly].cep-auto {
  background: var(--surface-soft, #f4f6f9);
  color: var(--ink-muted, #5a6478);
}

.check-row {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  cursor: pointer;
}

.check-row input[type="checkbox"] {
  width: auto;
  margin: 0;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
}

.photo-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #fff;
}

.photo-card a {
  display: block;
  aspect-ratio: 4 / 3;
  background: var(--surface-soft, #f4f6f9);
}

.photo-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.photo-meta {
  padding: 0.5rem 0.65rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.82rem;
}

label {
  display: block;
  margin-bottom: 0.3rem;
  font-weight: 600;
  font-size: 0.86rem;
  color: var(--ink);
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.8rem;
  font: inherit;
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(29, 106, 159, 0.15);
}

textarea { min-height: 100px; resize: vertical; }

input.money-br {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.filters form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  width: 100%;
  align-items: flex-end;
}

.filters label {
  margin-bottom: 0.25rem;
  font-size: 0.8rem;
}

.filters input,
.filters select {
  max-width: 280px;
}

/* ——— Tabs ——— */
.tabs {
  display: flex;
  gap: 0;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  border-bottom: 2px solid var(--line);
}

.tabs a {
  padding: 0.7rem 1.15rem;
  border-radius: 0;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.92rem;
}

.tabs a:hover {
  color: var(--ink);
  background: var(--surface-2);
}

.tabs a.is-active {
  background: transparent;
  border-bottom-color: var(--accent);
  color: var(--accent);
}

/* ——— Login ——— */
.login-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  background: var(--bg);
}

.login-aside {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 2.5rem 3rem;
  background:
    linear-gradient(160deg, rgba(26, 54, 93, 0.92), rgba(29, 106, 159, 0.85)),
    linear-gradient(135deg, #0f2744 0%, #1a365d 55%, #1d4e89 100%);
  color: #fff;
  position: relative;
  overflow: hidden;
}

.login-aside::after {
  content: "";
  position: absolute;
  inset: auto -20% -30% 20%;
  height: 70%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.08), transparent 65%);
  pointer-events: none;
}

.login-aside .brand-mark {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.25);
}

.login-aside .brand-logo-wrap {
  width: 220px;
  min-height: 58px;
  padding: 0.55rem 0.85rem;
}

.login-aside .brand {
  position: relative;
  z-index: 1;
}

.login-aside .brand-text strong,
.login-aside .brand-text small {
  color: #fff;
}

.login-aside .brand-text small {
  color: rgba(255, 255, 255, 0.7);
}

.login-aside-copy {
  position: relative;
  z-index: 1;
  max-width: 380px;
}

.login-aside-copy h2 {
  margin: 2.5rem 0 0.75rem;
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.login-aside-copy p {
  margin: 0;
  color: rgba(255, 255, 255, 0.78);
  font-size: 1rem;
  line-height: 1.55;
}

.login-aside-foot {
  position: relative;
  z-index: 1;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.55);
}

.login-main {
  display: grid;
  place-items: center;
  padding: 2rem 1.5rem;
}

.login-card {
  width: min(400px, 100%);
  padding: 2rem 2.1rem;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.login-card .brand {
  display: none;
}

.login-card h1 {
  font-size: 1.5rem;
  margin-bottom: 0.35rem;
}

.login-card form {
  display: grid;
  gap: 1rem;
  margin-top: 1.35rem;
}

.login-card .btn {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.8rem 1.1rem;
}

.stack {
  display: grid;
  gap: 1rem;
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.empty {
  padding: 2rem 1.5rem;
  text-align: center;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border: 1px dashed var(--line);
}

/* ——— Diárias / serviços ——— */
.dias-lista {
  display: grid;
  gap: 0.4rem;
  max-height: 320px;
  overflow: auto;
  padding: 0.25rem 0.1rem 0.1rem;
}

.dia-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.dia-row.is-sunday {
  border-color: #f5d0a0;
  background: var(--warn-soft);
}

.dia-row.is-falta {
  border-color: #fecdca;
  background: var(--danger-soft);
}

.dia-row.is-pago {
  border-color: #a6f4c5;
  background: var(--ok-soft);
}

.dia-row select {
  max-width: 160px;
  padding: 0.4rem 0.55rem;
}

.dia-info {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: baseline;
}

.period-nav {
  margin-bottom: 1rem;
}

.period-nav__controls {
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.period-nav__title {
  font-size: 1.05rem;
  display: block;
}

.period-nav__meta {
  font-size: 0.85rem;
}

.period-nav__form {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.btn.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.service-card {
  display: grid;
  gap: 0.2rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.service-card:hover {
  border-color: var(--line-strong);
  background: #fff;
}

.service-card.is-active {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(29, 106, 159, 0.12);
}

.service-card .badge {
  justify-self: start;
  margin-top: 0.3rem;
}

.rt-box {
  grid-column: 1 / -1;
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.check-line {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 600;
  cursor: pointer;
}

.check-line input {
  width: auto;
  margin: 0;
  accent-color: var(--accent);
}

.rt-preview {
  margin-top: 0.75rem;
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-sm);
  background: #fff;
  border: 1px solid var(--line);
  line-height: 1.45;
  font-size: 0.92rem;
}

.rt-summary {
  margin: 0 0 1.25rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.doc-section .panel-head {
  align-items: flex-start;
}

.doc-section .panel-head .muted {
  margin-top: 0.25rem;
}

details summary {
  cursor: pointer;
  list-style: none;
}

details summary::-webkit-details-marker {
  display: none;
}

/* ——— Modal ——— */
body.modal-open {
  overflow: hidden;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background: rgba(21, 32, 51, 0.52);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.18s ease;
}

.modal-backdrop.is-visible {
  opacity: 1;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  width: min(100%, 440px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 2px);
  box-shadow: 0 24px 48px rgba(21, 32, 51, 0.18);
  overflow: hidden;
  transform: translateY(10px) scale(0.98);
  transition: transform 0.18s ease;
}

.modal-backdrop.is-visible .modal {
  transform: translateY(0) scale(1);
}

.modal-folha-ponto {
  width: min(100%, 520px);
}

.modal-brand {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.35rem 1.5rem 1.25rem;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-mid) 100%);
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-brand-text h2 {
  margin: 0.15rem 0 0.35rem;
  font-size: 1.35rem;
  color: #fff;
}

.modal-brand-text p {
  margin: 0;
  font-size: 0.92rem;
  color: rgba(255, 255, 255, 0.82);
  max-width: 36ch;
  line-height: 1.45;
}

.modal-kicker {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.65);
}

.modal-close {
  border: 0;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.22);
}

.modal-body {
  padding: 1.25rem 1.5rem 1.5rem;
}

.modal-preview {
  margin-bottom: 1.1rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.modal-preview strong {
  display: block;
  margin-bottom: 0.45rem;
  font-size: 0.88rem;
  color: var(--ink);
}

.modal-preview ul {
  margin: 0;
  padding-left: 1.15rem;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.modal-form {
  gap: 0.85rem;
}

.modal-form label {
  font-size: 0.88rem;
  font-weight: 600;
}

.modal-form select,
.modal-form input[type="month"] {
  width: 100%;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 0.55rem;
  margin-top: 1.15rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.logo-preview-box {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 88px;
  padding: 1rem 1.15rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.logo-preview-img {
  max-width: 240px;
  max-height: 72px;
  width: auto;
  height: auto;
  display: block;
  object-fit: contain;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.modal-head h2 {
  margin: 0;
  font-size: 1.15rem;
}

/* ——— Responsivo ——— */
@media (max-width: 1200px) {
  .grid-stats--5 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .grid-stats--4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 960px) {
  .topbar {
    height: auto;
  }

  .topbar-inner {
    flex-wrap: wrap;
    align-items: center;
    height: auto;
    padding: 0.75rem 1rem;
    gap: 0.65rem;
  }

  .nav-toggle {
    display: inline-flex;
    margin-left: auto;
  }

  .nav {
    display: none;
    order: 3;
    flex-basis: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0.15rem;
    padding-top: 0.35rem;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
  }

  .nav.is-open {
    display: flex;
  }

  .nav a {
    padding: 0.75rem 1rem;
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  .nav a[href="logout.php"] {
    margin-left: 0;
    margin-top: 0.35rem;
  }

  .brand-logo-wrap {
    width: 148px;
    min-height: 38px;
  }

  .page {
    padding: 1.25rem 1rem 2.5rem;
  }

  .page-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .page-head .actions {
    width: 100%;
  }

  .page-head .actions .btn {
    flex: 1 1 auto;
    min-width: min(100%, 160px);
  }

  .charts,
  .split,
  .login-wrap {
    grid-template-columns: 1fr;
  }

  .grid-stats--2,
  .grid-stats--3,
  .grid-stats--4,
  .grid-stats--5 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .login-aside {
    min-height: 220px;
    padding: 1.75rem 1.5rem;
  }

  .login-aside-copy h2 {
    margin-top: 1.25rem;
    font-size: 1.4rem;
  }

  .filters input,
  .filters select {
    max-width: none;
    flex: 1 1 100%;
  }

  .panel-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .tabs a {
    flex: 1 1 auto;
    text-align: center;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .period-nav__controls {
    flex-direction: column;
    align-items: stretch;
  }

  .period-nav__controls > .actions {
    justify-content: space-between;
    width: 100%;
  }

  .period-nav__controls > div.text-center {
    order: -1;
  }

  td.actions {
    min-width: 130px;
  }

  td.actions .btn,
  td.actions form .btn {
    width: 100%;
  }
}

@media (max-width: 640px) {
  html, body {
    font-size: 15px;
  }

  .page-head h1 {
    font-size: 1.4rem;
  }

  .stat strong {
    font-size: 1.25rem;
  }

  .grid-stats,
  .grid-stats--2,
  .grid-stats--3,
  .grid-stats--4,
  .grid-stats--5 {
    grid-template-columns: 1fr;
  }

  .btn {
    min-height: 44px;
    padding: 0.7rem 1rem;
  }

  .btn-small {
    min-height: 40px;
    padding: 0.45rem 0.75rem;
  }

  .actions .btn {
    flex: 1 1 calc(50% - 0.25rem);
    min-width: 0;
  }

  .actions .btn:only-child {
    flex: 1 1 100%;
  }

  input, select, textarea {
    font-size: 16px;
  }

  .dia-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.55rem;
  }

  .dia-row select {
    max-width: none;
    width: 100%;
  }

  .dias-lista {
    max-height: none;
  }

  .table-wrap table {
    min-width: 560px;
  }

  .modal-backdrop {
    padding: 0;
    align-items: flex-end;
  }

  .modal {
    width: 100%;
    max-height: 92vh;
    max-height: 92dvh;
    border-radius: var(--radius) var(--radius) 0 0;
    overflow-y: auto;
  }

  .modal-folha-ponto {
    width: 100%;
  }

  .modal-foot {
    flex-direction: column-reverse;
  }

  .modal-foot .btn {
    width: 100%;
  }

  .photo-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  }

  .login-main {
    padding: 1.25rem 1rem 2rem;
  }

  .login-card {
    padding: 1.5rem 1.25rem;
  }

  .footer {
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
  }

  .page {
    padding-left: max(1rem, env(safe-area-inset-left, 0px));
    padding-right: max(1rem, env(safe-area-inset-right, 0px));
    padding-bottom: calc(2rem + env(safe-area-inset-bottom, 0px));
  }

  .topbar-inner {
    padding-left: max(1rem, env(safe-area-inset-left, 0px));
    padding-right: max(1rem, env(safe-area-inset-right, 0px));
  }
}

@media (max-width: 480px) {
  .actions .btn {
    flex: 1 1 100%;
  }

  .tabs {
    flex-direction: column;
    border-bottom: 0;
    gap: 0.35rem;
  }

  .tabs a {
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    margin-bottom: 0;
    border-bottom-width: 1px;
  }

  .tabs a.is-active {
    border-color: var(--accent);
    background: var(--accent-soft);
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
