:root {
  --color-primary: #e63946;
  --color-primary-dark: #c1121f;
  --color-text: #2b2d42;
  --color-muted: #6c757d;
  --color-bg: #f4f6f9;
  --color-card: #ffffff;
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--color-text);
  background: var(--color-bg);
}

body.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #fff 0%, #fde8ea 100%);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--color-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 32px 28px;
}

.logo-wrap {
  text-align: center;
  margin-bottom: 24px;
}

.logo-wrap img {
  max-width: 220px;
  width: 100%;
  height: auto;
}

.login-card h1 {
  font-size: 1.35rem;
  margin: 0 0 8px;
  text-align: center;
}

.login-card p.subtitle {
  text-align: center;
  color: var(--color-muted);
  margin: 0 0 24px;
  font-size: 0.95rem;
}

.input-group {
  position: relative;
  margin-bottom: 16px;
}

.input-group i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-muted);
}

.input-group input {
  width: 100%;
  height: 48px;
  border: 1px solid #dde3ea;
  border-radius: 10px;
  padding: 0 14px 0 42px;
  font-size: 1rem;
}

.input-group input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(230, 57, 70, 0.15);
}

.btn-primary {
  width: 100%;
  height: 48px;
  border: none;
  border-radius: 10px;
  background: var(--color-primary);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary:hover { background: var(--color-primary-dark); }

.error-message {
  display: none;
  background: #fde8ea;
  color: #b00020;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}

.success-message {
  display: none;
  background: #e8f5e9;
  color: #1b5e20;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}

#loader {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.85);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

#loader.show { display: flex; }

.loader-spinner {
  width: 42px;
  height: 42px;
  border: 4px solid #eee;
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Dashboard */
.portal-header {
  background: #fff;
  border-bottom: 1px solid #e8edf2;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.portal-header img { max-height: 48px; }

.portal-main {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.welcome-card, .filters-card, .table-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 20px;
  margin-bottom: 20px;
}

.welcome-card h2 {
  margin: 0 0 6px;
  font-size: 1.4rem;
}

.welcome-card p {
  margin: 0;
  color: var(--color-muted);
}

.filters-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  align-items: end;
}

.filters-row label {
  display: block;
  font-size: 0.85rem;
  margin-bottom: 4px;
  color: var(--color-muted);
}

.filters-row select,
.filters-row .btn-filter {
  width: 100%;
  height: 40px;
  border-radius: 8px;
  border: 1px solid #dde3ea;
  padding: 0 10px;
}

.btn-filter {
  background: #17a2b8;
  color: #fff;
  border: none;
  cursor: pointer;
  font-weight: 600;
}

.btn-logout {
  background: transparent;
  border: 1px solid #dde3ea;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  color: var(--color-text);
}

.table-card table {
  width: 100%;
  border-collapse: collapse;
}

.table-card th,
.table-card td {
  padding: 12px 10px;
  border-bottom: 1px solid #eef2f6;
  text-align: left;
}

.table-card th {
  background: #f8f9fb;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--color-muted);
}

.btn-download {
  background: #28a745;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 0.9rem;
}

.btn-download:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.pagination-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.pagination-bar .btn-page {
  border: 1px solid #dde3ea;
  background: #fff;
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
}

.pagination-bar .btn-page.active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

.pagination-bar .btn-page:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.empty-state {
  text-align: center;
  color: var(--color-muted);
  padding: 24px 12px;
}

.portal-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.tab-btn {
  border: 1px solid #dde3ea;
  background: #fff;
  border-radius: 999px;
  padding: 10px 18px;
  cursor: pointer;
  color: var(--color-text);
  font-weight: 600;
}

.tab-btn.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.grupos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.grupo-card {
  background: var(--color-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 18px;
}

.grupo-card-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 8px;
}

.grupo-card h3 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.35;
}

.grupo-meta {
  margin: 4px 0;
  font-size: 0.9rem;
  color: var(--color-muted);
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge-ok { background: #d4edda; color: #155724; }
.badge-off { background: #f8d7da; color: #721c24; }

.progress {
  width: 100%;
  height: 22px;
  background: #eef2f6;
  border-radius: 999px;
  overflow: hidden;
  margin: 12px 0;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #38bdf8);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  transition: width .25s ease;
}

.btn-colaboradores {
  width: 100%;
  border: none;
  border-radius: 8px;
  padding: 10px 12px;
  background: #2b2d42;
  color: #fff;
  cursor: pointer;
  font-weight: 600;
}

.portal-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 30, 0.45);
  z-index: 1000;
  padding: 20px;
  align-items: center;
  justify-content: center;
}

.portal-modal.show { display: flex; }

.portal-modal-dialog {
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow: auto;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}

.portal-modal-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 8px;
  align-items: flex-start;
}

.portal-modal-header h3 {
  margin: 0 0 4px;
  font-size: 1.1rem;
}

.modal-meta {
  margin: 0;
  color: var(--color-muted);
  font-size: 0.9rem;
}

.btn-modal-close {
  border: none;
  background: transparent;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  color: var(--color-muted);
}

.portal-modal-body { padding: 8px 20px 20px; }

.modal-avance-wrap { margin-bottom: 14px; }

#tb-colaboradores {
  width: 100%;
  border-collapse: collapse;
}

#tb-colaboradores th,
#tb-colaboradores td {
  padding: 10px 8px;
  border-bottom: 1px solid #eef2f6;
  text-align: left;
}

#tb-colaboradores th {
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--color-muted);
}

@media (max-width: 600px) {
  .table-card table, .table-card thead, .table-card tbody, .table-card th, .table-card td, .table-card tr {
    display: block;
  }
  .table-card thead { display: none; }
  .table-card tr {
    margin-bottom: 12px;
    border: 1px solid #eef2f6;
    border-radius: 8px;
    padding: 8px;
  }
  .table-card td {
    border: none;
    padding: 6px 8px;
  }
  .table-card td::before {
    content: attr(data-label);
    font-weight: 600;
    display: block;
    font-size: 0.75rem;
    color: var(--color-muted);
    margin-bottom: 2px;
  }
}
