/* ===== VARIÁVEIS ===== */
:root {
  --primary: #074866;
  --primary-dark: #053650;
  --primary-light: #0a5f82;
  --accent: #E05E3B;
  --accent-hover: #c4522f;
  --bg: #F0E6D6;
  --card-bg: #ffffff;
  --sidebar-bg: #074866;
  --sidebar-text: #b8cfd9;
  --sidebar-active: #E05E3B;
  --border: #ddd3c5;
  --text: #2c3e50;
  --text-muted: #6c757d;
  --success: #27ae60;
  --warning: #f39c12;
  --danger: #e74c3c;
  --info: #2980b9;
  --sidebar-width: 240px;
  --topbar-height: 60px;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.12);
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; font-size: 14px; color: var(--text); background: var(--bg); }
a { text-decoration: none; color: inherit; }
ul { list-style: none; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ===== LAYOUT ===== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-logo {
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-logo-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-logo-img {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}
.sidebar-logo h2 {
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
}
.sidebar-logo span {
  color: var(--sidebar-text);
  font-size: 12px;
  font-weight: 400;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.nav-section-title {
  padding: 8px 16px 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: rgba(255,255,255,0.4);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: var(--sidebar-text);
  font-size: 13.5px;
  border-radius: 0;
  transition: background 0.15s, color 0.15s;
  position: relative;
}
.nav-item:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
}
.nav-item.active {
  background: var(--sidebar-active);
  color: #fff;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}
.nav-icon {
  width: 18px;
  text-align: center;
  opacity: 0.85;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,0.1);
}
.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.user-avatar {
  width: 34px;
  height: 34px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}
.user-name {
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
}
.user-perfil {
  color: var(--sidebar-text);
  font-size: 11px;
}
.btn-logout {
  width: 100%;
  background: rgba(255,255,255,0.08);
  border: none;
  color: var(--sidebar-text);
  padding: 7px 12px;
  border-radius: var(--radius);
  font-size: 12.5px;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s, color 0.15s;
}
.btn-logout:hover {
  background: rgba(255,255,255,0.15);
  color: #fff;
}

/* ===== MAIN CONTENT ===== */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ===== TOPBAR ===== */
.topbar {
  height: var(--topbar-height);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ===== PAGE BODY ===== */
.page-body {
  padding: 24px;
  flex: 1;
}

/* ===== MES/ANO SELECTOR ===== */
.period-bar {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.period-bar label {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
}
.period-bar select {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 12px;
  background: var(--bg);
  color: var(--text);
  font-size: 13.5px;
  min-width: 120px;
}
.period-bar select:focus {
  outline: none;
  border-color: var(--primary);
}

/* ===== CARDS DE LOJA ===== */
.lojas-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.loja-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.loja-header {
  display: flex;
  align-items: center;
  padding: 14px 20px;
  cursor: pointer;
  gap: 16px;
  transition: background 0.15s;
  user-select: none;
}
.loja-header:hover {
  background: #f5ede2;
}

.loja-badge {
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
}

.loja-nome {
  font-weight: 600;
  font-size: 14.5px;
  color: var(--text);
  flex: 1;
}
.loja-cidade {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 1px;
}

.loja-metas-resumo {
  display: flex;
  gap: 20px;
  align-items: center;
}
.meta-chip {
  text-align: right;
}
.meta-chip .label {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.5px;
}
.meta-chip .value {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
}
.meta-chip .value.pending {
  color: var(--warning);
}
.meta-chip .value.filled {
  color: var(--success);
}

.loja-expand-icon {
  color: var(--text-muted);
  transition: transform 0.2s;
  font-size: 16px;
}
.loja-card.expanded .loja-expand-icon {
  transform: rotate(180deg);
}

.loja-body {
  display: none;
  border-top: 1px solid var(--border);
  padding: 20px;
  background: #fdf7f0;
}
.loja-card.expanded .loja-body {
  display: block;
}

/* ===== METAS FORM ===== */
.metas-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.form-group label {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}
.form-group input {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 14px;
  color: var(--text);
  background: #fff;
  transition: border-color 0.15s;
}
.form-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(7,72,102,0.1);
}
.form-group input:read-only {
  background: var(--bg);
  color: var(--text-muted);
  cursor: default;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

/* ===== SALVAR TUDO ===== */
.salvar-tudo-bar {
  display: flex;
  justify-content: flex-end;
  padding-top: 16px;
  margin-top: 16px;
  border-top: 1px solid var(--border);
}
.salvar-tudo-bar .btn {
  min-width: 160px;
}

/* ===== SEÇÃO CONSULTORAS ===== */
.consultoras-section h4 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.consultoras-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.consultoras-table th {
  background: var(--primary);
  color: #fff;
  padding: 10px 14px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.consultoras-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  color: var(--text);
}
.consultoras-table tr:last-child td {
  border-bottom: none;
}
.consultoras-table tr:hover td {
  background: #f5ede2;
}
.consultoras-table .meta-input {
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 6px 10px;
  width: 140px;
  font-size: 13.5px;
}
.consultoras-table .meta-input:focus {
  outline: none;
  border-color: var(--primary);
}
.consultoras-table .meta-input:read-only {
  background: var(--bg);
  color: var(--text-muted);
  cursor: default;
  border-color: transparent;
}

/* ===== BOTÕES ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  border: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.15s;
  line-height: 1;
}
.btn-sm {
  padding: 5px 11px;
  font-size: 12.5px;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-dark);
}
.btn-accent {
  background: var(--accent);
  color: #fff;
}
.btn-accent:hover {
  background: var(--accent-hover);
}
.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-success:hover {
  background: #219a52;
}
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-outline:hover {
  background: var(--bg);
}
.btn-ghost {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 5px 8px;
}
.btn-ghost:hover {
  color: var(--text);
  background: var(--bg);
}
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover {
  background: #c4522f;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===== BADGE STATUS ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.badge-success { background: #d4edda; color: #155724; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-danger  { background: #f8d7da; color: #721c24; }
.badge-info    { background: #cce5ff; color: #004085; }

/* ===== TABELAS ADMIN ===== */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card-bg);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.data-table th {
  background: var(--primary);
  color: #fff;
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  color: var(--text);
}
.data-table tr:last-child td {
  border-bottom: none;
}
.data-table tr:hover td {
  background: #f5ede2;
}
.data-table .actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

/* ===== TOOLBAR ===== */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.toolbar-right {
  margin-left: auto;
  display: flex;
  gap: 10px;
}
.search-input {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13.5px;
  min-width: 200px;
  background: var(--card-bg);
}
.search-input:focus {
  outline: none;
  border-color: var(--primary);
}
.filter-select {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13.5px;
  background: var(--card-bg);
}
.filter-select:focus {
  outline: none;
  border-color: var(--primary);
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}
.modal {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(-20px);
  transition: transform 0.2s;
}
.modal-overlay.open .modal {
  transform: translateY(0);
}
.modal-header {
  padding: 18px 24px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-muted);
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
}
.modal-close:hover {
  background: var(--bg);
  color: var(--text);
}
.modal-body {
  padding: 20px 24px;
}
.modal-footer {
  padding: 14px 24px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.modal .form-group {
  margin-bottom: 14px;
}
.modal .form-group:last-child {
  margin-bottom: 0;
}
.modal .form-group label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 5px;
  display: block;
}
.modal .form-group input,
.modal .form-group select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 9px 12px;
  font-size: 14px;
  color: var(--text);
  transition: border-color 0.15s;
}
.modal .form-group input:focus,
.modal .form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(7,72,102,0.1);
}

/* ===== TOAST ===== */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: var(--radius);
  background: var(--card-bg);
  box-shadow: var(--shadow-md);
  border-left: 4px solid;
  font-size: 13.5px;
  color: var(--text);
  min-width: 260px;
  max-width: 380px;
  animation: slideIn 0.2s ease;
}
.toast.success { border-color: var(--success); }
.toast.error   { border-color: var(--danger); }
.toast.info    { border-color: var(--info); }
.toast.warning { border-color: var(--warning); }
.toast-icon { font-size: 16px; }
.toast.success .toast-icon { color: var(--success); }
.toast.error   .toast-icon { color: var(--danger); }
.toast.info    .toast-icon { color: var(--info); }
.toast.warning .toast-icon { color: var(--warning); }
.toast-msg { flex: 1; }
@keyframes slideIn {
  from { transform: translateX(30px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state .empty-icon {
  font-size: 40px;
  margin-bottom: 12px;
  opacity: 0.4;
}
.empty-state p {
  font-size: 14px;
}

/* ===== LOADING ===== */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  font-size: 13.5px;
}
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== LOGIN PAGE ===== */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  width: 100%;
  max-width: 380px;
  padding: 40px 36px;
}
.login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.login-logo h1 {
  font-size: 20px;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.2;
}
.login-logo p {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 4px;
}
.login-form .form-group {
  margin-bottom: 16px;
}
.login-form .form-group label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.login-form .form-group input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 14px;
  transition: border-color 0.15s;
}
.login-form .form-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(7,72,102,0.1);
}
.btn-login {
  width: 100%;
  padding: 11px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14.5px;
  font-weight: 600;
  margin-top: 6px;
  transition: background 0.15s;
}
.btn-login:hover {
  background: var(--primary-dark);
}
.login-images {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}
.login-images img {
  max-height: 70px;
  max-width: 140px;
  object-fit: contain;
}

/* ===== AUDITORIA ===== */
.audit-table td .campo-tag {
  background: #d8eaf2;
  color: #074866;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 11.5px;
  font-weight: 600;
}
.audit-table .val-ant { color: var(--text-muted); text-decoration: line-through; }
.audit-table .val-new { color: var(--success); font-weight: 600; }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  :root { --sidebar-width: 200px; }
}
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
  .loja-metas-resumo {
    display: none;
  }
  .metas-form {
    grid-template-columns: 1fr;
  }
  .topbar {
    padding: 0 16px;
  }
  .page-body {
    padding: 16px;
  }
  .hamburger {
    display: flex !important;
  }
}

.hamburger {
  display: none;
  background: none;
  border: none;
  flex-direction: column;
  gap: 4px;
  padding: 4px;
  cursor: pointer;
}
.hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
}

.overlay-sidebar {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 99;
}
.overlay-sidebar.show {
  display: block;
}
