/* ==========================================================================
   CONFIGURAÇÕES: modal (<dialog>) com visual moderno
   Paleta herdada de modern.css: --pond, --bg, --line
   ========================================================================== */

.cfg-modal {
  --cfg-ink: #15293a;
  --cfg-text: #334e5f;
  --cfg-muted: #7b8f9c;
  --cfg-line: #e4ebf0;
  --cfg-soft: #f6f9fb;
  --cfg-pond: var(--pond, #214a63);
  --cfg-ok: #15803d;
  --cfg-bad: #b91c1c;

  width: min(1040px, calc(100vw - 32px));
  height: min(780px, calc(100dvh - 40px));
  max-height: calc(100dvh - 40px);
  padding: 0;
  border: 0;
  border-radius: 18px;
  background: #fff;
  color: var(--cfg-text);
  font-size: 13px;
  box-shadow: 0 30px 80px -20px rgba(15, 30, 42, 0.45), 0 0 0 1px rgba(15, 30, 42, 0.06);
  overflow: hidden;
}
.cfg-modal[hidden] { display: none !important; }
.cfg-modal[open] { animation: cfg-in 0.22s cubic-bezier(0.2, 0.8, 0.2, 1); }
.cfg-modal::backdrop {
  background: rgba(15, 30, 42, 0.42);
  backdrop-filter: blur(3px);
  animation: cfg-fade 0.2s ease;
}
@keyframes cfg-in {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to { opacity: 1; transform: none; }
}
@keyframes cfg-fade { from { opacity: 0; } to { opacity: 1; } }

.cfg-shell {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

/* ---------- Cabeçalho ---------- */
.cfg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--cfg-line);
}
.cfg-head-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.cfg-head-title h2 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -0.01em; color: var(--cfg-ink); }
.cfg-head-title p { margin: 2px 0 0; font-size: 12px; color: var(--cfg-muted); }
.cfg-head-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--cfg-pond), #2f6584);
  color: #fff;
  box-shadow: 0 6px 16px -6px rgba(33, 74, 99, 0.6);
}
.cfg-head-icon svg { width: 18px; height: 18px; }
.cfg-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--cfg-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.cfg-icon-btn:hover { background: #eef3f6; color: var(--cfg-ink); }
.cfg-icon-btn:focus-visible { outline: 2px solid rgba(33, 74, 99, 0.4); outline-offset: 2px; }

/* ---------- Corpo: abas + painéis ---------- */
.cfg-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 196px minmax(0, 1fr);
}
.cfg-tabs {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 10px;
  background: var(--cfg-soft);
  border-right: 1px solid var(--cfg-line);
  overflow-y: auto;
}
.cfg-tabs button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: #4b6172;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.cfg-tabs button svg { width: 16px; height: 16px; flex: 0 0 16px; }
.cfg-tabs button:hover { background: #fff; color: var(--cfg-pond); }
.cfg-tabs button.is-selected {
  background: #fff;
  color: var(--cfg-pond);
  box-shadow: 0 1px 2px rgba(15, 30, 42, 0.08), 0 0 0 1px var(--cfg-line);
}
.cfg-tabs button:focus-visible { outline: 2px solid rgba(33, 74, 99, 0.35); outline-offset: 1px; }

.cfg-panels { min-height: 0; overflow-y: auto; padding: 22px 26px 26px; }
.cfg-panel { display: flex; flex-direction: column; gap: 6px; }
.cfg-panel[hidden] { display: none !important; }

.cfg-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0 10px;
}
.cfg-panel > .cfg-section-head:first-child { margin-top: 0; }
.cfg-section-head h3 { margin: 0; font-size: 13.5px; font-weight: 700; color: var(--cfg-ink); }
.cfg-section-head p { margin: 3px 0 0; font-size: 12px; color: var(--cfg-muted); line-height: 1.45; max-width: 560px; }

.cfg-count {
  flex: 0 0 auto;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--cfg-pond);
  background: #eaf2f7;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

/* ---------- Campos ---------- */
.cfg-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px 16px; }
.cfg-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.cfg-label { font-size: 11.5px; font-weight: 600; color: var(--cfg-text); }

.cfg-modal input[type="text"],
.cfg-modal input[type="search"],
.cfg-modal input[type="number"],
.cfg-modal input[type="password"],
.cfg-modal select {
  height: 36px;
  padding: 0 11px;
  border: 1px solid #d3dee6;
  border-radius: 10px;
  background: #fff;
  font: inherit;
  font-size: 13px;
  color: var(--cfg-ink);
  min-width: 0;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.cfg-modal select { padding-right: 30px; }
.cfg-modal input:focus,
.cfg-modal select:focus {
  outline: none;
  border-color: var(--cfg-pond);
  box-shadow: 0 0 0 3px rgba(33, 74, 99, 0.13);
}

.cfg-hint { margin: 6px 0 0; font-size: 11.5px; color: var(--cfg-muted); line-height: 1.45; }
.cfg-preview { margin-top: 10px; color: #4b6172; }
.cfg-empty { text-align: center; color: var(--cfg-muted); padding: 22px 10px !important; }

.cfg-addon {
  display: flex;
  align-items: stretch;
  border: 1px solid #d3dee6;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.cfg-addon:focus-within { border-color: var(--cfg-pond); box-shadow: 0 0 0 3px rgba(33, 74, 99, 0.13); }
.cfg-addon > span {
  display: flex;
  align-items: center;
  padding: 0 11px;
  background: var(--cfg-soft);
  color: var(--cfg-muted);
  font-size: 12px;
  font-weight: 700;
}
.cfg-addon > span:first-child { border-right: 1px solid #d3dee6; }
.cfg-addon > span:last-child { border-left: 1px solid #d3dee6; }
.cfg-addon input {
  flex: 1;
  min-width: 0;
  height: 36px;
  padding: 0 11px;
  border: 0;
  outline: none;
  background: transparent;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--cfg-ink);
}

.cfg-input-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cfg-input-row > input[type="text"],
.cfg-input-row > input[type="password"] { flex: 1 1 260px; max-width: 420px; }
.cfg-actions-row { margin-top: 10px; }
.cfg-actions-row .cfg-status { margin: 0; }

/* Segmentado */
.cfg-segment {
  display: inline-flex;
  padding: 3px;
  border-radius: 11px;
  background: #eef3f6;
  gap: 2px;
  position: relative;
}
.cfg-segment label { position: relative; cursor: pointer; }
.cfg-segment input { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }
.cfg-segment span {
  display: block;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: #4b6172;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.cfg-segment label:hover span { color: var(--cfg-ink); }
.cfg-segment input:checked + span {
  background: #fff;
  color: var(--cfg-pond);
  box-shadow: 0 1px 3px rgba(15, 30, 42, 0.12);
}
.cfg-segment input:focus-visible + span { outline: 2px solid rgba(33, 74, 99, 0.35); outline-offset: 1px; }
.cfg-route-custom { margin-top: 12px; }

/* Interruptor em linhas (Custos e cobrança) */
.cfg-switch-list { display: flex; flex-direction: column; border: 1px solid var(--cfg-line); border-radius: 12px; overflow: hidden; }
.cfg-switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--cfg-ink);
  cursor: pointer;
}
.cfg-switch-row + .cfg-switch-row { border-top: 1px solid var(--cfg-line); }
.cfg-switch-row:hover { background: var(--cfg-soft); }

/* ---------- Toolbar e tabela de usuários ---------- */
.cfg-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin: 4px 0 10px; }
.cfg-search { position: relative; display: flex; align-items: center; flex: 1 1 240px; max-width: 340px; }
.cfg-search svg { position: absolute; left: 11px; color: var(--cfg-muted); pointer-events: none; }
.cfg-search input { width: 100%; padding-left: 34px !important; }
.cfg-bulk { display: flex; gap: 6px; }

.cfg-table-wrap { overflow-x: auto; border: 1px solid var(--cfg-line); border-radius: 12px; }
.cfg-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
.cfg-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: left;
  padding: 10px 12px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--cfg-muted);
  background: var(--cfg-soft);
  border-bottom: 1px solid var(--cfg-line);
  white-space: nowrap;
}
.cfg-table td { padding: 9px 12px; border-bottom: 1px solid #f0f4f7; vertical-align: middle; }
.cfg-table tr:last-child td { border-bottom: 0; }
.cfg-table tbody tr:hover td { background: #fafcfd; }
.cfg-table tr[hidden] { display: none; }
.cfg-center { text-align: center; }

.cfg-person { display: flex; align-items: center; gap: 10px; min-width: 190px; }
.cfg-person strong { display: block; font-size: 12.5px; color: var(--cfg-ink); }
.cfg-person small { display: block; font-size: 11px; color: var(--cfg-muted); margin-top: 1px; }

.cfg-avatar {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border-radius: 50%;
  font-size: 11.5px;
  font-weight: 700;
  overflow: hidden;
}
.cfg-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

.cfg-table .cfg-alias { width: 100%; max-width: 170px; height: 32px; font-size: 12.5px; }
.cfg-color-input {
  width: 36px;
  height: 28px;
  padding: 0 2px;
  border: 1px solid #d3dee6;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}
.cfg-photo-actions { display: flex; gap: 10px; white-space: nowrap; }

.cfg-link {
  padding: 2px 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--cfg-pond);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.cfg-link:hover { color: var(--cfg-ink); }
.cfg-link.danger { color: var(--cfg-bad); }

/* Interruptor */
.cfg-switch { position: relative; display: inline-block; width: 38px; height: 22px; cursor: pointer; flex: 0 0 38px; }
.cfg-switch input { position: absolute; opacity: 0; width: 0; height: 0; margin: 0; }
.cfg-switch > span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #cdd7df;
  transition: background 0.18s;
}
.cfg-switch > span::after {
  content: "";
  position: absolute;
  left: 2px;
  top: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.22);
  transition: transform 0.18s;
}
.cfg-switch input:checked + span { background: var(--cfg-ok); }
.cfg-switch input:checked + span::after { transform: translateX(16px); }
.cfg-switch input:focus-visible + span { box-shadow: 0 0 0 3px rgba(33, 74, 99, 0.25); }

/* ---------- Botões e estado ---------- */
.cfg-btn {
  height: 34px;
  padding: 0 14px;
  border: 1px solid #d3dee6;
  border-radius: 10px;
  background: #fff;
  color: var(--cfg-text);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s, box-shadow 0.15s;
}
.cfg-btn:hover { border-color: var(--cfg-pond); color: var(--cfg-pond); }
.cfg-btn:focus-visible { outline: 2px solid rgba(33, 74, 99, 0.35); outline-offset: 2px; }
.cfg-btn.primary {
  background: linear-gradient(180deg, #2a5b78, var(--cfg-pond));
  border-color: var(--cfg-pond);
  color: #fff;
  box-shadow: 0 4px 12px -4px rgba(33, 74, 99, 0.55);
}
.cfg-btn.primary:hover { filter: brightness(1.08); color: #fff; }
.cfg-btn.danger { color: var(--cfg-bad); border-color: #fecaca; }
.cfg-btn.danger:hover { border-color: var(--cfg-bad); color: var(--cfg-bad); }

.cfg-status { margin: 8px 0 0; font-size: 12px; color: var(--cfg-muted); }
.cfg-status.ok { color: var(--cfg-ok); font-weight: 600; }
.cfg-status.bad { color: var(--cfg-bad); font-weight: 600; }

/* ---------- Rodapé e aviso de saída ---------- */
.cfg-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 22px;
  border-top: 1px solid var(--cfg-line);
  background: #fbfcfd;
}
.cfg-foot-actions { display: flex; gap: 8px; align-items: center; }
.cfg-dirty {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 600;
  color: #92400e;
}
.cfg-dirty[hidden] { display: none !important; }
.cfg-dirty i { width: 7px; height: 7px; border-radius: 50%; background: #f59e0b; box-shadow: 0 0 0 3px #fef3c7; }

.cfg-leave {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 22px;
  background: #fff;
  border-top: 1px solid #fde68a;
  box-shadow: 0 -10px 24px -12px rgba(15, 30, 42, 0.25);
  animation: cfg-rise 0.2s ease;
}
.cfg-leave[hidden] { display: none !important; }
.cfg-leave p { margin: 0; font-size: 12.5px; color: var(--cfg-text); }
.cfg-leave strong { color: var(--cfg-ink); }
@keyframes cfg-rise { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Responsivo ---------- */
@media (max-width: 760px) {
  .cfg-modal { width: calc(100vw - 16px); height: calc(100dvh - 16px); max-height: calc(100dvh - 16px); border-radius: 14px; }
  .cfg-body { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .cfg-tabs { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--cfg-line); padding: 8px; }
  .cfg-tabs button { white-space: nowrap; }
  .cfg-tabs button span { display: none; }
  .cfg-tabs button.is-selected span { display: inline; }
  .cfg-panels { padding: 16px; }
  .cfg-foot { flex-direction: column-reverse; align-items: stretch; }
  .cfg-foot-actions { justify-content: flex-end; }
}

/* ---------- Engrenagem na taskbar (ao lado do sino) ---------- */
.taskbar .settings-trigger {
  width: 28px;
  height: 28px;
  min-width: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.08);
  color: #e8f0f5;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.taskbar .settings-trigger svg { width: 15px; height: 15px; transition: transform 0.45s ease; }
.taskbar .settings-trigger:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.22);
  color: #ffffff;
}
.taskbar .settings-trigger:hover svg { transform: rotate(60deg); }
.taskbar .settings-trigger[aria-pressed="true"] {
  background: rgba(247, 162, 135, 0.18);
  border-color: rgba(247, 162, 135, 0.55);
  color: #f7a287;
}
.taskbar .settings-trigger:focus-visible { outline: 2px solid rgba(247, 162, 135, 0.7); outline-offset: 2px; }

/* ---------- Rodapé: aparece só com alterações, alinhado à direita ---------- */
.cfg-foot-actions { margin-left: auto; }
.cfg-foot[hidden] { display: none !important; }

/* ---------- Fila inicial: mesmos botões dos filtros da lista ---------- */
.cfg-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.cfg-pill { position: relative; cursor: pointer; }
.cfg-pill input { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }
.cfg-pill span {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 14px;
  border-radius: 999px;
  background: #eef3f6;
  color: #3e5a6b;
  font-size: 12.5px;
  font-weight: 600;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.cfg-pill:hover span { background: #e2ebf1; color: var(--cfg-ink); }
.cfg-pill input:checked + span {
  background: var(--cfg-pond);
  color: #fff;
  box-shadow: 0 4px 12px -4px rgba(33, 74, 99, 0.55);
}
.cfg-pill input:focus-visible + span { outline: 2px solid rgba(33, 74, 99, 0.4); outline-offset: 2px; }

/* ---------- Conta ---------- */
.cfg-account-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--cfg-line);
  border-radius: 12px;
  background: var(--cfg-soft);
}
.cfg-account-card strong { display: block; font-size: 13px; color: var(--cfg-ink); }
.cfg-account-card p { margin: 2px 0 0; }
.cfg-account-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--cfg-ok); box-shadow: 0 0 0 4px #dcfce7; flex: 0 0 10px; }

.cfg-signout { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cfg-signout-confirm {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 10px;
  border: 1px solid #fecaca;
  border-radius: 10px;
  background: #fff7f7;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--cfg-ink);
}
.cfg-signout-confirm[hidden] { display: none !important; }

/* ---------- Tela de entrada (sessão encerrada) ---------- */
.signin-gate {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(160deg, #1d303d, #214a63);
}
.signin-gate[hidden] { display: none !important; }
.signin-card {
  width: min(380px, 100%);
  padding: 28px 26px 24px;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 30px 70px -20px rgba(0, 0, 0, 0.45);
  color: var(--cfg-text, #334e5f);
  animation: cfg-in 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.signin-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  margin-bottom: 14px;
  border-radius: 13px;
  background: linear-gradient(135deg, #214a63, #2f6584);
  color: #fff;
}
.signin-card h2 { margin: 0; font-size: 18px; font-weight: 700; color: #15293a; letter-spacing: -0.01em; }
.signin-sub { margin: 6px 0 18px; font-size: 12.5px; line-height: 1.5; color: #607583; }
.signin-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.signin-field span { font-size: 11.5px; font-weight: 600; color: #334e5f; }
.signin-field input {
  height: 40px;
  padding: 0 12px;
  border: 1px solid #d3dee6;
  border-radius: 10px;
  font: inherit;
  font-size: 14px;
}
.signin-field input:focus { outline: none; border-color: #214a63; box-shadow: 0 0 0 3px rgba(33, 74, 99, 0.13); }
.signin-error { min-height: 18px; margin: 4px 0 10px; font-size: 12px; font-weight: 600; color: #b91c1c; }
.signin-submit { width: 100%; height: 40px; }
.signin-submit:disabled { opacity: 0.6; cursor: wait; }

/* ---------- Títulos e rótulos do modal não podem ser selecionados ---------- */
.cfg-modal h2,
.cfg-modal h3,
.cfg-modal label,
.cfg-modal .cfg-label,
.cfg-modal .cfg-head,
.cfg-modal .cfg-tabs,
.cfg-modal .cfg-tabs button,
.cfg-modal .cfg-pill span,
.cfg-modal .cfg-segment span,
.cfg-modal .cfg-count,
.cfg-modal .cfg-table th,
.cfg-modal .cfg-switch-row,
.cfg-modal .cfg-section-head h3 {
  -webkit-user-select: none;
  user-select: none;
}

/* ---------- Notificações do navegador ---------- */
.cfg-notify-card { flex-wrap: wrap; }
.cfg-notify-text { flex: 1; min-width: 180px; }
.cfg-notify-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.cfg-account-dot.is-off { background: #cdd7df; box-shadow: 0 0 0 4px #eef3f6; }
.cfg-switch-row > span:first-child { display: flex; flex-direction: column; min-width: 0; }
.cfg-switch-row small { display: block; margin-top: 2px; font-size: 11.5px; font-weight: 500; color: var(--cfg-muted); }