/* ==========================================================================
   Stats21 — design system (Bootstrap 5.3 + tokens próprios)
   --------------------------------------------------------------------------
   · A cor da marca vem de --brand (inline no <head>, lida do style.css da
     instalação ou do AP.COR_PRINCIPAL — ver marcaCores()).
   · Modo escuro: [data-bs-theme="dark"] no <html> (Bootstrap 5.3 nativo);
     os tokens abaixo trocam com ele.
   · As classes do layout antigo (AdminLTE 3: content-wrapper, content-header,
     img-circle, ribbon…) continuam a funcionar — ver «Compatibilidade».
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  --brand: #009fe3;
  --brand-2: #b3ffe6;
  --brand-ink: #ffffff;
  --brand-soft: color-mix(in srgb, var(--brand) 10%, transparent);
  --brand-soft-2: color-mix(in srgb, var(--brand) 18%, transparent);

  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f6;
  --border: #e3e8ef;
  --border-strong: #cfd6e0;
  --text: #1b2330;
  --text-muted: #667085;
  --text-soft: #8a94a6;

  --ok: #16a34a;      --ok-soft: #dcfce7;      --ok-ink: #14532d;
  --warn: #d97706;    --warn-soft: #fef3c7;    --warn-ink: #78350f;
  --err: #dc2626;     --err-soft: #fee2e2;     --err-ink: #7f1d1d;
  --info: #0284c7;    --info-soft: #e0f2fe;    --info-ink: #0c4a6e;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .14);

  --sidebar-w: 248px;
  --sidebar-w-min: 68px;
  --topbar-h: 56px;

  --bs-body-bg: var(--bg);
  --bs-body-color: var(--text);
  --bs-border-color: var(--border);
  --bs-secondary-color: var(--text-muted);
  --bs-link-color: var(--brand);
  --bs-link-hover-color: color-mix(in srgb, var(--brand) 80%, #000);
  --bs-link-color-rgb: 0, 159, 227;
  --bs-font-sans-serif: "Source Sans Pro", "Source Sans 3", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --bs-body-font-size: .9375rem;
  --bs-border-radius: var(--radius-sm);
  --bs-card-border-radius: var(--radius);
}

[data-bs-theme="dark"] {
  --brand-soft: color-mix(in srgb, var(--brand) 18%, transparent);
  --brand-soft-2: color-mix(in srgb, var(--brand) 28%, transparent);

  --bg: #0e131a;
  --surface: #151c26;
  --surface-2: #1a2330;
  --surface-3: #212c3b;
  --border: #253142;
  --border-strong: #344358;
  --text: #e5eaf1;
  --text-muted: #9aa6b8;
  --text-soft: #7b8799;

  --ok-soft: #12321f;   --ok-ink: #86efac;
  --warn-soft: #3a2a0c; --warn-ink: #fcd34d;
  --err-soft: #3b1414;  --err-ink: #fca5a5;
  --info-soft: #0c2b3d; --info-ink: #7dd3fc;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 1px 3px rgba(0, 0, 0, .5);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, .55);

  --bs-body-bg: var(--bg);
  --bs-body-color: var(--text);
  --bs-border-color: var(--border);
  --bs-secondary-color: var(--text-muted);
  --bs-tertiary-bg: var(--surface-2);
  --bs-secondary-bg: var(--surface-3);
  --bs-emphasis-color: #fff;
}

/* ---------- Base ---------- */
html { -webkit-text-size-adjust: 100%; }
body { background: var(--bg); color: var(--text); font-feature-settings: "tnum" 0; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
a.btn:hover, .nav-link:hover, .dropdown-item:hover, .list-group-item-action:hover { text-decoration: none; }
h1, h2, h3, h4, h5, h6 { color: var(--text); font-weight: 600; letter-spacing: -.01em; }
.text-muted { color: var(--text-muted) !important; }
code { color: color-mix(in srgb, var(--brand) 70%, var(--text)); }
::selection { background: var(--brand-soft-2); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.num, td.num, .tabular { font-variant-numeric: tabular-nums; }
hr { border-color: var(--border); opacity: 1; }

/* ---------- Shell ---------- */
.app-shell { min-height: 100vh; }
.app-sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 1040;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  transition: width .18s ease, transform .2s ease;
}
.app-main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex; flex-direction: column;
  transition: margin-left .18s ease;
}
.app-topbar {
  position: sticky; top: 0; z-index: 1030;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: .5rem;
  padding: 0 1rem;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(160%) blur(8px);
  border-bottom: 1px solid var(--border);
}
.app-content { flex: 1 1 auto; }
.app-footer {
  padding: .9rem 1.5rem; font-size: .8rem; color: var(--text-soft);
  border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
}
.app-footer a { color: var(--text-muted); }

/* Sidebar compacta (desktop) */
body.sidebar-min .app-sidebar { width: var(--sidebar-w-min); }
body.sidebar-min .app-main { margin-left: var(--sidebar-w-min); }
body.sidebar-min .app-sidebar .nav-label,
body.sidebar-min .app-sidebar .nav-group-title,
body.sidebar-min .app-sidebar .brand-name,
body.sidebar-min .app-sidebar .sidebar-user-info { display: none; }
body.sidebar-min .app-sidebar .nav-link { justify-content: center; padding-left: 0; padding-right: 0; }
body.sidebar-min .app-sidebar .nav-group { padding-top: .35rem; }
body.sidebar-min .app-sidebar .nav-group + .nav-group { border-top: 1px solid var(--border); }

/* Mobile: sidebar off-canvas */
.sidebar-backdrop { display: none; }
@media (max-width: 991.98px) {
  .app-sidebar { transform: translateX(-100%); width: var(--sidebar-w) !important; box-shadow: var(--shadow-lg); }
  .app-main { margin-left: 0 !important; }
  body.sidebar-open .app-sidebar { transform: none; }
  body.sidebar-open .sidebar-backdrop {
    display: block; position: fixed; inset: 0; z-index: 1035; background: rgba(8, 12, 18, .45);
  }
  body.sidebar-min .app-sidebar .nav-label,
  body.sidebar-min .app-sidebar .nav-group-title,
  body.sidebar-min .app-sidebar .brand-name,
  body.sidebar-min .app-sidebar .sidebar-user-info { display: revert; }
}

/* ---------- Sidebar ---------- */
.sidebar-brand {
  height: var(--topbar-h); flex: 0 0 auto;
  display: flex; align-items: center; gap: .6rem;
  padding: 0 1rem; border-bottom: 1px solid var(--border);
  color: var(--text); font-weight: 700; letter-spacing: -.01em;
}
.sidebar-brand:hover { text-decoration: none; color: var(--text); }
.sidebar-brand .brand-mark {
  width: 32px; height: 32px; border-radius: 9px; flex: 0 0 32px;
  display: grid; place-items: center;
  background: var(--brand); color: var(--brand-ink); font-size: .95rem; font-weight: 800;
  box-shadow: 0 2px 6px color-mix(in srgb, var(--brand) 40%, transparent);
}
.sidebar-brand .brand-name { font-size: 1.02rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-brand .brand-name small { display: block; font-size: .68rem; font-weight: 600; color: var(--text-soft); text-transform: uppercase; letter-spacing: .06em; }
.sidebar-scroll { flex: 1 1 auto; overflow-y: auto; padding: .5rem .6rem 1rem; scrollbar-width: thin; }
.nav-group { padding-top: .75rem; }
.nav-group:first-child { padding-top: .25rem; }
/* Títulos dos grupos (não clicáveis) na cor do clube: em --text-soft mal se
   distinguiam dos itens. */
.nav-group-title {
  font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  color: var(--brand); padding: 0 .65rem .3rem;
}
.app-sidebar .nav-link {
  display: flex; align-items: center; gap: .7rem;
  padding: .45rem .65rem; margin: 1px 0; border-radius: var(--radius-sm);
  color: var(--text-muted); font-weight: 500; font-size: .9rem; line-height: 1.25;
  position: relative;
}
.app-sidebar .nav-link .bi { font-size: 1.05rem; width: 1.25rem; text-align: center; flex: 0 0 1.25rem; }
.app-sidebar .nav-link:hover { background: var(--surface-3); color: var(--text); }
.app-sidebar .nav-link.active {
  background: var(--brand-soft); color: var(--brand); font-weight: 600;
}
.app-sidebar .nav-link.active::before {
  content: ""; position: absolute; left: -.6rem; top: 20%; bottom: 20%;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--brand);
}
.sidebar-user {
  flex: 0 0 auto; border-top: 1px solid var(--border);
  padding: .65rem .8rem; display: flex; align-items: center; gap: .6rem;
}
.sidebar-user img { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border); }
.sidebar-user-info { min-width: 0; line-height: 1.2; }
.sidebar-user-info a { color: var(--text); font-weight: 600; font-size: .88rem; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-info span { font-size: .72rem; color: var(--text-soft); }

/* ---------- Topbar ---------- */
.topbar-btn {
  width: 38px; height: 38px; border-radius: var(--radius-sm);
  display: inline-grid; place-items: center; flex: 0 0 38px;
  border: 1px solid transparent; background: transparent; color: var(--text-muted);
  font-size: 1.1rem; position: relative;
}
.topbar-btn:hover { background: var(--surface-3); color: var(--text); }
.topbar-btn .dot {
  position: absolute; top: 7px; right: 7px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--err); box-shadow: 0 0 0 2px var(--surface);
}
.topbar-search {
  flex: 1 1 auto; max-width: 520px; margin: 0 .5rem;
  display: flex; align-items: center; gap: .55rem;
  height: 38px; padding: 0 .75rem;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface-2); color: var(--text-soft); font-size: .9rem;
  cursor: text; text-align: left;
}
.topbar-search:hover { border-color: var(--border-strong); color: var(--text-muted); }
.topbar-search span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.topbar-search kbd { margin-left: auto; white-space: nowrap; }
@media (max-width: 767.98px) { .topbar-search kbd { display: none; } }
kbd {
  font-family: inherit; font-size: .7rem; font-weight: 600;
  padding: .1rem .38rem; border-radius: 5px;
  background: var(--surface); color: var(--text-muted);
  border: 1px solid var(--border); box-shadow: 0 1px 0 var(--border);
}
.topbar-user { display: flex; align-items: center; gap: .5rem; padding: .2rem .35rem .2rem .2rem; border-radius: 999px; border: 1px solid transparent; background: transparent; color: var(--text); }
.topbar-user:hover { background: var(--surface-3); }
.topbar-user img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; }
.topbar-user span { font-weight: 600; font-size: .88rem; }
@media (max-width: 575.98px) { .topbar-user span, .topbar-search span, .topbar-search kbd { display: none; } .topbar-search { flex: 0 0 38px; width: 38px; padding: 0; justify-content: center; margin: 0; } }

.dropdown-menu {
  --bs-dropdown-bg: var(--surface); --bs-dropdown-border-color: var(--border);
  --bs-dropdown-link-color: var(--text); --bs-dropdown-link-hover-bg: var(--surface-3);
  --bs-dropdown-link-active-bg: var(--brand); --bs-dropdown-border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: .35rem; font-size: .9rem;
}
.dropdown-item { border-radius: 6px; display: flex; align-items: center; gap: .55rem; }
.dropdown-item .bi { color: var(--text-muted); }

/* ---------- Página (compatível com content-wrapper/content-header/content) ---------- */
.content-wrapper { padding: 1.25rem 1.5rem 2rem; }
.content-wrapper > .content-header { padding: 0 0 1rem; }
.content-wrapper > .content-header > .container-fluid,
.content-wrapper > .content > .container-fluid { padding-left: 0; padding-right: 0; }
.content-header h1, .content-header .h1 { font-size: 1.4rem; font-weight: 650; margin: 0; line-height: 1.3; display: flex; align-items: center; flex-wrap: wrap; gap: .4rem .55rem; }
.content-header h1 .bi { color: var(--brand); }
.content-header .row { align-items: center; row-gap: .5rem; }
.content-header .row.mb-2 { margin-bottom: 0 !important; }
.breadcrumb { margin: 0; font-size: .82rem; --bs-breadcrumb-divider-color: var(--text-soft); --bs-breadcrumb-item-active-color: var(--text-muted); align-items: center; }
.breadcrumb a { color: var(--text-muted); }
.content-header .breadcrumb { flex-wrap: wrap; gap: .25rem 0; }
.content-header .row .breadcrumb, .content-header .breadcrumb.float-sm-end { justify-content: flex-end; }
@media (max-width: 575.98px) {
  .content-wrapper { padding: 1rem .9rem 1.5rem; }
  .content-header .breadcrumb { justify-content: flex-start; }
}
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* ---------- Cards ---------- */
.card {
  --bs-card-bg: var(--surface); --bs-card-border-color: var(--border);
  --bs-card-cap-bg: transparent; --bs-card-border-radius: var(--radius);
  --bs-card-inner-border-radius: calc(var(--radius) - 1px);
  box-shadow: var(--shadow-sm); margin-bottom: 1.25rem;
}
.card-header { padding: .8rem 1rem; border-bottom-color: var(--border); display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; }
.card-header > .card-title, .card-title { margin: 0; font-size: 1rem; font-weight: 600; }
.card-header .card-tools, .card-header .ms-auto { margin-left: auto; }
.card-footer { background: var(--surface-2); border-top-color: var(--border); }
.card-outline { border-top: 3px solid var(--brand); }
.card.h-100 { margin-bottom: 0; }
.row > [class*="col"] > .card.h-100 { margin-bottom: 1.25rem; }

/* ---------- Botões ---------- */
.btn { --bs-btn-font-weight: 500; --bs-btn-border-radius: var(--radius-sm); display: inline-flex; align-items: center; justify-content: center; gap: .35rem; }
.btn-sm { --bs-btn-border-radius: 6px; }
.btn-primary, .cor_principal.btn, .btn.cor_principal {
  --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-color: var(--brand-ink);
  --bs-btn-hover-bg: color-mix(in srgb, var(--brand) 88%, #000); --bs-btn-hover-border-color: color-mix(in srgb, var(--brand) 88%, #000); --bs-btn-hover-color: var(--brand-ink);
  --bs-btn-active-bg: color-mix(in srgb, var(--brand) 80%, #000); --bs-btn-active-border-color: color-mix(in srgb, var(--brand) 80%, #000); --bs-btn-active-color: var(--brand-ink);
  --bs-btn-disabled-bg: var(--brand); --bs-btn-disabled-border-color: var(--brand);
  --bs-btn-focus-shadow-rgb: 0, 159, 227;
}
.btn-outline-primary {
  --bs-btn-color: var(--brand); --bs-btn-border-color: var(--brand);
  --bs-btn-hover-bg: var(--brand); --bs-btn-hover-border-color: var(--brand); --bs-btn-hover-color: var(--brand-ink);
  --bs-btn-active-bg: var(--brand); --bs-btn-active-border-color: var(--brand);
}
.btn-light, .btn-ghost {
  --bs-btn-bg: var(--surface); --bs-btn-border-color: var(--border); --bs-btn-color: var(--text);
  --bs-btn-hover-bg: var(--surface-3); --bs-btn-hover-border-color: var(--border-strong); --bs-btn-hover-color: var(--text);
}

/* ---------- Tabelas ---------- */
.table {
  --bs-table-bg: transparent; --bs-table-color: var(--text);
  --bs-table-border-color: var(--border);
  --bs-table-hover-bg: var(--surface-2); --bs-table-hover-color: var(--text);
  --bs-table-striped-bg: color-mix(in srgb, var(--surface-3) 45%, transparent);
  font-size: .875rem; margin-bottom: 0;
}
.table > thead > tr > th, .table > thead th {
  font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-muted); background: var(--surface-2); border-bottom-width: 1px; white-space: nowrap;
  vertical-align: middle;
}
.table > :not(caption) > * > * { padding: .5rem .65rem; vertical-align: middle; }
.table-sm > :not(caption) > * > *, table.compact > :not(caption) > * > * { padding: .3rem .5rem; }
.table-light, .thead-light, tr.table-light > * { --bs-table-bg: var(--surface-2); --bs-table-color: var(--text); }
.table-responsive { border-radius: var(--radius-sm); }
td.nums, td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.card-body > .table-responsive:only-child, .card-body.p-0 > .table { margin: 0; }

/* DataTables (bootstrap5) */
div.dataTables_wrapper div.dataTables_filter input { margin-left: .4rem; width: 14rem; max-width: 100%; }
div.dataTables_wrapper div.dataTables_length select { width: auto; display: inline-block; }
div.dataTables_wrapper div.dataTables_info { color: var(--text-muted); font-size: .82rem; padding-top: .7rem; }
div.dataTables_wrapper div.dataTables_processing {
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow);
}
div.dataTables_wrapper .dt-buttons { margin-bottom: .5rem; gap: .25rem; }
div.dataTables_wrapper .dt-buttons .btn { --bs-btn-bg: var(--surface); --bs-btn-border-color: var(--border); --bs-btn-color: var(--text); --bs-btn-hover-bg: var(--surface-3); --bs-btn-hover-color: var(--text); --bs-btn-hover-border-color: var(--border-strong); font-size: .8rem; padding: .25rem .6rem; }
div.dataTables_wrapper .top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .5rem; }
div.dataTables_wrapper .top > div { padding-top: 0 !important; }
div.dataTables_wrapper .bottom { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; }
.page-link { --bs-pagination-bg: var(--surface); --bs-pagination-border-color: var(--border); --bs-pagination-color: var(--text-muted); --bs-pagination-hover-bg: var(--surface-3); --bs-pagination-hover-color: var(--text); --bs-pagination-active-bg: var(--brand); --bs-pagination-active-border-color: var(--brand); font-size: .82rem; }
.pagination { --bs-pagination-active-bg: var(--brand); --bs-pagination-active-border-color: var(--brand); --bs-pagination-bg: var(--surface); --bs-pagination-border-color: var(--border); --bs-pagination-color: var(--text-muted); --bs-pagination-hover-bg: var(--surface-3); --bs-pagination-hover-color: var(--text); --bs-pagination-disabled-bg: var(--surface); }
table.dataTable thead th, table.dataTable thead td { border-bottom-color: var(--border) !important; }
table.dataTable img.thumb, img.thumb { width: 32px; height: 32px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-2); }
table.dataTable tbody tr.selected > * { box-shadow: inset 0 0 0 9999px var(--brand-soft-2); color: var(--text); }
table.dataTable thead tr:nth-child(2) th { padding: .25rem !important; background: var(--surface); text-transform: none; letter-spacing: 0; }
table.dataTable thead tr:nth-child(2) input, table.dataTable thead tr:nth-child(2) select { font-size: .78rem; padding: .2rem .4rem; min-height: 0; height: auto; }

/* ---------- Formulários ---------- */
.form-control, .form-select {
  --bs-body-bg: var(--surface);
  background-color: var(--surface); border-color: var(--border-strong); color: var(--text);
}
.form-control:focus, .form-select:focus { border-color: var(--brand); box-shadow: 0 0 0 .2rem var(--brand-soft-2); }
.form-control::placeholder { color: var(--text-soft); }
.form-label, label { font-weight: 500; color: var(--text); }
.form-text { color: var(--text-muted); }
.input-group-text { background: var(--surface-2); border-color: var(--border-strong); color: var(--text-muted); }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }

/* select2 (tema por omissão) alinhado com o Bootstrap 5 e o modo escuro */
.select2-container--default .select2-selection--single,
.select2-container--default .select2-selection--multiple {
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); min-height: 38px;
}
.select2-container--default .select2-selection--single { height: 38px; }
.select2-container--default .select2-selection--single .select2-selection__rendered { line-height: 36px; color: var(--text); padding-left: .75rem; }
.select2-container--default .select2-selection--single .select2-selection__arrow { height: 36px; }
.select2-container--default.select2-container--focus .select2-selection--multiple,
.select2-container--default.select2-container--open .select2-selection--single { border-color: var(--brand); box-shadow: 0 0 0 .2rem var(--brand-soft-2); }
.select2-dropdown { background: var(--surface); border-color: var(--border-strong); color: var(--text); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); }
.select2-container--default .select2-search--dropdown .select2-search__field { background: var(--surface-2); color: var(--text); border-color: var(--border); border-radius: 6px; }
.select2-container--default .select2-results__option--highlighted[aria-selected],
.select2-container--default .select2-results__option--highlighted.select2-results__option--selectable { background: var(--brand); }
.select2-container--default .select2-results__option--selected,
.select2-container--default .select2-results__option[aria-selected=true] { background: var(--surface-3); }
.select2-container--default .select2-selection--multiple .select2-selection__choice { background: var(--brand-soft); border-color: var(--brand-soft-2); color: var(--text); border-radius: 5px; }
.select2-container .select2-search--inline .select2-search__field { color: var(--text); }

/* ---------- Alertas, badges, pills ---------- */
.alert { border-radius: var(--radius-sm); border-width: 1px; font-size: .9rem; }
.alert .bi { margin-top: .15rem; }
.alert-success { --bs-alert-bg: var(--ok-soft); --bs-alert-color: var(--ok-ink); --bs-alert-border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.alert-warning { --bs-alert-bg: var(--warn-soft); --bs-alert-color: var(--warn-ink); --bs-alert-border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.alert-danger  { --bs-alert-bg: var(--err-soft);  --bs-alert-color: var(--err-ink);  --bs-alert-border-color: color-mix(in srgb, var(--err) 30%, transparent); }
.alert-info    { --bs-alert-bg: var(--info-soft); --bs-alert-color: var(--info-ink); --bs-alert-border-color: color-mix(in srgb, var(--info) 30%, transparent); }
.alert a { color: inherit; text-decoration: underline; font-weight: 600; }
.badge { font-weight: 600; letter-spacing: .01em; }
.state-pill, .pill {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .12rem .5rem; border-radius: 999px;
  font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap;
  background: var(--surface-3); color: var(--text-muted);
}
.state-ok, .pill-ok { background: var(--ok-soft) !important; color: var(--ok-ink) !important; }
.state-pending, .state-unknown, .pill-warn { background: var(--warn-soft) !important; color: var(--warn-ink) !important; }
.state-failed, .state-fetch_failed, .state-not_found, .state-parse_error, .state-no_current_club, .pill-err { background: var(--err-soft) !important; color: var(--err-ink) !important; }
.pill-info, .state-running { background: var(--info-soft) !important; color: var(--info-ink) !important; }
.pill-brand { background: var(--brand-soft); color: var(--brand); }

/* ---------- KPI / métricas ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .9rem; margin-bottom: 1.25rem; }
@media (max-width: 575.98px) { .kpi-grid { gap: .6rem; } .kpi-card { padding: .75rem .8rem; } .kpi-card .kpi-num { font-size: 1.35rem; } }
.kpi-card {
  --c: var(--brand);
  display: block; height: 100%;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .9rem 1rem; box-shadow: var(--shadow-sm);
  color: var(--text); text-decoration: none; text-align: left;
  position: relative; overflow: hidden;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.kpi-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--c); }
a.kpi-card:hover { transform: translateY(-1px); box-shadow: var(--shadow); border-color: var(--border-strong); text-decoration: none; color: var(--text); }
.kpi-card .kpi-num, .kpi-num { font-size: 1.65rem; font-weight: 700; line-height: 1.1; color: var(--text); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.kpi-card .kpi-lbl, .kpi-lbl { font-size: .72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; margin-top: .25rem; }
.kpi-card .kpi-ico { position: absolute; right: .9rem; top: .85rem; font-size: 1.2rem; color: var(--c); opacity: .85; }
.kpi-card .kpi-sub { font-size: .78rem; color: var(--text-soft); margin-top: .35rem; }

/* Atalhos */
.quick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .5rem; }
.quick-link {
  display: flex; align-items: center; gap: .6rem;
  padding: .55rem .7rem; border-radius: var(--radius-sm);
  color: var(--text); background: var(--surface); border: 1px solid var(--border);
  font-size: .86rem; font-weight: 500;
}
.quick-link:hover { background: var(--surface-2); border-color: var(--border-strong); text-decoration: none; color: var(--text); }
.quick-link i { font-size: 1rem; color: var(--brand); width: 1.1rem; text-align: center; }
.quick-section-title { grid-column: 1/-1; font-size: .68rem; text-transform: uppercase; color: var(--text-soft); font-weight: 700; letter-spacing: .07em; margin: .6rem .1rem .1rem; }
.quick-section-title:first-child { margin-top: 0; }

/* Listas simples de linhas (feeds, tenants) */
.row-list { list-style: none; margin: 0; padding: 0; }
.row-list > li { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .5rem 0; border-bottom: 1px solid var(--border); font-size: .88rem; }
.row-list > li:last-child { border-bottom: 0; }

/* Estado vazio */
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--text-muted); }
.empty-state .bi { font-size: 2rem; color: var(--text-soft); display: block; margin-bottom: .5rem; }

/* ---------- Pesquisa global (Ctrl+K) ---------- */
.cmdk .modal-dialog { max-width: 640px; margin-top: 10vh; }
.cmdk .modal-content { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); overflow: hidden; }
.cmdk-input { display: flex; align-items: center; gap: .6rem; padding: .85rem 1rem; border-bottom: 1px solid var(--border); }
.cmdk-input .bi { font-size: 1.1rem; color: var(--text-soft); }
.cmdk-input input { flex: 1; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 1.05rem; }
.cmdk-results { max-height: 60vh; overflow-y: auto; padding: .4rem; }
.cmdk-group { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--text-soft); padding: .55rem .65rem .25rem; }
.cmdk-item { display: flex; align-items: center; gap: .7rem; padding: .5rem .65rem; border-radius: 8px; color: var(--text); cursor: pointer; }
.cmdk-item:hover, .cmdk-item.sel { background: var(--brand-soft); color: var(--text); text-decoration: none; }
.cmdk-item .ico { width: 30px; height: 30px; flex: 0 0 30px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-muted); overflow: hidden; }
.cmdk-item .ico img { width: 100%; height: 100%; object-fit: cover; }
.cmdk-item .t { font-weight: 600; font-size: .92rem; line-height: 1.2; }
.cmdk-item .s { font-size: .78rem; color: var(--text-muted); }
.cmdk-item .k { margin-left: auto; font-size: .72rem; color: var(--text-soft); }
.cmdk-foot { display: flex; gap: 1rem; padding: .5rem 1rem; border-top: 1px solid var(--border); font-size: .74rem; color: var(--text-soft); background: var(--surface-2); }
.cmdk-empty { padding: 2rem 1rem; text-align: center; color: var(--text-muted); font-size: .9rem; }

/* ---------- Modais, tooltips, toasts ---------- */
.modal-content { background: var(--surface); border-color: var(--border); border-radius: var(--radius); }
.modal-header, .modal-footer { border-color: var(--border); }
.tooltip-inner { white-space: pre-line; text-align: left; max-width: 320px; }
.toast-stack { position: fixed; right: 1rem; bottom: 1rem; z-index: 1090; display: flex; flex-direction: column; gap: .5rem; }

/* ---------- Compatibilidade (layout antigo AdminLTE 3 / BS4) ---------- */
.img-circle { border-radius: 50% !important; }
.elevation-1, .elevation-2, .elevation-3, .elevation-4 { box-shadow: var(--shadow) !important; }
.text-lg { font-size: 1.2rem !important; }
.text-sm { font-size: .875rem !important; }
.text-cor_principal { color: var(--brand) !important; }
.cor_principal { background-color: var(--brand) !important; color: var(--brand-ink) !important; }
.cor_secundaria, tr.cor_secundaria > th, tr.cor_secundaria > td { background-color: var(--surface-2) !important; color: var(--text-muted); }
.pc { }
@media (max-width: 600px) { .pc { display: none !important; } }
.ribbon-wrapper { position: absolute; right: -2px; top: -2px; width: 90px; height: 90px; overflow: hidden; z-index: 10; }
.ribbon-wrapper.ribbon-lg { width: 120px; height: 120px; }
.ribbon-wrapper .ribbon {
  position: absolute; right: -32px; top: 18px; width: 130px; transform: rotate(45deg);
  text-align: center; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  padding: .2rem 0; box-shadow: var(--shadow-sm);
}
.ribbon-wrapper.ribbon-lg .ribbon { right: 0; top: 26px; width: 160px; }
.card { position: relative; }

/* Tabelas de detalhe de sync / reconciliação (cores que existiam inline) */
.val-changed { background: var(--warn-soft) !important; }
.val-empty { color: var(--text-soft); font-style: italic; }
.pers-yes { color: var(--ok); } .pers-no { color: var(--err); }
.extra-row td { background: color-mix(in srgb, var(--warn-soft) 60%, transparent) !important; }
.field-tbl thead { background: var(--surface-2) !important; }
.raw-key { font-family: ui-monospace, Consolas, monospace; font-size: .74rem; color: var(--text-muted); }

/* Correcções para o modo escuro de estilos que as views ainda fixam em claro */
[data-bs-theme="dark"] .bg-light { background-color: var(--surface-2) !important; color: var(--text); }
[data-bs-theme="dark"] .bg-white { background-color: var(--surface) !important; }
[data-bs-theme="dark"] .text-dark { color: var(--text) !important; }
[data-bs-theme="dark"] .badge.text-dark, [data-bs-theme="dark"] .bg-warning.text-dark, [data-bs-theme="dark"] .text-bg-warning { color: #1b1b1b !important; }
[data-bs-theme="dark"] .lg-filters, [data-bs-theme="dark"] .step, [data-bs-theme="dark"] .kpi-strip > div,
[data-bs-theme="dark"] .quick-link, [data-bs-theme="dark"] code.url { background: var(--surface-2) !important; border-color: var(--border) !important; color: var(--text) !important; }
[data-bs-theme="dark"] .cs-tenant-tbl th, [data-bs-theme="dark"] .lg-table th, [data-bs-theme="dark"] .lg-act th { background: var(--surface-2) !important; color: var(--text-muted) !important; }
[data-bs-theme="dark"] .run-running, [data-bs-theme="dark"] .sync-row.is-running, [data-bs-theme="dark"] .cs-tenant-err { background: var(--warn-soft) !important; }
[data-bs-theme="dark"] .lg-msg b, [data-bs-theme="dark"] .cs-conteudo-cell .item b { color: var(--text) !important; }
[data-bs-theme="dark"] img.flag, [data-bs-theme="dark"] .brand-mark { filter: none; }

/* ---------- Impressão ---------- */
@media print {
  .app-sidebar, .app-topbar, .app-footer, .dt-buttons, .dataTables_filter, .dataTables_length, .dataTables_paginate, .btn, .no-print { display: none !important; }
  .app-main { margin: 0 !important; }
  .content-wrapper { padding: 0 !important; }
  .card { box-shadow: none; border-color: #ccc; break-inside: avoid; }
  body { background: #fff; color: #000; }
}
.d-contents { display: contents; }

/* ---------- Páginas de autenticação ---------- */
.auth-page { min-height: 100vh; background:
  radial-gradient(1200px 600px at 10% -10%, var(--brand-soft-2), transparent 60%),
  radial-gradient(900px 500px at 110% 110%, var(--brand-soft), transparent 60%), var(--bg); }
.auth-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2rem 1rem; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 1.75rem; }
.auth-brand { display: flex; align-items: center; gap: .7rem; margin-bottom: 1.5rem; }
.auth-brand .brand-mark { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--brand); color: var(--brand-ink); font-weight: 800; }
.auth-brand b { display: block; line-height: 1.1; }
.auth-brand small { color: var(--text-soft); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.auth-title { font-size: 1.35rem; margin: 0 0 .35rem; }
.auth-sub { color: var(--text-muted); font-size: .9rem; margin-bottom: 1.25rem; }
.auth-foot { margin-top: 1.25rem; font-size: .78rem; color: var(--text-soft); }

/* ---------- Ficha 360 (jogador / clube) ---------- */
.hero { display: grid; grid-template-columns: auto 1fr auto; gap: 1.25rem; align-items: start; }
.hero-photo { width: 104px; height: 104px; border-radius: 16px; object-fit: cover; background: var(--surface-3); border: 1px solid var(--border); }
.hero-photo.logo { object-fit: contain; padding: .5rem; background: var(--surface); }
.hero-name { font-size: 1.5rem; margin: 0 0 .25rem; display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; }
.hero-sub { display: flex; flex-wrap: wrap; gap: .35rem 1rem; color: var(--text-muted); font-size: .92rem; margin-bottom: .6rem; }
.hero-sub a { font-weight: 600; }
.hero-chips, .hero-links { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .5rem; }
.meta-chip { display: inline-flex; align-items: center; gap: .35rem; padding: .2rem .6rem; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: .82rem; color: var(--text); }
.src-link { display: inline-flex; align-items: center; gap: .35rem; padding: .2rem .55rem; border-radius: 7px; border: 1px solid var(--border); font-size: .8rem; color: var(--text-muted); background: var(--surface); }
.src-link img { width: 16px; height: 16px; }
.src-link:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.src-link.muted { border-style: dashed; }
.hero-actions { display: flex; flex-direction: column; gap: .4rem; min-width: 150px; }
.hero-actions .btn { justify-content: flex-start; }
img.flag { width: 20px; height: 15px; border-radius: 2px; vertical-align: -2px; box-shadow: 0 0 0 1px var(--border); }
@media (max-width: 767.98px) {
  .hero { grid-template-columns: auto 1fr; }
  .hero-side { grid-column: 1 / -1; }
  .hero-actions { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; min-width: 0; }
  .hero-actions > * { flex: 1 1 auto; }
  .hero-photo { width: 72px; height: 72px; }
  .hero-name { font-size: 1.2rem; }
}

.app-tabs { border-bottom: 1px solid var(--border); margin-bottom: 1rem; gap: .25rem; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.app-tabs .nav-link { border: 0; border-bottom: 2px solid transparent; color: var(--text-muted); font-weight: 600; font-size: .9rem; padding: .6rem .85rem; background: none; white-space: nowrap; border-radius: 0; }
.app-tabs .nav-link:hover { color: var(--text); border-bottom-color: var(--border-strong); }
.app-tabs .nav-link.active { color: var(--brand); border-bottom-color: var(--brand); background: none; }

.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .9rem 1.25rem; margin: 0; }
.fact dt { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-soft); font-weight: 700; margin-bottom: .15rem; }
.fact dt .bi { color: var(--text-soft); }
.fact dd { margin: 0; font-size: .95rem; }

.min-strip { display: flex; align-items: flex-end; gap: 3px; height: 110px; padding-top: 14px; border-bottom: 1px dashed var(--border-strong); overflow-x: auto; }
.min-bar { flex: 1 0 10px; max-width: 26px; border-radius: 4px 4px 0 0; position: relative; background: var(--brand); }
.min-bar.sup { background: color-mix(in srgb, var(--brand) 45%, transparent); }
.min-bar.nu { background: var(--border-strong); }
.min-bar i { position: absolute; top: -16px; left: 50%; transform: translateX(-50%); font-style: normal; font-size: .68rem; font-weight: 800; color: var(--ok); }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: -1px; margin-right: 3px; }
.card-y, .card-r { display: inline-block; width: 9px; height: 12px; border-radius: 2px; margin-right: 2px; vertical-align: -1px; }
.card-y { background: #facc15; } .card-r { background: #ef4444; }

.pct-row { display: grid; grid-template-columns: 110px 1fr 44px 70px; align-items: center; gap: .6rem; padding: .35rem 0; }
.pct-lbl { font-size: .86rem; color: var(--text-muted); }
.pct-bar { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.pct-bar > span { display: block; height: 100%; border-radius: 999px; }
.pct-val { text-align: right; font-variant-numeric: tabular-nums; }
.pct-raw { text-align: right; }

.timeline { list-style: none; margin: 0; padding: .75rem 1rem .75rem 1.75rem; position: relative; }
.timeline::before { content: ""; position: absolute; left: 1.05rem; top: 1rem; bottom: 1rem; width: 2px; background: var(--border); }
.timeline li { position: relative; display: flex; flex-direction: column; gap: .1rem; padding: .45rem 0; }
.timeline li::before { content: ""; position: absolute; left: -.95rem; top: .8rem; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--brand); }
.tl-date { font-size: .74rem; color: var(--text-soft); font-weight: 600; }
.painel-lazy { min-height: 120px; }
@media print { .app-tabs, .hero-actions { display: none !important; } .tab-pane { display: block !important; opacity: 1 !important; } }

/* ---------- Comparador ---------- */
.cmp-table th, .cmp-table td { vertical-align: middle; }
.cmp-table tbody th { font-size: .82rem; color: var(--text-muted); font-weight: 600; white-space: nowrap; }
.cmp-head { position: relative; display: flex; flex-direction: column; align-items: center; gap: .3rem; padding: .5rem 0; text-transform: none; letter-spacing: 0; }
.cmp-head img { width: 64px; height: 64px; border-radius: 14px; object-fit: cover; background: var(--surface-3); border: 1px solid var(--border); }
.cmp-nome { font-size: .95rem; font-weight: 700; color: var(--text); text-align: center; }
.cmp-x { position: absolute; top: .25rem; right: .25rem; color: var(--text-soft); }
.cmp-sec td { background: var(--surface-2); font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--text-soft); }
td.cmp-best { background: var(--ok-soft) !important; color: var(--ok-ink); font-weight: 700; }
.cmp-table > thead > tr > th { text-transform: none; letter-spacing: 0; font-size: .9rem; background: var(--surface); color: var(--text); }
.cmp-table > thead .small { font-size: .8rem; }

/* Modal de confirmação (data-confirm): as mensagens mudam de linha com a sequência barra-n. */
.confirmar-msg { white-space: pre-line; }

/* Coluna das acções do hero: as de edição e, por baixo, as de todos (seguir, PDF). */
.hero-side { display: flex; flex-direction: column; gap: .5rem; }
@media print { .hero-side { display: none !important; } }
