/* iLayerCert CRM — design system alinhado com o AuditsM (app-v3)
   Tipo: Inter. Barra lateral azul-escura, acento azul, cartões "azulcards".
   Tokens em CSS custom properties → tema claro/escuro via [data-theme="dark"].
   Carregado depois do Bootstrap; sobrepõe-se onde importa. */

:root {
  /* Tipografia */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Barra lateral */
  --sidebar-bg: #0F2B46;
  --sidebar-hover: #163a5c;
  --sidebar-active: #1a73e8;
  --sidebar-text: #a6b4c8;
  --sidebar-text-active: #ffffff;

  /* Superfícies */
  --canvas: #f8fafc;       /* fundo da app */
  --surface: #ffffff;      /* cartões / painéis */
  --surface-2: #f8fafc;    /* superfície subtil (gradiente dos azulcards, colunas) */
  --surface-3: #f1f5f9;    /* cabeçalho de tabela, hover de linha */
  --line: #e2e8f0;         /* contornos */
  --line-soft: #eef2f7;    /* divisórias leves */
  --field-border: #94a3b8; /* bordo dos campos de preenchimento (mais forte) */

  /* Texto */
  --text: #1e293b;
  --text-strong: #334155;
  --text-muted: #64748b;
  --text-faint: #94a3b8;

  /* Acento */
  --accent: #1a73e8;
  --accent-hover: #1557b0;
  --accent-strong: #2563eb;
  --accent-tint: #e8f0fe;
  --card-border: #3b82f6;  /* borda azul dos azulcards */

  /* Estado */
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
  --blue: #3b82f6;

  /* Fases do pipeline (mantidas, semânticas) */
  --st-prospect: #94a3b8;
  --st-waiting: #f59e0b;
  --st-ongoing: #1a73e8;
  --st-won: #22c55e;
  --st-lost: #ef4444;

  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 16px;
  --shadow: 0 1px 2px rgba(15,23,42,.05), 0 4px 12px rgba(15,23,42,.08);
  --shadow-card: 0 2px 4px rgba(0,0,0,.10), 0 6px 16px rgba(0,0,0,.12), 0 10px 30px rgba(0,0,0,.08);
  --shadow-card-hover: 0 4px 8px rgba(59,130,246,.15), 0 10px 25px rgba(0,0,0,.18), 0 16px 40px rgba(0,0,0,.10);

  --bs-primary: var(--accent);
  --bs-primary-rgb: 26, 115, 232;
  --bs-link-color: var(--accent);
  --bs-link-hover-color: var(--accent-hover);
  --bs-body-color: var(--text);
  --bs-border-color: var(--line);
}

[data-theme="dark"] {
  --sidebar-bg: #0a1929;
  --sidebar-hover: #132f4c;
  --sidebar-active: #1a73e8;
  --sidebar-text: #8ba0b8;

  --canvas: #0f172a;
  --surface: #1e293b;
  --surface-2: #16213a;
  --surface-3: #0b1220;
  --line: #334155;
  --line-soft: #273449;
  --field-border: #64748b;

  --text: #e2e8f0;
  --text-strong: #cbd5e1;
  --text-muted: #94a3b8;
  --text-faint: #7c8ea0;

  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  --accent-strong: #60a5fa;
  --accent-tint: #1e3a5f;

  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 12px rgba(0,0,0,.5);
  --shadow-card: 0 2px 4px rgba(0,0,0,.4), 0 6px 16px rgba(0,0,0,.45), 0 10px 30px rgba(0,0,0,.35);
  --shadow-card-hover: 0 4px 8px rgba(59,130,246,.25), 0 10px 25px rgba(0,0,0,.55), 0 16px 40px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }

body {
  font-family: var(--font);
  background: var(--canvas);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6, .font-display {
  font-family: var(--font);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

a { text-underline-offset: 2px; }

/* ---------- App shell: sidebar fixa + barra de topo + conteúdo ---------- */
.app-shell { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px;
}

/* marca em camadas */
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 24px; text-decoration: none; }
.brand .mark { flex: 0 0 auto; display: inline-flex; background: none; padding: 0; }
.brand .word { line-height: 1.1; }
.brand .word b { font-weight: 700; font-size: 18px; color: #fff; letter-spacing: -.02em; }
.brand .word .tag {
  display: inline-block; margin-top: 3px; font-size: 10.5px; font-weight: 600;
  color: #9ec5ff; background: rgba(26,115,232,.22);
  padding: 1px 8px; border-radius: 999px; letter-spacing: .08em; text-transform: uppercase;
}

.nav-side { display: flex; flex-direction: column; gap: 3px; margin-top: 4px; }
.nav-side a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--sidebar-text); text-decoration: none; font-weight: 500; font-size: 14.5px;
  transition: background .15s ease, color .15s ease;
}
.nav-side a i { font-size: 19px; line-height: 1; flex: 0 0 auto; width: 22px; text-align: center; }
.nav-side a:hover { background: var(--sidebar-hover); color: #fff; }
.nav-side a.active { background: var(--sidebar-active); color: #fff; box-shadow: 0 4px 12px rgba(26,115,232,.35); }

.side-foot { margin-top: auto; padding-top: 14px; }
.side-foot .side-hint { color: #6f84a0; font-size: 11.5px; padding: 0 8px; }

/* ---------- Barra de topo ---------- */
.app-main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 1030;
  background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 30px; min-height: 64px;
}
.topbar-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-title .tt-icon {
  width: 40px; height: 40px; border-radius: 11px; flex: 0 0 auto;
  display: grid; place-items: center; background: var(--accent-tint); color: var(--accent); font-size: 21px;
}
.topbar-title .tt-text { min-width: 0; }
.topbar-title h1 { font-size: 19px; margin: 0; line-height: 1.2; }
.topbar-title .tt-sub { font-size: 12.5px; color: var(--text-muted); margin: 1px 0 0; }

.topbar-right { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.topbar-right .header-actions { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 11px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text-muted); cursor: pointer;
  display: grid; place-items: center; font-size: 19px; transition: background .15s, color .15s, border-color .15s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--accent); border-color: var(--accent); }

/* menu de perfil (sem Bootstrap JS) */
.profile { position: relative; }
.profile-btn {
  display: flex; align-items: center; gap: 10px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px 5px 5px; cursor: pointer;
  color: var(--text); font: inherit; transition: border-color .15s, background .15s;
}
.profile-btn:hover { border-color: var(--accent); }
.profile-btn .avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: 0 0 auto;
  background: linear-gradient(135deg, #3b82f6, #1a73e8);
  color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 12.5px;
}
.profile-btn .pname { font-weight: 600; font-size: 13.5px; line-height: 1.1; }
.profile-btn .pname small { display: block; font-weight: 500; font-size: 11px; color: var(--text-faint); }
.profile-btn .caret { font-size: 16px; color: var(--text-faint); }

.profile-menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 210px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); padding: 6px; z-index: 1050; display: none;
}
.profile.is-open .profile-menu { display: block; }
.profile-menu .pm-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--line-soft); margin-bottom: 6px; }
.profile-menu .pm-head b { display: block; font-size: 13.5px; }
.profile-menu .pm-head span { font-size: 12px; color: var(--text-muted); }
.profile-menu a, .profile-menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 9px 10px; border-radius: 8px; border: 0; background: none; color: var(--text);
  font: inherit; font-size: 13.5px; cursor: pointer; text-decoration: none;
}
.profile-menu a:hover, .profile-menu button:hover { background: var(--surface-3); color: var(--accent); }
.profile-menu i { font-size: 17px; }
.profile-menu .pm-danger:hover { color: var(--red); }

/* conteúdo */
.app-main .container { max-width: 1160px; padding: 28px 30px 60px; width: 100%; }
.app-main .container.container-wide { max-width: none; }

/* mobile: sidebar vira barra horizontal no topo */
@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static; height: auto; flex-direction: row; align-items: center;
    flex-wrap: wrap; gap: 6px 4px; padding: 10px 14px;
  }
  .brand { padding: 0 10px 0 2px; }
  .nav-side { flex-direction: row; flex-wrap: wrap; margin: 0; }
  .nav-side a span.lbl { display: none; }
  .side-foot { display: none; }
  .topbar { padding: 12px 16px; }
  .topbar-title .tt-sub { display: none; }
  .profile-btn .pname { display: none; }
  .app-main .container { padding: 20px 16px 48px; }
}

/* ---------- Alertas ---------- */
.alert { border-radius: var(--radius-sm); border: 1px solid transparent; }
.alert-success { background: rgba(34,197,94,.12); color: #15803d; border-color: rgba(34,197,94,.25); }
[data-theme="dark"] .alert-success { color: #86efac; }

/* ---------- Cartões ---------- */
.card {
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); background: var(--surface); color: var(--text);
}
.card .card-title { font-family: var(--font); }

/* ligações rápidas do painel */
.quicklink .card { transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease; height: 100%; }
.quicklink:hover .card { transform: translateY(-3px); border-color: var(--card-border); box-shadow: var(--shadow-card); }
.quicklink .ql-icon {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
  background: var(--accent-tint); color: var(--accent); margin-bottom: 12px; font-size: 22px;
}
.quicklink .ql-icon svg { width: 22px; height: 22px; }

/* ---------- Botões ---------- */
.btn { border-radius: 10px; font-weight: 500; }
.btn-primary { background: var(--accent); border-color: var(--accent); }
.btn-primary:hover, .btn-primary:focus { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-outline-primary { color: var(--accent); border-color: var(--accent); }
.btn-outline-primary:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-outline-secondary { border-color: var(--line); color: var(--text); }
.btn-outline-secondary:hover { background: var(--surface-3); color: var(--text); border-color: var(--line); }
.btn-link { color: var(--accent); }
.btn-add {
  display: inline-flex; align-items: center; gap: 7px;
}
.btn-add i { font-size: 18px; }

/* ---------- Pills de filtro ---------- */
.nav-pills { gap: 6px; }
.nav-pills .nav-link { color: var(--text-muted); border: 1px solid var(--line); background: var(--surface); padding: 6px 14px; border-radius: 999px; font-size: 14px; }
.nav-pills .nav-link:hover { border-color: var(--accent); color: var(--accent); }
.nav-pills .nav-link.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- Tabelas ---------- */
.table { --bs-table-bg: transparent; --bs-table-color: var(--text); background: var(--surface); border-radius: var(--radius); overflow: hidden; border-collapse: separate; border-spacing: 0; box-shadow: var(--shadow); margin-bottom: 20px; color: var(--text); }
.table.bg-white { background: var(--surface) !important; }
.table thead th { background: var(--surface-3); color: var(--text-muted); font-weight: 600; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; border-bottom: none; padding: 12px 14px; }
.table td { padding: 12px 14px; vertical-align: middle; border-top: 1px solid var(--line-soft); color: var(--text); }
.table.table-striped > tbody > tr:nth-of-type(odd) > * { background: transparent; }
.table tbody tr:hover td { background: var(--accent-tint); }
.table td a { color: var(--text); font-weight: 600; text-decoration: none; }
.table td a:hover { color: var(--accent); }

/* ---------- Registo de alterações (audit log) ---------- */
.log-table { font-size: 12.5px; }
.log-table thead th { font-size: 10.5px; padding: 9px 12px; }
.log-table td { padding: 9px 12px; vertical-align: top; }
/* Divisor entre QUEM (data + utilizador) e O QUE FEZ (ação + entidade + detalhes) */
.log-table thead th.log-who, .log-table td.log-who { border-right: 2px solid var(--line); }
.log-table .log-user { font-weight: 600; color: var(--text-strong); white-space: nowrap; }
.log-table .log-when { color: var(--text-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.log-table .log-entity-type { font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-faint); }
.log-table .log-changes { font-size: 11.5px; line-height: 1.5; }
.log-table .log-changes li + li { margin-top: 1px; }
.log-table .log-changes .lc-arrow { color: var(--text-faint); padding: 0 2px; }

/* ---------- Badges / estado ---------- */
.badge { font-weight: 600; border-radius: 999px; padding: .35em .7em; font-size: 11.5px; }
.badge.text-bg-success { background: rgba(34,197,94,.15) !important; color: #15803d !important; }
.badge.text-bg-secondary { background: var(--surface-3) !important; color: var(--text-muted) !important; }
.badge.text-bg-primary { background: var(--accent-tint) !important; color: var(--accent) !important; }
.badge.text-bg-warning { background: rgba(245,158,11,.18) !important; color: #b45309 !important; }
.badge.text-bg-danger { background: rgba(239,68,68,.15) !important; color: #b91c1c !important; }
[data-theme="dark"] .badge.text-bg-success { color: #86efac !important; }
[data-theme="dark"] .badge.text-bg-warning { color: #fcd34d !important; }
[data-theme="dark"] .badge.text-bg-danger { color: #fca5a5 !important; }
[data-theme="dark"] .badge.text-bg-primary { color: #93c5fd !important; }

/* ---------- Formulários ---------- */
.form-control, .form-select {
  border-radius: 9px; border: 1.5px solid var(--field-border); background: var(--surface); color: var(--text);
  padding: .4rem .6rem; font-size: 14px;
}
.form-check-input { border: 1.5px solid var(--field-border); }
.form-control::placeholder { color: var(--text-faint); }
.form-control:focus, .form-select:focus {
  border-color: var(--accent); background: var(--surface); color: var(--text);
  box-shadow: 0 0 0 .2rem rgba(26,115,232,.18);
}
.form-label { font-weight: 600; font-size: 13.5px; color: var(--text-strong); }
.form-text { color: var(--text-muted); }
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }
[data-theme="dark"] .form-select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%2394a3b8' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
}

/* ---------- Paginação ---------- */
.pagination { gap: 4px; }
.page-link { border-radius: 9px !important; border-color: var(--line); color: var(--text); background: var(--surface); }
.page-link:hover { background: var(--surface-3); color: var(--accent); }
.page-item.active .page-link { background: var(--accent); border-color: var(--accent); color: #fff; }
.page-item.disabled .page-link { background: var(--surface); color: var(--text-faint); }

/* ---------- Quadro do pipeline ---------- */
.board { display: flex; gap: 14px; align-items: flex-start; padding-bottom: 16px; }
.board-column {
  flex: 1 1 0; min-width: 0; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 16px; padding: 11px;
}
@media (max-width: 900px) {
  .board { overflow-x: auto; }
  .board-column { flex: 0 0 240px; min-width: 240px; }
}
.board-col-head {
  display: flex; align-items: center; gap: 8px; padding: 0 4px 12px;
  font-size: 13px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .5px;
}
.board-col-head .col-ico { display: inline-flex; flex: 0 0 auto; }
.board-col-head .col-ico svg { width: 16px; height: 16px; }
.board-col-head .name { flex: 1 1 auto; min-width: 0; }
.board-col-head .count {
  flex: 0 0 auto; background: var(--line); color: var(--text-muted);
  border-radius: 10px; padding: 1px 8px; font-size: 12px; font-weight: 600;
}
.board-list { min-height: 44px; display: flex; flex-direction: column; gap: 10px; }

.board-card {
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 2px solid var(--card-border); border-radius: 14px; padding: 12px; cursor: grab;
  box-shadow: var(--shadow-card);
  transition: box-shadow .25s, transform .25s, border-color .25s;
}
.board-card:hover {
  border-color: var(--accent-strong); transform: translateY(-4px);
  box-shadow: var(--shadow-card-hover);
}
.board-card:active { cursor: grabbing; }

.board-card .card-title { display: flex; align-items: flex-start; gap: 10px; text-decoration: none; }
.board-card .doc-icon {
  width: 32px; height: 32px; border-radius: 8px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
}
.board-card .doc-icon svg { width: 17px; height: 17px; }
.board-card .card-head-text { min-width: 0; }
.board-card .deal-name {
  display: block; font-weight: 600;
  font-size: 13.5px; color: var(--text); line-height: 1.3; overflow-wrap: anywhere;
}
.board-card:hover .deal-name { color: var(--accent); }
.board-card .card-meta { display: block; font-size: 12px; color: var(--text-faint); margin-top: 2px; overflow-wrap: anywhere; }
.board-card .card-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.board-card .tag { font-size: 11px; padding: 2px 8px; border-radius: 6px; font-weight: 600; }
.board-card .tag-value { background: var(--accent-tint); color: var(--accent); }
.board-card .tag-lost { background: rgba(239,68,68,.15); color: #b42318; }
[data-theme="dark"] .board-card .tag-lost { color: #fca5a5; }
.board-card .card-footer {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line-soft);
  font-size: 12px; color: var(--text-muted);
}
.board-card .card-footer span { display: inline-flex; align-items: center; gap: 5px; }
.board-card .foot-ico { width: 14px; height: 14px; }
.sortable-ghost { opacity: .35; }
.sortable-chosen { box-shadow: 0 12px 28px -8px rgba(26,115,232,.45); }

/* ---------- Modal leve (sem Bootstrap JS) ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: grid; place-items: center; padding: 20px; z-index: 1060; }
.modal-overlay[hidden] { display: none; }
.modal-box {
  background: var(--surface); color: var(--text); border-radius: 16px; width: 100%; max-width: 560px; padding: 22px 24px 24px;
  box-shadow: 0 24px 60px -12px rgba(15,23,42,.45); max-height: 90vh; overflow-y: auto;
}
.modal-box-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-box-head h2 { font-size: 20px; margin: 0; color: var(--text); }
.modal-close { background: none; border: 0; font-size: 26px; line-height: 1; color: var(--text-muted); cursor: pointer; padding: 0 4px; }
.modal-close:hover { color: var(--text); }

/* ---------- Grelha de clientes / utilizadores (azulcards) ---------- */
.client-grid, .user-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(258px, 1fr)); gap: 16px; margin-bottom: 20px; }
.client-card, .user-card {
  display: flex; flex-direction: column; text-decoration: none;
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 2px solid var(--card-border); border-radius: 14px; padding: 16px;
  box-shadow: var(--shadow-card);
  transition: box-shadow .25s, transform .25s, border-color .25s;
}
.client-card:hover, .user-card:hover {
  border-color: var(--accent-strong); transform: translateY(-4px);
  box-shadow: var(--shadow-card-hover);
}
.client-card .cc-head, .user-card .cc-head { display: flex; align-items: flex-start; gap: 12px; }
.client-card .cc-icon, .user-card .cc-icon {
  width: 42px; height: 42px; border-radius: 11px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center; font-size: 22px;
}
.client-card .cc-icon svg, .user-card .cc-icon svg { width: 21px; height: 21px; }
.client-card .cc-title, .user-card .cc-title { min-width: 0; }
.client-card .cc-name, .user-card .cc-name {
  display: block; font-weight: 600;
  font-size: 15px; color: var(--text); line-height: 1.25;
}
.client-card:hover .cc-name, .user-card:hover .cc-name { color: var(--accent); }
.client-card .cc-sub, .user-card .cc-sub { display: block; font-size: 12.5px; color: var(--text-faint); margin-top: 3px; word-break: break-word; }
.client-card .cc-tags, .user-card .cc-tags { display: flex; align-items: center; justify-content: flex-start; gap: 8px; margin-top: 14px; }
.client-card .cc-tags { justify-content: space-between; }
.client-card .cc-sat { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); }
.client-card .cc-foot, .user-card .cc-foot {
  display: flex; align-items: center; gap: 6px; margin-top: 12px; padding-top: 10px;
  border-top: 1px solid var(--line-soft); font-size: 12px; color: var(--text-muted);
}
.client-card .cc-foot svg, .user-card .cc-foot svg { width: 14px; height: 14px; flex: 0 0 auto; }
.user-card .uc-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.user-card .uc-actions form { display: inline; margin: 0; }
.client-card .cc-main { display: flex; flex-direction: column; flex: 1 1 auto; text-decoration: none; color: inherit; }
.client-card .cc-actions { display: flex; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.client-card .cc-actions form { display: inline; margin: 0; }

/* ---------- Convidado / login ---------- */
.guest-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background:
  radial-gradient(1200px 500px at 50% -10%, #dbeafe 0%, var(--canvas) 55%); }
.guest-card { width: 100%; max-width: 400px; }
.guest-brand { display: flex; align-items: center; gap: 12px; justify-content: center; margin-bottom: 20px; }
.guest-brand .word b { font-weight: 700; font-size: 22px; color: var(--text); letter-spacing: -.02em; }
.guest-brand .word .tag { font-size: 11px; font-weight: 600; color: var(--accent); background: var(--accent-tint); padding: 1px 8px; border-radius: 999px; margin-left: 2px; }

/* ---------- Ficha do cliente (cabeçalho + separadores + cartões) ---------- */
.ficha-head { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.ficha-avatar {
  width: 56px; height: 56px; border-radius: 16px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 20px; color: #fff;
}
.ficha-avatar.is-client { background: linear-gradient(135deg, #22c55e, #15a34a); }
.ficha-avatar.is-prospect { background: linear-gradient(135deg, #3b82f6, #1a73e8); }
.ficha-id { flex: 1 1 auto; min-width: 0; }
.ficha-id h1 { font-weight: 600; font-size: 24px; color: var(--text); margin: 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ficha-id h1 .badge { font-size: 12px; }
.ficha-sub { margin: 4px 0 0; color: var(--text-faint); font-size: 13.5px; }
.ficha-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.ficha-actions form { margin: 0; }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 2px solid var(--line-soft); margin-bottom: 20px; }
.tab {
  appearance: none; background: none; border: 0; cursor: pointer;
  padding: 10px 16px; font-size: 14px; font-weight: 600; color: var(--text-muted);
  border-bottom: 2px solid transparent; margin-bottom: -2px; border-radius: 8px 8px 0 0;
  display: inline-flex; align-items: center; gap: 7px; transition: color .2s, border-color .2s, background .2s;
}
.tab:hover { color: var(--accent); background: var(--surface-2); }
.tab.is-active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-count { background: var(--line); color: var(--text-muted); border-radius: 10px; padding: 0 7px; font-size: 11.5px; font-weight: 600; }
.tab.is-active .tab-count { background: var(--accent-tint); color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 20px 22px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.panel-title { font-weight: 600; font-size: 15px; color: var(--text-strong); margin: 0 0 14px; }

.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px 24px; }
.fact { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.fact-wide { grid-column: 1 / -1; }
.fact-label { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-faint); }
.fact-value { font-size: 14.5px; color: var(--text); overflow-wrap: anywhere; }
.fact-value a { color: var(--accent); text-decoration: none; }
.fact-value a:hover { text-decoration: underline; }

/* dados da empresa em cartões agrupados */
.info-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; align-items: start; margin-bottom: 16px; }
.info-card { background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%); border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px; box-shadow: var(--shadow); }
.info-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--line-soft); }
.info-ico { width: 38px; height: 38px; border-radius: 10px; flex: 0 0 auto; display: flex; align-items: center; justify-content: center; font-size: 20px; }
.info-ico svg { width: 20px; height: 20px; }
.info-card-title { font-weight: 600; font-size: 15px; color: var(--text-strong); margin: 0; }
.card-facts { display: flex; flex-direction: column; gap: 12px; }

.contact-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.contact-card { background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%); border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.contact-top { display: flex; align-items: center; gap: 10px; }
.contact-avatar { width: 38px; height: 38px; border-radius: 10px; flex: 0 0 auto; display: flex; align-items: center; justify-content: center; background: var(--accent-tint); color: var(--accent); font-weight: 600; font-size: 14px; }
.contact-id { min-width: 0; }
.contact-name { display: block; font-weight: 600; font-size: 14px; color: var(--text); }
.contact-role { display: block; font-size: 12.5px; color: var(--text-faint); }
.contact-lines { display: flex; flex-direction: column; gap: 3px; font-size: 13px; }
.contact-lines a { color: var(--text-muted); text-decoration: none; overflow-wrap: anywhere; }
.contact-lines a:hover { color: var(--accent); text-decoration: underline; }
.contact-actions { display: flex; gap: 6px; margin-top: auto; }
.contact-actions form { margin: 0; }

.deal-group-title { font-weight: 600; font-size: 13.5px; color: var(--text-muted); margin: 4px 0 10px; }
.deal-group-title:not(:first-child) { margin-top: 20px; }
.deal-list { display: flex; flex-direction: column; gap: 10px; }
.deal-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: 12px; padding: 12px 14px; }
.deal-main { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.deal-stage { font-size: 11.5px; font-weight: 600; padding: 3px 10px; border-radius: 999px; color: #fff; white-space: nowrap; }
.stage-prospect { background: var(--st-prospect); }
.stage-waiting { background: var(--st-waiting); }
.stage-ongoing { background: var(--st-ongoing); }
.stage-won { background: var(--st-won); }
.stage-lost { background: var(--st-lost); }
.deal-next { font-size: 14px; color: var(--text); }
.deal-lost { font-size: 12px; color: #b42318; background: rgba(239,68,68,.15); padding: 2px 8px; border-radius: 6px; }
[data-theme="dark"] .deal-lost { color: #fca5a5; }
.deal-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.deal-value { font-weight: 600; color: var(--accent); font-size: 14px; }
.deal-date { font-size: 13px; color: var(--text-muted); }

.sat-list { display: flex; flex-direction: column; gap: 8px; }
.sat-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
.sat-row:last-child { border-bottom: 0; }
.sat-comment { flex: 1 1 auto; min-width: 0; color: var(--text); font-size: 14px; }
.sat-when, .sat-who { font-size: 12.5px; color: var(--text-faint); }

/* descrição em dl (ex.: ver negócio) */
dl.row dt { color: var(--text-muted); font-weight: 600; }
dl.row dd { color: var(--text); }

/* ---------- Formulário em secções ---------- */
.form-section { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.form-section-title { font-weight: 600; font-size: 14px; color: var(--text-strong); margin: 0 0 14px; }

/* texto utilitário coerente com o tema */
.text-muted { color: var(--text-muted) !important; }

/* pequenos acertos de ícones/legendas */
.client-card .cc-foot i, .user-card .cc-foot i { font-size: 15px; line-height: 1; }
.sub { color: var(--text-muted); }

/* ---------- a11y ---------- */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--accent); color: #fff; padding: 8px 14px; border-radius: 0 0 8px 0; z-index: 2000; }
.skip-link:focus { left: 0; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
