:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-light: #eef2ff;
  --ok: #059669;
  --ok-bg: #ecfdf5;
  --pendente: #d97706;
  --pendente-bg: #fffbeb;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 8px 24px -12px rgba(15, 23, 42, 0.15);
  --shadow-lg: 0 20px 45px -15px rgba(15, 23, 42, 0.25);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.006em;
}

h1, h2, h3 {
  font-family: inherit;
}

a {
  color: var(--primary);
  text-decoration: none;
}

svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Topbar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 0.7rem 1.5rem;
  flex-wrap: wrap;
}

.topbar::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), #7c3aed, var(--primary));
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  font-weight: 800;
  font-size: 0.7rem;
  letter-spacing: 0.02em;
  box-shadow: 0 4px 10px -2px rgba(79, 70, 229, 0.5);
}

.brand-text {
  font-weight: 700;
  font-size: 1.02rem;
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.brand-text small {
  font-weight: 500;
  color: var(--text-muted);
  font-size: 0.7rem;
}

.topbar-nav {
  display: flex;
  gap: 0.25rem;
  background: var(--bg);
  padding: 0.25rem;
  border-radius: 999px;
}

.topbar-nav a {
  padding: 0.45rem 1rem;
  border-radius: 999px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.88rem;
  transition: background 0.15s ease, color 0.15s ease;
}

.topbar-nav a:hover {
  color: var(--text);
}

.topbar-nav a.ativo {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 700;
  font-size: 0.8rem;
}

.user-name {
  font-weight: 600;
  color: var(--text);
}

.btn-logout {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font-weight: 600;
  font-size: 0.85rem;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.btn-logout:hover {
  background: var(--danger-bg);
  border-color: #fecaca;
  color: var(--danger);
}

/* Layout */

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 1.75rem 1.5rem 3rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1.5rem 1.6rem;
  margin-bottom: 1.5rem;
}

.card h2 {
  margin: 0 0 1.1rem;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding-bottom: 1rem;
  margin-bottom: 0.9rem;
  border-bottom: 1px solid var(--border);
}

.card-header h2 {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.badge-count {
  background: var(--primary-light);
  color: var(--primary-dark);
  border-radius: 999px;
  padding: 0.1rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 700;
}

/* Flash messages */

.flash-list {
  margin-bottom: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.flash {
  padding: 0.75rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.flash-sucesso {
  background: var(--ok-bg);
  color: var(--ok);
}

.flash-erro {
  background: var(--danger-bg);
  color: var(--danger);
}

/* Forms */

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

input,
select,
textarea {
  font: inherit;
  padding: 0.6rem 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: var(--bg);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 3.5px rgba(79, 70, 229, 0.14);
}

textarea {
  resize: vertical;
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  background-size: 18px;
  padding-right: 2.2rem;
}

.grid-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
}

.span-2 {
  grid-column: span 2;
}

.form-actions {
  display: flex;
  align-items: flex-end;
  gap: 0.6rem;
}

/* Buttons */

button {
  font: inherit;
  cursor: pointer;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border: none;
  padding: 0.62rem 1.3rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  transition: background 0.15s ease, transform 0.05s ease, box-shadow 0.15s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 10px -3px rgba(79, 70, 229, 0.45);
}

.btn-primary:hover {
  background: var(--primary-dark);
  box-shadow: 0 6px 16px -4px rgba(79, 70, 229, 0.55);
  transform: translateY(-1px);
}

.btn-secundario {
  background: var(--surface);
  border: 1.5px solid var(--border);
  color: var(--text);
}

.btn-secundario:hover {
  background: var(--bg);
}

.btn-block {
  width: 100%;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.btn-editar:hover {
  background: var(--primary-light);
  border-color: #c7d2fe;
  color: var(--primary-dark);
}

.btn-excluir:hover {
  background: var(--danger-bg);
  border-color: #fecaca;
  color: var(--danger);
}

/* Search input with icon */

.input-icon {
  position: relative;
  flex: 1;
  min-width: 220px;
  display: flex;
}

.input-icon svg {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.input-icon input {
  width: 100%;
  padding-left: 2.4rem;
}

/* Table filters (dashboard) */

.table-filtros {
  display: flex;
  gap: 0.6rem;
  margin: 0.25rem 0 1.1rem;
  flex-wrap: wrap;
}

.table-filtros select {
  min-width: 160px;
}

/* Table */

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

thead th {
  text-align: left;
  padding: 0.6rem 0.7rem;
  color: var(--text-muted);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1.5px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 0.65rem 0.7rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:hover {
  background: var(--bg);
}

.linha-vazia:hover {
  background: transparent;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  padding: 2.5rem 0.7rem;
  color: var(--text-muted);
}

.empty-state svg {
  width: 34px;
  height: 34px;
  opacity: 0.6;
}

.empty-state p {
  margin: 0;
  font-size: 0.88rem;
}

.acoes {
  display: flex;
  gap: 0.4rem;
  white-space: nowrap;
}

.inline-form {
  display: inline;
}

/* Status pills / toggle */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.pill-ok,
.status-ok {
  background: var(--ok-bg);
  color: var(--ok);
}

.pill-pendente,
.status-pendente {
  background: var(--pendente-bg);
  color: var(--pendente);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: currentColor;
}

.status-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: none;
  border-radius: 999px;
  padding: 0.3rem 0.8rem;
  font-size: 0.78rem;
  font-weight: 700;
}

.status-toggle:hover {
  filter: brightness(0.95);
}

.status-toggle:disabled {
  opacity: 0.6;
  cursor: wait;
}

/* Report summary cards */

.resumo-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.resumo-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.resumo-icone {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
  background: var(--bg);
  color: var(--text-muted);
}

.resumo-icone-ok {
  background: var(--ok-bg);
  color: var(--ok);
}

.resumo-icone-pendente {
  background: var(--pendente-bg);
  color: var(--pendente);
}

.resumo-icone-percent {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.resumo-valor {
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.resumo-label {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.resumo-ok .resumo-valor {
  color: var(--ok);
}

.resumo-pendente .resumo-valor {
  color: var(--pendente);
}

.barra-progresso {
  height: 10px;
  border-radius: 999px;
  background: var(--pendente-bg);
  overflow: hidden;
  margin-bottom: 1.5rem;
  border: 1px solid var(--border);
}

.barra-progresso-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--ok), #10b981);
  border-radius: 999px;
  transition: width 0.4s ease;
}

.filtros-relatorio {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  align-items: end;
}

.filtros-relatorio .form-actions {
  grid-column: 1 / -1;
  justify-content: flex-start;
}

.btn-exportar {
  font-size: 0.85rem;
  padding: 0.5rem 1.1rem;
}

/* Login */

body.login-page .container {
  max-width: none;
  padding: 0;
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.login-panel {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  background: linear-gradient(160deg, var(--primary-dark), var(--primary) 55%, #6d28d9);
  color: #fff;
}

.login-panel::before,
.login-panel::after {
  content: "";
  position: absolute;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  filter: blur(10px);
}

.login-panel::before {
  width: 320px;
  height: 320px;
  top: -100px;
  right: -80px;
}

.login-panel::after {
  width: 260px;
  height: 260px;
  bottom: -100px;
  left: -60px;
  background: rgba(255, 255, 255, 0.08);
}

.login-panel-content {
  position: relative;
  z-index: 1;
  max-width: 380px;
}

.login-panel .brand-mark-lg {
  width: 56px;
  height: 56px;
  font-size: 0.9rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.16);
  box-shadow: none;
  backdrop-filter: blur(6px);
}

.login-panel h1 {
  margin: 1.2rem 0 0.6rem;
  font-size: 2rem;
  letter-spacing: -0.02em;
}

.login-panel > .login-panel-content > p {
  margin: 0;
  opacity: 0.85;
  line-height: 1.55;
  font-size: 0.95rem;
}

.login-features {
  list-style: none;
  padding: 0;
  margin: 1.75rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.login-features li {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.9rem;
  opacity: 0.92;
}

.login-features li::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #fff;
  opacity: 0.85;
  flex-shrink: 0;
}

.login-form-side {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: var(--surface);
}

.login-card {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.login-form-brand {
  display: none;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}

.login-form-brand strong {
  font-size: 1rem;
}

.login-card h2 {
  margin: 0;
  font-size: 1.4rem;
  letter-spacing: -0.015em;
}

.login-sub {
  margin: 0.35rem 0 0;
  color: var(--text-muted);
  font-size: 0.88rem;
}

@media (max-width: 860px) {
  .login-wrap {
    grid-template-columns: 1fr;
  }

  .login-panel {
    display: none;
  }

  .login-form-side {
    min-height: 100vh;
  }

  .login-form-brand {
    display: flex;
  }
}

/* Modal */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 50;
}

.modal-overlay[hidden] {
  display: none;
}

.modal-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 1.6rem;
  width: 100%;
  max-width: 480px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  box-shadow: var(--shadow-lg);
  animation: modal-in 0.18s ease;
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-card h2 {
  grid-column: 1 / -1;
  margin: 0 0 0.25rem;
  font-size: 1.05rem;
}

/* Responsive */

@media (max-width: 960px) {
  .grid-form {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 720px) {
  .container {
    padding: 1.25rem 1rem 2.5rem;
  }

  .card {
    padding: 1.2rem;
  }

  .grid-form,
  .modal-card,
  .filtros-relatorio {
    grid-template-columns: 1fr;
  }

  .span-2,
  .filtros-relatorio .form-actions,
  .modal-card h2 {
    grid-column: 1;
  }

  .topbar {
    padding: 0.6rem 1rem;
  }

  .topbar-nav {
    order: 3;
    width: 100%;
    justify-content: center;
  }

  .brand-text small {
    display: none;
  }

  .user-name {
    display: none;
  }
}

@media (max-width: 640px) {
  thead {
    display: none;
  }

  table,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  tbody tr {
    margin-bottom: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.3rem 0.9rem;
    box-shadow: var(--shadow-sm);
  }

  tbody tr:hover {
    background: var(--surface);
  }

  tbody td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    border: none;
    border-bottom: 1px dashed var(--border);
    padding: 0.55rem 0;
    text-align: right;
  }

  tbody td:last-child {
    border-bottom: none;
  }

  tbody td::before {
    content: attr(data-label);
    font-weight: 700;
    color: var(--text-muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    text-align: left;
  }

  .linha-vazia {
    border: none !important;
    box-shadow: none !important;
  }

  .linha-vazia td {
    display: block;
    text-align: center;
  }

  .linha-vazia td::before {
    content: none;
  }

  .acoes {
    justify-content: flex-end;
  }
}
