* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --green: #16a34a;
  --yellow: #fbbf24;
  --red: #ef4444;
  --bg: #fafaf9;
  --card: #fff;
  --transition: all 0.3s ease;
}

body {
  font-family: system-ui, sans-serif;
  background: var(--bg);
  color: #0a0a0a;
  line-height: 1.6;
}

/* ==================== HIDDEN ==================== */
.hidden {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* ==================== LOGIN ==================== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--green), var(--yellow));
  padding: 20px;
}

.login-box {
  background: var(--card);
  padding: 40px;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-width: 440px;
  width: 100%;
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-header h1 {
  font-size: 32px;
  color: var(--green);
  margin-bottom: 8px;
}

/* ===============================
   MÉTRICAS DE LOGIN - CARDS
   =============================== */
.login-metrics {
  margin: 20px 0;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.metric-card {
  display: flex;
  align-items: center;
  padding: 12px;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  transition: transform 0.2s ease;
}

.metric-card:hover {
  transform: translateY(-2px);
}

.metric-card.total {
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  color: white;
}

.metric-card.ok {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
}

.metric-card.divergent {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: white;
}

.metric-card.missing {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: white;
}

.metric-card.count {
  background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
  color: white;
}

.metric-card.lines {
  background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
  color: white;
}

.metric-icon {
  font-size: 20px;
  margin-right: 10px;
  opacity: 0.9;
}

.metric-content {
  flex: 1;
}

.metric-label {
  font-size: 11px;
  opacity: 0.8;
  font-weight: 500;
  margin-bottom: 2px;
}

.metric-value {
  font-size: 14px;
  font-weight: bold;
}

@media (max-width: 480px) {
  .metrics-grid {
    grid-template-columns: 1fr;
  }
}

/* ==================== FORMS ==================== */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
}

input,
select,
textarea {
  width: 100%;
  padding: 12px;
  border: 2px solid #e5e5e5;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  transition: var(--transition);
}

input:focus,
select:focus,
textarea:focus {
  outline: 0;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.1);
}

input:disabled,
select:disabled,
textarea:disabled {
  background-color: #f3f4f6;
  cursor: not-allowed;
  color: #9ca3af;
}

/* ==================== BUTTONS ==================== */
.btn {
  width: 100%;
  padding: 12px 24px;
  border-radius: 8px;
  border: 0;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 10px;
}

.btn:focus {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--green);
  color: #fff;
}

.btn-primary:hover {
  background: #15803d;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(22, 163, 74, 0.3);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--yellow);
  color: #000;
}

.btn-secondary:hover {
  background: #f59e0b;
}

.btn-outline {
  background: transparent;
  border: 2px solid var(--green);
  color: var(--green);
}

.btn-outline:hover {
  background: var(--green);
  color: #fff;
}

.btn-cancel {
  background: #666;
  color: #fff;
}

.btn-cancel:hover {
  background: #555;
}

.btn-sm {
  padding: 8px 12px;
  font-size: 13px;
  width: auto;
  margin-bottom: 0;
}

/* ==================== CONTACT & STATS ==================== */
.contact {
  text-align: center;
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid #e5e5e5;
  font-size: 13px;
  color: #666;
}

.stats-box {
  background: linear-gradient(135deg, var(--green), #22c55e);
  color: #fff;
  padding: 20px;
  border-radius: 12px;
  margin-top: 20px;
  text-align: center;
}

/* ==================== ALERTS ==================== */
.alert {
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 16px;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.alert-error {
  background: #fee2e2;
  color: #dc2626;
  border: 2px solid var(--red);
}

.alert-success {
  background: #dcfce7;
  color: #15803d;
  border: 2px solid var(--green);
}

.alert-info {
  background: #e0f2fe;
  color: #0369a1;
  border: 2px solid #0ea5e9;
}

/* ==================== MODAL ==================== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  visibility: hidden;
  opacity: 0;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  pointer-events: none;
  backdrop-filter: blur(1px);
}

.modal:not(.hidden) {
  display: flex;
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--card);
  padding: 30px;
  border-radius: 16px;
  max-width: 800px;
  width: 92%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  max-height: 90vh;
  overflow-y: auto;
  animation: modalSlideIn 0.3s ease forwards;
  transform: translateY(0);
  opacity: 1;
  position: relative;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-30px);
    visibility: hidden;
  }
  to {
    opacity: 1;
    transform: translateY(0);
    visibility: visible;
  }
}

.modal.hidden .modal-content {
  animation: modalSlideOut 0.3s ease forwards;
}

@keyframes modalSlideOut {
  from {
    opacity: 1;
    transform: translateY(0);
    visibility: visible;
  }
  to {
    opacity: 0;
    transform: translateY(-30px);
    visibility: hidden;
  }
}

.modal-content h2 {
  color: var(--green);
  margin-bottom: 20px;
  font-size: 24px;
}

.modal-content h3 {
  color: var(--green);
  margin-bottom: 16px;
  font-size: 20px;
}

.modal-buttons {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.modal-small {
  max-width: 520px;
}

/* ==================== LAYOUT ==================== */
.app {
  display: flex;
  min-height: 100vh;
}

/* ==================== SIDEBAR ==================== */
.sidebar {
  width: 280px;
  background: #1e293b;
  color: #fff;
  padding: 24px 16px;
  overflow-y: auto;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
}

.sidebar h2 {
  font-size: 18px;
  margin-bottom: 20px;
}

.menu-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 8px;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 14px;
  margin-bottom: 6px;
  transition: var(--transition);
}

.menu-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.menu-btn:focus {
  outline: 2px solid #fff;
  outline-offset: -2px;
}

.menu-btn.active {
  background: var(--green);
  font-weight: 600;
}

.menu-btn.admin-only {
  display: none;
}

.menu-btn.admin-only.show {
  display: block;
}

/* ==================== MAIN CONTENT ==================== */
.main {
  flex: 1;
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  overflow-y: auto;
}

.header {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 3px solid var(--yellow);
}

.header h1 {
  font-size: 28px;
  color: var(--green);
}

/* ==================== STATS & CARDS ==================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card);
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  border-left: 4px solid var(--green);
  transition: var(--transition);
}

.stat-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.stat-label {
  font-size: 12px;
  color: #666;
  margin-bottom: 4px;
  text-transform: uppercase;
  font-weight: 600;
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--green);
}

.card {
  background: var(--card);
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  margin-bottom: 16px;
  border-left: 4px solid var(--yellow);
}

.card h3 {
  color: var(--green);
  margin-bottom: 16px;
}

/* ==================== TABLES ==================== */
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
}

th,
td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid #e5e5e5;
}

th {
  background: var(--green);
  color: #fff;
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 600;
}

tr:hover {
  background-color: #f9fafb;
}

/* ==================== USER BADGE ==================== */
.user-badge {
  background: var(--green);
  color: #fff;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 13px;
  display: inline-block;
}

/* ==================== TOOLBAR & FILTERS ==================== */
.conc-toolbar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 12px;
}

.conc-filters {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 12px;
  padding: 12px;
  background: #f9fafb;
  border-radius: 8px;
}

.conc-filters select,
.conc-filters input {
  max-width: 150px;
  padding: 8px 10px;
  font-size: 13px;
}

.conc-filters label {
  font-size: 13px;
  font-weight: 500;
  margin: 0;
}

/* ==================== CHIPS & STATUS ==================== */
.chip {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 12px;
}

.status-ok {
  background: #dcfce7;
  color: #064e3b;
  padding: 6px 8px;
  border-radius: 8px;
}

.status-div {
  background: #fee2e2;
  color: #7f1d1d;
  padding: 6px 8px;
  border-radius: 8px;
}

.status-miss {
  background: #f3f4f6;
  color: #374151;
  padding: 6px 8px;
  border-radius: 8px;
}

/* ==================== TABLE RESPONSIVE ==================== */
.table-responsive {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 60vh;
  padding-bottom: 12px;
  border-radius: 8px;
  border: 1px solid #e5e5e5;
}

/* ==================== UTILITIES ==================== */
.small {
  font-size: 12px;
}

.small-muted {
  font-size: 13px;
  color: #666;
  margin-top: 8px;
}

.row-actions button {
  margin-right: 6px;
}

/* ==================== ACTION BUTTONS ==================== */
.conc-action-btn,
.conc_btn_action {
  background: transparent;
  border: 0;
  font-weight: 700;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--green);
  margin-left: 8px;
  transition: var(--transition);
  display: inline-block;
  white-space: nowrap;
}

.conc-action-btn:hover,
.conc_btn_action:hover {
  background: #f3f4f6;
  transform: translateY(-2px);
}

.conc-action-btn:focus,
.conc_btn_action:focus {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

/* ==================== ACTIONS MODAL ==================== */
.action-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.action-list button {
  width: 100%;
  text-align: left;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid #e5e5e5;
  background: #fff;
  cursor: pointer;
  transition: var(--transition);
  font-size: 14px;
  font-weight: 500;
  white-space: normal;
  word-wrap: break-word;
  overflow: visible;
  line-height: 1.4;
  min-height: 40px;
  display: flex;
  align-items: center;
}

.action-list button:hover {
  background: #f7faf7;
  border-color: var(--green);
  transform: translateX(4px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.action-list button:focus {
  outline: 2px solid var(--green);
  outline-offset: -1px;
}

.action-list button:active {
  transform: translateX(2px);
}

/* ==================== WHATSAPP & CONTACT ==================== */
.whatsapp-login {
  display: block;
  margin-top: 14px;
  text-align: center;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 10px;
  background: #25d366;
  color: #fff;
  font-weight: 700;
  transition: var(--transition);
  border: 0;
  cursor: pointer;
}

.whatsapp-login:hover {
  background: #20ba5a;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
}

/* ==================== COMMENTS & TOOLTIPS ==================== */
.comment-icon {
  margin-left: 6px;
  cursor: pointer;
  color: #9e9e9e;
  position: relative;
  display: inline-block;
  transition: color 0.2s;
  font-size: 16px;
}

.comment-icon:hover {
  color: #2196f3;
}

.comment-icon::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(100% + 10px);
  background: #1e88e5;
  color: #fff;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  white-space: pre-wrap;
  word-wrap: break-word;
  max-width: 400px;
  z-index: 2000;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.comment-icon:hover::after {
  opacity: 1;
}

/* ==================== VIEWS ==================== */
.view {
  display: block;
}

.view.hidden {
  display: none;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    max-height: 200px;
    overflow-x: auto;
    display: flex;
    flex-direction: row;
    padding: 12px;
  }

  .app {
    flex-direction: column;
  }

  .main {
    padding: 16px;
  }

  .modal-content {
    width: 96%;
    padding: 20px;
    max-height: 95vh;
  }

  .modal-buttons {
    flex-direction: column;
  }

  .modal-buttons .btn {
    width: 100%;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .conc-filters {
    flex-direction: column;
  }

  .conc-filters select,
  .conc-filters input {
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  .modal-content {
    width: 100%;
    margin: 20px;
    border-radius: 12px;
  }

  .header h1 {
    font-size: 24px;
  }

  table {
    font-size: 12px;
  }

  th,
  td {
    padding: 8px;
  }
}

/* ==================== MODAL OVERLAY (NOVO) ==================== */
/* Para modais que usam .modal-overlay como container */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  visibility: hidden;
  opacity: 0;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  pointer-events: none;
  backdrop-filter: blur(1px);
}

.modal-overlay:not(.hidden) {
  display: flex;
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

/* Conteúdo interno do modal-overlay */
.modal-overlay > .modal {
  position: relative;
  background: var(--card);
  padding: 30px;
  border-radius: 16px;
  max-width: 800px;
  width: 92%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  max-height: 90vh;
  overflow-y: auto;
  animation: modalSlideIn 0.3s ease forwards;
}

.modal-overlay > .modal h3 {
  color: var(--green);
  margin-bottom: 16px;
  font-size: 20px;
}

/* Form control para modais */
.modal-overlay .form-control {
  width: 100%;
  padding: 12px;
  border: 2px solid #e5e5e5;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 12px;
  box-sizing: border-box;
}

.modal-overlay .form-control:focus {
  outline: 0;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.1);
}

/* Textarea em modais */
.modal-overlay textarea.form-control {
  resize: vertical;
  min-height: 100px;
}

/* Labels em modais */
.modal-overlay label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  font-size: 14px;
  color: #374151;
}

/* Botões dentro de modal-overlay */
.modal-overlay .btn {
  width: auto;
  margin-bottom: 0;
}