:root {
  --crm-primary: #0d2a4e;
  --crm-primary-deep: #082042;
  --crm-accent: #3fbc9e;
  --crm-accent-dark: #2a9a7e;
  --crm-bg: #eef2f7;
  --crm-surface: #ffffff;
  --crm-ink: #0d2a4e;
  --crm-muted: #5a6b7d;
  --crm-line: #d8e0ea;
  --crm-radius: 14px;
}

body.crm-app {
  background: var(--crm-bg);
  color: var(--crm-ink);
  font-family: "DM Sans", system-ui, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.crm-navbar {
  background: linear-gradient(90deg, var(--crm-primary-deep), var(--crm-primary) 60%, #1a4a7a);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
}

.crm-brand-logo {
  height: 28px;
  width: auto;
  display: block;
}

.crm-brand-text {
  letter-spacing: 0.02em;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 1100;
  padding: 0.5rem 1rem;
  background: var(--crm-surface);
  color: var(--crm-ink);
  border-radius: var(--crm-radius);
  font-weight: 600;
  text-decoration: none;
}

.skip-link:focus {
  top: 1rem;
  outline: 3px solid var(--crm-accent);
  outline-offset: 2px;
}

.crm-navbar .nav-link {
  color: rgba(255, 255, 255, 0.82);
  border-bottom: 2px solid transparent;
  padding-bottom: 0.35rem;
}

.crm-navbar .nav-link:hover {
  color: #fff;
}

.crm-navbar .nav-link.active {
  color: var(--crm-accent);
  border-bottom-color: var(--crm-accent);
  font-weight: 600;
}

.crm-main {
  width: 100%;
  max-width: 1200px;
  margin-inline: auto;
  flex: 1 0 auto;
}

.crm-footer {
  border-top: 1px solid var(--crm-line);
  background: var(--crm-surface);
  color: var(--crm-muted);
  flex-shrink: 0;
  margin-top: auto;
}

.crm-footer-brand {
  gap: .55rem;
}

.crm-footer-logo {
  display: inline-block;
  height: 18px;
  width: auto;
  opacity: .92;
}

/* Portal hero */
.portal-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  background: var(--crm-surface);
  border: 1px solid var(--crm-line);
  border-radius: var(--crm-radius);
  padding: 1.5rem 1.75rem;
  margin-bottom: 1.25rem;
}

.portal-hero-greeting h1 {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0 0 0.35rem;
  color: var(--crm-ink);
}

.portal-hero-greeting p {
  margin: 0;
  color: var(--crm-muted);
  font-size: 0.95rem;
}

.portal-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

.portal-hero-actions .btn {
  padding: 0.55rem 1.15rem;
}

.portal-hero-actions .btn-outline-secondary {
  border-color: var(--crm-line);
  color: var(--crm-ink);
}

.portal-hero-actions .btn-outline-secondary:hover {
  background: var(--crm-bg);
  border-color: var(--crm-muted);
  color: var(--crm-ink);
}

/* Plan strip */
.portal-plan-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  background: var(--crm-surface);
  border: 1px solid var(--crm-line);
  border-radius: var(--crm-radius);
  margin-bottom: 1.75rem;
  overflow: hidden;
}

.portal-plan-item {
  flex: 1 1 140px;
  padding: 0.9rem 1.25rem;
  min-width: 120px;
  border-right: 1px solid var(--crm-line);
}

.portal-plan-item:last-child {
  border-right: none;
}

.portal-plan-item .label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--crm-muted);
  margin-bottom: 0.25rem;
  font-weight: 600;
}

.portal-plan-item .value {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--crm-ink);
  margin: 0;
}

.portal-plan-item a {
  color: var(--crm-accent-dark);
  font-weight: 600;
  text-decoration: none;
  font-size: 0.9rem;
}

.portal-plan-item a:hover {
  color: var(--crm-primary);
  text-decoration: underline;
}

.portal-section-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--crm-muted);
  font-weight: 700;
  margin: 0 0 1rem;
}

/* Module cards */
.modulo-card,
.portal-mod-card {
  background: var(--crm-surface);
  border: 1px solid var(--crm-line);
  border-radius: var(--crm-radius);
  border-left: 4px solid var(--crm-primary);
  box-shadow: none;
  height: 100%;
  padding: 1.15rem 1.25rem;
  transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.modulo-card:hover,
.portal-mod-card:hover {
  border-color: var(--crm-accent);
  border-left-color: var(--crm-accent);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(13, 42, 78, 0.08);
}

.portal-mod-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(63, 188, 158, 0.14);
  color: var(--crm-primary);
  font-size: 1.25rem;
  flex-shrink: 0;
}

.portal-mod-card h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 0 0.35rem;
  color: var(--crm-ink);
}

.portal-mod-card .portal-mod-desc {
  font-size: 0.875rem;
  color: var(--crm-muted);
  margin: 0 0 0.75rem;
  line-height: 1.45;
}

.portal-mod-cta {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--crm-accent-dark);
  text-decoration: none;
}

.portal-mod-cta::after {
  content: " →";
}

a:hover .portal-mod-cta {
  color: var(--crm-primary);
  text-decoration: underline;
}

.portal-mod-ged {
  font-size: 0.75rem;
  color: var(--crm-muted);
  margin-top: 0.65rem;
}

.portal-aside {
  background: transparent;
  border: none;
  padding: 0;
}

.portal-aside-note {
  font-size: 0.8rem;
  color: var(--crm-muted);
  background: rgba(13, 42, 78, 0.04);
  border: 1px dashed var(--crm-line);
  border-radius: 10px;
  padding: 0.75rem 1rem;
}

.card-metric {
  border: 1px solid var(--crm-line);
  border-radius: var(--crm-radius);
  box-shadow: none;
  background: var(--crm-surface);
}

.card-metric .metric-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--crm-primary);
}

/* Status das empresas: mesma escala em todo o sistema (texto + ponto, sem depender só de cor) */
.badge.badge-status-ativa { background: #e3f5ec; color: #1e6b47; }
.badge.badge-status-trial { background: #e6f0fb; color: #1d4f91; }
.badge.badge-status-suspensa { background: #fdf3dc; color: #7a5200; }
.badge.badge-status-cancelada { background: #eceff3; color: #4a5561; }
[class*="badge-status-"]::before {
  content: "";
  display: inline-block;
  width: 0.45rem;
  height: 0.45rem;
  margin-right: 0.35rem;
  border-radius: 50%;
  background: currentColor;
  vertical-align: middle;
}

/* === Painel admin: visão geral === */
.kpi-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 1.1rem 1.2rem;
  background: var(--crm-surface);
  border: 1px solid var(--crm-line);
  border-radius: var(--crm-radius);
  color: inherit;
  text-decoration: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.kpi-card:hover {
  border-color: var(--crm-accent);
  box-shadow: 0 4px 16px rgba(13, 42, 78, 0.08);
  color: inherit;
}

.kpi-card:focus-visible {
  outline: 3px solid var(--crm-accent);
  outline-offset: 2px;
}

.kpi-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  font-size: 1.1rem;
  background: #e7f6f2;
  color: var(--crm-accent-dark);
}

.kpi-icon--primary { background: #e6ecf5; color: var(--crm-primary); }
.kpi-icon--success { background: #e3f5ec; color: #1e7a4c; }
.kpi-icon--warning { background: #fdf3dc; color: #8a5a00; }

.kpi-label {
  margin-top: 0.75rem;
  color: var(--crm-muted);
  font-size: 0.875rem;
  font-weight: 500;
}

.kpi-value {
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1.15;
  color: var(--crm-primary);
  font-variant-numeric: tabular-nums;
}

.kpi-hint {
  color: var(--crm-muted);
  font-size: 0.8rem;
}

.dash-panel {
  overflow: hidden;
  background: var(--crm-surface);
  border: 1px solid var(--crm-line);
  border-radius: var(--crm-radius);
}

.dash-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--crm-line);
}

.dash-panel-head h2 {
  margin: 0;
  color: var(--crm-primary);
  font-size: 1.05rem;
  font-weight: 600;
}

.dash-table {
  margin: 0;
  font-size: 0.92rem;
}

.dash-table thead th {
  padding: 0.7rem 1.25rem;
  background: #f7f9fc;
  border-bottom: 1px solid var(--crm-line);
  color: var(--crm-muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}

.dash-table tbody td {
  padding: 0.85rem 1.25rem;
  border-color: var(--crm-line);
  vertical-align: middle;
}

.dash-table tbody tr:hover {
  background: #f5f9fc;
}

.dash-company {
  color: var(--crm-ink);
  font-weight: 600;
  text-decoration: none;
}

.dash-company:hover {
  color: var(--crm-accent-dark);
  text-decoration: underline;
}

.dash-company,
.dash-slug {
  white-space: nowrap;
}

.dash-slug {
  padding: 0.1rem 0.4rem;
  border-radius: 6px;
  background: #f1f4f8;
  color: var(--crm-muted);
  font-size: 0.8rem;
}

.dash-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  color: var(--crm-muted);
  text-decoration: none;
}

.dash-action:hover,
.dash-action:focus-visible {
  background: #eef2f7;
  color: var(--crm-primary);
}

.dash-links a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.8rem 1.25rem;
  border-top: 1px solid var(--crm-line);
  color: var(--crm-ink);
  text-decoration: none;
}

.dash-links a:first-child {
  border-top: 0;
}

.dash-links a:hover {
  background: #f5f9fc;
}

.dash-links i {
  font-size: 1.1rem;
  color: var(--crm-accent-dark);
}

.dash-links small {
  display: block;
  color: var(--crm-muted);
}

.dash-empty {
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--crm-muted);
}

.dash-empty > i {
  font-size: 2rem;
  color: var(--crm-accent);
}

/* Botão primário em formato pílula, com gradiente e relevo leve (referência aprovada) */
.btn-primary {
  background: linear-gradient(180deg, #1a4a7a 0%, var(--crm-primary) 55%, var(--crm-primary-deep) 100%);
  border: 0;
  border-radius: 999px;
  box-shadow: 0 2px 0 var(--crm-primary-deep), 0 6px 14px rgba(13, 42, 78, 0.18);
  font-weight: 600;
  padding-inline: 1.15rem;
  transition: transform 0.12s, box-shadow 0.12s;
}

.btn-primary:hover,
.btn-primary:focus {
  background: linear-gradient(180deg, #235c93 0%, #1a4a7a 55%, var(--crm-primary) 100%);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(1px);
  box-shadow: 0 1px 0 var(--crm-primary-deep);
}

.btn-primary:focus-visible {
  outline: 3px solid var(--crm-accent);
  outline-offset: 2px;
}

/* Botões secundários acompanham o formato pílula */
.btn-outline-primary,
.btn-outline-secondary {
  border-radius: 999px;
  font-weight: 600;
}

/* Formulários: seções com título e ações fixas no rodapé */
.emp-form-section {
  margin-top: 0.75rem;
}

.emp-form-section h2 {
  margin: 0;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--crm-line);
  color: var(--crm-muted);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.form-text code {
  padding: 0.1rem 0.35rem;
  border-radius: 6px;
  background: #f1f4f8;
  color: var(--crm-muted);
}

.emp-form-actions {
  position: sticky;
  bottom: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.9rem 0;
  margin-top: 0.5rem;
  background: var(--crm-bg);
  border-top: 1px solid var(--crm-line);
}

.emp-mod-tile {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  height: 100%;
  margin: 0;
  padding: 0.75rem 1rem;
  background: var(--crm-surface);
  border: 1px solid var(--crm-line);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}

.emp-mod-tile:hover {
  border-color: var(--crm-accent);
}

.emp-mod-tile:has(input:checked) {
  border-color: var(--crm-accent);
  background: #f1fbf8;
}

.emp-mod-tile .form-check-input {
  float: none;
  margin: 0;
  flex-shrink: 0;
}

.emp-mod-tile-name {
  color: var(--crm-ink);
  font-weight: 600;
}

body.login-page {
  min-height: 100vh;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  font-family: "DM Sans", system-ui, sans-serif;
}

.login-brand-panel {
  flex: 1 1 320px;
  min-height: 100vh;
  background: linear-gradient(145deg, #082042 0%, #0d2a4e 45%, #4163ac 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.login-form-panel {
  flex: 1 1 360px;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: #fff;
}

.login-brand-inner { max-width: 380px; text-align: center; }
.login-brand-inner img.login-logo {
  width: min(100%, 300px);
  height: 52px;
  object-fit: cover;
  object-position: top center;
  margin-bottom: 1rem;
}
.login-brand-inner .tagline,
.login-brand-inner .login-tagline {
  color: var(--crm-accent);
  font-weight: 500;
  font-size: 1.05rem;
  margin: 0 0 0.5rem;
}
.login-brand-inner .login-sub {
  font-size: 0.85rem;
  opacity: 0.85;
  margin: 0;
}

.plano-card.destaque {
  border: 2px solid var(--crm-accent);
}

@media (max-width: 768px) {
  .portal-hero {
    flex-direction: column;
    align-items: flex-start;
  }
  .portal-plan-item {
    border-right: none;
    border-bottom: 1px solid var(--crm-line);
    flex: 1 1 100%;
  }
  .portal-plan-item:last-child {
    border-bottom: none;
  }
}

@media (max-width: 576px) {
  .crm-main { padding-left: 1rem; padding-right: 1rem; }
}


/* === Chamados (helpdesk nativo) === */
.chamados-layout { max-width: 1100px; }
.chamados-card {
  background: var(--crm-surface);
  border: 1px solid var(--crm-line);
  border-radius: var(--crm-radius);
}
.chamados-table thead th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--crm-muted);
  border-bottom-color: var(--crm-line);
}
.chamados-row:hover { background: rgba(63, 188, 158, 0.06); }
.chamados-badge {
  font-weight: 600;
  font-size: 0.72rem;
  padding: 0.35em 0.65em;
  border-radius: 6px;
}
.chamados-status-aberto { background: #e8f1fb; color: #1a4a7a; }
.chamados-status-em_atendimento { background: rgba(63, 188, 158, 0.18); color: var(--crm-accent-dark); }
.chamados-status-aguardando { background: #fff4e0; color: #9a6b12; }
.chamados-status-resolvido { background: #e6f6ee; color: #1d6b45; }
.chamados-status-cancelado { background: #f0f2f5; color: #5a6b7d; }
.chamados-prio-baixa { background: #eef2f7; color: var(--crm-muted); }
.chamados-prio-media { background: #e8f1fb; color: #1a4a7a; }
.chamados-prio-alta { background: #ffe8d9; color: #b45309; }
.chamados-prio-urgente { background: #fde8e8; color: #a12c2c; }
.chamados-descricao {
  padding: 0.85rem 1rem;
  background: var(--crm-bg);
  border-radius: 10px;
  border: 1px solid var(--crm-line);
  white-space: pre-wrap;
}
.chamados-meta dt { margin-bottom: 0.35rem; }
.chamados-meta dd { margin-bottom: 0.35rem; }
.chamados-thread { display: flex; flex-direction: column; gap: 0.75rem; }
.chamados-msg {
  padding: 0.75rem 0.9rem;
  border-radius: 10px;
  border: 1px solid var(--crm-line);
  background: #fff;
}
.chamados-msg-sistema { background: var(--crm-bg); color: var(--crm-muted); }
.chamados-msg-status { border-left: 3px solid var(--crm-primary); }
.chamados-msg-comentario { border-left: 3px solid var(--crm-accent); }
.chamados-stat {
  background: var(--crm-surface);
  border: 1px solid var(--crm-line);
  border-radius: var(--crm-radius);
  padding: 1rem 1.1rem;
  height: 100%;
}
.chamados-stat-accent {
  border-color: rgba(63, 188, 158, 0.45);
  background: linear-gradient(160deg, #fff 40%, rgba(63, 188, 158, 0.1));
}
.chamados-stat-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--crm-muted);
  margin-bottom: 0.25rem;
}
.chamados-stat-value {
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--crm-primary);
  line-height: 1.1;
}

/* Chamados full-port badges/KPI v4 */
.chamados-subnav .nav-link { border-radius: 999px; padding: .35rem .9rem; font-size: .9rem; }
.chamados-subnav .nav-link.active { background: var(--crm-accent, #3fbc9e); color: #fff; }
.chamados-kpi-card {
  display:block; text-decoration:none; color:inherit;
  background:#fff; border:1px solid rgba(0,0,0,.06); border-radius:12px;
  padding:1rem 1.1rem; min-height:96px; transition: box-shadow .15s, transform .15s;
}
a.chamados-kpi-card:hover { box-shadow: 0 6px 18px rgba(0,0,0,.08); transform: translateY(-1px); color:inherit; }
.chamados-kpi-label { font-size:.8rem; color:var(--crm-muted,#6b7c8f); }
.chamados-kpi-val { font-size:1.85rem; font-weight:700; line-height:1.2; margin-top:.35rem; }
.chamados-kpi-card.tone-info { border-left:4px solid #4a90d9; }
.chamados-kpi-card.tone-success { border-left:4px solid #3fbc9e; }
.chamados-kpi-card.tone-warning { border-left:4px solid #f0ad4e; }
.chamados-kpi-card.tone-danger { border-left:4px solid #e74c3c; }
.chamados-kpi-card.is-zero { opacity:.65; }
.chamados-status-ag_aprovacao { background:#f3e8ff; color:#6b21a8; }
.chamados-status-a_fazer { background:#e8f1fb; color:#1a4a7a; }
.chamados-status-pausado { background:#f0f2f5; color:#5a6b7d; }
.chamados-status-aguardando_cliente { background:#fff4e0; color:#9a6b12; }
.chamados-status-retido { background:#ffe8d9; color:#b45309; }
.chamados-status-expirado { background:#fde8e8; color:#a12c2c; }
.chamados-status-conferencia { background:#e8f8f5; color:#0f766e; }
.chamados-status-reaberto { background:#e8f1fb; color:#1a4a7a; }
.chamados-status-fechado { background:#e6f6ee; color:#1d6b45; }
.chamados-status-aguardando { background:#fff4e0; color:#9a6b12; }
.chamados-prio-critica { background:#3b0a0a; color:#fecaca; }

/* Chamados module (ported intranet tabs) */
.chamados-milvus-page .nav-pills.chamados-abas .nav-link { border-radius: 999px; }
.chamados-milvus-page .nav-pills.chamados-abas .nav-link.active { font-weight: 600; }
