:root {
  --primary: #006e62;
  --primary-light: #e6f5f3;
  --accent: #2a9d8f;
  --sidebar-bg: #e6f5f3;
  --sidebar-bg-hover: #cce8e2;
  --sidebar-text: #1a4d47;
  --sidebar-muted: #3d7a72;
  --success: #28a745;
  --warning: #ffc107;
  --danger: #dc3545;
  --bg: #f8f9fa;
  --text: #333;
  --border: #dee2e6;
  --code-bg: #f4f4f4;
  --sidebar-width: 280px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body.admin-app {
  font-family: "Segoe UI", Arial, sans-serif;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

body.admin-app.has-sidebar {
  margin-left: var(--sidebar-width);
}

/* Sidebar — mesmo padrão do guia de implantação */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  overflow-y: auto;
  padding: 20px 0;
  z-index: 100;
  box-shadow: 2px 0 8px rgba(0, 110, 98, 0.12);
  border-right: 1px solid #b8ddd6;
}

.sidebar-logo {
  text-align: center;
  padding: 16px;
  margin: 0 12px 12px;
  background: #fff;
  border-radius: 6px;
  border: 1px solid #b8ddd6;
}

.sidebar-logo img {
  max-width: 160px;
  height: auto;
}

.sidebar-title {
  font-size: 0.8em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--sidebar-muted);
  padding: 8px 20px 6px;
}

.sidebar-section {
  font-size: 0.72em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary);
  padding: 16px 20px 6px;
  margin-top: 4px;
}

.sidebar ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sidebar li {
  margin: 0;
}

.sidebar a {
  display: block;
  padding: 7px 20px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.86em;
  border-left: 3px solid transparent;
  transition: all 0.15s;
}

.sidebar a:hover,
.sidebar a.active {
  background: var(--sidebar-bg-hover);
  color: var(--primary);
  border-left-color: var(--primary);
  font-weight: 600;
}

.sidebar-user {
  margin: 16px 12px 0;
  padding: 12px;
  background: #fff;
  border: 1px solid #b8ddd6;
  border-radius: 6px;
  font-size: 0.82em;
  color: var(--sidebar-muted);
}

.sidebar-user strong {
  display: block;
  color: var(--sidebar-text);
  margin-bottom: 8px;
  word-break: break-all;
}

.sidebar-user .btn-sair {
  display: block;
  width: 100%;
  border: 1px solid #b8ddd6;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 0.9em;
  font-weight: 600;
  cursor: pointer;
}

.sidebar-user .btn-sair:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Conteúdo principal */
.main-content {
  max-width: 1100px;
  margin: 0 auto;
  background: #fff;
  padding: 32px 40px 48px;
  min-height: 100vh;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.main-content h1 {
  color: var(--primary);
  font-size: 1.75em;
  border-bottom: 3px solid var(--primary);
  padding-bottom: 10px;
  margin: 0 0 20px;
}

.main-content h2,
.main-content .h5 {
  color: var(--primary);
}

.main-content a {
  color: var(--primary);
}

.doc-meta {
  background: var(--primary-light);
  border: 1px solid #b8ddd6;
  border-radius: 6px;
  padding: 14px 18px;
  margin-bottom: 24px;
  font-size: 0.95em;
}

.doc-meta p {
  margin: 0 0 4px;
}

.doc-meta p:last-child {
  margin-bottom: 0;
}

.note {
  background: var(--primary-light);
  border-left: 4px solid var(--primary);
  padding: 12px 16px;
  margin: 16px 0;
  border-radius: 0 4px 4px 0;
}

.warn {
  background: #fff8e1;
  border-left: 4px solid var(--warning);
  padding: 12px 16px;
  margin: 16px 0;
  border-radius: 0 4px 4px 0;
}

/* Cards KPI */
.card-kpi {
  border: 1px solid #b8ddd6;
  border-left: 4px solid var(--primary);
  border-radius: 6px;
  background: #fff;
  box-shadow: none;
}

.card.shadow-sm,
.card {
  border: 1px solid #b8ddd6;
  border-radius: 6px;
  box-shadow: none !important;
}

.card-header {
  background: var(--primary-light) !important;
  border-bottom: 1px solid #b8ddd6 !important;
  color: var(--sidebar-text);
  font-weight: 600;
}

.card-footer {
  border-top: 1px solid #b8ddd6 !important;
  background: #fafcfb !important;
}

/* Tabelas no estilo do guia */
.table {
  font-size: 0.95em;
}

.table thead th,
.table > :not(caption) > * > th {
  background: var(--primary) !important;
  color: #fff !important;
  border-color: var(--primary) !important;
  font-weight: 600;
  padding: 10px 14px;
}

.table td {
  border-color: var(--border);
  padding: 8px 14px;
  vertical-align: top;
}

.table-hover tbody tr:hover {
  background: var(--primary-light);
}

.table-secondary {
  --bs-table-bg: #f0f4f3;
}

/* Botões verdes */
.btn-success,
.btn-primary,
.btn-guia {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: #fff !important;
}

.btn-success:hover,
.btn-primary:hover,
.btn-guia:hover {
  background: #005a50 !important;
  border-color: #005a50 !important;
}

.btn-outline-primary,
.btn-outline-secondary,
.btn-outline-success {
  color: var(--primary) !important;
  border-color: #b8ddd6 !important;
  background: #fff !important;
}

.btn-outline-primary:hover,
.btn-outline-secondary:hover,
.btn-outline-success:hover {
  background: var(--primary-light) !important;
  border-color: var(--primary) !important;
  color: var(--primary) !important;
}

.btn-outline-warning {
  color: #996c00 !important;
  border-color: #e0c36a !important;
  background: #fff !important;
}

.btn-outline-danger {
  color: var(--danger) !important;
  border-color: #f1b0b7 !important;
  background: #fff !important;
}

/* Badges */
.badge-inbound {
  background: var(--accent) !important;
}

.badge-outbound {
  background: var(--primary) !important;
}

.badge-sucesso {
  background: var(--success) !important;
}

.badge-erro {
  background: var(--danger) !important;
}

.badge-bloqueio {
  background: #e0a800 !important;
  color: #212529 !important;
}

.badge.text-bg-success {
  background: var(--primary) !important;
}

.badge.text-bg-light {
  background: var(--primary-light) !important;
  color: var(--sidebar-text) !important;
  border: 1px solid #b8ddd6 !important;
}

.progress {
  background: #e9f2f0;
}

.progress-bar.bg-success {
  background: var(--primary) !important;
}

.alert-success {
  background: var(--primary-light);
  border-color: #b8ddd6;
  color: var(--sidebar-text);
}

.alert-info {
  background: var(--primary-light);
  border-color: #b8ddd6;
  color: var(--sidebar-text);
}

.form-control:focus,
.form-select:focus,
.form-check-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 0.2rem rgba(0, 110, 98, 0.15);
}

.form-check-input:checked {
  background-color: var(--primary);
  border-color: var(--primary);
}

.page-footer {
  margin-top: 40px;
  padding-top: 16px;
  border-top: 1px solid #b8ddd6;
  color: var(--sidebar-muted);
  font-size: 0.875em;
}

/* Login (sem sidebar) */
body.admin-login {
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  font-family: "Segoe UI", Arial, sans-serif;
}

.login-shell {
  width: 100%;
  max-width: 440px;
}

.login-card {
  background: #fff;
  border: 1px solid #b8ddd6;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  padding: 28px 28px 24px;
}

.login-logo {
  text-align: center;
  padding: 12px;
  margin-bottom: 20px;
  background: var(--primary-light);
  border: 1px solid #b8ddd6;
  border-radius: 6px;
}

.login-logo img {
  max-width: 180px;
  height: auto;
}

.login-card h1 {
  color: var(--primary);
  font-size: 1.4em;
  border-bottom: 2px solid var(--primary);
  padding-bottom: 8px;
  margin: 0 0 12px;
  text-align: center;
}

.login-card .subtitle {
  color: var(--sidebar-muted);
  text-align: center;
  margin-bottom: 20px;
  font-size: 0.95em;
}

@media (max-width: 900px) {
  body.admin-app.has-sidebar {
    margin-left: 0;
  }

  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    box-shadow: none;
  }

  .main-content {
    padding: 20px 16px 32px;
    min-height: auto;
  }
}
