/*
 * Pórtico UI
 * Camada visual compartilhada. Mantém os seletores e comportamentos das telas
 * existentes e apenas consolida acabamento, ritmo e estados de interação.
 */
:root {
  --primary: #2468d8;
  --primary-hover: #1d57b6;
  --primary-soft: #eaf2ff;
  --success: #16845a;
  --danger: #c43d4b;
  --warning: #a56612;
  --info: #2876b7;
  --dark: #17243a;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-subtle: #f8fafc;
  --text: #172033;
  --text-muted: #69758a;
  --border: #dfe5ed;
  --border-strong: #cbd4e1;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(15, 32, 60, 0.07);
  --shadow-md: 0 8px 24px rgba(15, 32, 60, 0.09);
  --shadow-lg: 0 24px 64px rgba(8, 24, 50, 0.18);
  --focus-ring: 0 0 0 4px rgba(36, 104, 216, 0.13);
  --transition: 180ms ease;
}

html {
  color-scheme: light;
  scroll-behavior: smooth;
}

body:not(.master-app):not(.master-login-page) {
  color: var(--text);
  background:
    radial-gradient(circle at 100% 0, rgba(36, 104, 216, 0.045), transparent 24rem),
    var(--bg);
  font-family: "Segoe UI Variable", "Segoe UI", Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a,
input,
select,
textarea {
  transition:
    color var(--transition),
    background-color var(--transition),
    border-color var(--transition),
    box-shadow var(--transition),
    opacity var(--transition),
    transform var(--transition);
}

:focus-visible {
  outline: 3px solid rgba(36, 104, 216, 0.34);
  outline-offset: 2px;
}

::selection {
  color: #fff;
  background: var(--primary);
}

/* Navegação principal */
body:not(.master-app) .header {
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: linear-gradient(110deg, #142b4b 0%, #214b7e 60%, #285c98 100%);
  box-shadow: 0 5px 22px rgba(10, 30, 58, 0.2);
}

body:not(.master-app) .header-left {
  letter-spacing: -0.01em;
}

body:not(.master-app) .header-right {
  color: rgba(255, 255, 255, 0.86);
}

body:not(.master-app) .header-right button#logoutBtn {
  min-height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.1);
  font-weight: 600;
}

body:not(.master-app) .header-right button#logoutBtn:hover {
  background: #bd3c4a;
  box-shadow: 0 6px 14px rgba(122, 22, 35, 0.2);
}

body:not(.master-app) .sidebar {
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, #112846 0%, #183b67 100%);
  box-shadow: 6px 0 24px rgba(9, 28, 53, 0.08);
}

body:not(.master-app) .menu-item {
  position: relative;
  margin: 3px 10px;
  padding: 13px 16px;
  border-radius: 9px;
}

body:not(.master-app) .menu-item::before {
  content: "";
  position: absolute;
  inset: 11px auto 11px -10px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: transparent;
}

body:not(.master-app) .menu-item:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

body:not(.master-app) .menu-item.active {
  color: #fff;
  background: linear-gradient(90deg, rgba(74, 139, 232, 0.27), rgba(74, 139, 232, 0.12));
}

body:not(.master-app) .menu-item.active::before {
  background: #79abf4;
}

body:not(.master-app) .menu-group-toggle {
  width: calc(100% - 20px);
  margin-top: 9px;
  margin-bottom: 4px;
  color: rgba(255, 255, 255, 0.64);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

body:not(.master-app) .menu-group-toggle::before {
  display: none;
}

body:not(.master-app) .menu-group-toggle > i:first-child {
  font-size: 1rem;
  opacity: 0.82;
}

body:not(.master-app) .menu-group-toggle:hover,
body:not(.master-app) .menu-group-toggle[aria-expanded="true"] {
  color: #fff;
  background: rgba(7, 25, 49, 0.32);
}

body:not(.master-app) .submenu-item {
  margin: 1px 6px;
  padding: 10px 12px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.9rem;
}

body:not(.master-app) .submenu-item::before {
  inset: 9px auto 9px -17px;
  width: 2px;
}

body:not(.master-app) .sidebar.collapsed .submenu-item {
  margin: 1px 4px;
  padding: 9px 6px;
}

body:not(.master-app) .sidebar.collapsed .menu-group-toggle span {
  font-size: 0.54rem;
  letter-spacing: 0;
  line-height: 1.05;
  text-transform: none;
}

@media (min-width: 769px) and (max-width: 992px) {
  body:not(.master-app) .sidebar .submenu-item {
    margin: 1px 4px;
    padding: 9px 6px;
  }

  body:not(.master-app) .sidebar .menu-group-toggle span {
    font-size: 0.54rem;
    letter-spacing: 0;
    line-height: 1.05;
    text-transform: none;
  }
}

/* Conteúdo, painéis e indicadores */
body:not(.master-app) .lista-container {
  padding: 28px;
}

body:not(.master-app) .panel,
body:not(.master-app) .card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

body:not(.master-app) .panel {
  padding: 24px;
}

body:not(.master-app) .panel > h3,
body:not(.master-app) .panel-header-camera h3 {
  color: var(--dark);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

body:not(.master-app) .panel > h3 {
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom-color: var(--border);
}

body:not(.master-app) .dash,
body:not(.master-app) .indicador-card,
body:not(.master-app) .caixa-indicador,
body:not(.master-app) .mensalistas-kpis article,
body:not(.master-app) .assinatura-kpis article,
body:not(.master-app) .agent-summary-card,
body:not(.master-app) .usuarios-summary-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

body:not(.master-app) .dash {
  position: relative;
  overflow: hidden;
  min-height: 96px;
  padding: 18px;
  box-shadow: 0 7px 20px rgba(15, 32, 60, 0.12);
}

body:not(.master-app) .dash::after {
  content: "";
  position: absolute;
  right: -25px;
  bottom: -43px;
  width: 100px;
  height: 100px;
  border: 18px solid rgba(255, 255, 255, 0.08);
  border-radius: 50%;
}

body:not(.master-app) .indicador-card:hover,
body:not(.master-app) .mensalistas-kpis article:hover,
body:not(.master-app) .assinatura-kpis article:hover,
body:not(.master-app) .caixa-indicador:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* Campos e filtros */
body:not(.master-app) :is(input, select, textarea):not([type="checkbox"]):not([type="radio"]) {
  border-color: var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  background-color: #fff;
}

body:not(.master-app) :is(input, select, textarea):not([type="checkbox"]):not([type="radio"]):hover {
  border-color: #aebacb;
}

body:not(.master-app) :is(input, select, textarea):not([type="checkbox"]):not([type="radio"]):focus {
  outline: 0;
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
}

body:not(.master-app) input::placeholder,
body:not(.master-app) textarea::placeholder {
  color: #929daf;
}

body:not(.master-app) .filtros-alinhados,
body:not(.master-app) .filter-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
  box-shadow: none;
}

body:not(.master-app) .form-row label,
body:not(.master-app) .filtro-item-estadia label {
  color: var(--text-muted);
}

/* Ações */
body:not(.master-app) .btn,
body:not(.master-app) .btn-filtrar,
body:not(.master-app) .btn-registro-rapido,
body:not(.master-app) :is(.btn-primary, .btn-secondary, .btn-danger, .btn-warning) {
  min-height: 40px;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  font-weight: 650;
  line-height: 1.2;
  box-shadow: 0 1px 2px rgba(15, 32, 60, 0.08);
}

body:not(.master-app) .btn.blue,
body:not(.master-app) .btn-filtrar,
body:not(.master-app) .btn-registro-rapido,
body:not(.master-app) .btn-primary {
  background: linear-gradient(135deg, var(--primary), #1d59bc);
}

body:not(.master-app) .btn.green {
  background: var(--success);
}

body:not(.master-app) .btn.red {
  background: var(--danger);
}

body:not(.master-app) .btn.gray {
  background: #69758a;
}

body:not(.master-app) .btn:hover,
body:not(.master-app) .btn-filtrar:hover,
body:not(.master-app) .btn-registro-rapido:hover {
  opacity: 1;
  transform: translateY(-1px);
  box-shadow: 0 7px 16px rgba(15, 32, 60, 0.14);
}

body:not(.master-app) button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none !important;
  box-shadow: none !important;
}

body:not(.master-app) .actions-btn,
body:not(.master-app) .btn-icon,
body:not(.master-app) .filtro-botoes button,
body:not(.master-app) .page-btn {
  border-radius: var(--radius-sm);
}

/* Tabelas */
body:not(.master-app) .table-responsive {
  margin-top: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #fff;
}

body:not(.master-app) table {
  margin-top: 0;
}

body:not(.master-app) th {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: #536078;
  background: #f7f9fc;
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

body:not(.master-app) td {
  padding: 13px 14px;
  border-bottom-color: #edf0f4;
  color: #354057;
}

/* Tipo de movimentação — usado em Últimos Registros e Lista de Registros. */
body:not(.master-app) #tabelaUltimos td.entrada,
body:not(.master-app) #tabelaRegistros td.entrada,
body:not(.master-app) table td.tipo-entrada {
  color: #16845a;
  font-weight: 750;
}

body:not(.master-app) #tabelaUltimos td.saida,
body:not(.master-app) #tabelaRegistros td.saida,
body:not(.master-app) table td.tipo-saida {
  color: #c43d4b;
  font-weight: 750;
}

body:not(.master-app) tbody tr:last-child td {
  border-bottom: 0;
}

body:not(.master-app) tbody tr:hover {
  background: #f8faff;
}

body:not(.master-app) .status-badge,
body:not(.master-app) .situacao-badge,
body:not(.master-app) .perfil-badge,
body:not(.master-app) .senha-badge,
body:not(.master-app) .tipo-badge {
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

/* Modais */
body:not(.master-app) .modal-overlay,
body:not(.master-app) .modal-pagamento {
  background: rgba(8, 20, 39, 0.57);
  backdrop-filter: blur(4px);
}

body:not(.master-app) .modal-content-custom,
body:not(.master-app) .modal-content,
body:not(.master-app) .modal-pagamento-content,
body:not(.master-app) .modal-aviso-content {
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

body:not(.master-app) .modal-header-custom,
body:not(.master-app) .modal-pagamento-header {
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: linear-gradient(110deg, #142b4b, #285c98);
}

body:not(.master-app) .modal-footer-custom,
body:not(.master-app) .modal-pagamento-footer {
  border-top-color: var(--border);
  background: var(--surface-subtle);
}

body:not(.master-app) .tab-headers,
body:not(.master-app) .tabs-nvr {
  gap: 4px;
  overflow-x: auto;
}

body:not(.master-app) .tab-header,
body:not(.master-app) .tab-nvr {
  border-radius: 8px 8px 0 0;
  white-space: nowrap;
}

#modalCliente .tab-headers {
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}

#modalCliente .tab-headers::-webkit-scrollbar {
  display: none;
}

#modalCliente .tab-header.active::after {
  bottom: 0;
}

/* A área master já possui linguagem própria; estes detalhes alinham acessibilidade. */
.master-app :is(input, select, button):focus-visible,
.master-login-page :is(input, select, button):focus-visible {
  outline: 3px solid rgba(52, 121, 235, 0.32);
  outline-offset: 2px;
}

.master-app .metric-card,
.master-app .filter-panel,
.master-app .audit-panel {
  transition:
    transform var(--transition),
    box-shadow var(--transition);
}

.master-app .metric-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(15, 32, 60, 0.09);
}

@media (max-width: 768px) {
  body:not(.master-app) .lista-container,
  body:not(.master-app) .dashboard,
  body:not(.master-app) .main {
    padding-left: 16px;
    padding-right: 16px;
  }

  body:not(.master-app) .panel {
    padding: 18px;
  }

  body:not(.master-app) .header {
    padding-inline: 14px;
  }

  body:not(.master-app) .header-right {
    justify-content: flex-end;
  }

  body:not(.master-app) .table tr {
    overflow: hidden;
    border-color: var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
  }

  body:not(.master-app) .table td {
    min-height: 44px;
    padding: 12px 12px 12px 48%;
    border-bottom: 1px solid #edf0f4;
  }
}

@media (max-width: 560px) {
  #modalCliente .tab-headers {
    gap: 0;
    width: 100%;
  }

  #modalCliente .tab-header {
    flex: 1 1 25%;
    min-width: 0;
    margin-right: 0;
    padding: 0.6rem 0.2rem;
    font-size: 0;
    text-align: center;
  }

  #modalCliente .tab-header::before {
    content: attr(data-mobile-label);
    font-size: 0.75rem;
  }

  body:not(.master-app) .modal-body-custom {
    padding: 18px;
  }

  body:not(.master-app) .modal-footer-custom {
    flex-wrap: wrap;
    padding: 14px 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Feedback compartilhado: mesma linguagem visual de Auditoria e Empresas. */
.app-toast-region {
  position: fixed; z-index: 20000; right: 22px; bottom: 22px;
  width: min(390px, calc(100vw - 32px)); display: grid; gap: 10px;
  pointer-events: none;
}
.app-toast {
  --toast-accent: var(--info);
  display: grid; grid-template-columns: 38px minmax(0, 1fr) 28px;
  align-items: start; gap: 11px; padding: 14px 13px;
  border: 1px solid rgba(255, 255, 255, .12); border-radius: 12px;
  color: #fff; background: #172a47;
  box-shadow: 0 18px 44px rgba(8, 24, 50, .24);
  opacity: 0; transform: translateY(14px) scale(.98);
  transition: opacity .2s ease, transform .2s ease; pointer-events: auto;
}
.app-toast.is-visible { opacity: 1; transform: none; }
.app-toast--success { --toast-accent: #36c88b; }
.app-toast--error { --toast-accent: #f07480; }
.app-toast--warning { --toast-accent: #efb451; }
.app-toast__icon {
  width: 36px; height: 36px; display: grid; place-items: center;
  border-radius: 10px; color: #10233f; background: var(--toast-accent);
  font-size: .86rem; font-weight: 850;
}
.app-toast__content { min-width: 0; display: grid; gap: 3px; }
.app-toast__content strong { font-size: .76rem; letter-spacing: .01em; }
.app-toast__content span {
  color: #d7e3f2; font-size: .76rem; line-height: 1.45;
  white-space: pre-line; overflow-wrap: anywhere;
}
.app-toast__close {
  width: 28px; height: 28px; border: 0; border-radius: 7px;
  color: #aebfd5; background: transparent; font-size: 1.15rem; line-height: 1;
}
.app-toast__close:hover { color: #fff; background: rgba(255, 255, 255, .1); }

.app-confirm {
  position: fixed; inset: 0; margin: auto;
  width: min(560px, calc(100% - 32px)); height: fit-content; padding: 0; border: 0;
  border-radius: var(--radius-lg, 12px); color: var(--text, #172033); background: #fff;
  box-shadow: 0 24px 64px rgba(8, 24, 50, .22);
  overflow: hidden;
}
.app-confirm::backdrop { background: rgba(7, 18, 38, .56); backdrop-filter: blur(3px); }
.app-confirm form { padding: 0; }
.app-confirm__header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; color: #fff;
  background: linear-gradient(110deg, #142b4b, #285c98);
}
.app-confirm h2 { margin: 0; color: inherit; font-size: 1.15rem; font-weight: 600; line-height: 1.25; }
.app-confirm__close {
  width: 34px; height: 34px; padding: 0; border: 0; border-radius: 8px;
  color: #fff; background: transparent; font-size: 1.65rem; line-height: 1;
}
.app-confirm__close:hover { background: rgba(255, 255, 255, .12); }
.app-confirm__body { padding: 24px; text-align: center; }
.app-confirm p { margin: 0; color: #4f5c70; font-size: .92rem; line-height: 1.58; white-space: pre-line; }
.app-confirm__actions {
  display: flex; justify-content: center; gap: 18px; margin: 0; padding: 14px 20px;
  border-top: 1px solid var(--border, #e2e7ef); background: var(--surface-subtle, #f8fafc);
}
.app-confirm__actions button {
  min-height: 40px; padding: 0 18px; border-radius: 8px;
  font: inherit; font-weight: 700; cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.app-confirm__actions button:hover { transform: translateY(-1px); }
.app-confirm__cancel { border: 1px solid #cbd4e1; color: #354057; background: #fff; }
.app-confirm__submit {
  border: 0; color: #fff; background: linear-gradient(135deg, #2468d8, #1b55b0);
  box-shadow: 0 9px 22px rgba(36, 104, 216, .22);
}
.app-confirm--danger .app-confirm__submit {
  background: linear-gradient(135deg, #cf4452, #a92e3c);
  box-shadow: 0 9px 22px rgba(196, 61, 75, .2);
}

.modal-delete-confirmation .modal-header-custom h3,
.app-confirm h2 {
  margin: 0;
  color: inherit;
  font-size: 1.15rem;
  font-weight: 650;
  line-height: 1.25;
}
.modal-delete-confirmation .modal-close-btn,
.app-confirm__close {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: transparent;
  font-size: 1.65rem;
  line-height: 1;
  opacity: 1;
}
.modal-delete-confirmation .modal-close-btn:hover,
.app-confirm__close:hover { background: rgba(255, 255, 255, .12); }

.delete-confirmation__body,
.app-confirm__body {
  display: grid;
  gap: 8px;
  padding: 26px 28px;
  text-align: center;
}
.delete-confirmation__message {
  margin: 0;
  color: #354057;
  font-size: .95rem;
  line-height: 1.55;
}
.delete-confirmation__warning {
  margin: 0;
  color: #172033;
  font-size: .9rem;
  font-weight: 750;
  line-height: 1.45;
}
.delete-confirmation__warning:empty,
.delete-confirmation__detail:empty { display: none; }
.delete-confirmation__detail {
  margin: 8px 0 0;
  padding: 10px 12px;
  border: 1px solid #dfe6ef;
  border-radius: 8px;
  color: #354057;
  background: #f7f9fc;
  font-size: .84rem;
  font-weight: 700;
  line-height: 1.45;
}
.delete-confirmation__field { margin-top: 10px; text-align: left; }
.delete-confirmation__actions,
.app-confirm__actions {
  justify-content: center;
  gap: 12px;
  padding: 16px 20px;
  border-top: 1px solid var(--border, #e2e7ef);
  background: var(--surface-subtle, #f8fafc);
}
.delete-confirmation__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 128px;
  min-height: 42px;
  padding: 9px 18px;
  border-radius: 9px;
  font: inherit;
  font-size: .88rem;
  font-weight: 750;
  line-height: 1;
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.delete-confirmation__button:hover { transform: translateY(-1px); }
.delete-confirmation__button:focus-visible {
  outline: 3px solid rgba(52, 121, 235, .25);
  outline-offset: 2px;
}
.delete-confirmation__button--cancel {
  border: 1px solid #cbd4e1;
  color: #354057;
  background: #fff;
  box-shadow: 0 2px 5px rgba(15, 35, 65, .06);
}
.delete-confirmation__button--cancel:hover {
  border-color: #aebbcf;
  background: #f2f5f9;
  box-shadow: 0 5px 12px rgba(15, 35, 65, .1);
}
.modal-delete-confirmation .delete-confirmation__button--confirm,
.app-confirm--danger .delete-confirmation__button--confirm {
  border: 1px solid #ad2f3c;
  color: #fff;
  background: linear-gradient(135deg, #d84a58, #ad2f3c);
  box-shadow: 0 7px 16px rgba(196, 61, 75, .24);
}
.modal-delete-confirmation .delete-confirmation__button--confirm:hover,
.app-confirm--danger .delete-confirmation__button--confirm:hover {
  background: linear-gradient(135deg, #c73d4b, #942633);
  box-shadow: 0 9px 19px rgba(196, 61, 75, .3);
}
.delete-confirmation__button:disabled {
  cursor: not-allowed;
  opacity: .58;
  transform: none;
  box-shadow: none;
}

/* Confirmações destrutivas legadas seguem o mesmo padrão compacto. */
body:not(.master-app) .modal-delete-confirmation { max-width: 560px; }
body:not(.master-app) .modal-delete-confirmation .modal-header-custom { padding: 14px 20px; }
body:not(.master-app) .modal-delete-confirmation .modal-body-custom { padding: 24px; }
body:not(.master-app) .modal-delete-confirmation .modal-footer-custom {
  justify-content: center; gap: 18px; padding: 14px 20px;
}
@media (max-width: 560px) {
  .app-toast-region { right: 16px; bottom: 16px; }
  .app-confirm__actions { flex-direction: column-reverse; }
  .app-confirm__actions button { width: 100%; }
  body:not(.master-app) .modal-delete-confirmation .modal-footer-custom { flex-direction: column-reverse; }
  body:not(.master-app) .modal-delete-confirmation .modal-footer-custom .btn { width: 100%; }
}

/* Identificação do plano da empresa no cabeçalho compartilhado. */
body:not(.master-app) .current-plan {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  gap: 9px;
  min-height: 40px;
  margin-left: 5px;
  padding: 6px 12px;
  border: 1px solid rgba(159, 201, 245, .3);
  border-radius: 10px;
  background: rgba(255, 255, 255, .06);
  color: #d8eaff;
  line-height: 1.1;
  white-space: nowrap;
}
body:not(.master-app) .current-plan[hidden] { display: none; }
.current-plan-icon { width: 19px; height: 19px; flex-shrink: 0; }
.current-plan-copy { display: flex; flex-direction: column; gap: 4px; }
.current-plan-caption { font-size: .56rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; opacity: .8; }
.current-plan-name { font-size: .79rem; font-weight: 650; letter-spacing: .01em; }
body:not(.master-app) .current-plan[data-plan="premium"] {
  border-color: rgba(239, 204, 139, .45);
  background: linear-gradient(115deg, rgba(239, 204, 139, .13), rgba(239, 204, 139, .04));
  color: #f7dfb0;
}
body:not(.master-app) .current-plan[data-plan="trial"] {
  border-color: rgba(177, 190, 213, .3);
  background: rgba(187, 201, 222, .07);
  color: #dce4f0;
}
.plan-usage-warning {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 18px 0 calc(var(--sidebar-width) + 18px);
  padding: 10px 14px;
  border: 1px solid #e8c268;
  border-radius: 10px;
  background: #fff8e5;
  color: #72530b;
  font-size: .82rem;
  line-height: 1.4;
  transition: margin-left .3s ease;
}
body.sidebar-collapsed:not(.master-app) .plan-usage-warning {
  margin-left: calc(var(--sidebar-collapsed) + 18px);
}
@media (min-width: 769px) and (max-width: 992px) {
  body:not(.master-app) .plan-usage-warning {
    margin-left: calc(var(--sidebar-collapsed) + 18px);
  }
}
.plan-usage-warning.is-limit {
  border-color: #df8790;
  background: #fff0f1;
  color: #8d2530;
}
.plan-usage-warning i { flex: 0 0 auto; }
@media (max-width: 768px) {
  body:not(.master-app) .plan-usage-warning {
    margin: 10px 12px 0;
  }
  body:not(.master-app) .current-plan { margin-left: 0; padding: 5px 9px; min-height: 32px; gap: 6px; border-radius: 8px; }
  .current-plan-caption { display: none; }
  .current-plan-name { font-size: .72rem; }
  .current-plan-icon { width: 16px; height: 16px; }
  body:not(.master-app) .header-right #dataHoraAtual,
  body:not(.master-app) .header-right .notification { display: none; }
  body:not(.master-app) .header-right .user-info { min-width: 0; }
  body:not(.master-app) .header-right #infoUsuario { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
@media (max-width: 576px) {
  body:not(.master-app) .header { gap: 8px; }
  body:not(.master-app) .header-left { gap: 8px; }
  body:not(.master-app) .header-right { width: auto; min-width: 0; flex-wrap: nowrap; gap: 8px; }
  body:not(.master-app) .header-right .user-info { display: none; }
  body:not(.master-app) .header-right button#logoutBtn { padding: 6px 9px; }
}
/* Listagens: ação de cadastro depois dos filtros, sempre à esquerda. */
body .list-actions {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  width: 100%;
  margin: 16px 0;
  text-align: left;
}
body .list-actions > button {
  position: static;
  float: none;
  margin: 0;
  align-self: flex-start;
  min-height: 40px;
  width: auto;
}

/* Mesma superfície e ritmo para indicadores de todas as áreas. */
body :is(.metric-card, .indicador-card, .caixa-indicador,
  .mensalistas-kpis > article, .assinatura-kpis > article,
  .support-metrics > article, .agent-summary-card, .usuarios-summary-card) {
  box-sizing: border-box;
  min-height: 100px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
body :is(.mensalistas-kpis, .assinatura-kpis, .support-metrics,
  .agent-summary, .usuarios-summary, .metrics-grid) {
  gap: 16px;
  margin-bottom: 20px;
}
body :is(.metric-card, .indicador-card, .caixa-indicador,
  .mensalistas-kpis > article, .assinatura-kpis > article,
  .support-metrics > article, .agent-summary-card, .usuarios-summary-card) strong {
  font-size: 1.5rem;
  line-height: 1.25;
  font-weight: 700;
}

/* A visibilidade continua sob controle das telas (display/hidden). */
body .ui-loading,
body :is(.audit-state, .request-state, .support-state, .payment-loading,
  .master-payment-loading, .caixa-loading, .billing-state, .assinatura-state):has(.fa-spin) {
  padding: 40px 20px;
  min-height: 148px;
  box-sizing: border-box;
  text-align: center;
  color: var(--text-muted);
  font-size: .9rem;
  line-height: 1.5;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: none;
}
body .ui-loading > br { display: none; }
body .ui-loading > :is(strong, span),
body :is(.audit-state, .request-state, .support-state, .payment-loading,
  .master-payment-loading, .caixa-loading, .billing-state, .assinatura-state):has(.fa-spin) > :is(strong, span) {
  display: block;
  font-size: .9rem;
  font-weight: 400;
  color: var(--text-muted);
}
/* Um único spinner, inclusive nos estados montados dinamicamente. */
body :is(.fa-spinner, .fa-circle-notch).fa-spin {
  display: inline-block;
  box-sizing: border-box;
  width: 1em;
  height: 1em;
  border: 2px solid var(--border-strong);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: ui-loading-spin .8s linear infinite;
}
body :is(.fa-spinner, .fa-circle-notch).fa-spin::before { content: none; }
body .ui-loading > .fa-spin,
body :is(.audit-state, .request-state, .support-state, .payment-loading,
  .master-payment-loading, .caixa-loading, .billing-state, .assinatura-state):has(.fa-spin) > .fa-spin,
body .report-loading .fa-spin {
  display: block;
  width: 28px;
  height: 28px;
  margin: 0 auto 12px;
  font-size: 28px;
}
@keyframes ui-loading-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  body :is(.fa-spinner, .fa-circle-notch).fa-spin { animation-duration: 2s; }
}
@media (max-width: 600px) {
  body :is(.mensalistas-kpis, .assinatura-kpis, .support-metrics,
    .agent-summary, .usuarios-summary, .metrics-grid) { grid-template-columns: 1fr; }
}
[hidden] {
  display: none !important;
}
